/* --- Global Styles & Color Palette --- */
:root {
    --tan-ivory: #FDF6E3; --cherry-red: #812919; --hazelnut-tan: #C3A692; --egg-nogg-beige: #F3EAD3; --dark-text: #2c2c2c; --light-text: #FFFFFF; --gray-inactive: #A9A9A9; --dark-gray-text: #4a4a4a;
}

/* ====== Self-hosted fonts (new) ====== */
@font-face {
    font-family: 'Oswald';
    src: url('fonts/oswald-v57-cyrillic_latin-300.woff2') format('woff2');
    font-weight: 300; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'Oswald';
    src: url('fonts/oswald-v57-cyrillic_latin-500.woff2') format('woff2');
    font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'Montserrat';
    src: url('fonts/montserrat-v31-cyrillic_latin-regular.woff2') format('woff2');
    font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'Montserrat';
    src: url('fonts/montserrat-v31-cyrillic_latin-700.woff2') format('woff2');
    font-weight: 700; font-style: normal; font-display: swap;
}

body {
    margin: 0; font-family: 'Montserrat', sans-serif; background-color: var(--tan-ivory); color: var(--dark-text);
}
#app-container {
    max-width: 1200px; margin: 0 auto; padding: 0 2.5rem 2.5rem 2.5rem; box-sizing: border-box;
}
h1, h2, h3 {
    font-family: 'Oswald', sans-serif; color: var(--cherry-red); text-transform: uppercase;
}

/* --- Reusable Components --- */
.page-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; padding: 2rem 0 1rem 0; border-bottom: 4px solid var(--cherry-red);
position: sticky;
top: 0;
z-index: 5000;
background: var(--tan-ivory);
  }
.page-header h1 { font-size: 3rem; margin: 0; 
position: sticky;
top: 0;
z-index: 5000;background: var(--tan-ivory);}
.nav-button {
    background: var(--cherry-red); color: var(--light-text); padding: 0.8rem 1.6rem; border-radius: 8px; cursor: pointer; border: none; font-size: 1.1rem; font-weight: bold; transition: transform 0.2s; white-space: nowrap;
}
.nav-button:hover { transform: scale(1.05); }

/* --- Home Page --- */
.home-header {
    text-align: center;
    /* changed: photo header instead of solid color */
    background-image: url('images/icons/header.jpg'); /* 1920x612 */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
    padding-bottom: 4.25rem; /* room for the two bottom buttons */

    margin: 0 -2.5rem 2.5rem -2.5rem; padding: 2rem 2.5rem;
}
.home-header img { max-width: 250px; margin-bottom: 2rem; }

/* changed: transparent brand bar */
#brand-filters-container {
    background-color: transparent;
    padding: 1.5rem; border-radius: 12px;
}
#brand-filters {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem; max-height: 120px; overflow-y: auto;
}

/* changed: “Glass Light” pills */
.brand-filter-btn {
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.09);
    border: 1px solid rgba(255, 255, 255, 0.55);
    text-shadow: 0 1px 1px rgba(0,0,0,0.35);
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
    backdrop-filter: saturate(120%) blur(0.5px);
    padding: 0.6rem 1.2rem; border-radius: 20px; font-family: 'Montserrat', sans-serif; font-weight: 700; font-size: 1rem; cursor: pointer;
}
.brand-filter-btn:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.70);
    transform: translateY(-1px);
}
.brand-filter-btn:active {
    background: rgba(255, 255, 255, 0.22);
    transform: translateY(0);
}
.brand-filter-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.5);
}
/* active/inactive semantics preserved */
.brand-filter-btn.active {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.85);
    color: #FFFFFF;
}
.brand-filter-btn.inactive {
    background: rgba(255, 255, 255, 0.09);
    color: #e9e9e9;
}

