/* ==========================================================
   Bakery Co. — main stylesheet
   ========================================================== */

:root {
    --brand: #613721;
    --brand-light: #8a5a3c;
    --cream: #fdf6ef;
    --text: #2b1d14;
    --muted: #7a6a5e;
    --border: #ecdfd2;
    --radius: 12px;
    --shadow: 0 4px 16px rgba(97, 55, 33, 0.08);
    --header-h: 69px;       /* fallback; main.js measures the real height and overrides this live */
    --scroll-offset: 130px; /* fallback; main.js measures header + topbar height and overrides this live */
}

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

/* The [hidden] attribute is used throughout (cart stepper, modal bits,
   badges) to show/hide elements from JS. Some of those elements also get a
   class-based `display` rule (e.g. .cart-stepper { display: flex }), and an
   author class rule beats the browser's built-in [hidden] rule in the
   cascade — so without this, hidden elements could stay visible. This
   forces [hidden] to always win, everywhere. */
[hidden] { display: none !important; }

body {
    font-family: 'Poppins', sans-serif;
    color: var(--text);
    background: var(--cream);
    line-height: 1.5;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }
img { max-width: 100%; display: block; }

.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ---------- Header ---------- */
.site-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
}

.logo { display: flex; align-items: center; gap: 8px; }
.logo img { height: 40px; width: auto; }
.logo-text { font-weight: 700; font-size: 1.2rem; color: var(--brand); }

.main-nav { display: flex; gap: 28px; }
.main-nav a {
    font-weight: 500;
    color: var(--text);
    padding-bottom: 4px;
    border-bottom: 2px solid transparent;
    transition: border-color .2s;
    font-size: .88rem !important;
}
.main-nav a.active,
.main-nav a:hover { border-color: var(--brand); color: var(--brand); }

.header-actions { display: flex; align-items: center; gap: 14px; }

.btn-outline {
    border: 1px solid var(--brand);
    color: var(--brand);
    background: transparent;
    padding: 8px 18px;
    border-radius: 30px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    font-size: .9rem;
}
.btn-outline:hover { background: var(--brand); color: #fff; }

.btn-primary {
    background: var(--brand);
    color: #fff;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.btn-primary:hover { background: var(--brand-light); }
.btn-block { width: 100%; }

.nav-toggle {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid var(--border);
    cursor: pointer;
    flex: 0 0 auto;
}
.nav-toggle span { width: 16px; height: 2px; background: var(--text); }

/* Circular icon button (account) used on mobile */
.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid var(--border);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex: 0 0 auto;
    color: var(--brand);
}
.icon-btn svg { width: 18px; height: 18px; }

.logo-center { display: flex; flex-direction: column; align-items: center; text-align: center; }
.logo-tagline {
    font-size: .6rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-top: 1px;
}

/* ---------- Banner carousel ---------- */
.banner-wrap {
    max-width: none !important;
    margin: 24px auto 0;
    padding: 0 20px;
}
.banner-carousel {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 6;
    overflow: hidden;
    background: var(--border);
    border-radius: 20px;
}
.banner-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity .5s ease;
}
.banner-slide.active { opacity: 1; }
.banner-slide img { width: 100%; height: 100%; object-fit: cover; }
.banner-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--muted);
    background: var(--border);
}

.carousel-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,.85);
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--brand);
}
.carousel-arrow.prev { left: 16px; }
.carousel-arrow.next { right: 16px; }

.carousel-dots {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
}
.carousel-dots span {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,.6);
    cursor: pointer;
}
.carousel-dots span.active { background: #fff; }

/* ---------- Tagline / section heading (dashed line style) ---------- */
.section-heading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-top: 36px;
}
.section-heading h2,
.section-heading h4 {
    color: var(--brand);
    font-size: 1.4rem;
    white-space: nowrap;
}
.section-heading.small h4 { font-size: 1.1rem; }
.section-heading .heading-line {
    flex: 1;
    max-width: 60px;
    border-top: 1px dashed var(--brand-light);
}
.section-subtext {
    text-align: center;
    color: var(--muted);
    font-size: .85rem;
    margin-top: 6px;
    margin-bottom: 24px;
}

