/* ==========================================================================
   اجزای مشترک: هدر، منو، جستجو، کشوها، مودال، توست، کارت محصول، فوتر
   ========================================================================== */

/* ---------- نوار بالا ---------- */
.topbar { background: var(--navy-950); color: #c9d3e8; font-size: var(--fs-xs); }
.topbar__inner { display: flex; justify-content: space-between; align-items: center; gap: 16px; min-height: 36px; }
.topbar span, .topbar a { display: inline-flex; align-items: center; gap: 6px; }
.topbar__links { gap: 20px !important; }
.topbar a:hover { color: #fff; }

/* ---------- هدر ---------- */
.header { position: sticky; top: 0; z-index: 50; background: #fff; transition: box-shadow .25s; }
.header.is-scrolled { box-shadow: 0 8px 24px -14px rgba(11, 22, 48, .35); }
.header__main { display: flex; align-items: center; gap: clamp(12px, 2.5vw, 32px); min-height: 76px; }
.header__burger { display: none; }

.logo { display: inline-flex; align-items: center; gap: 10px; flex-shrink: 0; }
.logo__text { display: grid; line-height: 1.3; }
.logo__text strong { font-size: 1.2rem; font-weight: 900; color: var(--navy-900); letter-spacing: -.2px; }
.logo__text small { font-size: .7rem; color: var(--muted); font-weight: 500; }

.search { position: relative; flex: 1; max-width: 620px; display: flex; }
.search input {
  width: 100%; height: 48px; padding: 0 18px 0 54px;
  border: 1.5px solid var(--border); border-radius: 12px; background: var(--surface-2);
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.search input::-webkit-search-cancel-button { display: none; }
.search input:focus { outline: none; background: #fff; border-color: var(--navy-700); box-shadow: 0 0 0 4px rgba(26, 50, 99, .1); }
.search__btn { position: absolute; left: 5px; top: 5px; width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center; background: var(--navy-800); color: #fff; transition: background .2s; }
.search__btn:hover { background: var(--accent); }
.search__suggest { position: absolute; top: calc(100% + 8px); inset-inline: 0; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; z-index: 60; max-height: 70vh; overflow: auto; }
.sg { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 10px; font-size: var(--fs-sm); }
.sg:hover, .sg.is-active { background: var(--surface-2); }
.sg img { width: 44px; height: 44px; object-fit: contain; border-radius: 8px; background: #fff; border: 1px solid var(--border); }
.sg__txt { display: grid; flex: 1; line-height: 1.5; }
.sg__txt small { color: var(--muted); }
.sg__price { font-weight: 700; white-space: nowrap; }
.sg--cat { color: var(--navy-700); }
.sg--all { justify-content: center; color: var(--accent-600); font-weight: 700; border-top: 1px solid var(--border); margin-top: 4px; border-radius: 0 0 8px 8px; }
.sg--empty { color: var(--muted); justify-content: center; padding: 18px; }

.header__actions { display: flex; align-items: center; gap: 6px; margin-inline-start: auto; }
.hbtn { position: relative; display: inline-flex; align-items: center; gap: 8px; height: 48px; padding: 0 14px; border-radius: 12px; font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); transition: background .2s, color .2s; }
.hbtn:hover { background: var(--surface-2); color: var(--navy-900); }
.hbtn--cart { background: var(--navy-800); color: #fff; }
.hbtn--cart:hover { background: var(--navy-700); color: #fff; }
.cart-count { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 800; display: grid; place-items: center; line-height: 1; }
.cart-count.is-empty { background: rgba(255, 255, 255, .2); }
.cart-count.bump { animation: bump .5s var(--ease); }
@keyframes bump { 30% { transform: scale(1.45); } 60% { transform: scale(.9); } }

/* ---------- منوی اصلی ---------- */
.nav { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); background: #fff; }
.nav__inner { display: flex; align-items: center; gap: 28px; min-height: 52px; }
.nav__list { display: flex; gap: 4px; }
.nav__list a { display: block; padding: 8px 14px; border-radius: 8px; font-weight: 600; font-size: var(--fs-sm); color: var(--text-2); position: relative; transition: color .2s, background .2s; }
.nav__list a:hover { color: var(--navy-900); background: var(--surface-2); }
.nav__list a.is-active { color: var(--accent-600); }
.nav__list a.is-active::after { content: ''; position: absolute; bottom: -9px; inset-inline: 14px; height: 2.5px; background: var(--accent); border-radius: 2px; }
.nav__cta { margin-inline-start: auto; display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-sm); font-weight: 700; color: var(--navy-700); }
.nav__cta:hover { color: var(--accent-600); }

.mega { position: relative; }
.mega__btn { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border-radius: 9px; background: var(--accent-50); color: var(--accent-600); font-weight: 800; font-size: var(--fs-sm); }
.mega__btn .icon:last-child { transition: transform .2s; }
.mega.is-open .mega__btn .icon:last-child { transform: rotate(180deg); }
.mega__panel { position: absolute; top: calc(100% + 8px); right: 0; width: min(640px, 90vw); display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 10px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); opacity: 0; visibility: hidden; transform: translateY(6px); transition: .2s var(--ease); z-index: 70; }
.mega.is-open .mega__panel, .mega:hover .mega__panel, .mega:focus-within .mega__panel { opacity: 1; visibility: visible; transform: none; }
.mega__item { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; font-size: var(--fs-sm); font-weight: 600; transition: background .15s; }
.mega__item:hover { background: var(--surface-2); color: var(--accent-600); }
.mega__item img { width: 44px; height: 44px; object-fit: contain; background: var(--surface-2); border-radius: 8px; padding: 3px; }

/* ---------- کشوها و مودال ---------- */
.drawer, .modal { position: fixed; inset: 0; z-index: 100; visibility: hidden; }
.drawer.is-open, .modal.is-open { visibility: visible; }
.drawer__overlay, .modal__overlay { position: absolute; inset: 0; background: rgba(7, 15, 34, .55); opacity: 0; transition: opacity .25s; backdrop-filter: blur(2px); }
.is-open > .drawer__overlay, .is-open > .modal__overlay { opacity: 1; }
.drawer__panel { position: absolute; top: 0; bottom: 0; width: min(420px, 92vw); background: #fff; display: flex; flex-direction: column; transition: transform .3s var(--ease); box-shadow: var(--shadow-lg); }
.drawer--cart .drawer__panel { left: 0; transform: translateX(-100%); }
.drawer--nav .drawer__panel { right: 0; transform: translateX(100%); width: min(340px, 88vw); }
.drawer.is-open .drawer__panel { transform: none; }
.drawer__head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.drawer__head h2 { font-size: var(--fs-md); }
.drawer__head h2 span { color: var(--muted); font-weight: 500; font-size: var(--fs-sm); }
.drawer__body { flex: 1; overflow: auto; padding: 8px 20px; }
.drawer__foot { padding: 16px 20px 20px; border-top: 1px solid var(--border); display: grid; gap: 12px; background: var(--surface-2); }
.drawer__foot:empty { display: none; }

.mini-item { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); align-items: flex-start; }
.mini-item img { width: 64px; height: 64px; object-fit: contain; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.mini-item__info { flex: 1; display: grid; gap: 8px; min-width: 0; }
.mini-item__name { font-size: var(--fs-sm); font-weight: 600; line-height: 1.6; }
.mini-item__name:hover { color: var(--accent-600); }
.mini-item__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: var(--fs-sm); }
.mini-total { display: flex; justify-content: space-between; align-items: center; font-size: var(--fs-md); }
.free-note { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--warn); background: var(--warn-50); padding: 8px 12px; border-radius: 8px; }
.free-note.is-free { color: var(--success); background: var(--success-50); }

.mnav { display: grid; padding: 12px; overflow: auto; }
.mnav > a { padding: 12px; border-radius: 10px; font-weight: 600; }
.mnav > a:hover, .mnav > a.is-active { background: var(--surface-2); color: var(--accent-600); }
.mnav__title { font-size: var(--fs-xs); color: var(--muted); font-weight: 700; padding: 16px 12px 6px; border-top: 1px solid var(--border); margin-top: 8px; }
.mnav .mnav__cat { display: flex; align-items: center; gap: 10px; font-weight: 500; font-size: var(--fs-sm); padding: 8px 12px; }
.mnav__cat img { width: 32px; height: 32px; object-fit: contain; background: var(--surface-2); border-radius: 6px; }

.modal { display: grid; place-items: center; padding: 16px; }
.modal__box { position: relative; width: min(440px, 100%); max-height: 90vh; overflow: auto; background: #fff; border-radius: var(--radius-lg); padding: 32px 28px 28px; box-shadow: var(--shadow-lg); transform: translateY(16px) scale(.98); opacity: 0; transition: .25s var(--ease); }
.modal.is-open .modal__box { transform: none; opacity: 1; }
.modal__close { position: absolute; top: 12px; left: 12px; }
.modal__title { font-size: var(--fs-lg); margin-bottom: 6px; }
.modal__box .form { margin-top: 20px; }
.sub-title { display: flex; align-items: center; gap: 8px; font-size: var(--fs-base); margin: 20px 0 10px; }
.orders { display: grid; gap: 8px; margin-bottom: 16px; }
.orders li { display: flex; justify-content: space-between; gap: 12px; padding: 12px; background: var(--surface-2); border-radius: 10px; font-size: var(--fs-sm); }
.orders li > div { display: grid; gap: 2px; }
.orders li > div:last-child { text-align: left; justify-items: end; }
.orders small { color: var(--muted); }
.pill { display: inline-block; font-size: 11px; padding: 1px 10px; border-radius: 99px; background: var(--warn-50); color: var(--warn); font-weight: 700; }

/* ---------- توست ---------- */
.toast-root { position: fixed; bottom: 20px; left: 20px; z-index: 200; display: grid; gap: 10px; width: min(380px, calc(100vw - 40px)); }
.toast { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--navy-900); color: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg); transform: translateY(20px); opacity: 0; transition: .3s var(--ease); font-size: var(--fs-sm); border-inline-start: 4px solid var(--success); }
.toast.is-in { transform: none; opacity: 1; }
.toast--error { border-color: var(--red); }
.toast--info { border-color: #6c8fd8; }
.toast__img { width: 44px; height: 44px; object-fit: contain; background: #fff; border-radius: 8px; }
.toast__icon { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, .12); }
.toast__body { flex: 1; line-height: 1.7; }
.toast__action { color: #ffb08f; font-weight: 700; }
.toast__action:hover { text-decoration: underline; }
.toast__close { color: #9aa7c4; }
.toast__close:hover { color: #fff; }

/* ---------- عنوان بخش‌ها ---------- */
.section { padding-block: var(--section); }
.section--gray { background: var(--surface-2); }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: var(--s-8); flex-wrap: wrap; }
.section-head h2 { font-size: var(--fs-xl); display: flex; align-items: center; gap: 10px; }
.section-head h2 .icon { color: var(--accent); }
.section-head p { color: var(--muted); margin-top: 4px; }
.link-more { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: var(--fs-sm); color: var(--navy-700); padding: 8px 0; }
.link-more:hover { color: var(--accent-600); gap: 10px; }
.link-more, .link-more .icon { transition: .2s; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-xs); font-weight: 800; color: var(--accent-600); background: var(--accent-50); padding: 4px 12px; border-radius: 99px; }

/* ---------- کارت محصول ---------- */
.grid-products { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.pcard { position: relative; display: flex; flex-direction: column; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; transition: box-shadow .3s var(--ease), transform .3s var(--ease), border-color .3s; }
.pcard:hover { box-shadow: var(--shadow-lg); transform: translateY(-4px); border-color: transparent; }
.pcard__media { position: relative; display: block; aspect-ratio: 1; background: #fff; overflow: hidden; border-bottom: 1px solid var(--border); }
.pcard__media img { width: 100%; height: 100%; object-fit: contain; padding: 14px; transition: transform .5s var(--ease); }
.pcard:hover .pcard__media img { transform: scale(1.07); }
.pcard.is-out .pcard__media img { filter: grayscale(.8); opacity: .65; }
.pcard__badges { position: absolute; top: 10px; right: 10px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.badge { display: inline-block; font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 6px; line-height: 1.6; }
.badge--off { background: var(--red); color: #fff; }
.badge--new { background: var(--navy-800); color: #fff; }
.pcard__body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.pcard__meta { display: flex; justify-content: space-between; align-items: center; font-size: var(--fs-xs); }
.pcard__brand { color: var(--navy-700); font-weight: 700; background: var(--navy-100); padding: 1px 8px; border-radius: 5px; }
.pcard__brand:hover { background: var(--navy-800); color: #fff; }
.pcard__rating { display: inline-flex; align-items: center; gap: 3px; color: var(--muted); }
.pcard__rating .icon { color: #f5a524; fill: #f5a524; }
.pcard__title { font-size: var(--fs-base); font-weight: 700; line-height: 1.65; min-height: 3.3em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pcard__title a:hover { color: var(--accent-600); }
.pcard__spec { font-size: var(--fs-xs); color: var(--muted); }
.pcard__price { display: grid; justify-items: end; margin-top: auto; padding-top: 4px; line-height: 1.5; }
.pcard__price del { font-size: var(--fs-sm); }
.pcard__price del.is-placeholder { visibility: hidden; }
.pcard__price strong { font-size: var(--fs-md); font-weight: 800; }
.pcard__actions { display: grid; grid-template-columns: auto 1fr; gap: 8px; margin-top: 8px; }
.pcard__actions .btn--sm { padding: 0 10px; }

.stock { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 700; }
.stock::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.stock--in { color: var(--success); }
.stock--low { color: var(--warn); }
.stock--out { color: var(--red); }

/* اسکلتون بارگذاری */
.pcard--skeleton { pointer-events: none; }
.sk { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 6px; }
.sk--media { aspect-ratio: 1; border-radius: 0; }
.sk--line { height: 12px; margin: 6px 0; }
.w40 { width: 40%; } .w50 { width: 50%; } .w60 { width: 60%; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ریل افقی محصولات (موبایل) */
.rail { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 18px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 10px; scrollbar-width: thin; }
.rail > * { scroll-snap-align: start; }
@media (min-width: 1100px) { .rail { grid-auto-flow: initial; grid-template-columns: repeat(5, 1fr); overflow: visible; } .rail > :nth-child(n+6) { display: none; } }

/* ---------- تعداد ---------- */
.qty { display: inline-flex; align-items: center; border: 1.5px solid var(--border); border-radius: 10px; background: #fff; height: 46px; }
.qty button { width: 42px; height: 100%; display: grid; place-items: center; color: var(--navy-800); transition: background .15s; }
.qty button:hover:not(:disabled) { background: var(--surface-2); }
.qty button:disabled { color: var(--border-strong); }
.qty span, .qty input { min-width: 36px; text-align: center; font-weight: 800; border: 0; width: 44px; background: transparent; }
.qty input:focus { outline: none; }
.qty--sm { height: 34px; border-radius: 8px; }
.qty--sm button { width: 30px; }
.qty--sm span { min-width: 26px; font-size: var(--fs-sm); }

/* ---------- حالت خالی ---------- */
.empty { display: grid; justify-items: center; gap: 14px; text-align: center; padding: 64px 16px; color: var(--muted); }
.empty .icon { color: var(--border-strong); }
.empty h3 { color: var(--text); font-size: var(--fs-lg); }
.empty--sm { padding: 48px 8px; }

/* ---------- مسیر صفحه ---------- */
.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--muted); padding-block: 18px; }
.breadcrumb a:hover { color: var(--accent-600); }
.breadcrumb .icon { opacity: .5; }
.breadcrumb [aria-current] { color: var(--text-2); font-weight: 600; }

/* ---------- انیمیشن ظاهر شدن ---------- */
.js-ready .reveal { opacity: 0; transform: translateY(22px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
.js-ready .reveal.is-visible { opacity: 1; transform: none; }
.reveal-stagger > * { transition-delay: calc(var(--i, 0) * 60ms); }

/* ---------- فوتر ---------- */
.footer { background: var(--navy-900); color: #b8c3da; margin-top: var(--section); }
.footer__grid { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1.4fr; gap: 40px; padding-block: 56px 40px; }
.footer .logo__text strong { color: #fff; }
.footer .logo__text small { color: #8794b2; }
.footer__about p { margin: 18px 0; font-size: var(--fs-sm); line-height: 2; }
.footer__title { color: #fff; font-size: var(--fs-base); margin-bottom: 16px; }
.footer__links { display: grid; gap: 8px; font-size: var(--fs-sm); }
.footer__links a:hover { color: #fff; padding-inline-start: 4px; }
.footer__links a { transition: .2s; }
.footer__contact { display: grid; gap: 14px; font-size: var(--fs-sm); }
.footer__contact li { display: flex; gap: 10px; align-items: flex-start; }
.footer__contact .icon { color: var(--accent); margin-top: 4px; }
.footer__contact a:hover { color: #fff; }
.socials { display: flex; gap: 10px; }
.socials a { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; background: rgba(255, 255, 255, .07); color: #fff; transition: .2s; }
.socials a:hover { background: var(--accent); transform: translateY(-2px); }
.footer__bottom { border-top: 1px solid rgba(255, 255, 255, .08); font-size: var(--fs-xs); }
.footer__bottom-inner { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-block: 18px; }
.footer__note { color: #8794b2; }

/* ---------- واکنش‌گرا ---------- */
@media (max-width: 1100px) {
  .footer__grid { grid-template-columns: 1fr 1fr; }
  .nav__cta { display: none; }
}
@media (max-width: 900px) {
  .header__burger { display: inline-grid; }
  .nav { display: none; }
  .header__main { flex-wrap: wrap; gap: 8px 10px; padding-block: 10px; min-height: 0; }
  .search { order: 5; flex-basis: 100%; max-width: none; }
  .hbtn__label { display: none; }
  .hbtn { padding: 0 10px; height: 44px; }
  .hide-sm { display: none !important; }
}
@media (max-width: 560px) {
  .topbar__inner > span:first-child { font-size: 11px; }
  .topbar__links { display: none !important; }
  .topbar__inner { justify-content: center; }
  .logo__text small { display: none; }
  .logo-mark { width: 34px; height: 34px; }
  .grid-products { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .pcard__body { padding: 10px 10px 12px; }
  .pcard__title { font-size: var(--fs-sm); }
  .pcard__actions { grid-template-columns: 1fr; }
  .pcard__actions .btn--ghost { display: none; }
  .pcard__price strong { font-size: var(--fs-base); }
  .footer__grid { grid-template-columns: 1fr; gap: 28px; }
  .toast-root { left: 12px; right: 12px; bottom: 12px; width: auto; }
  .rail { grid-auto-columns: 62%; gap: 10px; }
}
