html.theme-light .cart-bar {
    background: linear-gradient(to top, rgba(250,248,245,0.97) 80%, transparent);
}
html.theme-light .out-of-stock { background: rgba(240,236,230,0.85); color: var(--text-muted); }

/* ─── Light Theme Override ─── */
html.theme-light {
    --bg: #faf8f5;
    --sidebar-bg: #f0ece6;
    --surface: #ffffff;
    --surface-hover: #f5f2ed;
    --card-bg: #ffffff;
    --border: #e0d8cc;
    --border-light: #c8beb0;
    --gold: #b8902a;
    --gold-dim: #d4b860;
    --gold-light: #e8c96a;
    --text: #1a1410;
    --text-muted: #6a5f52;
    --text-dim: #a09080;
    --success: #4a8a4a;
    --warning: #b87830;
    --danger: #c04040;
    overscroll-behavior: none;
    touch-action: pan-x pan-y;
}
html.theme-light body {
    background: var(--bg);
    color: var(--text);
}
html.theme-light .sidebar {
    background: var(--sidebar-bg);
    border-color: var(--border);
}
html.theme-light .cat-btn { color: var(--text); }
html.theme-light .cat-btn:hover, html.theme-light .cat-btn.active {
    background: var(--surface-hover);
    border-color: var(--gold);
}
html.theme-light .product-card {
    background: var(--card-bg);
    border-color: var(--border);
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}
html.theme-light .topbar { background: var(--surface); border-color: var(--border); }
html.theme-light .cart-panel { background: var(--surface); border-color: var(--border); }
html.theme-light .cart-item { border-color: var(--border); }
html.theme-light .checkout-btn { background: var(--gold); color: #1a1410; }
html.theme-light .btn-primary { background: var(--gold); color: #1a1410; }
html.theme-light .btn-ghost { border-color: var(--border); color: var(--text); }
html.theme-light .stepper { border-color: var(--border); }
html.theme-light .stepper-btn { color: var(--text); }
html.theme-light .price-total { color: var(--gold); }
html.theme-light .lang-btn { border-color: var(--border); color: var(--text); }
html.theme-light .cart-item-name { color: var(--text); }
html.theme-light .cart-item-price { color: var(--text-muted); }
html.theme-light .sidebar-brand { color: var(--text); }
html.theme-light .topbar-title { color: var(--text); }

/* Theme toggle button */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition);
    margin-top: auto;
    margin-bottom: 12px;
    flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--gold); color: var(--gold); }
.theme-toggle svg { flex-shrink: 0; }

/*
 * Cigar Lounge — POS Frontend CSS
 * Dark luxury · Touch-first · iPad tablet
 */

/* ─── Reset & Root ─── */
:root {
    --bg: #0f0d0b;
    --sidebar-bg: #1a1612;
    --surface: #1e1a15;
    --surface-hover: #262019;
    --card-bg: #221d17;
    --border: #2e2820;
    --border-light: #3a3228;
    --gold: #c9a84c;
    --gold-dim: #8a7234;
    --gold-light: #e8c96a;
    --text: #f0ebe3;
    --text-muted: #8a7f70;
    --text-dim: #5a5248;
    --success: #5a9a5a;
    --warning: #c98a3c;
    --danger: #c95050;
    --radius: 12px;
    --radius-lg: 16px;
    --ease-out: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --transition: 0.22s var(--ease-out);
}

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

html, body {
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', 'Noto Sans SC', -apple-system, sans-serif;
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
    /* Prevent pull-to-refresh on the whole page */
    overscroll-behavior: none;
    touch-action: pan-x pan-y;
}

/* ─── App Shell — Flex layout ─── */
.app-shell {
    display: flex;
    height: 100vh;       /* Fixed viewport height — no dvh jitter */
    width: 100%;
    overflow: hidden;
}

/* ─── Sidebar — flex item, fixed width, independent scroll ─── */
.sidebar {
    width: 220px;
    flex-shrink: 0;
    height: 100vh;               /* Explicit height for flex children */
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;             /* Sidebar itself doesn't scroll */
    /* NO position:fixed — use natural flex scroll instead */
}

.sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 26px;     /* Logo → text spacing */
    flex-shrink: 0;
    cursor: pointer;
    user-select: none;
}