#category-grid {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 2.5rem;
}
.card {
    background: #fff; border-radius: 12px; box-shadow: 0 5px 15px rgba(0,0,0,0.08); overflow: hidden; cursor: pointer; text-align: center; transition: transform 0.2s, box-shadow 0.2s;
}
.card:hover { transform: translateY(-8px); box-shadow: 0 10px 20px rgba(0,0,0,0.12); }
.card img { width: 100%; height: 350px; object-fit: cover; display: block; }
.card h3 { padding: 1.5rem; margin: 0; font-size: 2.5rem; }

/* --- Product Menu Page --- */
#product-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.4rem;
}
.product-card-info {
    font-weight: bold; font-size: 1.2rem; margin-top: 1rem; padding: 0 0.5rem; display: flex; justify-content: space-between;
}

/* new: apply Oswald 300 ONLY on the products list (page 3) */
.view-products #product-grid h3,
.view-products #product-grid .product-card-info span {
    font-family: 'Oswald', system-ui, -apple-system, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    font-weight: 300;
    letter-spacing: 0.2px;
}

/* --- Product Detail Page --- */
#product-detail-layout { display: flex; flex-direction: column; align-items: center; gap: 2rem; }
#image-gallery-container { width: 100%; max-width: 800px; text-align: center; }
#image-gallery { position: relative; cursor: pointer; user-select: none; border-radius: 12px; overflow: hidden; box-shadow: 0 10px 25px rgba(0,0,0,0.15); }
#image-gallery img { width: 100%; height: auto; aspect-ratio: 1 / 1; object-fit: contain; display: none; }
#image-gallery img.active { display: block; }
#product-info-pane { display: grid; grid-template-columns: 1fr auto; gap: 2rem; width: 100%; background: #fff; padding: 2.5rem; border-radius: 12px; box-shadow: 0 5px 15px rgba(0,0,0,0.08); }
#product-info h1 { font-size: 4rem; margin: 0; }
#product-info h2 { font-size: 2rem; margin: 0 0 1.5rem 0; color: var(--dark-text); }
.description { line-height: 1.7; margin-bottom: 2rem; max-height: 300px; overflow-y: auto; }
.order-form .input-group { display: flex; gap: 1rem; align-items: center; margin-bottom: 1rem; }
.order-form input { width: 80px; padding: 0.8rem; font-size: 1.2rem; text-align: center; border: 2px solid var(--tan-ivory); border-radius: 8px; }
.order-form button { flex-grow: 1; background: var(--cherry-red); color: var(--light-text); border: none; padding: 1rem; font-size: 1.1rem; font-weight: bold; border-radius: 8px; cursor: pointer; }
.product-tag { font-size: 1.5rem; font-weight: bold; text-transform: uppercase; margin-bottom: 1rem; }
.product-tag-new { color: #007BFF; }
.product-tag-category { color: #6c757d; }

/* Detail page image window should be white */
#image-gallery {
  background: #fff;
}

/* The empty space created by object-fit: contain should also be white */
#image-gallery img {
  background: #fff;
  box-sizing: border-box;
}

/* Zoom out a bit ONLY when the image is not square */
#image-gallery img.non-square {
  padding: 18px; /* adjust 12–24px depending on preference */
}


/* Detail page: stack order box vertically on smaller screens */
@media (max-width: 1100px) {
  #order-box {
    grid-template-columns: 1fr !important; /* override inline 1fr 1fr */
  }

  #order-box .ob-unit,
  #order-box .ob-box,
  #order-box .ob-singleqty,
  #order-box .ob-boxqty,
  #order-box .ob-btn {
    grid-column: 1 / -1;
  }

  /* Desired vertical order:
     1) box price
     2) box qty
     3) unit price
     4) unit qty
     5) order button
  */
  #order-box .ob-box { order: 1; }
  #order-box .ob-boxqty { order: 2; }
  #order-box .ob-unit { order: 3; }
  #order-box .ob-singleqty { order: 4; }
  #order-box .ob-btn { order: 5; }
}


