/* MyStore design system — tokens + base components.
   Framework-free. Every component draws from the tokens below; the brand color
   is injected at runtime from store settings via the --brand custom property,
   so a component never hardcodes a color. Layout uses logical properties
   (margin-inline, inset-*) so RTL mirroring is automatic. */

:root {
  /* Brand (overridable per store: <html style="--brand:#..."> from settings) */
  --brand:        #2E7D32;
  --brand-dark:   #1B5E20;
  --brand-tint:   #E8F5E9;
  --on-brand:     #ffffff;

  /* Neutral scale */
  --gray-0:  #ffffff;
  --gray-50: #f8fafc;
  --gray-100:#f1f5f9;
  --gray-200:#e2e8f0;
  --gray-300:#cbd5e1;
  --gray-400:#94a3b8;
  --gray-500:#64748b;
  --gray-600:#475569;
  --gray-700:#334155;
  --gray-800:#1e293b;
  --gray-900:#0f172a;

  /* Semantic */
  --success: #16a34a;
  --warn:    #d97706;
  --danger:  #dc2626;
  --info:    #2563eb;

  /* Surfaces / text */
  --bg:      var(--gray-50);
  --card:    var(--gray-0);
  --text:    var(--gray-900);
  --text-muted: var(--gray-500);
  --border:  var(--gray-200);

  /* Radius scale */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-pill: 999px;

  /* Spacing scale (4px grid) */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px;

  /* Type scale */
  --fs-xs: 0.75rem; --fs-sm: 0.875rem; --fs-md: 1rem;
  --fs-lg: 1.125rem; --fs-xl: 1.375rem; --fs-2xl: 1.75rem;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.08);
  --shadow-md: 0 4px 12px rgba(15,23,42,.10);
  --shadow-lg: 0 10px 30px rgba(15,23,42,.14);

  --tap: 44px;              /* minimum touch target */
  --font-en: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-ur: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", "Nafees Nastaleeq", serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-en);
  font-size: var(--fs-md);
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
[dir="rtl"] body, body[dir="rtl"] { font-family: var(--font-ur); line-height: 1.9; }

h1,h2,h3 { margin: 0 0 var(--s-3); line-height: 1.25; }
a { color: var(--brand-dark); }
img { max-width: 100%; }

.container { padding: var(--s-4); max-width: 640px; margin-inline: auto; }
.muted { color: var(--text-muted); }
.stack > * + * { margin-top: var(--s-3); }

/* ── Top bar ─────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--brand); color: var(--on-brand);
  box-shadow: var(--shadow-sm);
}
.topbar h1 { font-size: var(--fs-lg); margin: 0; flex: 1; }
.topbar .icon-btn { color: var(--on-brand); }
.icon-btn {
  min-width: var(--tap); min-height: var(--tap);
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; font-size: 1.25rem; cursor: pointer;
  color: inherit; border-radius: var(--r-sm);
}

/* ── Bottom navigation ───────────────────────────────────────────────── */
.bottom-nav {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  background: var(--card); border-top: 1px solid var(--border);
  padding: var(--s-1) 0 max(var(--s-1), env(safe-area-inset-bottom));
}
.bottom-nav a {
  flex: 1; text-align: center; text-decoration: none;
  color: var(--text-muted); font-size: var(--fs-xs);
  padding: var(--s-1); min-height: var(--tap);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.bottom-nav a.active { color: var(--brand); font-weight: 600; }
.bottom-nav .ic { font-size: 1.25rem; }
.has-bottom-nav { padding-bottom: 72px; }

/* ── Card ────────────────────────────────────────────────────────────── */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
  padding: var(--s-4);
}
.card + .card { margin-top: var(--s-3); }

/* ── Product / list row ──────────────────────────────────────────────── */
.list-row {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) 0; border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: 0; }
.list-row .thumb {
  width: 52px; height: 52px; border-radius: var(--r-md);
  background: var(--brand-tint); display: grid; place-items: center; font-size: 1.5rem; flex: none;
}
.list-row .grow { flex: 1; min-width: 0; }
.list-row .title { font-weight: 600; }
.list-row .sub { color: var(--text-muted); font-size: var(--fs-sm); }