/* ---------- Section titles ---------- */
.section-title,
.section-title-alt {
    font-size: 1.3rem;
    margin: 36px 0 18px;
    color: var(--brand);
}
.section-title-alt { text-align: center; }

/* ---------- Category grid ---------- */
.category-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
}
.category-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    text-align: center;
    box-shadow: var(--shadow);
    transition: transform .15s;
}
.category-card:hover { transform: translateY(-3px); }
.category-card.is-extra { display: none; }
.category-card.is-extra.show { display: block; }
.category-card-img {
    width: 100%;
    aspect-ratio: 4 / 3;
    background: var(--border);
}
.category-card-img img { width: 100%; height: 100%; object-fit: cover; }
.category-card span {
    display: block;
    padding: 10px 8px;
    font-size: .85rem;
    font-weight: 500;
}

.btn-view-all {
    display: block;
    margin: 24px auto 0;
    background: var(--brand);
    color: #fff;
    border: none;
    padding: 10px 28px;
    border-radius: 30px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.btn-view-all:hover { background: var(--brand-light); }

/* ---------- Features strip ---------- */
.features-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin: 36px auto;
}
.feature-item {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    text-align: center;
}
.feature-icon { font-size: 1.6rem; margin-bottom: 8px; }
.feature-item h5 { font-size: .9rem; margin-bottom: 4px; color: var(--brand); }
.feature-item p { font-size: .78rem; color: var(--muted); }

/* ---------- Promo box ---------- */
.promo-section { margin-bottom: 36px; }
.promo-box {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 22px 26px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.promo-discount {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 10px;
}
.promo-code {
    display: inline-flex;
    align-items: center;
    font-size: .82rem;
    border: 1px dashed var(--brand-light);
    border-radius: 20px;
    padding: 6px 16px;
    color: var(--brand);
    background: var(--cream);
}
.promo-badge {
    flex: 0 0 auto;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: 700;
}

/* ---------- Product carousel (horizontal, auto-scrolling cards) ---------- */
.product-carousel { position: relative; }
.product-scroll {
    display: flex;
    gap: 18px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 12px;
    scrollbar-width: none;
}
.product-scroll::-webkit-scrollbar { display: none; }
.product-card-v2 {
    flex: 0 0 200px;
    scroll-snap-align: start;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    box-shadow: var(--shadow);
}
.product-img-v2 {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 8px;
    overflow: hidden;
    background: var(--border);
    margin-bottom: 10px;
}
.product-img-v2 img { width: 100%; height: 100%; object-fit: cover; }
.stock-dot {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #3cb043;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,.05);
}
.qty-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    background: #3cb043;
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}
.product-title-v2 {
    font-size: .88rem;
    font-weight: 600;
    min-height: 2.3em;
    margin-bottom: 8px;
}
.product-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.price-v2 { font-weight: 700; color: var(--brand); font-size: .9rem; }
.price-v2 .old-price { font-weight: 400; margin-right: 4px; }
.btn-view {
    background: var(--brand);
    color: #fff;
    border: none;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
}
.btn-view:hover { background: var(--brand-light); }

.product-dots {
    position: static;
    transform: none;
    justify-content: center;
    margin-top: 8px;
}
.product-dots span {
    background: var(--border);
}
.product-dots span.active {
    background: var(--brand);
}