.sidebar-logo {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--gold), var(--gold-dim));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0f0d0b;
    flex-shrink: 0;
}

.sidebar-brand {
    font-family: 'Playfair Display', serif;
    font-size: 1.0rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.2;
}

.sidebar-brand small {
    display: block;
    font-family: 'Inter', sans-serif;
    font-size: 0.65rem;
    font-weight: 400;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* Category nav — FULL independent scroll inside sidebar */
.sidebar-nav {
    flex: 1;
    min-height: 0;       /* Critical: allows flex child to shrink below content size */
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch; /* iOS native momentum */
    overscroll-behavior: contain;      /* prevent scroll chaining */
    padding: 12px 10px;
    /* Thin elegant scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.cat-label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-dim);
    padding: 10px 8px 6px;
}

/* Category buttons */
.cat-btn {
    display: flex;
    align-items: center;
    gap: 12px;      /* Icon → text gap */
    width: 100%;
    padding: 12px 10px;
    background: none;
    border: none;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 0.88rem;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s var(--ease-out), color 0.2s var(--ease-out);
    text-align: left;
    position: relative;
    user-select: none;
}

.cat-btn:hover { background: var(--surface-hover); color: var(--text); }

.cat-btn.active {
    background: linear-gradient(135deg, rgba(201,168,76,0.15), rgba(201,168,76,0.05));
    color: var(--gold);
}

.cat-btn.active::before {
    content: '';
    position: absolute;
    left: 0; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 60%;
    background: var(--gold);
    border-radius: 0 3px 3px 0;
}

/* Icon: small, rounded, gap from text */
.cat-icon {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    flex-shrink: 0;
    transition: background 0.2s var(--ease-out);
}

.cat-btn.active .cat-icon { background: rgba(201,168,76,0.2); }

.cat-count {
    margin-left: auto;
    font-size: 0.7rem;
    background: var(--surface);
    padding: 2px 8px;
    border-radius: 100px;
    color: var(--text-dim);
    flex-shrink: 0;
}

/* ─── Main Content ─── */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* Top bar */
.topbar {
    padding: 14px 24px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.topbar-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.15rem;
    color: var(--text);
    flex: 1;
}

.lang-selector {
.refresh-btn {
    background: none;
    border: 1.5px solid var(--text-secondary);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    transition: border-color .15s, color .15s;
}
.refresh-btn:active { opacity: .6; }
html.theme-light .refresh-btn { border-color: var(--text-secondary); color: var(--text); }

 position: relative; }

.lang-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 100px;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    transition: border-color 0.2s var(--ease-out), color 0.2s var(--ease-out);
    font-family: inherit;
}

.lang-btn:hover { border-color: var(--gold-dim); color: var(--gold); }

.lang-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: all 0.2s var(--ease-out);
    min-width: 100px;
    z-index: 50;
}
.lang-menu.open { opacity: 1; visibility: visible; transform: translateY(0); }

.lang-menu button {
    display: block;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
}
.lang-menu button:hover { background: var(--surface-hover); color: var(--gold); }

/* ─── Products Area — ONLY this area scrolls ─── */
.products-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch; /* iOS momentum */
    overscroll-behavior: contain;
    padding: 20px 24px 120px;
    scroll-behavior: smooth;
    /* Thin scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.products-area::-webkit-scrollbar { width: 4px; }
.products-area::-webkit-scrollbar-track { background: transparent; }
.products-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Products grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    align-items: stretch;
}

/* ─── Product Card ─── */
.product-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition:
        transform 0.3s var(--ease-spring),
        border-color 0.25s var(--ease-out),
        box-shadow 0.3s var(--ease-out);
    user-select: none;
    display: flex;
    flex-direction: column;
    min-height: 300px;
    max-height: 340px;
    will-change: transform;
}

.product-card:hover {
    border-color: var(--border-light);
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    transform: translateY(-4px);
}

.product-card:active { transform: scale(0.97); }

.product-image {
    width: 100%;
    height: 160px;
    overflow: hidden;
    background: #15120e;
    flex-shrink: 0;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s var(--ease-out);
}
.product-card:hover .product-image img { transform: scale(1.07); }

.product-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1612, #221d17);
    color: var(--gold-dim);
    opacity: 0.3;
}