/* --- Cart Page --- */
#cart-content { background: #fff; padding: 2.5rem; border-radius: 12px; }
.cart-item { display: grid; grid-template-columns: 1fr auto auto auto; gap: 1.5rem; align-items: center; padding: 1.5rem 0; border-bottom: 2px solid var(--tan-ivory); }
.cart-item img { width: 100px; height: 100px; object-fit: contain; }
.cart-item-details h3 { margin: 0; }
.cart-item-details p { margin: 0.5rem 0 0 0; color: #666; }
/* NEW: Total Price Style */
#cart-total {
    text-align: right; font-size: 1.8rem; font-family: 'Oswald', sans-serif; margin-top: 2rem;
}
#checkout-form { margin-top: 2rem; display: grid; grid-template-columns: 1fr; gap: 1rem; }
#checkout-form input { padding: 1rem; font-size: 1rem; border: 1px solid #ccc; border-radius: 8px; }
#order-button { background: var(--cherry-red); color: white; font-size: 1.2rem; padding: 1rem; border: none; border-radius: 8px; cursor: pointer; }
/* NEW: Hides elements during PDF generation to prevent errors */
.pdf-hide {
    display: none !important;
}
.pdf-header {
    margin-bottom: 2rem;
}

/* --- Responsive (Phone) Design --- */
@media (max-width: 768px) {
    #app-container { padding: 0 1rem 1rem 1rem; }
    .home-header { margin: 0 -1rem 1.5rem -1rem; padding: 1.5rem 1rem; }
    .page-header { flex-wrap: wrap; gap: 1rem; padding-top: 1.5rem; }
    .page-header h1 { font-size: 2rem; width: 100%; text-align: center; order: -1; }
    #category-grid, #product-grid { grid-template-columns: 1fr; gap: 1.5rem; }
    .card img { height: 280px; }
    .card h3 { font-size: 2rem; }
    #product-info-pane { grid-template-columns: 1fr; padding: 1.5rem; }
    #product-info h1 { font-size: 2.5rem; }
    #product-info h2 { font-size: 1.5rem; }
    .order-form button { font-size: 1rem; }
    .cart-item { grid-template-columns: 1fr; text-align: center; }
    .cart-item img { margin: 0 auto; }
}

/* Photo-only product grid: tighter + avoid crop in portrait */
.view-products .product-card--photoonly {
    padding: 0.55rem;
}

.view-products .product-card--photoonly img {
    height: 330px;          /* slightly smaller so it feels “zoomed out” */
    object-fit: contain;    /* key: prevents left/right crop */
    background: #fff;       /* keeps it clean if image has transparent/odd borders */
    border-radius: 10px;    /* matches your rounded style */
}

.view-products .product-card--photoonly{
  padding: 0.55rem;
  aspect-ratio: 1 / 1;      /* key: square tile */
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Make the image fit inside the square without cropping */
.view-products .product-card--photoonly img{
  width: 100%;
  height: 100% !important;  /* override the global 350px height */
  object-fit: contain;
  background: #fff;
  border-radius: 10px;
}

@media (max-width: 1100px){
  #product-grid{
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ---- Chocolate header smudge (CSS-only) ---- */
.home-header {
  position: relative;           /* create a positioning context */
  z-index: 1;
  padding-bottom: 1.75rem;      /* tiny breathing room so the smudge doesn't overlap content */
  margin-bottom: 1.75rem;
}

/* A blurred copy of the header background that extends below it */
.home-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -28px;                /* how far the smudge extends below the header */
  height: 76px;                 /* smudge thickness (tune 60–100px) */

  /* inherit the same photo so alignment matches */
  background-image: inherit;
  background-size: inherit;
  background-position: inherit;
  background-repeat: inherit;

  filter: blur(14px);           /* smudge strength */
  transform: scaleY(0.85);      /* compress a bit so blur doesn’t grow too tall */
  pointer-events: none;

  /* fade the smudge out toward the page background */
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,0) 0%, rgba(0,0,0,.9) 45%, rgba(0,0,0,0) 100%);
          mask-image: linear-gradient(to bottom, rgba(0,0,0,0) 0%, rgba(0,0,0,.9) 45%, rgba(0,0,0,0) 100%);
  z-index: 0;
}

/* Optional: a very light shadow for depth (can keep or remove) */
.home-header {
  box-shadow: 0 18px 40px -28px rgba(0,0,0,0.35);
}

