:root {
    --bg-color: #0f1015;
    --surface-color: rgba(25, 27, 36, 0.7);
    --gold: #d4af37;
    --gold-hover: #f1cf5b;
    --text-primary: #f0f0f0;
    --text-secondary: #9da0a8;
    --border-color: rgba(212, 175, 55, 0.15);
    --danger: #ff4d4d;
    --success: #00cc66;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(212, 175, 55, 0.05), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(212, 175, 55, 0.05), transparent 25%);
}

.gold-text {
    color: var(--gold);
}

.glass-panel {
    background: var(--surface-color);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* Login Page Specific */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-panel {
    width: 100%;
    max-width: 400px;
    padding: 3rem 2rem;
    text-align: center;
}

.logo h1 {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: 2px;
    margin-bottom: 0.5rem;
}

.logo p {
    color: var(--text-secondary);
    font-weight: 300;
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

input[type="text"],
input[type="password"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 0.8rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.2);
}

.btn {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-gold {
    background: var(--gold);
    color: #000;
}

.btn-gold:hover {
    background: var(--gold-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
}

.btn-danger {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
}
.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.w-100 { width: 100%; }

.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert.error {
    background: rgba(255, 77, 77, 0.1);
    border: 1px solid rgba(255, 77, 77, 0.3);
    color: #ffb3b3;
}

.test-creds {
    margin-top: 1.5rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}

/* Layout (Dashboard) */
.layout-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    border-right: 1px solid var(--border-color);
    padding: 2rem 0;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    overflow: hidden;
    white-space: nowrap;
}
.sidebar.collapsed {
    width: 80px;
}
.sidebar.collapsed .sidebar-logo-img {
    width: 44px;
    height: 44px;
    margin: 0 auto;
}
.sidebar.collapsed .logo h1 {
    display: none !important;
}
.sidebar.collapsed .nav-links li a .nav-text { display: none; }
.sidebar.collapsed .user-info p { display: none; }
.sidebar.collapsed .user-info form { display: flex; justify-content: center; }
.sidebar.collapsed .user-info .btn { padding: 0.5rem; font-size: 0.8rem; }

.hamburger {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    margin-right: 1rem;
    transition: color 0.3s;
}
.hamburger:hover {
    color: var(--gold);
}

.sidebar .logo {
    text-align: center;
    margin-bottom: 2.2rem;
    padding: 0 0.5rem;
}
.sidebar .logo a {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.sidebar-logo-img {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(212, 175, 55, 0.6);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar-logo-img:hover {
    transform: scale(1.08);
    border-color: var(--gold);
    box-shadow: 0 0 18px rgba(212, 175, 55, 0.5);
}
.sidebar .logo h1 {
    font-size: 1.45rem;
    font-weight: 800;
    margin: 0;
    letter-spacing: 1.5px;
    white-space: nowrap;
}

/* Login Panel Brand Logo */
.login-panel .brand-logo-img {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 1.25rem auto;
    display: block;
    border: 3px solid var(--gold);
    box-shadow: 0 0 25px rgba(212, 175, 55, 0.35);
    transition: transform 0.3s ease;
}
.login-panel .brand-logo-img:hover {
    transform: scale(1.06);
}

.nav-links {
    list-style: none;
    flex-grow: 1;
}

.nav-links li a {
    display: block;
    padding: 1rem 2rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.3s;
    border-left: 3px solid transparent;
}

.nav-links li a:hover,
.nav-links li a.active {
    background: rgba(212, 175, 55, 0.05);
    color: var(--gold);
    border-left-color: var(--gold);
}

.user-info {
    padding: 1rem 2rem;
    border-top: 1px solid rgba(255,255,255,0.05);
    text-align: center;
}
.user-info .role {
    font-size: 0.8rem;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.user-info .btn { margin-top: 1rem; width: 100%; font-size: 0.9rem;}

.main-content {
    flex-grow: 1;
    padding: 2rem 3rem;
    overflow-y: auto;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

/* Cards & Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    padding: 1.25rem 1.4rem;
    min-width: 0;
}

.stat-card h3 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-card .value {
    font-size: clamp(1.2rem, 2vw, 1.85rem);
    font-weight: 600;
    color: var(--gold);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Tables */
.table-container {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

th {
    color: var(--text-secondary);
    font-weight: 400;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
}

/* POS specific */
.pos-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
    height: calc(100vh - 100px);
}

.products-area {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    align-content: start;
    overflow-y: auto;
}

.product-card {
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s;
}
.product-card:hover {
    transform: scale(1.02);
    border-color: var(--gold);
}
.product-card h4 { margin-bottom: 0.5rem; }
.product-card .price { color: var(--gold); font-weight: 600; }

.cart-area {
    display: flex;
    flex-direction: column;
}
.cart-items {
    flex-grow: 1;
    overflow-y: auto;
    margin-bottom: 1rem;
}
.cart-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.cart-total {
    font-size: 1.5rem;
    text-align: right;
    margin: 1rem 0;
    color: var(--gold);
}

/* =======================================
   RESPONSIVENESS (Media Queries)
   ======================================= */

/* Tablet and Smaller */
@media (max-width: 1024px) {
    .dashboard-grid, .pos-grid {
        grid-template-columns: 1fr !important;
        height: auto !important;
    }

    .pos-layout {
        flex-direction: column !important;
        overflow: auto !important;
        height: auto !important;
    }
    
    .pos-main {
        overflow-y: visible !important;
    }

    .pos-sidebar {
        width: 100% !important;
        border-left: none !important;
        border-top: 1px solid var(--border-color) !important;
        padding: 1.5rem !important;
    }
    
    .products-area {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
    }
}

/* Mobile Devices */
@media (max-width: 768px) {
    .layout-container {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        width: 280px;
        height: 100vh;
        z-index: 9999;
        background: rgba(15, 16, 21, 0.95);
        backdrop-filter: blur(20px);
        transition: left 0.3s ease;
        border-right: 1px solid var(--border-color);
    }

    .sidebar.mobile-open {
        left: 0;
    }

    /* Force the hamburger button to show nav text when open on mobile even if collapsed class is present */
    .sidebar.mobile-open.collapsed {
        width: 280px;
    }
    .sidebar.mobile-open.collapsed .logo h1 span.gold-text { display: inline; }
    .sidebar.mobile-open.collapsed .logo h1::before { content: none; }
    .sidebar.mobile-open.collapsed .logo h1 { font-size: 2rem; letter-spacing: 2px; }
    .sidebar.mobile-open.collapsed .nav-links li a .nav-text { display: inline; }
    .sidebar.mobile-open.collapsed .user-info p { display: block; }
    .sidebar.mobile-open.collapsed .user-info .btn { padding: 0.8rem 1.5rem; font-size: 0.9rem; }
    
    .sidebar:not(.mobile-open) {
        /* Fix display issues when sliding out */
        overflow-y: auto;
    }

    .main-content, .pos-main {
        padding: 1rem;
        width: 100%;
        overflow-x: hidden;
    }
    
    .header, .pos-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1rem;
        padding-top: 10px;
    }

    /* Important: Override inline grids from views */
    .dashboard-grid, .stats-grid, .variant-grid {
        grid-template-columns: 1fr !important;
    }

    .pos-filters {
        flex-direction: column;
    }

    .pos-filters input, .pos-filters select, .pos-filters button {
        width: 100% !important;
    }

    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        width: 100%;
    }
    
    .table-container {
        width: 100vw;
        margin-left: -1rem;
        padding: 0 1rem;
    }

    .login-panel {
        padding: 2rem 1.5rem;
    }

    .variant-modal-content, .receipt-container {
        width: 95% !important;
        padding: 1.5rem;
    }
}

/* Password Toggle Wrapper */
.password-field-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.password-field-wrapper input {
    width: 100%;
    padding-right: 42px !important;
}

.password-toggle-btn {
    position: absolute;
    right: 8px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.15rem;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
    user-select: none;
}

.password-toggle-btn:hover {
    color: var(--gold);
    background: rgba(255, 255, 255, 0.05);
}

/* Size Preset Pills */
.size-preset-btn {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.size-preset-btn:hover, .size-preset-btn.active {
    background: rgba(212, 175, 55, 0.2);
    border-color: var(--gold);
    color: var(--gold);
}

/* =======================================
   SCROLLBAR & LAYOUT OPTIMIZATIONS
   ======================================= */
/* Custom Scrollbars */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.25);
    border-radius: 4px;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.35);
    border-radius: 4px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: var(--gold);
}

/* Dedicated Table Scroll Container with Sticky Headers & X/Y Scrolling */
.table-scroll-container {
    max-height: 56vh;
    overflow-y: auto;
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.15);
    position: relative;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

.table-scroll-container table {
    width: 100%;
    min-width: 850px; /* Guarantees horizontal X scroll on smaller screens to prevent awkward stacking */
    border-collapse: separate;
    border-spacing: 0;
}

.table-scroll-container thead th {
    position: sticky;
    top: 0;
    background: #181a24;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.table-scroll-container td {
    vertical-align: middle;
}

.table-scroll-container td.actions-cell,
.table-scroll-container td:last-child {
    white-space: nowrap; /* Prevents action buttons from wrapping and stacking on top of each other */
}

/* Universal KPI Grid for Management Pages */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
    width: 100%;
}
.kpi-card {
    padding: 1.15rem 1.25rem;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-radius: 10px;
}
.kpi-card h3 {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.kpi-card .kpi-value {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Universal Filter Panel & Filter Group */
.filter-panel {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.filter-group label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}
.filter-input {
    padding: 0.6rem 0.85rem;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    font-family: inherit;
    font-size: 0.88rem;
}
.filter-input:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.2);
}

/* Pagination Bar Component */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 0.5rem 0.25rem 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin-top: 0.85rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.pagination-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.page-btn {
    padding: 5px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
    border-radius: 6px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    font-weight: 500;
}

.page-btn:hover:not(:disabled) {
    border-color: var(--gold);
    color: var(--gold);
    background: rgba(212, 175, 55, 0.12);
    transform: translateY(-1px);
}

.page-btn.active {
    background: var(--gold);
    color: #000;
    font-weight: 700;
    border-color: var(--gold);
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.3);
}

