/* =============================================================================
   Zagros Tech — Components (UI Core)
   قانون طلایی: قبل از ساخت چیز جدید، اینجا را بگرد.
   ============================================================================= */

/* ---------- Button ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 44px; padding: 0 var(--s-5);
  border-radius: var(--r-1); border: 1px solid transparent;
  font-weight: 700; font-size: var(--fs-base); white-space: nowrap;
  cursor: pointer; user-select: none;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }

.btn-primary {
  color: var(--brand-contrast);
  background: linear-gradient(180deg, var(--brand), var(--brand-strong));
  border-color: var(--brand-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.btn-primary:hover:not(:disabled) { background: var(--brand-strong); }

.btn-accent {
  color: #fff; background: var(--accent); border-color: var(--accent-strong);
}
[data-theme='dark'] .btn-accent { color: #0b0f16; }
.btn-accent:hover:not(:disabled) { background: var(--accent-strong); }

.btn-ghost { color: var(--text); background: var(--surface); border-color: var(--border-strong); }
.btn-ghost:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }

.btn-quiet { color: var(--text-dim); background: transparent; border-color: transparent; padding-inline: var(--s-3); }
.btn-quiet:hover:not(:disabled) { color: var(--brand); background: var(--brand-tint); }

.btn-danger { color: #fff; background: var(--danger); }
.btn-block { display: flex; width: 100%; }
.btn-sm { min-height: 36px; padding: 0 var(--s-4); font-size: var(--fs-sm); }
.btn-lg { min-height: 52px; padding: 0 var(--s-6); font-size: var(--fs-md); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: var(--r-1); color: var(--text-dim);
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.icon-btn:hover { color: var(--brand); background: var(--brand-tint); }
.icon-btn svg { width: 22px; height: 22px; }

/* ---------- Card ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-2); overflow: hidden;
}
.card-pad { padding: var(--s-5); }

/* براکت گوشه — حسّ بلوپرینت */
.bracket { position: relative; }
.bracket::before, .bracket::after {
  content: ''; position: absolute; width: 14px; height: 14px;
  border: 1.5px solid var(--brand); pointer-events: none;
}
.bracket::before { inset-block-start: 8px; inset-inline-start: 8px; border-inline-end: 0; border-block-end: 0; }
.bracket::after { inset-block-end: 8px; inset-inline-end: 8px; border-inline-start: 0; border-block-start: 0; }

/* ---------- Badge / Chip ---------- */
.badge {
  display: inline-flex; align-items: center; gap: var(--s-1);
  padding: 2px var(--s-2); border-radius: var(--r-1);
  font-size: var(--fs-xs); font-weight: 700; line-height: 1.6;
  border: 1px solid currentColor; color: var(--text-dim);
}
.badge-brand { color: var(--brand); }
.badge-accent { color: var(--accent); }
.badge-danger { color: var(--danger); }
.badge-solid { border: 0; background: var(--brand-tint); color: var(--brand); }

.chip {
  display: inline-flex; align-items: center; gap: var(--s-2);
  min-height: 38px; padding: 0 var(--s-4); border-radius: var(--r-pill);
  border: 1px solid var(--border-strong); background: var(--surface);
  font-size: var(--fs-sm); cursor: pointer;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.chip:hover { border-color: var(--brand); }
.chip[aria-pressed='true'], .chip.is-active {
  border-color: var(--brand); color: var(--brand); background: var(--brand-tint);
}

/* ---------- Form ---------- */
.field { display: flex; flex-direction: column; gap: var(--s-2); margin-bottom: var(--s-4); }
.field > label { font-size: var(--fs-sm); font-weight: 700; color: var(--text); }
.field .hint { font-size: var(--fs-xs); color: var(--text-dim); }
.field .error { font-size: var(--fs-xs); color: var(--danger); min-height: 1em; }

.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: var(--s-2) var(--s-3);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--r-1);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.textarea { min-height: 96px; resize: vertical; line-height: var(--lh-body); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: var(--sh-focus);
}
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.field.is-invalid .input, .field.is-invalid .select, .field.is-invalid .textarea { border-color: var(--danger); }

.switch { display: inline-flex; align-items: center; gap: var(--s-3); cursor: pointer; font-size: var(--fs-sm); }
.switch input { position: absolute; opacity: 0; }
.switch .track {
  width: 42px; height: 24px; border-radius: var(--r-pill);
  background: var(--surface-3); border: 1px solid var(--border-strong); position: relative;
  transition: background var(--dur) var(--ease);
}
.switch .track::after {
  content: ''; position: absolute; inset-block-start: 2px; inset-inline-start: 2px;
  width: 18px; height: 18px; border-radius: 50%; background: var(--surface);
  box-shadow: var(--sh-1); transition: transform var(--dur) var(--ease);
}
.switch input:checked + .track { background: var(--brand); border-color: var(--brand); }
.switch input:checked + .track::after { transform: translateX(-18px); }
[dir='ltr'] .switch input:checked + .track::after { transform: translateX(18px); }

