:root {
    --bg-dark: #121212;
    --bg-panel: rgba(30, 30, 30, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --accent-color: #00e5ff;
    --accent-hover: #00b8cc;
    --text-primary: #ffffff;
    --text-secondary: #aaaaaa;
    --success: #00e676;
    --danger: #ff1744;
    --warning: #ffea00;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Prompt', 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    /* Adding a subtle background gradient */
    background: radial-gradient(circle at 10% 20%, rgb(20, 20, 20) 0%, rgb(10, 10, 10) 90%);
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 10px;
    gap: 10px;
}

/* --- Top Bar --- */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-panel);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 15px 25px;
    height: 80px;
    position: relative;
    z-index: 100;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--accent-color);
}

.barcode-container {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid var(--accent-color);
    border-radius: 8px;
    padding: 10px 20px;
    width: 70%;
    max-width: 850px;
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.2);
    transition: all 0.3s ease;
}

.barcode-container:focus-within {
    box-shadow: 0 0 25px rgba(0, 229, 255, 0.5);
    transform: scale(1.02);
}

.barcode-container i {
    color: var(--accent-color);
    font-size: 1.5rem;
    margin-right: 15px;
}

.barcode-container input {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.2rem;
    font-family: 'Inter', sans-serif;
    width: 100%;
    outline: none;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 20px;
    font-size: 1.2rem;
}

.avatar {
    width: 45px;
    height: 45px;
    background: #333;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid var(--border-color);
}

/* --- Main Layout --- */
.main-layout {
    display: flex;
    gap: 10px;
    flex: 1;
    overflow: hidden;
}

/* --- Left Side: Products --- */
.product-section {
    flex: 2;
    background: var(--bg-panel);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.category-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    overflow-x: auto;
    padding-bottom: 15px;
    min-height: 70px;
    align-items: flex-start;
}

/* Make scrollbar for category-tabs more visible */
.category-tabs::-webkit-scrollbar {
    height: 8px;
}
.category-tabs::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.3); 
    border-radius: 10px;
}
.category-tabs::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.4); 
    border-radius: 10px;
}
.category-tabs::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.6); 
}

.tab-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-family: 'Prompt', sans-serif;
    font-size: 1rem;
    white-space: nowrap;
    transition: all 0.2s;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.tab-btn.active {
    background: var(--accent-color);
    color: #000;
    font-weight: 600;
    border-color: var(--accent-color);
}

.product-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
    padding-right: 5px;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 18px;
    height: 18px;
}
::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.2); 
    border-radius: 10px;
}
::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2); 
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.4); 
}

.product-card {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    position: relative;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
    border-color: var(--accent-color);
}

/* Product Section */
.product-section {
    flex: 1; /* Changed from 2 to 1 to reduce width by half and share space with cart list */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
    opacity: 1;
}

.product-section.collapsed {
    flex: 0;
    width: 0;
    padding: 0;
    margin: 0;
    opacity: 0;
    border: none;
    pointer-events: none;
}

