/* ==========================================================================
   فروشگاه ← صفحه‌ی محصولات (/products — templates/products.html) — همه‌چیز زیر .shop
   آیکون‌ها: templates/partials/shop_icons.html (SVG خطی، رنگ = currentColor)
   ========================================================================== */
.shop{ --shop-accent: var(--ruby, #C81243); --shop-accent-2: var(--ruby-light, #FF4368);
  --shop-soft: rgba(200, 18, 67, .07); --shop-soft-2: rgba(200, 18, 67, .14);
  --shop-line: var(--border-soft, #F7E9EB); --shop-sticky-top: calc(var(--header-h, 71px) + 8px);
  --shop-glass: rgba(255, 255, 255, .62); }
body.theme-dark .shop{ --shop-soft: rgba(255, 67, 104, .10); --shop-soft-2: rgba(255, 67, 104, .18); --shop-glass: rgba(31, 15, 27, .62); }
.shop *{ box-sizing: border-box; }
.shop .ic{ width: 1.1em; height: 1.1em; flex: 0 0 auto; vertical-align: middle; }

/* ---------- Header: glass + twinkling dots (same palette as the homepage sparkles) ---------- */
.shop-hero{ padding: 22px 0 0; }
.shop-head{
  position: relative; overflow: hidden; border-radius: 26px; padding: 20px 24px;
  background:
    radial-gradient(90% 160% at 100% 0%, rgba(255, 67, 104, .14), transparent 55%),
    radial-gradient(70% 140% at 0% 100%, rgba(240, 180, 41, .12), transparent 60%),
    var(--shop-glass);
  backdrop-filter: blur(6px) saturate(140%); -webkit-backdrop-filter: blur(6px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, .7); box-shadow: var(--shadow-card);
}
body.theme-dark .shop-head{ border-color: var(--border); }
.shop-head > *:not(.shop-dots){ position: relative; z-index: 1; }
.shop-dots{ position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.shop-dots i{
  position: absolute; inset-inline-start: var(--x); top: var(--y); width: var(--s, 5px); height: var(--s, 5px); border-radius: 50%;
  animation: shopTwinkle 4s ease-in-out infinite; animation-delay: var(--d, 0s); opacity: 0;
}
.shop-dots i.r{ background: var(--ruby-light, #FF4368); box-shadow: 0 0 14px 4px rgba(255, 67, 104, .45); }
.shop-dots i.g{ background: var(--gold, #F0B429); box-shadow: 0 0 14px 4px rgba(240, 180, 41, .42); }
.shop-dots i.o{ background: #FF8A3D; box-shadow: 0 0 14px 4px rgba(255, 138, 61, .42); }
@keyframes shopTwinkle{ 0%,100%{ opacity: 0; transform: scale(.6); } 50%{ opacity: .95; transform: scale(1.15); } }
@media (prefers-reduced-motion: reduce){ .shop-dots i{ animation: none; opacity: .5; } }

.shop-crumbs{ display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: .75rem; color: var(--text-faint); margin: 0 0 12px; padding: 0; list-style: none; }
.shop-crumbs a{ display: inline-flex; align-items: center; gap: 5px; color: var(--text-muted); text-decoration: none; font-weight: 700; }
.shop-crumbs a .ic{ width: 14px; height: 14px; }
.shop-crumbs a:hover{ color: var(--shop-accent); }
.shop-crumbs li + li::before{ content: "‹"; margin-left: 6px; opacity: .55; }
.shop-crumbs li[aria-current]{ color: var(--text); font-weight: 800; }
.shop-head-row{ display: flex; align-items: center; gap: 15px; }
.shop-head-ico{
  flex: 0 0 auto; width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(140deg, var(--shop-accent-2), var(--shop-accent));
  box-shadow: 0 12px 26px -12px var(--shop-accent), inset 0 1px 0 rgba(255,255,255,.35);
}
.shop-head-ico .ic{ width: 27px; height: 27px; stroke-width: 1.8; }
.shop-head-text{ flex: 1 1 auto; min-width: 0; }
.shop-head h1{ margin: 0; font-size: clamp(1.15rem, 3vw, 1.6rem); font-weight: 900; color: var(--text); line-height: 1.45; }
.shop-scope-line{ margin: 4px 0 0; font-size: .82rem; color: var(--text); font-weight: 700; display: flex; gap: 4px 8px; flex-wrap: wrap; align-items: center; }
.shop-scope-line > .ic{ color: var(--shop-accent); width: 16px; height: 16px; }
.shop-scope-line a{ display: inline-flex; align-items: center; gap: 4px; color: var(--shop-accent); text-decoration: none; font-weight: 800; white-space: nowrap; }
.shop-scope-line a .ic{ width: 15px; height: 15px; transition: transform .15s; }
.shop-scope-line a:hover .ic{ transform: translateX(-3px); }
.shop-scope-line.muted{ color: var(--text-muted); font-weight: 600; }
.shop-head-count{ flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 78px; padding: 9px 12px;
  border-radius: 18px; background: rgba(255,255,255,.7); border: 1px solid var(--shop-line); }
body.theme-dark .shop-head-count{ background: rgba(0,0,0,.2); }
.shop-head-count b{ font-family: var(--font-mono); font-size: 1.4rem; font-weight: 800; color: var(--shop-accent); line-height: 1.2; }
.shop-head-count span{ font-size: .7rem; color: var(--text-faint); font-weight: 800; }

.shop-btn{
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px; border-radius: 12px;
  font: inherit; font-size: .82rem; font-weight: 800; cursor: pointer; text-decoration: none; white-space: nowrap;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); transition: all .15s;
}
.shop-btn:hover{ border-color: var(--shop-accent-2); color: var(--shop-accent); }
.shop-btn.primary{ background: linear-gradient(135deg, var(--shop-accent), var(--shop-accent-2)); color: #fff; border-color: transparent;
  box-shadow: 0 10px 22px -12px var(--shop-accent); }
.shop-btn.primary:hover{ color: #fff; filter: brightness(1.06); }

/* ---------- Sticky toolbar ---------- */
.shop-bar{
  position: sticky; top: var(--shop-sticky-top); z-index: 30; margin-top: 12px; border-radius: 20px; padding: 8px;
  background: color-mix(in srgb, var(--surface) 90%, transparent); border: 1px solid var(--border);
  backdrop-filter: blur(16px) saturate(150%); -webkit-backdrop-filter: blur(16px) saturate(150%);
  box-shadow: 0 14px 34px -24px rgba(89, 8, 36, .5);
}
.shop-tools{ display: flex; gap: 8px; align-items: stretch; }
.shop-tools-end{ display: flex; gap: 8px; flex: 0 0 auto; }

.shop-search{ position: relative; flex: 1 1 auto; min-width: 0; margin: 0; }
.shop-search input{
  width: 100%; height: 50px; padding: 0 44px 0 42px !important; border-radius: 15px !important; font: inherit; font-size: .9rem;
  border: 1.5px solid var(--border) !important; background: var(--bg-soft) !important; color: var(--text);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.shop-search input:focus{ outline: none; border-color: var(--shop-accent-2) !important; box-shadow: 0 0 0 4px var(--shop-soft); background: var(--surface) !important; }
.shop-search input::-webkit-search-cancel-button{ display: none; }
.shop-search-ico{ position: absolute; right: 15px; top: 50%; transform: translateY(-50%); width: 19px !important; height: 19px !important; color: var(--text-faint); pointer-events: none; }
.shop-search-clear{ position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border-radius: 10px;
  background: var(--surface-3); color: var(--text-muted); display: grid; place-items: center; text-decoration: none; }
.shop-search-clear .ic{ width: 15px; height: 15px; }
.shop-search-clear:hover{ background: var(--shop-accent); color: #fff; }

/* dropdown / sheet */
.shop-dd{ position: relative; flex: 0 0 auto; }
.shop-dd > summary{ list-style: none; }
.shop-dd > summary::-webkit-details-marker{ display: none; }
.shop-dd-btn{
  height: 50px; display: inline-flex; align-items: center; gap: 8px; padding: 0 14px; border-radius: 15px; cursor: pointer; user-select: none;
  border: 1.5px solid var(--border); background: var(--bg-soft); color: var(--text); font-size: .84rem; font-weight: 800; white-space: nowrap;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.shop-dd-btn .lead{ color: var(--shop-accent); width: 17px; height: 17px; }
.shop-dd-btn .chev{ width: 16px; height: 16px; color: var(--text-faint); transition: transform .2s; }
.shop-dd-btn:hover, .shop-dd[open] > .shop-dd-btn{ border-color: var(--shop-accent-2); background: var(--surface); }
.shop-dd[open] > .shop-dd-btn .chev{ transform: rotate(180deg); }
.shop-dd-btn.is-set{ border-color: var(--shop-accent-2); background: var(--shop-soft); }
.shop-dd-label{ max-width: 170px; overflow: hidden; text-overflow: ellipsis; }

/* the category button: bigger, two-line, coloured icon */
.shop-dd-btn.cat{ padding: 0 10px 0 12px; min-width: 230px; }
.shop-dd-ico{ width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; color: #fff; flex: 0 0 auto;
  background: linear-gradient(140deg, var(--shop-accent-2), var(--shop-accent)); box-shadow: 0 6px 14px -8px var(--shop-accent); }
.shop-dd-ico .ic{ width: 18px; height: 18px; }
.shop-dd-text{ display: flex; flex-direction: column; line-height: 1.35; min-width: 0; flex: 1 1 auto; text-align: right; }
.shop-dd-text small{ font-size: .66rem; color: var(--text-faint); font-weight: 800; }
.shop-dd-text .shop-dd-label{ max-width: 210px; font-size: .86rem; }

.shop-dd-panel{
  position: absolute; top: calc(100% + 10px); left: 0; z-index: 60; min-width: 220px; padding: 10px; border-radius: 18px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-pop); animation: shopIn .18s ease;
}
.shop-dd-cat .shop-dd-panel{ right: 0; left: auto; width: min(560px, calc(100vw - 40px)); padding: 12px; }
.shop-dd-panel.wide{ width: min(460px, calc(100vw - 32px)); }
.shop-sheet-head{ display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 4px 10px; }
.shop-sheet-head b{ font-size: .8rem; color: var(--text-muted); font-weight: 800; }
.shop-sheet-grab{ display: none; }
.shop-sheet-x{ display: none; border: 0; background: var(--surface-3); color: var(--text-muted); width: 32px; height: 32px; border-radius: 10px; cursor: pointer; place-items: center; }
.shop-sheet-x .ic{ width: 16px; height: 16px; }

.shop-cat-grid{ display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.shop-cat-card{
  position: relative; display: flex; align-items: center; gap: 11px; padding: 12px; border-radius: 15px; text-decoration: none; color: var(--text);
  border: 1.5px solid var(--border); background: var(--bg-soft); transition: border-color .15s, background .15s, transform .15s;
}
.shop-cat-card:hover{ border-color: var(--shop-accent-2); background: var(--surface); transform: translateY(-1px); }
.cc-ico{ width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; flex: 0 0 auto;
  color: var(--shop-accent); background: var(--shop-soft); border: 1px solid var(--shop-soft-2); }
.cc-ico .ic{ width: 21px; height: 21px; }
.cc-text{ display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.cc-text b{ font-size: .86rem; font-weight: 800; line-height: 1.55; }
.cc-text small{ font-size: .72rem; color: var(--text-faint); font-weight: 700; font-family: var(--font-mono); }
.cc-check{ margin-right: auto; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto;
  color: transparent; border: 1.5px solid var(--border); transition: all .15s; }
.cc-check .ic{ width: 14px; height: 14px; stroke-width: 2.6; }
.shop-cat-card.is-active{ border-color: var(--shop-accent); background: var(--shop-soft); }
.shop-cat-card.is-active .cc-ico{ color: #fff; background: linear-gradient(140deg, var(--shop-accent-2), var(--shop-accent)); border-color: transparent; }
.shop-cat-card.is-active .cc-check{ background: var(--shop-accent); border-color: var(--shop-accent); color: #fff; }

.shop-dd-chips{ display: flex; flex-wrap: wrap; gap: 6px; }
.shop-dd-item{ display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 12px; text-decoration: none; color: var(--text);
  font-size: .86rem; font-weight: 700; }
.shop-dd-item .ic{ width: 17px; height: 17px; color: var(--text-faint); }
.shop-dd-item:hover{ background: var(--bg-soft); }
.shop-dd-item.is-active{ background: var(--shop-soft); color: var(--shop-accent); }
.shop-dd-item.is-active .ic{ color: var(--shop-accent); }
body.theme-dark .shop-dd-item.is-active{ color: var(--text); }
.shop-dd-item .tick{ margin-right: auto; }
@keyframes shopIn{ from{ opacity: 0; transform: translateY(-6px) } to{ opacity: 1; transform: none } }

.shop-chip{
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 5px; padding: 8px 13px; border-radius: 999px; text-decoration: none;
  border: 1px solid var(--border); background: transparent; color: var(--text-muted); font-size: .8rem; font-weight: 700; white-space: nowrap; transition: all .15s;
}
.shop-chip:hover{ color: var(--text); border-color: var(--shop-accent-2); }
.shop-chip.is-active{ background: var(--shop-soft-2); border-color: var(--shop-accent-2); color: var(--shop-accent); }
body.theme-dark .shop-chip.is-active{ color: var(--text); }

.shop-backdrop{ position: fixed; inset: 0; z-index: 70; background: rgba(20, 6, 14, .45); backdrop-filter: blur(3px); animation: shopFade .2s ease; }
.shop-backdrop[hidden]{ display: none; }
@keyframes shopFade{ from{ opacity: 0 } to{ opacity: 1 } }
html.shop-sheet-open, html.shop-sheet-open body{ overflow: hidden !important; }

/* ---------- Results header + active filters ---------- */
.shop-results{ display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 22px 0 14px; }
.shop-results-count{ font-size: .92rem; color: var(--text-muted); }
.shop-results-count b{ color: var(--text); font-family: var(--font-mono); font-size: 1.05rem; }
.shop-results-count .pg{ color: var(--text-faint); }
.shop-active{ display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.shop-pill{
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 11px; border-radius: 999px; font-size: .76rem; font-weight: 800;
  background: var(--shop-soft); color: var(--text); border: 1px solid var(--shop-soft-2);
}
.shop-pill > .ic{ width: 14px; height: 14px; color: var(--shop-accent); }
.shop-pill a{ display: grid; place-items: center; width: 21px; height: 21px; border-radius: 50%; text-decoration: none;
  background: var(--surface); color: var(--text-muted); border: 1px solid var(--border); transition: all .15s; }
.shop-pill a .ic{ width: 12px; height: 12px; stroke-width: 2.4; }
.shop-pill a:hover{ background: var(--shop-accent); color: #fff; border-color: transparent; }
.shop-clear-all{ font-size: .76rem; font-weight: 800; color: var(--shop-accent); text-decoration: none; margin-right: 4px; }
.shop-clear-all:hover{ text-decoration: underline; }

/* ---------- Empty ---------- */
.shop-empty{ text-align: center; padding: 56px 20px; border-radius: 24px; border: 1.5px dashed var(--border); background: var(--surface); }
.shop-empty-ico{ display: inline-grid; place-items: center; width: 68px; height: 68px; border-radius: 22px; margin-bottom: 12px;
  color: var(--shop-accent); background: var(--shop-soft); border: 1px solid var(--shop-soft-2); }
.shop-empty-ico .ic{ width: 32px; height: 32px; stroke-width: 1.7; }
.shop-empty h3{ margin: 0 0 6px; font-size: 1.1rem; color: var(--text); }
.shop-empty p{ margin: 0 0 18px; color: var(--text-muted); font-size: .9rem; }
.shop-empty .shop-empty-actions{ display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* ---------- Pagination ---------- */
.shop-pages{ display: flex; align-items: center; justify-content: center; gap: 8px; margin: 34px 0 6px; flex-wrap: wrap; }
.shop-page{ min-width: 44px; height: 44px; padding: 0 12px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  text-decoration: none; border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
  font-family: var(--font-mono); font-weight: 700; font-size: .88rem; transition: all .15s; }
.shop-page:hover{ border-color: var(--shop-accent-2); color: var(--shop-accent); }
.shop-page.is-active{ background: linear-gradient(135deg, var(--shop-accent), var(--shop-accent-2)); border-color: transparent; color: #fff; }
.shop-page.nav{ font-family: var(--font-fa); font-size: .82rem; font-weight: 800; }
.shop-page.nav .ic{ width: 16px; height: 16px; }
.shop-page.dots{ border: 0; background: none; }

/* sticky needs html/body not to be scroll containers */
@supports (overflow: clip){ html, body{ overflow-x: clip !important; overflow-y: visible !important; } }

/* ---------- Mobile: dropdowns become bottom sheets ---------- */
@media (max-width: 720px){
  .shop-hero{ padding-top: 14px; }
  .shop-head{ padding: 15px 15px 16px; border-radius: 22px; }
  .shop-crumbs{ margin-bottom: 10px; }
  .shop-head-row{ gap: 12px; }
  .shop-head-ico{ width: 46px; height: 46px; border-radius: 15px; }
  .shop-head-ico .ic{ width: 23px; height: 23px; }
  .shop-head-count{ min-width: 60px; padding: 7px 8px; border-radius: 15px; }
  .shop-head-count b{ font-size: 1.15rem; }
  .shop-scope-line{ font-size: .76rem; }

  .shop-bar{ padding: 7px; border-radius: 18px; background: color-mix(in srgb, var(--surface) 96%, transparent); }
  .shop-tools{ flex-wrap: wrap; gap: 7px; }
  .shop-dd-cat{ flex: 1 1 100%; }
  .shop-dd-btn.cat{ width: 100%; min-width: 0; height: 54px; }
  .shop-dd-text .shop-dd-label{ max-width: none; }
  .shop-search{ flex: 1 1 100%; order: 2; }
  .shop-search input{ height: 46px; font-size: .86rem; }
  .shop-tools-end{ flex: 1 1 100%; order: 3; }
  .shop-tools-end .shop-dd{ flex: 1 1 0; min-width: 0; }
  .shop-tools-end .shop-dd-btn{ width: 100%; height: 44px; justify-content: center; font-size: .8rem; padding: 0 10px; }
  .shop-tools-end .shop-dd-label{ max-width: 120px; }
  /* نوار چسبیده: فقط دکمه‌ی دسته + جست‌وجو، کنار هم و فشرده */
  .shop-bar.is-stuck .shop-tools-end{ display: none; }
  .shop-bar.is-stuck .shop-dd-cat{ flex: 0 0 auto; }
  .shop-bar.is-stuck .shop-dd-btn.cat{ width: auto; height: 46px; padding: 0 8px; }
  .shop-bar.is-stuck .shop-dd-text small, .shop-bar.is-stuck .shop-dd-btn.cat .chev{ display: none; }
  .shop-bar.is-stuck .shop-dd-text .shop-dd-label{ max-width: 84px; font-size: .76rem; }
  .shop-bar.is-stuck .shop-search{ flex: 1 1 0; order: 0; }

  /* the panel is a bottom sheet */
  .shop-dd-panel, .shop-dd-cat .shop-dd-panel, .shop-dd-panel.wide{
    position: fixed; top: auto; left: 0; right: 0; bottom: 0; z-index: 80; width: auto; min-width: 0; max-height: 78vh; overflow-y: auto;
    border-radius: 24px 24px 0 0; padding: 10px 16px calc(18px + env(safe-area-inset-bottom)); animation: shopSheet .26s cubic-bezier(.2,.9,.3,1);
    box-shadow: 0 -20px 50px -20px rgba(0,0,0,.45);
  }
  .shop-sheet-head{ position: relative; padding-top: 14px; margin: 0 0 14px; }
  .shop-sheet-head b{ font-size: .95rem; color: var(--text); }
  .shop-sheet-grab{ display: block; position: absolute; top: 0; left: 50%; width: 42px; height: 5px; margin-left: -21px; border-radius: 99px; background: var(--border); }
  .shop-sheet-x{ display: grid; }
  .shop-cat-grid{ grid-template-columns: minmax(0, 1fr); }
  .shop-cat-card{ padding: 13px; }
  .shop-dd-item{ padding: 14px 12px; font-size: .92rem; }
  .shop-chip{ padding: 9px 14px; font-size: .84rem; }
}
@keyframes shopSheet{ from{ transform: translateY(100%) } to{ transform: none } }

/* برگه‌ی پایینی باز است: backdrop-filter روی نوار، position:fixed فرزندان را نسبت به خودِ نوار
   می‌کرد (نه صفحه)، و z-indexِ نوار برگه را زیرِ پس‌زمینه‌ی تیره می‌برد — هر دو را موقتاً برمی‌داریم. */
html.shop-sheet-open .shop-bar{ z-index: 90; backdrop-filter: none; -webkit-backdrop-filter: none; }
/* دکمه‌ی شناورِ گفت‌وگو روی برگه‌ی پایینی نیفتد */
html.shop-sheet-open #nchat{ display: none !important; }

/* ---------- یک پنلِ یکپارچه: نوارِ فیلتر + نتایج + محصولات روی یک پس‌زمینه ---------- */
.shop-panel{
  position: relative; margin-top: 14px; padding: 10px 14px 26px; border-radius: 30px;
  background:
    radial-gradient(60% 40% at 100% 0%, rgba(255, 67, 104, .07), transparent 70%),
    radial-gradient(50% 30% at 0% 100%, rgba(240, 180, 41, .07), transparent 70%),
    rgba(255, 255, 255, .55);
  border: 1px solid rgba(255, 255, 255, .8);
  box-shadow: 0 24px 60px -36px rgba(89, 8, 36, .35), inset 0 1px 0 rgba(255,255,255,.9);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
body.theme-dark .shop-panel{ background: rgba(31, 15, 27, .5); border-color: var(--border); box-shadow: 0 24px 60px -36px rgba(0,0,0,.6); }
.shop-panel .shop-bar{ margin-top: 0; background: color-mix(in srgb, var(--surface) 94%, transparent); }
.shop-panel .shop-results{ margin: 18px 6px 14px; }
.shop-panel .shop-empty{ background: color-mix(in srgb, var(--surface) 80%, transparent); }
.shop-panel .shop-pages{ margin-bottom: 0; }
/* backdrop-filter روی پنل، position:fixedِ برگه‌ی پایینی را نسبت به پنل می‌کرد — وقتِ باز بودن برگه برداشته می‌شود */
html.shop-sheet-open .shop-panel{ backdrop-filter: none; -webkit-backdrop-filter: none; }
@media (max-width: 720px){
  .shop-panel{ margin-top: 12px; padding: 7px 7px 20px; border-radius: 24px; }
  .shop-panel .shop-results{ margin: 14px 4px 12px; }
}