.page-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

.page-size-select {
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--gold);
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
}

/* Universal Product Thumbnail with Hover Glow */
.product-img-thumb {
    width: 42px;
    height: 42px;
    object-fit: cover;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.product-img-thumb:hover {
    transform: scale(1.18);
    border-color: var(--gold);
    box-shadow: 0 4px 14px rgba(212, 175, 55, 0.45);
}

/* QR & Barcode Scanner Modal Styling */
#scannerModal .variant-modal-content {
    background: #151821;
    border: 1px solid rgba(212, 175, 55, 0.35);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8), 0 0 20px rgba(212, 175, 55, 0.15);
}

#reader {
    width: 100% !important;
    border: 1px dashed rgba(212, 175, 55, 0.4) !important;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.35);
    overflow: hidden;
}

#reader video {
    border-radius: 8px;
    max-width: 100% !important;
}

#reader button {
    background: var(--gold) !important;
    color: #0f1015 !important;
    font-weight: 600 !important;
    border: none !important;
    border-radius: 8px !important;
    padding: 8px 16px !important;
    margin: 6px 4px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    font-size: 0.9rem !important;
}

#reader button:hover {
    background: var(--gold-hover) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.35);
}

#reader select {
    background: #1f222e !important;
    color: #f0f0f0 !important;
    border: 1px solid rgba(212, 175, 55, 0.25) !important;
    border-radius: 8px !important;
    padding: 8px 12px !important;
    font-size: 0.85rem !important;
    margin: 6px 0 !important;
    outline: none !important;
    max-width: 100%;
}