.product-card .icon {
    font-size: 2rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.product-card .name {
    font-size: 0.95rem;
    margin-bottom: 8px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-card .price {
    color: var(--success);
    font-weight: 600;
    font-size: 1.1rem;
}

/* --- Middle Side: Cart List --- */
.cart-list-section {
    flex: 1;
    background: var(--bg-panel);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* --- Right Side: Cart Summary --- */
.cart-section {
    flex: 1;
    min-width: 300px;
    max-width: 350px;
    background: var(--bg-panel);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.cart-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cart-header h2 {
    font-size: 1.2rem;
}

.order-id {
    background: rgba(255, 255, 255, 0.1);
    padding: 5px 10px;
    border-radius: 5px;
    font-family: 'Inter', monospace;
    font-size: 0.9rem;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.empty-cart-msg {
    text-align: center;
    color: var(--text-secondary);
    margin-top: 50px;
    font-size: 1.1rem;
}

.cart-item {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    background: rgba(0, 0, 0, 0.4);
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid var(--accent-color);
    animation: slideIn 0.2s ease-out;
    gap: 15px;
    flex-shrink: 0;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

.item-info {
    flex: 2;
    display: flex;
    flex-direction: column;
}

.item-name {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 2px;
    color: var(--accent-color);
}

.item-price {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.item-qty-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(0,0,0,0.6);
    border-radius: 20px;
    padding: 5px 10px;
    flex: 1;
}

.item-total {
    flex: 1;
    text-align: right;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--success);
}

.qty-btn {
    background: transparent;
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.6rem;
    transition: all 0.2s;
}

.qty-btn:hover {
    background: rgba(255,255,255,0.2);
    transform: scale(1.1);
}

.item-qty {
    font-weight: 600;
    font-size: 1.3rem;
    width: 50px;
    text-align: center;
}

.item-total {
    font-weight: 700;
    font-size: 1.2rem;
    width: 100%;
    text-align: center;
    color: var(--success);
}

.cart-summary {
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid var(--border-color);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    color: var(--text-secondary);
}

.grand-total {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed var(--border-color);
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0;
}

.grand-total span:last-child {
    color: var(--accent-color);
}

.action-buttons {
    padding: 15px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

#pay-btn {
    grid-column: span 2;
    padding: 20px;
    font-size: 1.2rem;
}

.btn {
    border: none;
    border-radius: 8px;
    padding: 15px;
    font-family: 'Prompt', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    color: white;
}

.btn:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: none;
    transform: none;
}

.btn-danger { background: var(--danger); }
.btn-warning { background: var(--warning); color: #000; }
.btn-info { background: #3498db; color: #fff; }
.btn-primary { background: #3b82f6; color: #fff; }
.btn-success { background: var(--success); color: #000; }

/* --- Modal --- */
.modal {
    display: none;
    position: fixed;
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(5px);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.modal-content {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 30px;
    width: 400px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

/* Make date picker icon visible on dark background */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}

/* Hide number input spin buttons */
input[type="number"]::-webkit-inner-spin-button, 
input[type="number"]::-webkit-outer-spin-button { 
    -webkit-appearance: none; 
    margin: 0; 
}
input[type="number"] {
    -moz-appearance: textfield;
}

.btn-secondary { background: #6c757d; color: #fff; }
.btn-secondary:hover { background: #5a6268; }

/* Custom Select for Filters */
select.filter-type-select {
    appearance: none;
    background-color: rgba(0, 229, 255, 0.1) !important;
    color: var(--accent-color) !important;
    border: 1px solid var(--accent-color) !important;
    border-radius: 8px;
    padding: 8px 35px 8px 15px !important;
    font-family: 'Prompt', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2300e5ff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e") !important;
    background-repeat: no-repeat !important;
    background-position: right 10px center !important;
    background-size: 1em !important;
    transition: all 0.3s ease;
}
select.filter-type-select:hover {
    background-color: rgba(0, 229, 255, 0.2) !important;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.3);
}
select.filter-type-select:focus {
    outline: none;
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.5);
}
select.filter-type-select option {
    background-color: #2a2a2a;
    color: white;
}

@keyframes blink-warning {
    0% { background: var(--warning); color: #000; box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.7); transform: scale(1); }
    50% { background: #ff1744; color: #fff; border-color: #ff1744; box-shadow: 0 0 25px 10px rgba(255, 23, 68, 0.9); transform: scale(1.08); font-weight: 800; }
    100% { background: var(--warning); color: #000; box-shadow: 0 0 0 0 rgba(255, 193, 7, 0); transform: scale(1); }
}

.btn-blink {
    animation: blink-warning 0.8s infinite;
    border: 2px solid #ff1744 !important;
    z-index: 10;
    position: relative;
}

/* =========================================================================
   RESPONSIVE DESIGN (Media Queries)
   ========================================================================= */

/* --- Mobile Bottom Navigation (Hidden by default on Desktop) --- */
.mobile-bottom-nav {
    display: none;
}

/* --- Tablets and Small Laptops (max-width: 1024px) --- */
@media (max-width: 1024px) {
    .barcode-container {
        width: 35%;
    }
    .cart-section {
        min-width: 280px;
    }
}

/* --- Mobile Phones (max-width: 768px) --- */
@media (max-width: 768px) {
    body {
        height: auto;
        overflow: auto;
    }
    
    .app-container {
        height: 100vh;
        padding: 5px;
        padding-bottom: 70px; /* Space for bottom nav */
    }

    .topbar {
        height: auto;
        padding: 10px;
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .logo {
        justify-content: center;
        font-size: 1.2rem;
    }

    .barcode-container {
        width: 100%;
        max-width: 100%;
    }

    .user-info {
        justify-content: space-between;
    }

    /* POS Mobile Tab Switching Layout */
    .main-layout {
        position: relative;
    }

    /* By default on mobile, show Products, hide Cart sections */
    .mobile-tab-products .product-section {
        display: flex !important;
        width: 100%;
        flex: 1;
    }
    .mobile-tab-products .cart-list-section,
    .mobile-tab-products .cart-section {
        display: none !important;
    }

    /* When Cart tab is active, hide Products, show Cart sections stacked vertically */
    .mobile-tab-cart .product-section {
        display: none !important;
    }
    .mobile-tab-cart .cart-list-section,
    .mobile-tab-cart .cart-section {
        display: flex !important;
        width: 100%;
        max-width: 100%;
        flex: none;
    }
    .mobile-tab-cart .cart-list-section {
        min-height: 300px;
        margin-bottom: 10px;
    }
    .mobile-tab-cart .main-layout {
        flex-direction: column;
        overflow-y: auto;
    }

    /* Mobile Bottom Navigation Bar */
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #1e1e1e;
        border-top: 1px solid var(--border-color);
        height: 60px;
        z-index: 1000;
        box-shadow: 0 -5px 15px rgba(0,0,0,0.5);
    }

    .mobile-tab-btn {
        flex: 1;
        background: transparent;
        border: none;
        color: var(--text-secondary);
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 5px;
        font-size: 0.8rem;
        cursor: pointer;
        transition: all 0.2s;
        position: relative;
    }

    .mobile-tab-btn i {
        font-size: 1.2rem;
    }

    .mobile-tab-btn.active {
        color: var(--accent-color);
    }

    .mobile-cart-badge {
        position: absolute;
        top: 5px;
        right: calc(50% - 25px);
        background: var(--danger);
        color: white;
        font-size: 0.7rem;
        font-weight: bold;
        padding: 2px 6px;
        border-radius: 10px;
    }

    /* Modals */
    .modal-content {
        width: 95%;
        padding: 20px;
        margin: auto;
    }
    
    #cash-form .btn {
        padding: 10px;
        font-size: 0.9rem;
    }
    #cash-change {
        font-size: 2.5rem !important;
    }

    /* Responsive Admin Table (Card Layout) */
    .admin-table thead {
        display: none;
    }
    .admin-table, .admin-table tbody, .admin-table tr, .admin-table td {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }
    .admin-table tr {
        margin-bottom: 15px;
        background: rgba(255,255,255,0.05);
        border-radius: 8px;
        padding: 10px;
        border: 1px solid var(--border-color);
    }
    .admin-table td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        text-align: right;
        padding: 8px 5px;
        border-bottom: 1px solid rgba(255,255,255,0.05);
        word-break: break-word;
        overflow-wrap: break-word;
        white-space: normal;
        gap: 10px;
    }
    .admin-table td > div {
        flex: 1;
        display: flex;
        justify-content: flex-end;
    }
    .admin-table td:last-child {
        border-bottom: none;
    }
    .admin-table td::before {
        content: attr(data-label);
        font-weight: bold;
        text-align: left;
        color: var(--text-secondary);
        flex-shrink: 0;
        margin-right: 15px;
        white-space: nowrap;
    }
}