/* ---------- Products ---------- */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}
.product-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.product-img {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 8px;
    overflow: hidden;
    background: var(--border);
}
.product-img img { width: 100%; height: 100%; object-fit: cover; }
.product-title { font-size: .95rem; font-weight: 600; min-height: 2.4em; }
.product-price { display: flex; align-items: baseline; gap: 8px; }
.old-price { text-decoration: line-through; color: var(--muted); font-size: .85rem; }
.new-price { font-weight: 700; color: var(--brand); }
.btn-add {
    margin-top: auto;
    background: var(--cream);
    border: 1px solid var(--brand);
    color: var(--brand);
    font-weight: 600;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
}
.btn-add:hover { background: var(--brand); color: #fff; }

.empty-note { color: var(--muted); font-size: .9rem; }

/* ---------- Footer ---------- */
.site-footer {
    background: #2b1d14;
    color: #e9ded3;
    margin-top: 60px;
    padding-top: 40px;
}
.footer-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 30px;
    padding-bottom: 30px;
}
.footer-col h6 { margin-bottom: 14px; color: #fff; font-size: .95rem; }
.footer-col ul li { margin-bottom: 8px; }
.footer-col a { opacity: .8; font-size: .88rem; }
.footer-col a:hover { opacity: 1; }
.footer-col p { opacity: .8; font-size: .88rem; margin-bottom: 6px; }
.payment-icons { display: flex; gap: 10px; flex-wrap: wrap; }
.payment-icons img { height: 22px; filter: brightness(0) invert(1); opacity: .85; }

.footer-bottom {
    border-top: 1px solid rgba(255,255,255,.1);
    padding: 16px 20px;
    font-size: .8rem;
    opacity: .7;
    text-align: center;
}

/* ---------- Login modal ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: #fff;
    border-radius: var(--radius);
    padding: 28px;
    width: 90%;
    max-width: 380px;
    position: relative;
}
.modal-close {
    position: absolute;
    top: 12px; right: 14px;
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--muted);
}
.modal-box h3 { margin-bottom: 18px; color: var(--brand); }
.modal-box label { display: block; font-size: .85rem; font-weight: 500; margin: 14px 0 6px; }
.phone-input {
    display: flex;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.phone-input .prefix { padding: 12px; background: var(--cream); font-weight: 600; }
.phone-input input {
    border: none;
    padding: 12px;
    flex: 1;
    font-family: inherit;
    font-size: 1rem;
}
.phone-input input:focus { outline: none; }
.agree-check {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: .8rem;
    color: var(--muted);
    font-weight: 400 !important;
}
.agree-check a { color: var(--brand); text-decoration: underline; }
.agree-check input { margin-top: 3px; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
    .header-inner {
        display: grid;
        grid-template-columns: 38px 1fr 38px;
        align-items: center;
        column-gap: 10px;
    }
    .nav-toggle { display: flex; }
    .icon-btn { display: flex; }
    .header-actions { justify-content: flex-end; }
    .btn-outline.account-text { display: none; }

    .main-nav {
        display: none;
        grid-column: 1 / -1;
        order: 4;
    }
    .main-nav.open {
        display: flex;
        flex-direction: column;
        gap: 0;
        background: #fff;
        border-top: 1px solid var(--border);
        margin: 10px -20px 0;
        padding: 6px 20px;
    }
    .main-nav.open a {
        padding: 12px 0;
        border-bottom: 1px solid var(--border);
        border-bottom-width: 1px;
    }
    .main-nav.open a.active,
    .main-nav.open a:hover { border-color: var(--border); }

    .footer-grid { grid-template-columns: repeat(2, 1fr); }
    .features-strip { grid-template-columns: repeat(2, 1fr); }
    .promo-box { flex-direction: row; text-align: left; }
}

/* Phones: 3-column category grid, tighter spacing, to match the compact
   mobile layout (see reference design). */
@media (max-width: 560px) {
    .container { padding: 0 14px; }

    .site-header { background: var(--cream); }
    .header-inner { padding: 10px 14px; }
    .logo img { height: 30px; }
    .logo-text { font-size: 1rem; }

    .banner-wrap { padding: 0 14px; margin-top: 14px; }
    .banner-carousel { aspect-ratio: 16 / 9; border-radius: 16px; }

    .section-heading { margin-top: 24px; }
    .section-heading h2 { font-size: 1.15rem; white-space: normal; text-align: center; }

    .category-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
    .category-card span { font-size: .72rem; padding: 8px 6px; }

    .features-strip { grid-template-columns: repeat(2, 1fr); gap: 10px; }

    .promo-box { padding: 18px; border-radius: 16px; }
    .promo-discount { font-size: 1.2rem; }

    .product-card-v2 { flex: 0 0 150px; padding: 10px; }
    .product-title-v2 { font-size: .8rem; }
    .price-v2 { font-size: .82rem; }
    .btn-view { padding: 5px 12px; font-size: .74rem; }
}
/* ==========================================================
   Additions/replacements needed for the single-scroll, card-grid
   category layout shown in the reference design. Append these to
   your existing stylesheet — they only touch products-page classes,
   nothing else on the site.
   ========================================================== */

/* ---------- Desktop two-column layout ---------- */
.products-page.container {
    display: flex;
    align-items: flex-start;
    gap: 28px;
    /* Defensive: sticky breaks silently if any ancestor clips overflow.
       Force this explicitly rather than relying on nothing else setting it. */
    overflow: visible;
}

/* ---------- Products heading + delivery slot row ----------
   These had no rules at all before: the heading/count sat unstyled, and
   the delivery-slot button had no layout and no sizing on its two SVG
   icons — so the browser fell back to the default ~300x150px SVG box,
   which is what made the chevron render huge and the button balloon into
   a tall card instead of a compact pill. */
.delivery-slot-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin: 4px 0 16px;
}
.products-heading {
    display: flex;
    align-items: baseline;
    gap: 10px;
    font-size: 1.25rem;
    color: var(--brand);
}
.item-count {
    font-size: .82rem;
    font-weight: 500;
    color: var(--muted);
}
.delivery-slot-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #f6f6f6;
    border: 1px solid var(--border);
    border-radius: 30px;
    padding: 10px 16px;
    font-family: inherit;
    font-size: .85rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}