#reader select option {
    background: #1a1d26;
    color: #f0f0f0;
}

#reader a {
    color: var(--gold) !important;
    text-decoration: underline !important;
    font-size: 0.85rem !important;
}

#reader span, #reader div {
    color: #d1d5db !important;
}

#reader__dashboard_section {
    padding: 12px !important;
    background: rgba(255, 255, 255, 0.03) !important;
    border-radius: 8px;
}

#reader__status_span {
    color: var(--gold) !important;
    font-size: 0.85rem !important;
    font-weight: 500;
}

/* =======================================
   POS VARIANT SELECTION MODAL
   ======================================= */
#variantModal .variant-modal-content {
    background: #151822;
    background: linear-gradient(155deg, rgba(28, 32, 44, 0.98), rgba(18, 20, 28, 0.98));
    border: 1px solid rgba(212, 175, 55, 0.35);
    border-radius: 14px;
    width: 520px;
    max-width: 100%;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 25px rgba(212, 175, 55, 0.12);
    overflow: hidden;
    position: relative;
}

.variant-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1.15rem 1.4rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.02);
    flex-shrink: 0;
    gap: 12px;
}

.btn-close-modal {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-secondary);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.btn-close-modal:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    color: #ef4444;
    transform: scale(1.05);
}

.variant-modal-body {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 1.25rem 1.4rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    min-height: 0;
}

.variant-modal-footer {
    padding: 1rem 1.4rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(15, 17, 23, 0.95);
    flex-shrink: 0;
}



