/* CSS Reset & Variables */
:root {
    /* Layout */
    --sidebar-width: 260px;
    --cart-width: 350px;
    --header-height: 70px;
    --border-radius-lg: 16px;
    --border-radius-md: 12px;
    --border-radius-sm: 8px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    /* Typography */
    --font-family: 'Outfit', sans-serif;

    /* Status Colors (remain constant) */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent-primary: #3b82f6;
    --accent-hover: #2563eb;
    
    --border-color: #334155;
    --table-header-bg: rgba(15, 23, 42, 0.5);
    --shadow-glow: 0 0 15px rgba(59, 130, 246, 0.3);
    --view-header-bg: rgba(30, 41, 59, 0.8);
}

[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --accent-primary: #3b82f6;
    --accent-hover: #2563eb;
    
    --border-color: #e2e8f0;
    --table-header-bg: #f8fafc;
    --shadow-glow: 0 4px 12px rgba(59, 130, 246, 0.15);
    --view-header-bg: rgba(255, 255, 255, 0.8);
}


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

body {
    font-family: var(--font-family);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden; /* Prevent body scroll, handle in sections */
    -webkit-font-smoothing: antialiased;
}

/* App Layout */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    max-height: 100vh;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.logo-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.logo-text {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #60a5fa, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    flex: 1;
    list-style: none;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.nav-links::-webkit-scrollbar {
    width: 5px;
}

.nav-links::-webkit-scrollbar-track {
    background: transparent;
}

.nav-links::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 16px;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-item:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    transform: translateX(4px);
}

.nav-item.active {
    background-color: rgba(59, 130, 246, 0.1);
    color: var(--accent-primary);
    border-right: 3px solid var(--accent-primary);
}

.nav-item-header {
    padding: 8px 20px 4px 52px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-footer {
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f59e0b, #ea580c);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    box-shadow: var(--shadow-sm);
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
}

.user-role {
    font-size: 12px;
    color: var(--text-muted);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--border-radius-sm);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--danger);
}

/* Main Content */
.main-content {
    flex: 1;
    position: relative;
    overflow: hidden;
    background-color: var(--bg-primary);
}

.view-section {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.view-section.active {
    opacity: 1;
    visibility: visible;
    z-index: 10;
}

.view-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--view-header-bg);
    backdrop-filter: blur(8px);
}

.view-header h2 {
    font-size: 22px;
    font-weight: 600;
}

/* Common UI Elements */
.search-bar {
    display: flex;
    align-items: center;
    background-color: var(--bg-tertiary);
    border-radius: 30px;
    padding: 8px 16px;
    width: 300px;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.search-bar:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.search-bar input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    outline: none;
    margin-left: 8px;
    width: 100%;
    font-family: var(--font-family);
}

.btn-primary {
    background-color: var(--accent-primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    font-family: var(--font-family);
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

/* Counter Layout */
.counter-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.products-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 24px;
    overflow-y: auto;
}

.categories-tabs {
    display: flex;
    gap: 12px;
    margin-bottom: 32px;
    overflow-x: auto;
    padding: 4px 4px 12px 4px;
    -webkit-overflow-scrolling: touch; 
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-color);
}

.categories-tabs::-webkit-scrollbar {
    height: 4px;
}

.categories-tabs::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.category-btn {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 10px 24px;
    border-radius: 30px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    transition: all 0.2s;
    font-family: var(--font-family);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 80px;
    height: 40px;
    flex-shrink: 0;
}

.category-btn.active, .category-btn:hover {
    background-color: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.product-card {
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border-color);
}

.product-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-primary);
}

/* List View for POS */
.products-grid.list-view {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.products-grid.list-view .product-card {
    display: flex;
    align-items: center;
    height: auto;
    padding: 10px;
}

.products-grid.list-view .product-image {
    width: 50px;
    height: 50px;
    border-radius: var(--border-radius-sm);
    margin-right: 15px;
    flex-shrink: 0;
}

.products-grid.list-view .product-info {
    display: flex;
    flex: 1;
    justify-content: space-between;
    align-items: center;
    padding: 0;
}

.products-grid.list-view .product-name {
    margin: 0;
    font-size: 15px;
}

.products-grid.list-view .product-price {
    font-size: 15px;
    font-weight: 600;
    color: var(--accent-primary);
}

.product-image {
    height: 140px;
    background-color: var(--bg-tertiary);
    background-size: cover;
    background-position: center;
}

.product-info {
    padding: 16px;
}

.product-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-price {
    color: var(--accent-primary);
    font-weight: 700;
    font-size: 18px;
}

/* Cart Area */
.cart-area {
    width: var(--cart-width);
    background-color: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

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

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}

.empty-cart-msg {
    text-align: center;
    color: var(--text-muted);
    margin-top: 50px;
}

.cart-summary {
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-primary);
}

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