/* ===== Flyers (ПРОМОЦИИ) fullscreen viewer ===== */
#flyers-view {
  position: fixed; inset: 0; z-index: 9999;
  background: #000; display: flex; flex-direction: column;
}
#flyers-chrome {
  position: absolute; inset: 0; pointer-events: none;
}
#flyers-back, #flyers-pager {
  position: absolute; top: 12px; pointer-events: auto;
}
#flyers-back { left: 12px; }
#flyers-pager { right: 16px; color: #fff; font-family: 'Montserrat', sans-serif; }
#flyers-stage {
  position: absolute; inset: 0;
  display: grid; place-items: center; overflow: hidden;
}
#flyers-stage .flyer-img {
  max-height: 100vh; max-width: 100vw;
  width: auto; height: auto; object-fit: contain; /* no crop */
  user-select: none;
  -webkit-user-drag: none;
}

/* === Glass pill: stronger "ON" state (a bit less transparent, whiter) === */
.brand-filter-btn.active {
  background: rgba(255, 255, 255, 0.34);   /* was ~0.22 */
  border-color: rgba(255, 255, 255, 0.95); /* crisper edge */
  color: #FFFFFF;
  text-shadow: 0 1px 1px rgba(0,0,0,0.35); /* keep legible on dark photo */
}

.brand-filter-btn.active:hover {
  background: rgba(255, 255, 255, 0.42);
  border-color: #FFFFFF;
}

.brand-filter-btn.active:active {
  background: rgba(255, 255, 255, 0.50);
}

/* === Cart: price left of remove, and cherry-red remove button === */
.cart-item {
  /* info | qty controls | line total | remove */
  grid-template-columns: 1fr auto auto auto;
}

.cart-item .ci-price {
  font-family: 'Oswald', sans-serif;
  font-weight: 300;
  font-size: 1.6rem;
  white-space: nowrap;
}

.cart-item .ci-remove .btn-remove {
  background: var(--cherry-red);
  color: #fff;
  border: none;
}

/* Keep desktop layout on phones too so price never drops under */
@media (max-width: 768px) {
  .cart-item {
    grid-template-columns: 1fr auto auto auto;
    align-items: center;
    text-align: left;
  }
}

/* Hide all UI-only controls during PDF capture */
.pdf-mode .ui-only { display: none !important; }

/* ===== Generic image zoom overlay ===== */
#zoom-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,.9);
  display: none; align-items: center; justify-content: center;
  touch-action: none; /* enable pinch/drag */
}
#zoom-overlay.active { display: flex; }
#zoom-overlay img {
  max-width: 100vw; max-height: 100vh;
  will-change: transform;
  transform-origin: center center;
  user-select: none; -webkit-user-drag: none;
  cursor: grab;
}
#zoom-overlay img:active { cursor: grabbing; }
#zoom-overlay .zoom-close {
  position: fixed; top: 12px; right: 12px;
}
#zoom-overlay .zoom-reset {
  position: fixed; bottom: 16px; right: 16px;
}

/* ===== Category color system (edit values below) ===== */
/* Default/failsafe uses var(--cherry-red) = #812919 */
:root{
  /* set any category color here; leave as var(--cherry-red) to use default */
  --cat-Protein: #24201E;
  --cat-Без_захар: #00A0AF;
  --cat-Бисквити: #7C4D25;
  --cat-Бонбони: #CC0000;
  --cat-Вафли: #F29400;
  --cat-Десерти: #FF0099;
  --cat-Други: #8C3087;
  --cat-Празнични: #786855;
  --cat-Кроасани: #00CC00;
  --cat-Напитки: #0033FF;
  --cat-Солени: #006600;
  --cat-Сухи_Пасти: var(--cherry-red);
  /* DO NOT define Шоколадови Изделия → will fall back to default */
}

/* Make the title bar white text on a colored background */
#category-grid .card h3{
  color:#fff;
  background: var(--card-color, var(--cherry-red)); /* category color or default */
  padding: 1.25rem 1.5rem;
  border-top: 1px solid rgba(0,0,0,0.06);
}