.product-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.out-of-stock { background: rgba(15,13,11,0.7); color: var(--text-dim); }
.low-stock { background: rgba(201,138,60,0.15); color: #e8a060; backdrop-filter: blur(2px); }

.product-info {
    flex: 1;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 8px;
    min-height: 0;
}

.product-name {
    font-family: 'Playfair Display', serif;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.product-spec {
    font-size: 0.72rem;
    color: var(--text-dim);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.product-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: auto;
}

.product-price {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gold);
}

/* Qty stepper — icon gap fixed */
.qty-stepper {
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 100px;
    overflow: hidden;
    flex-shrink: 0;
}

.qty-btn {
    width: 34px;
    height: 34px;
    background: none;
    border: none;
    color: var(--gold);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    -webkit-tap-highlight-color: transparent;
    position: relative;
}
.qty-btn:active { background: var(--surface-hover); }
.qty-btn:disabled {
    color: #555 !important;
    cursor: not-allowed;
    pointer-events: none;
}
.qty-btn:disabled .x-icon { display: var(--show-x, none); }
.qty-btn:disabled .minus-icon { display: none; }
.qty-btn:not(:disabled) .x-icon { display: none; }

@keyframes qtyFlash {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.35); color: var(--gold); }
    100% { transform: scale(1); }
}
.qty-num { transition: color 0.15s; }
.qty-flash { animation: qtyFlash 0.3s ease-out; }

.qty-num {
    min-width: 28px;
    text-align: center;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
}

.unavailable-text {
    font-size: 0.7rem;
    color: var(--text-dim);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* ─── Bottom Cart Bar ─── */
.cart-bar {
    position: fixed;
    bottom: 0;
    left: 220px;
    right: 0;
    height: 80px;
    background: linear-gradient(to top, rgba(15,13,11,0.97) 80%, transparent);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    padding: 0 24px;
    z-index: 100;
    pointer-events: none;
}

.cart-bar-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    pointer-events: all;
    width: 100%;
}

.cart-summary {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 20px;
    cursor: pointer;
}

.cart-items-count {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 10px 18px;
    border-radius: 100px;
}

.cart-icon-wrap { position: relative; color: var(--gold); }

.cart-badge {
    position: absolute;
    top: -6px; right: -8px;
    background: var(--danger);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px; height: 18px;
    border-radius: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-total-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.cart-total {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gold);
    margin-right: 8px;    /* Gap before checkout button */
}

.checkout-btn {
    padding: 14px 32px;
    background: linear-gradient(135deg, var(--gold), var(--gold-dim));
    color: #0f0d0b;
    border: none;
    border-radius: 100px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s var(--ease-spring), box-shadow 0.2s var(--ease-out);
    font-family: inherit;
    letter-spacing: 0.03em;
    box-shadow: 0 4px 20px rgba(201,168,76,0.25);
}
.checkout-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(201,168,76,0.35); }
.checkout-btn:active { transform: scale(0.97); }
.checkout-btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; transform: none; }

/* ─── Responsive ─── */
@media (orientation: landscape) {
    .products-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

@media (orientation: portrait) {
    .products-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

@media (max-width: 900px) {
    .sidebar { width: 180px; }
    .cart-bar { left: 180px; }
}

@media (max-width: 600px) {
    .sidebar { display: none; }
    .cart-bar { left: 0; }
    .products-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .products-area { padding: 12px 12px 90px; }
}

/* ─── Animations ─── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(22px); }
    to   { opacity: 1; transform: translateY(0); }
}

.product-card {
    animation: fadeInUp 0.45s var(--ease-out) both;
}

/* Stagger */
.product-card:nth-child(1)  { animation-delay: 0ms; }
.product-card:nth-child(2)  { animation-delay: 55ms; }
.product-card:nth-child(3)  { animation-delay: 110ms; }
.product-card:nth-child(4)  { animation-delay: 165ms; }
.product-card:nth-child(5)  { animation-delay: 220ms; }
.product-card:nth-child(6)  { animation-delay: 275ms; }
.product-card:nth-child(7)  { animation-delay: 330ms; }
.product-card:nth-child(8)  { animation-delay: 385ms; }
.product-card:nth-child(n+9){ animation-delay: 440ms; }