.summary-row.total-row {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dashed var(--border-color);
    color: var(--text-primary);
    font-size: 20px;
    font-weight: 700;
}

.payment-actions {
    padding: 20px 24px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.btn-pay {
    padding: 14px;
    border-radius: var(--border-radius-sm);
    border: none;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-family);
}

.cash-btn { background-color: var(--success); color: white; }
.cash-btn:hover { background-color: #059669; transform: translateY(-2px); }

.card-btn { background-color: var(--warning); color: white; }
.card-btn:hover { background-color: #d97706; transform: translateY(-2px); }

.upi-btn { background-color: var(--accent-primary); color: white; }
.upi-btn:hover { background-color: var(--accent-hover); transform: translateY(-2px); }

.hold-btn { background-color: #6b7280; color: white; }
.hold-btn:hover { background-color: #4b5563; transform: translateY(-2px); }

.credit-btn { background-color: #8b5cf6; color: white; }
.credit-btn:hover { background-color: #7c3aed; transform: translateY(-2px); }

.multi-btn { background: linear-gradient(135deg, var(--accent-primary), #ec4899); color: white; }
.multi-btn:hover { background: linear-gradient(135deg, var(--accent-hover), #db2777); transform: translateY(-2px); }

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    overflow-y: auto;
    padding: 20px;
    transition: opacity 0.3s;
}

.modal-overlay.modal-high {
    z-index: 3000;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.login-card {
    background-color: var(--bg-secondary);
    padding: 40px;
    border-radius: var(--border-radius-lg);
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    border: 1px solid var(--border-color);
    transform: translateY(0);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    margin: auto;
}

.modal-overlay.hidden .login-card {
    transform: translateY(50px);
}

.login-toggle-btn {
    background: none;
    border: none;
    color: var(--accent-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--border-radius-sm);
    margin-top: 16px;
    text-decoration: none;
}

.login-toggle-btn:hover {
    color: var(--accent-hover);
    background-color: var(--bg-tertiary);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.logo-icon-large {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 16px;
}

.login-header h2 {
    font-size: 28px;
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-secondary);
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 14px;
}

.input-group input {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-family);
    transition: all 0.2s;
}

.input-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.full-width {
    width: 100%;
    justify-content: center;
    padding: 14px;
    font-size: 16px;
}

/* Data Tables */
.table-container {
    padding: 24px;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.data-table th, .data-table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background-color: var(--table-header-bg);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.05em;
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table tr:hover td {
    background-color: var(--bg-tertiary);
}

.action-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    margin-right: 8px;
    transition: color 0.2s;
}

.action-btn:hover {
    color: var(--accent-primary);
}
.action-btn.delete:hover {
    color: var(--danger);
}

/* Cart Item */
.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px dashed var(--border-color);
}

.cart-item-info {
    flex: 1;
}

.cart-item-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.cart-item-price {
    color: var(--accent-primary);
    font-size: 14px;
    font-weight: 700;
}

.cart-item-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-tertiary);
    border-radius: 20px;
    padding: 4px 8px;
}

.qty-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-qty {
    font-size: 14px;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

/* Orders List Specific */
.filter-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.filter-btn.active {
    background: var(--bg-secondary);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    display: inline-block;
    text-transform: uppercase;
}

.badge-cash { background: #bbf7d0; color: #166534; }
.badge-upi { background: #bfdbfe; color: #1e3a8a; }
.badge-card { background: #fef08a; color: #854d0e; }
.badge-cod { background: #ffedd5; color: #ea580c; }
.badge-razorpay { background: #e0f2fe; color: #0369a1; }
.badge-cashfree { background: #fae8ff; color: #a21caf; }
.badge-paypal { background: #e0f2fe; color: #1d4ed8; }
.badge-credit { background: #f3e8ff; color: #6b21a8; }
.badge-cheque { background: #f1f5f9; color: #475569; }
.badge-bank-transfer { background: #ccfbf1; color: #0f766e; }
.badge-completed { background: #dcfce7; color: #15803d; }
.badge-cancelled { background: #fee2e2; color: #b91c1c; }
.badge-deleted { background: #fee2e2; color: #b91c1c; }
.badge-new { background: #cffafe; color: #0891b2; }

.order-link {
    font-weight: 700;
    color: var(--text-primary);
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: transparent;
    transition: text-decoration-color 0.2s;
}

.order-link:hover {
    text-decoration-color: var(--text-primary);
}

.status-badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    display: inline-block;
}

.category-badge {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

/* Print CSS */
@media print {
    body * {
        visibility: hidden;
    }
    #invoice-modal, #invoice-modal * {
        visibility: visible;
    }
    #invoice-modal {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        background: white;
    }
    #close-invoice-modal, #btn-invoice-delete, #btn-invoice-wa, #btn-invoice-print-pos, #btn-invoice-print-pdf {
        display: none !important;
    }
}

/* --- Responsive Design --- */

.mobile-only {
    display: none !important;
}

/* Tablet & Mobile Shared */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 80px; /* Mini sidebar on tablets */
    }

    .sidebar .logo-text,
    .sidebar .nav-item span:not(.material-icons-outlined),
    .sidebar .user-details,
    .sidebar .sidebar-footer button {
        display: none;
    }

    .sidebar .nav-item {
        justify-content: center;
        padding: 14px 0;
    }

    .sidebar .nav-item .material-icons-outlined {
        margin: 0;
        font-size: 24px;
    }

    .sidebar .dropdown-arrow {
        display: none !important;
    }

    .sidebar .nav-dropdown {
        position: absolute;
        left: 80px;
        width: 200px;
        background: var(--bg-secondary);
        box-shadow: var(--shadow-lg);
        z-index: 100;
    }

    .cart-area {
        width: 300px;
    }
}

/* Mobile Specific (< 768px) */
@media (max-width: 768px) {
    .mobile-only {
        display: flex !important;
    }

    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        width: 280px;
        z-index: 1000;
        box-shadow: 20px 0 50px rgba(0,0,0,0.5);
        visibility: hidden;
    }

    .sidebar.active {
        left: 0;
        visibility: visible;
    }

    .sidebar .logo-text,
    .sidebar .nav-item span,
    .sidebar .user-details {
        display: flex !important;
    }

    .sidebar .nav-item {
        justify-content: flex-start;
        padding: 14px 20px;
    }

    .app-container {
        flex-direction: column;
    }

    .main-content {
        width: 100%;
    }

    .view-header {
        padding: 0 16px;
    }

    .view-header h2 {
        font-size: 18px;
    }

    /* Counter Responsive */
    .pos-mobile-tabs {
        display: none !important; /* Hide tabs switcher on mobile */
    }

    #pos-floating-cart-btn {
        display: none !important; /* Hide floating cart bar since cart is always visible */
    }

    #counter-view .counter-layout {
        flex-direction: row !important; /* Row layout on tablets for side-by-side products and cart */
        flex: 1 !important;
        height: calc(100% - 60px) !important;
        overflow: hidden !important;
    }

    #counter-view .products-area {
        display: flex !important; /* Ensure products grid is visible on mobile and tablets */
        flex: 1 !important;
    }

    #counter-view .cart-area {
        display: flex !important; /* Always show cart */
        width: 300px !important;
        max-height: none !important;
        border-top: none !important;
        border-left: 1px solid var(--border-color) !important;
        height: 100% !important;
        padding: 12px !important;
    }

    /* Small mobile screens/phones portrait: optimize with clean tabs switcher */
    @media (max-width: 600px) {
        .pos-mobile-tabs {
            display: flex !important;
        }
        
        #counter-view .counter-layout {
            flex-direction: column !important;
            height: calc(100% - 110px) !important; /* Adjust height to fit tab bar */
        }
        
        /* By default show products, hide cart */
        #counter-view .products-area {
            display: flex !important;
            height: 100% !important;
            width: 100% !important;
        }
        #counter-view .cart-area {
            display: none !important;
            width: 100% !important;
            height: 100% !important;
            border-left: none !important;
        }
        
        /* When show-cart class is present, hide products and show cart */
        #counter-view .counter-layout.show-cart .products-area {
            display: none !important;
        }
        #counter-view .counter-layout.show-cart .cart-area {
            display: flex !important;
        }
    }

    /* Responsive Grid Column Overrides for Dashboard/Analytics */
    @media (max-width: 768px) {
        /* Optimize Dashboard stat cards grid for mobile/tablet */
        div[style*="grid-template-columns: repeat(4, 1fr)"] {
            grid-template-columns: repeat(2, 1fr) !important;
            gap: 12px !important;
            margin-bottom: 16px !important;
        }
        
        /* Optimize charts/tables area on mobile */
        div[style*="display: grid; grid-template-columns: 1fr 1fr"] {
            grid-template-columns: 1fr !important;
            gap: 16px !important;
        }
    }
    
    @media (max-width: 480px) {
        div[style*="grid-template-columns: repeat(4, 1fr)"] {
            grid-template-columns: 1fr !important;
        }
    }


    #mobile-search-container .search-bar {
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        background-color: var(--bg-primary) !important;
        border: 1px solid var(--border-color) !important;
        border-radius: var(--border-radius-sm) !important;
        padding: 10px 14px !important;
    }

    #mobile-search-container .search-bar input {
        width: 100% !important;
    }

    /* Header optimization for POS on mobile */
    #counter-view .view-header {
        flex-wrap: nowrap;
        gap: 8px;
        padding: 0 12px;
        height: auto;
        min-height: 60px;
        justify-content: space-between;
    }

    #counter-view .view-toggle {
        display: none !important; /* Hide list/grid toggle on mobile */
    }

    #counter-view .search-bar {
        margin-left: 8px !important;
        flex: 1;
        min-width: 100px;
        max-width: 150px;
    }

    #counter-view #pos-search-input {
        width: 100% !important;
        padding: 6px !important;
        font-size: 13px;
    }

    #counter-view .header-actions {
        margin-right: 0 !important;
    }

    #counter-view #pos-staff-select {
        width: 90px !important;
        font-size: 11px;
        padding: 6px !important;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
    }

    .product-image {
        height: 100px;
    }

    .product-info {
        padding: 10px;
    }

    .product-name {
        font-size: 14px;
    }

    /* Table Responsiveness */
    .table-container {
        padding: 12px;
    }

    .data-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    /* Form Grids */
    .settings-layout, 
    #item-form .input-group[style*="display: flex"],
    #staff-form .input-group[style*="display: flex"] {
        grid-template-columns: 1fr !important;
        display: block !important;
    }

    #item-form .input-group[style*="display: flex"] > div,
    #staff-form .input-group[style*="display: flex"] > div {
        margin-bottom: 16px;
    }

    /* Modals */
    .modal-overlay {
        align-items: flex-start;
        padding: 20px 10px;
    }
    .login-card {
        width: 100%;
        max-width: 100%;
        padding: 30px 20px;
        border-radius: 16px;
        margin-top: 10px;
        margin-bottom: 20px;
    }
    .login-header h2 {
        font-size: 22px;
    }
    .logo-icon-large {
        width: 64px;
        height: 64px;
    }
    .login-header {
        margin-bottom: 24px;
    }

    /* Stats Grid */
    div[style*="grid-template-columns: repeat(4, 1fr)"] {
        grid-template-columns: 1fr 1fr !important;
    }
}

