/* ============================================================
   LINKS — base: tokens, type, shared components
   Palette: hyperlink cobalt + warm amber on porcelain.
   Signature: the interlocking-links mark + dotted "chain" rule.
   ============================================================ */

:root {
  --ink: #101418;
  --ink-soft: #3d434b;
  --muted: #6d7480;
  --paper: #fafaf8;
  --card: #ffffff;
  --line: #ebecea;
  --line-strong: #dcdeda;

  --accent: #2b50f0;
  --accent-deep: #1c3ad1;
  --accent-tint: #edf1fe;
  --amber: #f59e1b;
  --amber-deep: #9e6206;
  --amber-tint: #fdf1dc;
  --success: #1e9e5a;
  --success-tint: #e6f5ec;
  --danger: #d64545;
  --danger-tint: #fbecec;

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(16, 20, 24, .04), 0 8px 24px -12px rgba(16, 20, 24, .12);
  --shadow-lift: 0 2px 6px rgba(16, 20, 24, .06), 0 18px 40px -16px rgba(16, 20, 24, .22);

  --field-bg: #f1f2f0;        /* filled inputs, chips, qty buttons */
  --field-hover: #e8e9e6;
  --photo-bg: #f0f1ee;        /* image placeholders */
  --skel-a: #ecedeb;
  --skel-b: #f4f5f3;
  --inverse-bg: var(--ink);   /* ink pills: cart button, active chip, toast */
  --inverse-fg: #ffffff;
  --header-bg: rgba(250, 250, 248, .96);
  --overlay-bg: rgba(16, 20, 24, .5);
  --glass-hi: rgba(255, 255, 255, .32);   /* liquid-glass top highlight */
  --glass-edge: rgba(255, 255, 255, .25); /* liquid-glass border */

  --font-display: "Gabarito", system-ui, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-urdu: "Noto Nastaliq Urdu", serif;
}

html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }

html[data-theme="dark"] {
  --ink: #eef1f5;
  --ink-soft: #c3c9d3;
  --muted: #8b93a1;
  --paper: #0f1216;
  --card: #171b21;
  --line: #242a33;
  --line-strong: #39414d;

  --accent: #5d7bff;
  --accent-deep: #a9b8ff;    /* readable ON accent-tint in dark */
  --accent-tint: #1d2745;
  --amber: #f5a524;
  --amber-deep: #ffc65f;
  --amber-tint: #3a2d10;
  --success: #2ebd70;
  --success-tint: #12331f;
  --danger: #ff6b6b;
  --danger-tint: #3d1b1b;

  --field-bg: #21262e;
  --field-hover: #292f39;
  --photo-bg: #21262e;
  --skel-a: #21262e;
  --skel-b: #2a303b;
  --inverse-bg: #eef1f5;
  --inverse-fg: #12161c;
  --header-bg: rgba(15, 18, 22, .96);
  --overlay-bg: rgba(0, 0, 0, .62);
  --glass-hi: rgba(255, 255, 255, .16);
  --glass-edge: rgba(255, 255, 255, .12);

  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 8px 24px -12px rgba(0, 0, 0, .7);
  --shadow-lift: 0 2px 6px rgba(0, 0, 0, .55), 0 18px 40px -16px rgba(0, 0, 0, .8);
}

/* dark surfaces need hairlines where light relied on shadows */
html[data-theme="dark"] .card { border-color: var(--line); }

* { box-sizing: border-box; }

/* The hidden attribute must always win, even over display:grid/flex rules.
   Without this, elements like the login screen stay visible after JS hides them. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  font-size: 16px;
  line-height: 1.5;
}

/* Urdu: nastaliq needs generous line height and a slightly larger size */
body.ur { font-family: var(--font-urdu), var(--font-body); line-height: 2; }
body.ur .display { font-family: var(--font-urdu); font-weight: 700; letter-spacing: 0; }
body.ur input, body.ur textarea, body.ur select, body.ur button { font-family: inherit; }
body.ur .latin { font-family: var(--font-body); } /* numbers, codes, phone */

.display {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.15;
}