/* Map cards to colors using their data-category (works on home + subcategories) */
#category-grid .card[data-category="Protein"]             { --card-color: var(--cat-Protein); }
#category-grid .card[data-category="Без Захар"]           { --card-color: var(--cat-Без_захар); }
#category-grid .card[data-category="Бисквити"]            { --card-color: var(--cat-Бисквити); }
#category-grid .card[data-category="Бонбони"]             { --card-color: var(--cat-Бонбони); }
#category-grid .card[data-category="Вафли"]               { --card-color: var(--cat-Вафли); }
#category-grid .card[data-category="Десерти"]             { --card-color: var(--cat-Десерти); }
#category-grid .card[data-category="Други"]               { --card-color: var(--cat-Други); }
#category-grid .card[data-category="Празнични"]             { --card-color: var(--cat-Празнични); }
#category-grid .card[data-category="Кроасани"]            { --card-color: var(--cat-Кроасани); }
#category-grid .card[data-category="Напитки"]             { --card-color: var(--cat-Напитки); }
#category-grid .card[data-category="Солени"]              { --card-color: var(--cat-Солени); }
#category-grid .card[data-category="Сухи Пасти"]          { --card-color: var(--cat-Сухи_Пасти); }
/* "Шоколадови Изделия" intentionally not mapped → falls back to var(--cherry-red) */

/* Optional: same color bar on subcategory tiles (they carry data-category too) */

/* Toast */
#toast {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%) translateY(8px);
  background: rgba(0,0,0,.85); color:#fff; padding:10px 14px; border-radius:10px;
  font-size: 0.95rem; z-index: 9999; opacity:0; transition: opacity .18s, transform .18s;
}
#toast.show { opacity:1; transform: translateX(-50%) translateY(0); }

/* ===== Home Search (overlay) + header buttons ===== */

.home-header-actions{
    position: absolute;
    left: 1.05rem;
    right: 1.05rem;
    bottom: 1.05rem;

    display: flex;
    justify-content: space-between; /* left button + right button */
    align-items: flex-end;

    pointer-events: none; /* so only buttons are clickable */
}
.home-header-actions > *{
    pointer-events: auto;
}

/* Small circular glass button (mirrors promo position) */
.home-search-btn{
    width: 42px;
    height: 42px;
    border-radius: 999px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 0;
    color: #FFFFFF;

    background: rgba(255,255,255,0.09);
    border: 1px solid rgba(255,255,255,0.55);
    text-shadow: 0 1px 1px rgba(0,0,0,0.35);
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    backdrop-filter: saturate(120%) blur(0.5px);

    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}
.home-search-btn:hover{
    background: rgba(255,255,255,0.16);
    border-color: rgba(255,255,255,0.70);
    transform: translateY(-1px);
}
.home-search-btn svg{
    width: 18px;
    height: 18px;
    opacity: 0.92;
}

/* Promo button stays your existing style, just pinned bottom-right by the container */
.home-promo-btn{
    /* keep brand-filter-btn look, but ensure it sits nicely */
    white-space: nowrap;
}

/* Overlay */
body.search-open{ overflow: hidden; }

.search-overlay{
    position: fixed;
    inset: 0;
    z-index: 9999;

    background: rgba(0,0,0,0.38);

    display: flex;
    align-items: flex-start;
    justify-content: center;

    padding: 1.25rem;
}
.search-overlay.hidden{ display:none; }

.search-panel{
    width: min(720px, 100%);
    margin-top: 0.25rem;

    border: 2px solid var(--tan-ivory);
    border-radius: 16px;

    background: rgba(255,255,255,0.92);
    box-shadow: 0 10px 25px rgba(0,0,0,0.25);
    backdrop-filter: blur(2px);
    overflow: hidden;
}

.search-bar{
    display: flex;
    gap: 0.65rem;
    align-items: center;

    padding: 0.85rem;
    border-bottom: 1px solid rgba(0,0,0,0.08);
}