/* ---------- Stepper (qty) ---------- */
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: var(--r-1); }
.stepper button { width: 40px; height: 40px; display: grid; place-items: center; color: var(--text-dim); }
.stepper button:hover { color: var(--brand); }
.stepper .val { min-width: 44px; text-align: center; font-weight: 700; font-family: var(--font-mono); }

/* ---------- Price block ---------- */
.price { display: flex; align-items: baseline; gap: var(--s-2); flex-wrap: wrap; }
.price .now { font-size: var(--fs-xl); font-weight: 900; font-family: var(--font-mono); color: var(--text); }
.price .was { font-size: var(--fs-sm); color: var(--text-faint); text-decoration: line-through; font-family: var(--font-mono); }
.price .unit { font-size: var(--fs-sm); color: var(--text-dim); }
.price-contact { font-size: var(--fs-md); font-weight: 800; color: var(--brand); }

/* ---------- Skeleton ---------- */
.skel { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2));
  background-size: 200% 100%; animation: skel 1.3s ease-in-out infinite; border-radius: var(--r-1); }
@keyframes skel { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: var(--s-8) var(--s-4); color: var(--text-dim); }
.empty svg { width: 56px; height: 56px; margin: 0 auto var(--s-4); color: var(--text-faint); }
.empty h3 { margin-bottom: var(--s-2); }

/* ---------- Toast ---------- */
#toast-host {
  position: fixed; inset-block-start: calc(var(--header-h) + var(--s-3)); inset-inline-end: var(--s-4);
  display: flex; flex-direction: column; gap: var(--s-2); z-index: var(--z-toast); pointer-events: none;
}
.toast {
  pointer-events: auto; min-width: 240px; max-width: 360px;
  padding: var(--s-3) var(--s-4); border-radius: var(--r-1);
  background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--sh-2);
  font-size: var(--fs-sm); display: flex; gap: var(--s-3); align-items: flex-start;
  animation: toast-in var(--dur-in) var(--ease);
  border-inline-start: 3px solid var(--brand);
}
.toast.ok { border-inline-start-color: var(--success); }
.toast.err { border-inline-start-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

/* ---------- Modal ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px); z-index: var(--z-modal);
  display: grid; place-items: center; padding: var(--s-4);
  animation: fade var(--dur-in) var(--ease);
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-3); width: 100%; max-width: 560px;
  max-height: 90dvh; overflow-y: auto; box-shadow: var(--sh-2);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--border); }
.modal-body { padding: var(--s-5); }
.modal-lg { max-width: 900px; }

/* ---------- Drawer (cart) ---------- */
.drawer {
  position: fixed; inset-block: 0; inset-inline-end: 0; width: min(420px, 92vw);
  background: var(--surface); border-inline-start: 1px solid var(--border-strong);
  z-index: var(--z-drawer); display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform var(--dur-in) var(--ease);
}
[dir='rtl'] .drawer { transform: translateX(-100%); }
.drawer.is-open { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--border); }
.drawer-body { flex: 1; overflow-y: auto; padding: var(--s-4) var(--s-5); }
.drawer-foot { padding: var(--s-4) var(--s-5); border-top: 1px solid var(--border); }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: calc(var(--z-drawer) - 1); animation: fade var(--dur-in) var(--ease); }

/* ---------- Pagination ---------- */
.pager { display: flex; align-items: center; justify-content: center; gap: var(--s-2); margin-top: var(--s-6); flex-wrap: wrap; }
.pager button {
  min-width: 40px; height: 40px; padding: 0 var(--s-2);
  border: 1px solid var(--border-strong); border-radius: var(--r-1);
  color: var(--text-dim); font-weight: 700; font-family: var(--font-mono);
}
.pager button:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.pager button[aria-current='page'] { background: var(--brand); color: var(--brand-contrast); border-color: var(--brand); }
.pager button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- Product card ---------- */
.pcard {
  display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-2); overflow: hidden;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.pcard:hover { border-color: var(--brand); }
.pcard .media { aspect-ratio: 4 / 3; background: var(--surface-2); position: relative; overflow: hidden; }
.pcard .media img { width: 100%; height: 100%; object-fit: cover; transition: transform 400ms var(--ease); }
.pcard:hover .media img { transform: scale(1.04); }
.pcard .media .tags { position: absolute; inset-block-start: var(--s-2); inset-inline-start: var(--s-2); display: flex; gap: var(--s-1); flex-wrap: wrap; }
.pcard .body { padding: var(--s-4); display: flex; flex-direction: column; gap: var(--s-2); flex: 1; }
.pcard .brand { font-size: var(--fs-xs); color: var(--text-dim); }
.pcard .name { font-size: var(--fs-base); font-weight: 700; line-height: 1.5; }
.pcard .name a::after { content: ''; position: absolute; inset: 0; }
.pcard .foot { margin-block-start: auto; padding-top: var(--s-2); }

