/* ==========================================================
   products.css — everything for the products page.
   Replaces BOTH "additions" blocks you appended to style.css
   (delete those; keep the rest of style.css as is).
   ========================================================== */

:root {
    --header-h: 69px;        /* main JS re-measures the real header height */
    --scroll-offset: 150px;  /* header + sticky topbar; measured by products.js */
    --pbrown: #3f2a1d;
}

[hidden] { display: none !important; }

/* ---------- Layout ---------- */
.products-page.container {
    display: flex;
    align-items: flex-start;
    gap: 24px;
    max-width: 1280px;
    padding-top: 12px;
    /* NEVER put overflow-x:hidden on an ancestor of a sticky element: it
       turns that ancestor into a scroll container and sticky stops working.
       (That was why the sidebar/topbar never followed the scroll.) */
    overflow: visible;
}
.products-main { flex: 1; min-width: 0; }

/* ---------- Sidebar ---------- */
.menu-sidebar {
    position: sticky;
    top: calc(var(--header-h) + 12px);
    flex: 0 0 250px;
    width: 250px;
    max-height: calc(100vh - var(--header-h) - 24px);
    overflow-y: auto;
    background: #fff;
    border: 1px solid #ececec;
    border-radius: 14px;
    padding: 14px 0;
    scrollbar-width: thin;
}
.menu-sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 18px 10px;
}
.menu-sidebar-head h3 { font-size: 1rem; font-weight: 700; color: #1a1a1a; }
.menu-sidebar-close {
    display: none;
    background: none;
    border: 0;
    font-size: 1.7rem;
    line-height: 1;
    cursor: pointer;
    color: #333;
}

.menu-list { display: flex; flex-direction: column; }
.menu-item { display: flex; align-items: center; }

.menu-item-link,
.menu-subitem {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: .84rem;
    color: #333;
    border-left: 3px solid transparent;
    transition: background-color .15s, border-color .15s;
}
.menu-item-link { flex: 1; padding: 11px 14px 11px 16px; }
.menu-subitem   { padding: 9px 14px 9px 30px; font-size: .8rem; color: #555; }

.menu-item-link.active,
.menu-subitem.active {
    font-weight: 700;
    color: #111;
    background: #f4f4f4;
    border-left-color: #111;
}
.menu-count {
    font-style: normal;
    font-size: .74rem;
    font-weight: 500;
    color: #999;
}
.menu-expand-btn {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    margin-right: 12px;
    border-radius: 50%;
    border: 1px solid #ccc;
    background: #fff;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: .8rem;
    line-height: 1;
}
.menu-subs { display: none; flex-direction: column; padding-bottom: 4px; }
.menu-group.open .menu-subs { display: flex; }

/* ---------- Sticky topbar ---------- */
.products-topbar {
    position: sticky;
    top: var(--header-h);
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--cream);
    padding: 10px 0;
}
.search-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1px solid #e3e3e3;
    border-radius: 10px;
    padding: 8px 12px;
    flex: 0 0 250px;
}
.search-pill > svg { width: 16px; height: 16px; flex-shrink: 0; color: #888; }
.search-pill input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    font-family: inherit;
    font-size: .85rem;
    color: #222;
}
.search-pill input::-webkit-search-cancel-button { display: none; }
.mic-btn {
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    color: #888;
    display: flex;
}
.mic-btn svg { width: 16px; height: 16px; }
.mic-btn.listening { color: #d33; }

.chip-row {
    flex: 1;
    min-width: 0;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 7px 12px;
    font-family: inherit;
    font-size: .78rem;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    white-space: nowrap;
}
.chip svg { width: 13px; height: 13px; }
.chip.active { background: var(--pbrown); border-color: var(--pbrown); color: #fff; }
.chip.active svg { stroke: #fff; }

/* Filters dropdown. `position: fixed` because .chip-row scrolls horizontally
   and would clip an absolutely-positioned child. products.js sets top/left. */
.filter-dropdown { flex-shrink: 0; }
.filter-panel {
    position: fixed;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
    padding: 8px;
    min-width: 210px;
    max-height: 70vh;
    overflow-y: auto;
    z-index: 210;
}
.filter-panel-scroll { display: flex; flex-direction: column; }
.filter-panel-label {
    font-size: .7rem;
    font-weight: 700;
    color: #999;
    padding: 6px 10px 2px;
}
.filter-option {
    background: none;
    border: 0;
    text-align: left;
    padding: 9px 10px;
    border-radius: 8px;
    font-family: inherit;
    font-size: .86rem;
    color: #333;
    cursor: pointer;
    white-space: nowrap;
}
.filter-option:hover,
.filter-option.active { background: #f6f0e8; color: var(--pbrown); font-weight: 700; }
.filter-panel-categories { display: none; }

/* ---------- Delivery slot row ---------- */
.delivery-slot-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin: 6px 0 4px;
}
.products-heading { font-size: .95rem; font-weight: 700; color: #1a1a1a; }
.delivery-slot-btn {
    display: none;
    align-items: center;
    gap: 8px;
    background: #fbe0ad;
    border: 0;
    border-radius: 30px;
    padding: 9px 16px;
    font-family: inherit;
    font-size: .8rem;
    font-weight: 600;
    color: #3a2a10;
    cursor: pointer;
    white-space: nowrap;
}
.delivery-slot-btn svg { width: 15px; height: 15px; flex-shrink: 0; }

/* ---------- Section headings ---------- */
.cat-section, .subcat-group { scroll-margin-top: var(--scroll-offset); }
.section-heading-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 22px 0 12px;
}
.section-heading-title {
    font-size: .8rem;
    font-weight: 800;
    letter-spacing: .03em;
    color: #222;
    white-space: nowrap;
}
.section-heading-title .sep { color: #aaa; font-weight: 500; margin: 0 3px; }
.section-heading-rule { flex: 1; height: 1px; background: #e2e2e2; }
.section-heading-count { font-size: .78rem; color: #888; white-space: nowrap; }

/* ---------- Cards ---------- */
.cat-section-products {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px 20px;
    margin-bottom: 26px; /* room for the ADD button that overhangs the image */
}
.prc {
    background: #fff;
    border: 1px solid #ececec;
    border-radius: 14px;
    padding: 16px;
    display: flex;
    gap: 14px;
    align-items: flex-start;
}
.prc-body { flex: 1; min-width: 0; }

.prc-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.prc-badge {
    background: #fdf1d1;
    color: #7a5b00;
    font-size: .66rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 5px;
    white-space: nowrap;
}
.prc-trend {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #e07a1f;
    font-size: .72rem;
    font-weight: 600;
    margin-bottom: 4px;
}
.prc-title { font-size: .92rem; font-weight: 700; color: #1a1a1a; line-height: 1.3; margin-bottom: 6px; cursor: pointer; }
.prc-unit { font-weight: 500; color: #777; font-size: .82rem; }
.prc-prep {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: linear-gradient(90deg, #fdf1d1, #fffaf0);
    color: #7a5b00;
    font-size: .7rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
    margin-bottom: 8px;
}
.prc-price { display: block; font-size: 1.05rem; font-weight: 800; color: #1a1a1a; margin-bottom: 4px; }
.prc-price .old-price { font-weight: 500; color: #999; text-decoration: line-through; font-size: .82rem; margin-right: 6px; }
.prc-save {
    display: inline-block;
    vertical-align: middle;
    margin-left: 8px;
    background: #1e9e4a;
    color: #fff;
    font-size: .66rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 5px;
}
.prc-stars { font-size: .78rem; letter-spacing: 1px; color: #f5b400; margin-bottom: 6px; }
.prc-stars .dim { color: #e2e2e2; }
.prc-desc {
    font-size: .8rem;
    color: #666;
    line-height: 1.45;
    margin: 4px 0 2px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.prc-desc.expanded { -webkit-line-clamp: unset; overflow: visible; }
.read-more { display: inline-block; font-size: .78rem; font-weight: 700; color: #1a1a1a; }

/* Image + ADD control */
.prc-media { position: relative; width: 128px; flex-shrink: 0; }
.prc-media img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 10px;
    background: #f2f2f2;
    cursor: pointer;
}
.prc.is-out .prc-media img { opacity: .55; }
.prc-outbadge {
    position: absolute;
    top: 8px; left: 8px;
    background: var(--pbrown);
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 5px;
    z-index: 2;
}
.prc-cart-control {
    position: absolute;
    left: 50%;
    bottom: -14px;
    transform: translateX(-50%);
    width: 88%;
}
.cart-btn-add {
    width: 100%;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 7px 0;
    font-family: inherit;
    font-weight: 800;
    font-size: .8rem;
    color: var(--pbrown);
    box-shadow: 0 2px 6px rgba(0, 0, 0, .1);
    cursor: pointer;
}
.cart-btn-add:disabled { color: #999; background: #f2f2f2; border-color: #e5e5e5; cursor: not-allowed; box-shadow: none; }
.cart-stepper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--pbrown);
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .1);
    overflow: hidden;
}
.cart-stepper .cart-btn { background: transparent; border: 0; color: #fff; font-weight: 800; font-size: .95rem; padding: 7px 12px; cursor: pointer; line-height: 1; }
.cart-stepper .cart-qty { color: #fff; font-weight: 700; font-size: .85rem; }

.empty-note { color: #777; font-size: .9rem; padding: 30px 0; text-align: center; }

/* ---------- Floating cart bar / scroll-top ---------- */
.view-cart-bar {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    display: none;
    align-items: center;
    gap: 12px;
    background: var(--pbrown);
    color: #fff;
    padding: 10px 20px 10px 12px;
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .28);
    cursor: pointer;
    z-index: 80;
}
.view-cart-bar.show { display: flex; }
.vc-icon { display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; background: rgba(255, 255, 255, .15); flex-shrink: 0; }
.vc-label { font-weight: 800; font-size: .95rem; display: block; }
.vc-sub { font-size: .78rem; opacity: .85; display: block; }
.vc-arrow { font-size: 1.3rem; line-height: 1; margin-left: 4px; }

.scroll-top-btn {
    position: fixed;
    right: 18px;
    bottom: 90px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid #e3e3e3;
    background: #fff;
    color: #333;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 70;
}

/* ---------- Mobile bottom bar (hidden on desktop) ---------- */
.mobile-bottom-bar { display: none; }

.menu-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 55;
}
.menu-backdrop.open { display: block; }
#filterPanelBackdrop { display: block; z-index: 205; }

/* ---------- Product popup ---------- */
.product-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(20, 15, 10, .55);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 300;
}
.product-modal-backdrop.open { display: flex; }
.product-modal {
    background: #fff;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
    display: flex;
    flex-direction: column;
}
.product-modal-media { position: relative; flex-shrink: 0; }
.product-modal-media img { width: 100%; height: 260px; object-fit: cover; background: #f2f2f2; }
.product-modal-media-actions { position: absolute; top: 14px; right: 14px; display: flex; gap: 8px; }
.modal-icon-btn {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: #fff;
    border: 0;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
    cursor: pointer;
    font-size: 1.2rem;
    color: #333;
}
.product-modal-body { padding: 20px; }
.product-modal-title { font-size: 1.15rem; font-weight: 800; color: #1a1a1a; margin: 4px 0 8px; }
.product-modal-desc { font-size: .9rem; color: #555; line-height: 1.55; }
#modalDescText { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.product-modal-desc.expanded #modalDescText { -webkit-line-clamp: unset; overflow: visible; }
.product-modal-footer {
    position: sticky;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--pbrown);
    color: #fff;
    border: 0;
    padding: 16px 22px;
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
}
.pm-price { font-weight: 700; }
.pm-cta { font-weight: 800; }

/* ==========================================================
   Mobile / tablet (<= 780px)
   ========================================================== */
@media (max-width: 780px) {
    .products-page.container { display: block; padding-top: 0; padding-bottom: 96px; }

    /* sidebar leaves the layout entirely: off-canvas drawer */
    .menu-sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        width: 82%;
        max-width: 320px;
        max-height: 100vh;
        border-radius: 0;
        border: 0;
        z-index: 60;
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: 4px 0 24px rgba(0, 0, 0, .18);
    }
    .menu-sidebar.open { transform: translateX(0); }
    .menu-sidebar-close { display: block; }

    /* search lives in the bottom bar; topbar is just the chips */
    #desktopSearchPill { display: none; }
    .products-topbar { padding: 8px 0; }

    .cat-section-products { grid-template-columns: 1fr; gap: 20px; }
    .prc { padding: 12px; gap: 10px; }
    .prc-media { width: 38%; max-width: 150px; }
    .products-heading { font-size: .95rem; }
    .delivery-slot-btn { font-size: .76rem; padding: 8px 12px; }

    .mobile-bottom-bar {
        display: flex;
        align-items: center;
        gap: 10px;
        position: fixed;
        left: 0; right: 0; bottom: 0;
        padding: 10px 14px;
        background: #fff;
        box-shadow: 0 -4px 16px rgba(0, 0, 0, .08);
        z-index: 90;
    }
    .mobile-bottom-bar .search-pill { flex: 1; background: #f4f4f4; border-color: #f4f4f4; }
    .mobile-menu-btn {
        flex: 0 0 auto;
        background: var(--pbrown);
        color: #fff;
        border: 0;
        border-radius: 10px;
        padding: 11px 22px;
        font-family: inherit;
        font-weight: 700;
        font-size: .88rem;
        cursor: pointer;
    }

    .view-cart-bar { bottom: 78px; padding: 9px 16px 9px 10px; gap: 10px; }
    .scroll-top-btn { bottom: 140px; right: 14px; }

    /* Filters becomes a bottom sheet that also lists categories */
    .filter-panel {
        left: 0; right: 0; bottom: 0;
        top: auto;
        width: 100%;
        max-height: 75vh;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -8px 30px rgba(0, 0, 0, .22);
        padding: 14px 14px 20px;
    }
    .filter-panel-categories { display: block; }
    .filter-cat-list {
        max-height: 40vh;
        overflow-y: auto;
        margin-bottom: 8px;
        border-bottom: 1px solid #eee;
        padding-bottom: 8px;
    }
}

@media (max-width: 480px) {
    .product-modal-backdrop { padding: 10px; }
    .product-modal { max-height: 94vh; border-radius: 16px; }
    .product-modal-media img { height: 200px; }
    .product-modal-body { padding: 16px; }
}