#search-input{
    flex: 1;
    min-width: 0;

    padding: 0.75rem 0.85rem;
    border-radius: 12px;
    border: 2px solid var(--tan-ivory);

    outline: none;
    background: #FFFFFF;
    color: var(--dark-gray-text);

    font-weight: 600;
    font-size: 1rem;
}

#search-input:focus{
    border-color: rgba(129,41,25,0.35);
}

.search-close-btn{
    width: 44px;
    height: 44px;
    border-radius: 12px;

    border: 2px solid var(--tan-ivory);
    background: rgba(255,255,255,0.75);

    cursor: pointer;
    font-weight: 900;
    font-size: 1.35rem;
    line-height: 1;
    color: var(--dark-gray-text);
}

.search-results{
    padding: 0.85rem;
    max-height: calc(100vh - 190px);
    overflow: auto;

    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.search-hint{
    padding: 0.5rem 0.25rem;
    color: var(--dark-gray-text);
    opacity: 0.85;
    font-weight: 600;
}

.search-result-item{
    display: flex;
    gap: 0.85rem;
    align-items: center;

    padding: 0.65rem;
    border-radius: 12px;
    border: 2px solid var(--tan-ivory);
    background: #FFFFFF;

    cursor: pointer;
}
.search-result-item:hover{
    background: rgba(253,246,227,0.35);
}

.search-result-item img{
    width: 56px;
    height: 56px;
    object-fit: contain;

    border-radius: 10px;
    border: 1px solid rgba(0,0,0,0.08);
    background: #FFFFFF;
}

.search-result-text{
    flex: 1;
    min-width: 0;
}

.search-result-title{
    font-weight: 800;
    color: var(--dark-gray-text);
    line-height: 1.15;
}

.search-result-meta{
    margin-top: 0.25rem;
    display: flex;
    gap: 0.65rem;
    flex-wrap: wrap;

    font-weight: 600;
    color: var(--dark-gray-text);
    opacity: 0.85;
    font-size: 0.95rem;
}

.search-result-price{
    margin-left: auto;
    white-space: nowrap;

    font-weight: 900;
    color: var(--dark-gray-text);
}

/* Cart qty controls (match site style) */
.ci-qty {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  justify-content: flex-start;
}

.qty-input {
  width: 74px;
  padding: 0.8rem;
  font-size: 1.1rem;
  text-align: center;
  border: 2px solid var(--tan-ivory);
  border-radius: 10px;
  background: #fff;
  color: var(--dark-gray-text);
  font-weight: 700;
}

.qty-btn {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 2px solid var(--tan-ivory);
  background: var(--egg-nogg-beige);
  color: var(--dark-text);
  font-weight: 900;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.ci-unit-price,
.ci-qty-text {
  margin: 0.35rem 0 0 0;
}

/* ===== Home brand list button + overlay ===== */

.home-header-left {
  display: flex;
  gap: 0.65rem;
  align-items: flex-end;
}

/* Brand overlay (similar to search overlay) */
.brand-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(0,0,0,0.38);

  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1.25rem;
}
.brand-overlay.hidden { display: none; }

.brand-panel {
  width: min(720px, 100%);
  margin-top: 0.25rem;

  border: 2px solid var(--tan-ivory);
  border-radius: 16px;

  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 25px rgba(0,0,0,0.25);
  backdrop-filter: blur(2px);
  overflow: hidden;
}

.brand-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;

  padding: 0.85rem;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}
.brand-panel-header h2 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--dark-gray-text);
}

.brand-list {
  padding: 0.85rem;
  max-height: calc(100vh - 190px);
  overflow: auto;

  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.brand-item-btn {
  width: 100%;
  text-align: left;

  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  border: 2px solid var(--tan-ivory);
  background: #FFFFFF;

  font-family: "Oswald", sans-serif;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--dark-gray-text);

  cursor: pointer;
}
.brand-item-btn:hover {
  background: rgba(253, 246, 227, 0.35);
}

/* ===== Brand overlay: pill + navigate row ===== */