.delivery-slot-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--brand);
}
@media (max-width: 560px) {
    .products-heading { font-size: 1.05rem; }
    .delivery-slot-btn { font-size: .78rem; padding: 8px 12px; }
}
/* ==========================================================
   Additions/replacements needed for the single-scroll, card-grid
   category layout shown in the reference design. Append these to
   your existing stylesheet — they only touch products-page classes,
   nothing else on the site.
   ========================================================== */

/* ---------- Sticky topbar + sidebar ---------- */
.menu-sidebar {
    position: sticky;
    top: 0;
    align-self: flex-start;
    max-height: 100vh;
    overflow-y: auto;
}

/* ---------- Global overflow safety ----------
   Nothing on this page should ever force the whole viewport to scroll
   sideways. Anything that legitimately needs to scroll sideways (the chip
   row) opts in explicitly with its own overflow-x: auto below — this just
   stops any stray wide child from stretching its parent. */
.products-page,
.products-main,
.products-topbar,
.delivery-slot-row,
.product-list {
    max-width: 100%;
    overflow-x: hidden;
}

.products-topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #fff;
    padding-bottom: 12px;
}

/* Active category/subcategory in the sidebar: bold text + left accent bar,
   matching the "Family Favourites" highlighted row in the reference shot. */
.menu-item-link,
.menu-subitem {
    border-left: 3px solid transparent;
    transition: background-color .15s, border-color .15s;
}
.menu-item-link.active,
.menu-subitem.active {
    font-weight: 700;
    color: #111;
    background: #f6f6f6;
    border-left-color: #111;
}

/* scroll-margin-top stops an anchor jump / scrollIntoView from tucking a
   section's heading behind the sticky topbar. Must match SCROLL_OFFSET in
   main.js. */
.cat-section,
.subcat-group {
    scroll-margin-top: 130px;
}

/* ---------- Section heading (breadcrumb + rule + item count) ---------- */
.section-heading-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 28px 0 14px;
}
.cat-section:first-child .section-heading-row { margin-top: 8px; }

.section-heading-title {
    font-size: .82rem;
    font-weight: 800;
    letter-spacing: .03em;
    color: #222;
    white-space: nowrap;
    margin: 0;
    text-transform: uppercase;
}
.section-heading-title .sep {
    color: #bbb;
    font-weight: 500;
    margin: 0 4px;
}
.section-heading-rule {
    flex: 1;
    height: 1px;
    background: #e2e2e2;
}
.section-heading-count {
    font-size: .82rem;
    color: #888;
    white-space: nowrap;
}

/* ---------- Card grid ---------- */
.cat-section-products {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 8px;
}
@media (max-width: 780px) {
    .cat-section-products { grid-template-columns: 1fr; }
}

.prc {
    background: #fff;
    border: 1px solid #ececec;
    border-radius: 14px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .04);
    padding: 16px;
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.prc-body {
    flex: 1;
    min-width: 0;
}