/* Sidebar Overlay for mobile */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    display: none;
}

.sidebar-overlay.active {
    display: block;
}

/* Staff Specific */
.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}
.role-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.role-owner { background: #fef9c3; color: #ca8a04; }
.role-manager { background: #dbeafe; color: #2563eb; }
.role-cashier { background: #ffedd5; color: #ea580c; }

/* Scanner Animation */
@keyframes scan {
    0% { top: 0; }
    100% { top: 100%; }
}

/* Custom Dropdown & Utility Classes */
.hidden:not(.modal-overlay) {
    display: none !important;
}

.search-results-dropdown {
    background-color: var(--bg-secondary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--border-radius-md) !important;
    box-shadow: var(--shadow-lg), var(--shadow-glow) !important;
    padding: 8px 0 !important;
    margin-top: 4px !important;
}

.search-item {
    padding: 12px 16px !important;
    cursor: pointer !important;
    transition: background-color 0.2s ease, color 0.2s ease !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
    color: var(--text-primary) !important;
}

.search-item:last-child {
    border-bottom: none !important;
}

.search-item:hover {
    background-color: var(--bg-tertiary) !important;
    color: var(--accent-primary) !important;
}

/* Toggle Switch Slider Styles for Shopify Setup Messages Modal */
.switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #475569;
    transition: 0.3s;
    border-radius: 24px;
}
.switch-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}
.switch-label input {
    opacity: 0;
    width: 0;
    height: 0;
}
.switch-label input:checked + .switch-slider {
    background-color: var(--success) !important;
}
.switch-label input:checked + .switch-slider:before {
    transform: translateX(20px);
}

/* Hide HTML5 Up/Down Spinners for Cart Quantity Input */
.cart-qty-input::-webkit-outer-spin-button,
.cart-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.cart-qty-input {
    -moz-appearance: textfield;
}

/* Dashboard Interactive Cards */
#home-low-stock-card {
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
#home-low-stock-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(245, 158, 11, 0.4);
}