img { max-width: 100%; display: block; }
a { color: var(--accent); }
button { font: inherit; cursor: pointer; }
button, .btn, .chip, .product-card { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
input, select, textarea { font: inherit; color: inherit; }

/* ---------- the chain rule (signature divider) ---------- */
.ribbon {
  height: 6px;
  background: radial-gradient(circle 2.4px at 50% 50%, var(--accent) 97%, transparent) 0 50% / 16px 6px repeat-x;
  opacity: .55;
}
.ribbon.thin { height: 5px; background-size: 14px 5px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-weight: 600;
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
  transition: transform .06s ease, box-shadow .15s ease, background .15s ease;
  min-height: 46px;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary {
  color: #fff;
  border: 1px solid var(--glass-edge);
  background:
    radial-gradient(130% 70% at 50% 0%, rgba(255, 255, 255, .28), transparent 62%),
    linear-gradient(180deg, #5b76ff 0%, #2b50f0 55%, #2140d6 100%);
  box-shadow:
    inset 0 1px 0 var(--glass-hi),
    inset 0 -1px 1px rgba(0, 0, 0, .18),
    0 8px 22px -10px rgba(43, 80, 240, .7);
  text-shadow: 0 1px 1px rgba(0, 0, 0, .15);
}
.btn-primary:hover { filter: brightness(1.07); }
.btn-primary:active { box-shadow: inset 0 2px 6px rgba(0, 0, 0, .25); filter: brightness(.97); }
.btn-ghost { border-color: var(--line-strong); background: transparent; }
.btn-ghost:hover { background: var(--card); }
.btn-danger { background: var(--danger-tint); color: var(--danger); border-color: transparent; }
.btn-whatsapp {
  color: #fff;
  border: 1px solid var(--glass-edge);
  background:
    radial-gradient(130% 70% at 50% 0%, rgba(255, 255, 255, .26), transparent 62%),
    linear-gradient(180deg, #33c46e 0%, #1fa855 55%, #178a45 100%);
  box-shadow:
    inset 0 1px 0 var(--glass-hi),
    inset 0 -1px 1px rgba(0, 0, 0, .18),
    0 8px 22px -10px rgba(31, 168, 85, .75);
  text-shadow: 0 1px 1px rgba(0, 0, 0, .15);
}
.btn-whatsapp:hover { filter: brightness(1.07); }
.btn-whatsapp:active { box-shadow: inset 0 2px 6px rgba(0, 0, 0, .25); }
.btn-block { width: 100%; }
.btn-big { padding: 15px 22px; font-size: 17px; min-height: 54px; }

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid var(--accent);
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, white);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- forms ---------- */
.field { margin-bottom: 16px; }
.field > label { display: block; font-weight: 600; margin-bottom: 6px; }
.field .hint { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.input, .field input[type="text"], .field input[type="tel"], .field input[type="number"],
.field input[type="email"], .field input[type="password"], .field textarea, .field select {
  width: 100%;
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--field-bg);
  padding: 12px 14px;
  min-height: 48px;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--accent);
  background: var(--card);
  outline: none;
  box-shadow: 0 0 0 4px var(--accent-tint);
}
.field.invalid input, .field.invalid textarea { border-color: var(--danger); }
.field .err { display: none; color: var(--danger); font-size: 13.5px; margin-top: 4px; font-weight: 600; }
.field.invalid .err { display: block; }

/* ---------- bits ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .02em;
}
.badge-sale { background: var(--amber-tint); color: var(--amber-deep); }
.badge-out { background: #eeeeea; color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.muted { color: var(--muted); }

.empty {
  text-align: center;
  padding: 56px 20px;
  color: var(--muted);
}
.empty .display { color: var(--ink-soft); font-size: 20px; margin-bottom: 6px; }
.empty .art { font-size: 42px; margin-bottom: 10px; }

.demo-banner {
  background: var(--amber-tint);
  color: var(--amber-deep);
  border-bottom: 1px solid var(--line);
  text-align: center;
  font-size: 13.5px;
  font-weight: 600;
  padding: 7px 12px;
}

/* toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--inverse-bg);
  color: var(--inverse-fg);
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 300;
  max-width: min(92vw, 480px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* language toggle */
.lang-toggle {
  display: inline-flex;
  border: 1.5px solid var(--line-strong);
  border-radius: 999px;
  overflow: hidden;
  background: var(--card);
}
.lang-toggle button {
  border: 0;
  background: transparent;
  padding: 7px 14px;
  font-weight: 700;
  font-size: 14px;
  color: var(--muted);
  min-height: 38px;
}
.lang-toggle button.on { background: var(--inverse-bg); color: var(--inverse-fg); }
.lang-toggle .ur-label { font-family: var(--font-urdu); font-size: 15px; line-height: 1; }

/* modal / sheet scaffolding */
.overlay {
  position: fixed; inset: 0;
  background: var(--overlay-bg);
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
  z-index: 100;
}
.overlay.open { opacity: 1; pointer-events: auto; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* interlocking-links brand mark */
.mark {
  width: 36px; height: 36px; flex: 0 0 auto;
  display: inline-grid; place-items: center;
  background: var(--accent);
  border-radius: 11px;
  color: #fff;
  box-shadow: 0 6px 16px -8px rgba(43,80,240,.8);
}
.mark svg { width: 21px; height: 21px; }

/* ---------- shared components used by BOTH storefront and admin ---------- */
.chip {
  flex: 0 0 auto;
  border: 1.5px solid transparent;
  background: var(--field-bg);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 600;
  min-height: 40px;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
.chip:hover { background: var(--field-hover); }
.chip.on { background: var(--inverse-bg); border-color: var(--inverse-bg); color: var(--inverse-fg); }

.pay-options { display: grid; gap: 10px; }
.pay-option {
  display: flex; align-items: center; gap: 12px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--card);
  padding: 12px 14px;
  cursor: pointer;
}
.pay-option input { width: 20px; height: 20px; accent-color: var(--accent); flex: 0 0 auto; }
.pay-option .t { font-weight: 700; }
.pay-option .s { font-size: 13px; color: var(--muted); }
.pay-option:has(input:checked),
.pay-option.sel { border-color: var(--accent); background: var(--accent-tint); }

.form-err {
  display: none;
  background: var(--danger-tint);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-weight: 600;
  margin-bottom: 12px;
}
.form-err.show { display: block; }

/* theme toggle */
.theme-btn {
  width: 40px; height: 40px; flex: 0 0 auto;
  border-radius: 999px;
  border: 1.5px solid var(--line-strong);
  background: var(--card);
  color: var(--ink-soft);
  display: inline-grid; place-items: center;
  padding: 0;
}
.theme-btn svg { width: 19px; height: 19px; }
.theme-btn .sun { display: none; }
html[data-theme="dark"] .theme-btn .sun { display: block; }
html[data-theme="dark"] .theme-btn .moon { display: none; }