/* Badge pills ("Bestseller" / "Highly Ordered" / "New").
   NOTE: only render once tbl_product has real flags — see the TODO in
   products.php's render_product_card(). */
.prc-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}
.prc-badge {
    background: #fdf1d1;
    color: #7a5b00;
    font-size: .68rem;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 5px;
    white-space: nowrap;
}

/* Small "↗ Highly Ordered" trend line under the badges.
   NOTE: same missing-data caveat as the badges above. */
.prc-trend {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #e07a1f;
    font-size: .75rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.prc-title {
    font-size: .95rem;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 6px;
    line-height: 1.3;
}
.prc-unit {
    font-weight: 500;
    color: #777;
    font-size: .85rem;
}

/* Preparation-time pill. NOTE: needs a real prep_hours column — see TODO. */
.prc-prep {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: linear-gradient(90deg, #fdf1d1, #fffaf0);
    color: #7a5b00;
    font-size: .72rem;
    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: .85rem;
    margin-right: 6px;
}

/* Star rating. NOTE: needs a real avg_rating column/table — see TODO. */
.prc-stars {
    font-size: .78rem;
    letter-spacing: 1px;
    color: #f5b400;
    margin-bottom: 6px;
}
.prc-stars .dim { color: #e2e2e2; }

.prc-desc {
    font-size: .82rem;
    color: #666;
    line-height: 1.45;
    margin: 4px 0 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.prc-desc.expanded {
    -webkit-line-clamp: unset;
    overflow: visible;
}
.prc-desc .read-more {
    display: inline-block;
    margin-left: 4px;
    font-weight: 700;
    color: #b5651d;
    text-decoration: none;
    white-space: nowrap;
}

/* ---------- Image + ADD+ / stepper 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;
    display: block;
    background: #f2f2f2;
}

/* Out-of-stock state. NOTE: defaults to "in stock" for everything until a
   real column exists — see the $inStock TODO in products.php. */
.prc.is-out .prc-media img { opacity: .55; }
.prc-outbadge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: #3f2a1d;
    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-weight: 800;
    font-size: .82rem;
    color: #3f2a1d;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .1);
    cursor: pointer;
}
.cart-btn-add .plus {
    display: inline-block;
    margin-left: 2px;
}
.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: #3f2a1d;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .1);
    overflow: hidden;
}
.cart-stepper .cart-btn {
    background: transparent;
    border: none;
    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;
}

/* ---------- Floating "View Cart" bar ---------- */
.view-cart-bar {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    display: none;
    align-items: center;
    gap: 12px;
    background: #3f2a1d;
    color: #fff;
    padding: 10px 20px 10px 12px;
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .28);
    cursor: pointer;
    z-index: 50;
}
.view-cart-bar.show { display: flex; }
.view-cart-bar .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;
}
.view-cart-bar .vc-label {
    font-weight: 800;
    font-size: .95rem;
    display: block;
}
.view-cart-bar .vc-sub {
    font-size: .78rem;
    opacity: .85;
    display: block;
}
.view-cart-bar .vc-arrow {
    font-size: 1.3rem;
    line-height: 1;
    margin-left: 4px;
}

/* On mobile, sit the cart bar above the bottom search/menu bar. */
@media (max-width: 780px) {
    .view-cart-bar { bottom: 78px; }
}

/* ---------- Chip row (make sure it scrolls horizontally on narrow
   screens instead of wrapping/overflowing the viewport) ---------- */
.chip-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip-row .chip,
.filter-dropdown { flex-shrink: 0; }