/* ---------- Spec table ---------- */
.spec-group { margin-bottom: var(--s-5); }
.spec-group h4 { font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: 0.08em; color: var(--brand); margin-bottom: var(--s-2); }
.spec-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.spec-table tr { border-bottom: 1px solid var(--border); }
.spec-table th { text-align: start; font-weight: 500; color: var(--text-dim); padding: var(--s-3) 0; width: 45%; }
.spec-table td { padding: var(--s-3) 0; font-weight: 700; font-family: var(--font-mono); }
.spec-table td .u { color: var(--text-dim); font-weight: 400; margin-inline-start: 4px; }

/* ---------- Gallery ---------- */
.gallery { display: grid; gap: var(--s-3); }
.gallery .main { aspect-ratio: 4 / 3; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-2); overflow: hidden; }
.gallery .main img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.gallery .thumbs { display: flex; gap: var(--s-2); overflow-x: auto; padding-bottom: var(--s-1); }
.gallery .thumbs button { flex: 0 0 72px; aspect-ratio: 1; border: 1px solid var(--border); border-radius: var(--r-1); overflow: hidden; }
.gallery .thumbs button[aria-current='true'] { border-color: var(--brand); }
.gallery .thumbs img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Header / Nav ---------- */
.site-header {
  position: sticky; inset-block-start: 0; z-index: var(--z-header);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-block-end: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: var(--s-4); height: var(--header-h); }
.brand-logo { display: flex; align-items: center; gap: var(--s-2); font-weight: 900; font-size: var(--fs-md); flex-shrink: 0; }
.brand-logo img { width: 34px; height: 34px; }
.main-nav { display: none; }
.main-nav ul { display: flex; gap: var(--s-2); }
.main-nav a { padding: var(--s-2) var(--s-3); border-radius: var(--r-1); font-weight: 500; color: var(--text-dim); }
.main-nav a:hover, .main-nav a.is-active { color: var(--brand); background: var(--brand-tint); }
.header-actions { display: flex; align-items: center; gap: var(--s-1); margin-inline-start: auto; }
.cart-btn { position: relative; }
.cart-count {
  position: absolute; inset-block-start: 4px; inset-inline-end: 2px;
  min-width: 18px; height: 18px; padding: 0 4px; border-radius: var(--r-pill);
  background: var(--brand); color: var(--brand-contrast);
  font-size: 10px; font-weight: 800; display: grid; place-items: center; font-family: var(--font-mono);
}
@media (min-width: 960px) {
  .main-nav { display: block; }
  .hamburger { display: none; }
}

/* mobile nav drawer */
.mnav { position: fixed; inset-block: 0; inset-inline-start: 0; width: min(320px, 86vw); background: var(--surface); border-inline-end: 1px solid var(--border-strong); z-index: var(--z-drawer); transform: translateX(-100%); transition: transform var(--dur-in) var(--ease); padding: var(--s-5); overflow-y: auto; }
[dir='rtl'] .mnav { transform: translateX(100%); }
.mnav.is-open { transform: none; }
.mnav a { display: block; padding: var(--s-3); border-radius: var(--r-1); font-weight: 600; }
.mnav a:hover { background: var(--brand-tint); color: var(--brand); }

/* ---------- Footer ---------- */
.site-footer { position: relative; border-block-start: 1px solid var(--border); background: var(--surface); margin-block-start: var(--s-9); overflow: hidden; }
.site-footer::before {
  content: ''; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background: url('/assets/images/blueprint-tile.webp') repeat; background-size: 340px;
  opacity: 0.04;
}
:root[data-theme='dark'] .site-footer::before { opacity: 0.09; }
.site-footer > * { position: relative; z-index: 1; }
.footer-grid { display: grid; gap: var(--s-6); padding-block: var(--s-7); grid-template-columns: 1fr; }
.footer-grid h4 { font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); margin-bottom: var(--s-3); }
.footer-grid a { display: block; padding: var(--s-1) 0; color: var(--text-dim); font-size: var(--fs-sm); }
.footer-grid a:hover { color: var(--brand); }
.footer-bottom { border-block-start: 1px solid var(--border); padding-block: var(--s-4); font-size: var(--fs-xs); color: var(--text-faint); text-align: center; }
@media (min-width: 768px) { .footer-grid { grid-template-columns: 1.4fr 1fr 1fr 1fr; } }
@media (min-width: 1000px) { .footer-grid { grid-template-columns: 1.6fr 1fr 1fr 1fr 1.1fr; } }

/* ---------- Static content pages ---------- */
.static-page h1 { margin-bottom: var(--s-5); }
.static-body { color: var(--text); line-height: 1.9; }
.static-body h2 { font-size: var(--fs-lg); margin: var(--s-6) 0 var(--s-2); }
.static-body h3 { font-size: var(--fs-base); margin: var(--s-4) 0 var(--s-2); }
.static-body p { margin-block: var(--s-3); }
.static-body ul, .static-body ol { margin-block: var(--s-3); padding-inline-start: var(--s-6); }
.static-body li { margin-block: var(--s-1); }
.static-body a { color: var(--brand); text-decoration: underline; }
.static-body strong, .static-body b { color: var(--text); font-weight: 700; }