/* ── Stepper ─────────────────────────────────────────────────────────── */
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: var(--r-pill); overflow: hidden; }
.stepper button {
  min-width: var(--tap); min-height: var(--tap); border: 0; background: var(--gray-100);
  font-size: 1.25rem; cursor: pointer; color: var(--brand-dark);
}
.stepper .qty { min-width: 44px; text-align: center; font-weight: 600; }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--tap); padding: 0 var(--s-5);
  border: 1px solid transparent; border-radius: var(--r-md);
  font-size: var(--fs-md); font-weight: 600; cursor: pointer; text-decoration: none;
  background: var(--brand); color: var(--on-brand); width: auto;
}
.btn:active { background: var(--brand-dark); }
.btn.block { width: 100%; }
.btn.secondary { background: var(--gray-100); color: var(--text); border-color: var(--border); }
.btn.danger { background: var(--danger); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sticky { position: sticky; bottom: var(--s-4); box-shadow: var(--shadow-lg); }

/* ── Badges / chips ──────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px var(--s-2); border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600; }
.badge.brand { background: var(--brand-tint); color: var(--brand-dark); }
.badge.success { background: #dcfce7; color: #166534; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.danger { background: #fee2e2; color: #991b1b; }
.badge.muted { background: var(--gray-100); color: var(--gray-600); }
.price { font-weight: 700; }
.price-was { color: var(--text-muted); text-decoration: line-through; font-weight: 400; margin-inline-end: var(--s-2); }

/* ── Form fields ─────────────────────────────────────────────────────── */
.field { margin-bottom: var(--s-4); }
.field label { display: block; font-size: var(--fs-sm); font-weight: 600; margin-bottom: var(--s-1); }
.field input, .field select, .field textarea {
  width: 100%; min-height: var(--tap); padding: var(--s-2) var(--s-3);
  border: 1px solid var(--gray-300); border-radius: var(--r-md);
  font-size: var(--fs-md); font-family: inherit; background: var(--card); color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint);
}
.field .hint { font-size: var(--fs-sm); color: var(--text-muted); margin-top: var(--s-1); }
.field.rtl input, .field.rtl textarea { direction: rtl; font-family: var(--font-ur); }
.field-row { display: flex; gap: var(--s-3); }
.field-row .field { flex: 1; }

/* ── Search bar ──────────────────────────────────────────────────────── */
.search-bar {
  display: flex; align-items: center; gap: var(--s-2);
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-pill); padding: 4px var(--s-3); margin-bottom: var(--s-4);
}
.search-bar .search-ic { opacity: .6; }
.search-bar input { flex: 1; border: 0; outline: none; background: transparent; min-height: var(--tap); font-size: var(--fs-md); color: var(--text); font-family: inherit; }
.search-bar .search-go { border: 0; background: var(--brand); color: var(--on-brand); border-radius: var(--r-pill); min-height: 36px; padding: 0 var(--s-4); font-weight: 600; }

/* ── Sheet modal ─────────────────────────────────────────────────────── */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 40; display: grid; align-items: end; }
.sheet {
  background: var(--card); border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: var(--s-5); box-shadow: var(--shadow-lg); width: 100%; max-width: 640px; margin-inline: auto;
}
.sheet .grab { width: 40px; height: 4px; background: var(--gray-300); border-radius: var(--r-pill); margin: 0 auto var(--s-4); }

/* ── Toast ───────────────────────────────────────────────────────────── */
.toast-host { position: fixed; inset-inline: 0; bottom: 84px; z-index: 60; display: flex; flex-direction: column; align-items: center; gap: var(--s-2); pointer-events: none; }
.toast { background: var(--gray-900); color: #fff; padding: var(--s-3) var(--s-4); border-radius: var(--r-pill); box-shadow: var(--shadow-md); font-size: var(--fs-sm); }
.toast.success { background: var(--success); }
.toast.danger { background: var(--danger); }

/* ── Skeleton ────────────────────────────────────────────────────────── */
.skeleton { background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 37%, var(--gray-100) 63%); background-size: 400% 100%; animation: sk 1.4s ease infinite; border-radius: var(--r-md); }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.skeleton.line { height: 12px; margin: var(--s-2) 0; }
.skeleton.thumb { width: 52px; height: 52px; }

/* ── Empty state ─────────────────────────────────────────────────────── */
.empty { text-align: center; padding: var(--s-10) var(--s-4); color: var(--text-muted); }
.empty .big { font-size: 3rem; margin-bottom: var(--s-3); }
.empty p { margin: 0 0 var(--s-4); }

/* ── Status timeline ─────────────────────────────────────────────────── */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding-inline-start: var(--s-6); padding-bottom: var(--s-5); }
.timeline li::before { content: ""; position: absolute; inset-inline-start: 6px; top: 4px; bottom: -4px; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ""; position: absolute; inset-inline-start: 0; top: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--gray-300); border: 2px solid var(--card); }
.timeline li.done::after { background: var(--success); }
.timeline li.current::after { background: var(--brand); box-shadow: 0 0 0 4px var(--brand-tint); }
.timeline .when { font-size: var(--fs-xs); color: var(--text-muted); }

/* ── Utility ─────────────────────────────────────────────────────────── */
.row { display: flex; align-items: center; gap: var(--s-3); }
.between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--gray-900); --card: var(--gray-800); --text: var(--gray-50);
    --text-muted: var(--gray-400); --border: var(--gray-700);
    --gray-100: #263043; --gray-300: #3b4a63;
  }
}