/* PWA Connection Status & Offline Billing Styles */
@keyframes status-pulse {
    0% { transform: scale(0.95); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.5; }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    animation: status-pulse 2s infinite ease-in-out;
}

.status-dot.online {
    background-color: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.status-dot.offline {
    background-color: var(--warning);
    box-shadow: 0 0 8px var(--warning);
}

/* Offline badges and views */
.badge-draft {
    background-color: rgba(245, 158, 11, 0.15) !important;
    color: var(--warning) !important;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-pos {
    background-color: rgba(59, 130, 246, 0.15) !important;
    color: #3b82f6 !important;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-b2c {
    background-color: rgba(16, 185, 129, 0.15) !important;
    color: #10b981 !important;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-b2b {
    background-color: rgba(139, 92, 246, 0.15) !important;
    color: #8b5cf6 !important;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.badge-expense {
    background-color: rgba(239, 68, 68, 0.15) !important;
    color: #ef4444 !important;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Toast Container */
.toast-container {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

/* Toast Message */
.toast-message {
    pointer-events: auto;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 14px 24px;
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    font-family: var(--font-family);
    font-size: 15px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 320px;
    max-width: 500px;
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast-message.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-message.success {
    border-left: 4px solid var(--success);
}

.toast-message.error {
    border-left: 4px solid var(--danger);
}

.toast-message.info {
    border-left: 4px solid var(--accent-primary);
}

.toast-icon {
    font-size: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}


/* ==========================================================================
   INVOICE AND RECEIPT PRINT/PDF ISOLATED STYLING
   ========================================================================== */

/* Scope wrapper for all templates to isolate them from parent dark theme */
.invoice-body, 
.invoice-body *,
.invoice-box,
.invoice-box *,
.receipt-container,
.receipt-container * {
    color: #000000 !important;
    border-color: #000000 !important;
    box-sizing: border-box !important;
    text-shadow: none !important;
}

.invoice-body {
    font-family: 'Outfit', 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 11px;
    margin: 0 !important;
    padding: 10px !important;
    background-color: #ffffff !important;
    background: #ffffff !important;
    width: 100% !important;
    min-height: 100% !important;
}

/* Force light themes on cloned elements */
.invoice-box,
.receipt-container {
    background-color: #ffffff !important;
    background: #ffffff !important;
    box-shadow: none !important;
}

/* Ensure background of tables and cells is clean and transparent/white */
.invoice-box div, 
.invoice-box section, 
.invoice-box table, 
.invoice-box tr, 
.invoice-box td,
.receipt-container div,
.receipt-container table,
.receipt-container tr,
.receipt-container td {
    background-color: transparent !important;
    background: transparent !important;
}

.invoice-box th,
.receipt-container th {
    background-color: #f2f2f2 !important;
    background: #f2f2f2 !important;
}

/* A4 Invoice Styles */
.invoice-box {
    border: 1px solid #000000 !important;
    max-width: 210mm;
    margin: auto;
}

.invoice-box .header {
    text-align: center;
    border-bottom: 1px solid #000000 !important;
    padding: 10px;
    font-weight: bold;
    font-size: 16px;
    text-transform: uppercase;
}

.invoice-box .top-section {
    display: flex;
    border-bottom: 1px solid #000000 !important;
}

.invoice-box .seller-info {
    flex: 1.5;
    padding: 10px;
    border-right: 1px solid #000000 !important;
}

.invoice-box .invoice-meta {
    flex: 1;
    padding: 0;
}

.invoice-box .meta-row {
    display: flex;
    border-bottom: 1px solid #000000 !important;
    min-height: 35px;
}

.invoice-box .meta-row:last-child {
    border-bottom: none;
}

.invoice-box .meta-cell {
    flex: 1;
    padding: 5px;
    border-right: 1px solid #000000 !important;
}

.invoice-box .meta-cell:last-child {
    border-right: none;
}

.invoice-box .meta-label {
    font-size: 9px;
    font-weight: bold;
    margin-bottom: 3px;
    display: block;
    color: #444444 !important;
}

.invoice-box .buyer-consignee {
    display: flex;
    border-bottom: 1px solid #000000 !important;
    min-height: 100px;
}

.invoice-box .buyer-box {
    flex: 1;
    padding: 10px;
    border-right: 1px solid #000000 !important;
}

.invoice-box .buyer-box:last-child {
    border-right: none;
}

.invoice-box .items-table {
    width: 100%;
    border-collapse: collapse;
    min-height: 400px;
}

.invoice-box .items-table th, 
.invoice-box .items-table td {
    border: 1px solid #000000 !important;
    padding: 6px;
    text-align: left;
}

.invoice-box .items-table th {
    font-weight: bold;
}

.invoice-box .items-table td {
    vertical-align: top;
}

.invoice-box .right {
    text-align: right;
}

.invoice-box .center {
    text-align: center;
}

.invoice-box .summary-section {
    display: flex;
    border-bottom: 1px solid #000000 !important;
}

.invoice-box .amount-words {
    flex: 1.5;
    padding: 10px;
    border-right: 1px solid #000000 !important;
    font-size: 10px;
}

.invoice-box .totals-box {
    flex: 1;
    padding: 0;
}

.invoice-box .total-item {
    display: flex;
    justify-content: space-between;
    padding: 5px 10px;
    border-bottom: 1px solid #eee;
}

.invoice-box .total-item.grand {
    font-weight: bold;
    font-size: 14px;
    border-top: 1px solid #000000 !important;
}

.invoice-box .gst-breakdown {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0;
    border-bottom: 1px solid #000000 !important;
}

.invoice-box .gst-breakdown th, 
.invoice-box .gst-breakdown td {
    border: 1px solid #000000 !important;
    padding: 4px;
    font-size: 9px;
    text-align: center;
}

.invoice-box .footer-section {
    padding: 10px;
    display: flex;
}

.invoice-box .bank-details {
    flex: 1;
    font-size: 10px;
    line-height: 1.6;
}

.invoice-box .signature-box {
    flex: 1;
    text-align: right;
    font-size: 10px;
}

.invoice-box .sign-area {
    margin-top: 40px;
    font-weight: bold;
}

/* Scoped Thermal Receipt Styles */
.receipt-container {
    width: 100%;
    padding: 5px;
    box-sizing: border-box;
    text-align: center;
}

.receipt-container .logo {
    width: 80px;
    height: auto;
    margin: 0 auto 10px auto;
    display: block;
}

.receipt-container .biz-name {
    font-size: 18px;
    font-weight: 800;
    text-transform: uppercase;
    margin-bottom: 5px;
}

.receipt-container .biz-details {
    font-size: 11px;
    line-height: 1.4;
    color: #444 !important;
    margin-bottom: 10px;
}

.receipt-container .divider {
    border-top: 1px solid #ddd;
    margin: 10px 0;
}

.receipt-container .receipt-info {
    font-size: 12px;
    color: #555 !important;
    margin-bottom: 15px;
}

.receipt-container .totals-section {
    border-top: 1px solid #000;
    padding-top: 8px;
    margin-top: 10px;
}

.receipt-container .total-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    margin-bottom: 5px;
}

.receipt-container .grand-total {
    font-weight: 800;
    font-size: 15px;
    margin-top: 5px;
    border-top: 1px solid #ddd;
    padding-top: 8px;
}

.receipt-container .footer {
    margin-top: 25px;
    font-size: 12px;
    color: #555 !important;
    font-style: italic;
    border-top: 1px solid #ddd;
    padding-top: 10px;
}