/* ---------- "Filters" dropdown (price sort, + categories on mobile) ---------- */
.filter-dropdown {
    position: relative;
}
.filter-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .15);
    padding: 8px;
    min-width: 200px;
    max-height: 70vh;
    overflow-y: auto;
    z-index: 20;
}
.filter-panel[hidden] { display: none; }
.filter-panel-scroll {
    display: flex;
    flex-direction: column;
}
.filter-panel-label {
    font-size: .72rem;
    font-weight: 700;
    color: #999;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 6px 10px 2px;
}
.filter-option {
    background: none;
    border: none;
    text-align: left;
    padding: 9px 10px;
    border-radius: 8px;
    font-size: .88rem;
    color: #333;
    cursor: pointer;
    white-space: nowrap;
}
.filter-option:hover,
.filter-option.active {
    background: #f6f0e8;
    color: #3f2a1d;
    font-weight: 700;
}
.chip[data-chip="filters"].active,
.chip[data-chip="instock"].active {
    background: #3f2a1d;
    color: #fff;
    border-color: #3f2a1d;
}
.chip[data-chip="instock"].active svg { stroke: #fff; }

/* The duplicate category list rendered inside the popup (see
   div#filterPanelCategories in products.php) — desktop already has the
   real sidebar visible, so this stays hidden there and only appears on
   mobile, right below. */
.filter-panel-categories { display: none; }

/* On mobile, let the panel fill more width so option text never wraps
   awkwardly against the edge of the screen. */
@media (max-width: 480px) {
    .filter-panel { min-width: 180px; }
}

/* ---------- Mobile layout fix ----------
   This is the actual fix for "topbar full width / cards overflowing":
   on desktop the sidebar sits in a column next to .products-main, but on
   mobile it needs to come OUT of that layout entirely (fixed, off-canvas)
   instead of just being visually hidden — otherwise it still reserves
   column width and pushes everything else (topbar, chip row, card grid)
   wider than the viewport, which is what was forcing the horizontal
   overflow. */
@media (max-width: 780px) {
    .products-page.container {
        display: block;
    }
    .products-main {
        width: 100%;
        max-width: 100%;
    }
    .menu-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 82%;
        max-width: 320px;
        max-height: 100vh;
        background: #fff;
        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);
    }

    /* The "Filters" popup becomes a bottom sheet instead of a small
       anchored dropdown, and now shows the category list too, since the
       sidebar above is off-canvas at this width. */
    .filter-panel {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        width: 100%;
        max-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;
        z-index: 210;
    }
    .filter-panel-categories { display: block; }
    .filter-cat-list {
        display: flex;
        flex-direction: column;
        max-height: 40vh;
        overflow-y: auto;
        margin-bottom: 8px;
        border-bottom: 1px solid #eee;
        padding-bottom: 8px;
    }
    .filter-cat-list .menu-subs { padding-left: 12px; }
}

/* Backdrop behind the mobile "Filters" bottom sheet (see main.js
   openFilterPanel/closeFilterPanel). Scoped by ID so it doesn't depend on
   however your existing .menu-backdrop class shows/hides itself. */
#filterPanelBackdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 205;
}
#filterPanelBackdrop[hidden] { display: none; }

/* ---------- Extra responsiveness for narrow phones ---------- */
@media (max-width: 480px) {
    .prc { padding: 12px; gap: 10px; }
    .prc-media { width: 104px; }
    .cat-section-products { gap: 14px; }
    .section-heading-row { margin: 20px 0 10px; }
    .view-cart-bar { padding: 9px 16px 9px 10px; gap: 10px; }
    .view-cart-bar .vc-icon { width: 30px; height: 30px; }
}

/* ---------- Product detail popup (Image 1 reference) ---------- */
.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: 200;
}
.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;
    display: block;
    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: none;
    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-body .prc-badges { margin-bottom: 8px; }
.product-modal-body .prc-trend { margin-bottom: 6px; }

.product-modal-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: #1a1a1a;
    margin: 4px 0 8px;
}
.product-modal-body .prc-price {
    font-size: 1.05rem;
    margin-bottom: 8px;
}
.product-modal-body .prc-stars {
    font-size: .95rem;
    margin-bottom: 10px;
}
.product-modal-desc {
    font-size: .9rem;
    color: #555;
    line-height: 1.55;
    margin: 0;
}
.product-modal-desc #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;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #3f2a1d;
    color: #fff;
    border: none;
    padding: 16px 22px;
    font-size: 1rem;
    cursor: pointer;
}
.product-modal-footer .pm-price {
    font-weight: 700;
}
.product-modal-footer .pm-cta {
    font-weight: 800;
    letter-spacing: .02em;
}

/* Smaller phones: less backdrop padding (more usable width), shorter
   media image so the popup doesn't force scrolling on short viewports. */
@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; }
    .product-modal-footer { padding: 14px 18px; }
}