/* Each row: toggleable pill (flex:1) + narrow arrow button */
.brand-overlay-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Arrow button (navigate to brand page) */
.brand-overlay-nav {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 2px solid var(--tan-ivory);
  background: #fff;
  color: var(--dark-gray-text);
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.brand-overlay-nav:hover { background: var(--egg-nogg-beige); }

/* Pill buttons inside the light panel need different colors than the
   dark-header pills (white text on rgba won't read on a cream background) */
.brand-overlay .brand-filter-btn {
  flex: 1;
  text-align: center;
  text-shadow: none;
  backdrop-filter: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
}
.brand-overlay .brand-filter-btn.active {
  background: var(--cherry-red);
  color: #fff;
  border-color: var(--cherry-red);
}
.brand-overlay .brand-filter-btn.inactive {
  background: #f0f0f0;
  color: var(--gray-inactive);
  border-color: #ddd;
  text-decoration: line-through;
  text-decoration-color: var(--gray-inactive);
}

/* ===== Bulk brand order page ===== */

.bulk-header-note {
  margin: 0.25rem 0 1rem 0;
  color: var(--dark-gray-text);
  opacity: 0.85;
  font-weight: 600;
  font-size: 0.95rem;
}

.bulk-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.bulk-row {
  border: 2px solid var(--tan-ivory);
  border-radius: 14px;
  background: #fff;
  padding: 0.75rem;

  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: start;
}

.bulk-name-btn {
  background: none;
  border: none;
  padding: 0;
  margin: 0;

  text-align: left;
  cursor: pointer;

  font-weight: 800;
  color: var(--dark-gray-text);
  font-size: 1.05rem;
  line-height: 1.2;

  max-width: 100%;
}
.bulk-name-btn .bulk-name-text {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bulk-meta {
  margin-top: 0.25rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--dark-gray-text);
  opacity: 0.85;

  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.bulk-qty {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  justify-content: flex-end;
}

.bulk-qty input {
  width: 68px;
  padding: 0.65rem;
  text-align: center;
  border: 2px solid var(--tan-ivory);
  border-radius: 10px;
  font-weight: 800;
  color: var(--dark-gray-text);
}

.bulk-add-all {
  margin-top: 1rem;
  width: 100%;
}



/* --- Browse Mode (Brand scroll catalogue) --- */
body.browse-mode {
  background: var(--egg-nogg-beige);
}

/* Header: cream background like the main menu, with a colored brand label in the center */
.browse-page-header {
  background: var(--egg-nogg-beige);
  padding: 1.2rem 0 0.9rem 0;
  margin-bottom: 1.2rem;
}

.browse-top-brand-wrap {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 0;
}

.browse-top-brand {
  background: var(--cherry-red); /* overwritten by JS per brand */
  color: #fff;
  font-size: clamp(1.6rem, 4vw, 3rem);
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 0.25rem 1rem;
  border-radius: 14px;
  line-height: 1.05;
  box-shadow: 0 10px 18px rgba(0,0,0,0.10);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Glass buttons (white) for Back / Order in browse mode */
.browse-page-header .browse-glass-btn {
  background: rgba(255,255,255,0.55) !important;
  color: #3b2314 !important;
  border: 1px solid rgba(255,255,255,0.75);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 18px rgba(0,0,0,0.10);
}

.browse-page-header .browse-glass-btn:hover {
  transform: scale(1.03);
}

/* Body */
.browse-container {
  padding: 12px 14px 40px;
}

.browse-brand-section {
  margin: 0 0 26px 0;
}

.browse-brand-header {
  padding: 10px 2px 12px;
}

.browse-brand-name {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.2px;
  color: #3b2314;
}

.browse-brand-subhead {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: rgba(59,35,20,0.65);
}

/* 2 wide tiles per row */
.browse-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.browse-tile {
  user-select: none;
}

.browse-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 5px 15px rgba(0,0,0,0.08);
  padding: 0.55rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.browse-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Quick add button: dark red circle with white plus, minimal shadows */
.browse-quick-add {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 0;
  cursor: pointer;

  background: var(--cherry-red);
  color: #fff;
  font-size: 22px;
  font-weight: 900;
  line-height: 1;

  box-shadow:
    0 3px 8px rgba(0,0,0,0.22),
    2px 2px 0 rgba(0,0,0,0.18);
}

.browse-quick-add:active { transform: translateY(1px); }

.browse-quick-add.pulse {
  transform: scale(1.06);
  box-shadow:
    0 4px 10px rgba(0,0,0,0.26),
    2px 3px 0 rgba(0,0,0,0.18);
}

/* Titles removed in browse mode */
.browse-tile-title { display: none; }

.browse-placeholder {
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(0,0,0,0.03), rgba(0,0,0,0.01));
}

.browse-empty { padding: 30px 8px; text-align: center; }
.browse-empty-title { font-weight: 900; font-size: 18px; color: #3b2314; }
.browse-empty-sub { margin-top: 8px; color: rgba(59,35,20,0.75); }

/* ==========================================================
   PHONE LAYOUT  (≤ 480 px)
   Covers: Galaxy S8+ 360px · iPhone SE 375px · iPhone 12 Pro
   390px · Pixel 7 412px · iPhone 14 Pro Max 430px
   Placed last so it wins over any conflicting earlier rule.
   ========================================================== */
@media (max-width: 480px) {

    /* --- Outer container: tighter side padding --- */
    #app-container { padding: 0 0.65rem 0.65rem; }

    /* --- Home header: offset equals new container padding --- */
    .home-header {
        margin: 0 -0.65rem 1.2rem -0.65rem;
        padding: 1.2rem 0.65rem;
    }
    .home-header img { max-width: 170px; margin-bottom: 0.75rem; }

    /* --- Sticky page title bar --- */
    .page-header {
        padding-top: 0.75rem;
        margin-bottom: 0.85rem;
        gap: 0.4rem;
    }
    .page-header h1 { font-size: 1.4rem; }
    .nav-button { padding: 0.65rem 1rem; font-size: 0.9rem; }

    /* --- 2-column grids: categories, subcategories, products --- */
    #category-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    #product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.85rem;
    }

    /* Category/subcategory cards: flex so the image fills all space above
       the label — prevents the white-gap bug when one title wraps to two
       lines and makes the grid-row-mate's image appear shorter/blank. */
    #category-grid .card {
        display: flex;
        flex-direction: column;
    }
    #category-grid .card img {
        flex: 1 1 0;      /* grows to fill whatever space the label doesn't use */
        height: 0;         /* flex-grow controls size; ignore any fixed-px height */
        min-height: 90px;  /* safety floor */
        object-fit: cover;
    }
    #category-grid .card h3 {
        flex-shrink: 0;    /* label never compresses into the image area */
        font-size: 1.05rem;
        padding: 0.45rem 0.65rem;
    }

    /* --- Product detail page --- */
    #product-info-pane { padding: 1rem; gap: 0.85rem; }
    #product-info h1   { font-size: 1.8rem; }
    #product-info h2   { font-size: 1.25rem; }
    .description       { max-height: 180px; }

    /* --- Cart: stack rows instead of cramped 4-column grid --- */
    .cart-item {
        grid-template-columns: 1fr;
        gap: 0.65rem;
    }
    .cart-item .ci-qty    { justify-content: flex-start; }
    .cart-item .ci-price  { text-align: left; }
    .cart-item .ci-remove { text-align: left; }

    /* --- Main-screen filter pills: hidden on phone (brand overlay handles it) --- */
    #brand-filters-container { display: none; }

    /* Without the pill row the header shrinks; keep enough bottom room for
       the absolutely-positioned action buttons (42 px tall + 1.05 rem gap) */
    .home-header { padding-bottom: 3.8rem; }

    /* --- Brand filter pills (desktop only from this point; kept for reference) --- */
    .brand-filter-btn { font-size: 0.88rem; padding: 0.5rem 0.9rem; }

    /* --- Bulk order page: let long names wrap instead of ellipsis --- */
    .bulk-name-text { white-space: normal; }
}
