/* ==========================================================================
   Telangar — design tokens  (panel/static/css/tokens.css)
   Base: 21st.dev "Northern Lights" naming (shadcn), values revised for
   WCAG AA. No build step: plain CSS custom properties.

   Theme   : data-theme="light|dark" on <html>, rendered by the server from
             the cookie. No attribute => follows prefers-color-scheme.
   Surface : data-surface="elevated" (white cards + soft shadow, MUI Minimal)
             | "tonal" (tinted panels, no shadow, light headings, SaasAble)
   Density : data-density="compact" (admin) | "comfortable" (customer panel)
   RTL     : logical properties only (inline-start / inline-end).
   ========================================================================== */

/* ---------- Light (default) ---------- */
:root,
[data-theme="light"] {
  color-scheme: light;

  --background: #edf5f2;
  --foreground: #0c1f1a;
  --card: rgba(255,255,255,.88);
  --card-foreground: #0c1f1a;
  --popover: rgba(255,255,255,.88);
  --popover-foreground: #0c1f1a;
  --surface-2: rgba(255,255,255,.55);          /* inset areas, table header, hover   */
  --surface-tonal: #eef2f6;      /* SaasAble cool blue-grey panel       */

  --primary: #087a54;            /* brand green: fills, ring, active bar */
  --primary-foreground: #ffffff; /* dark text on green = 5.66:1 (AA)    */
  --primary-strong: #087a54;     /* green as TEXT/LINK = 5.07:1 on bg   */
  --primary-soft: rgba(8,122,84,.13);       /* active nav item background          */

  --secondary: #1f5fc4;          /* charts & emphasis only — never under white text */
  --secondary-strong: #1f5fc4;   /* blue as text = 5.9:1                */
  --secondary-foreground: #ffffff;
  --accent: #086e76;             /* charts only                         */
  --accent-foreground: #1f252b;

  --muted: rgba(255,255,255,.55);              /* cool grey — replaces beige #ddd9c4  */
  --muted-foreground: #3c5249;   /* 5.5:1 on bg                         */

  --destructive: #b3261e;        /* white text on it = 4.83:1           */
  --destructive-foreground: #ffffff;

  --border: rgba(12,31,26,.11);             /* decorative dividers only            */
  --input: rgba(12,31,26,.45);              /* form field borders = 3.4:1          */
  --ring: #087a54;

  /* status: soft background + strong text, always with a dot/icon */
  --success: #087a54;  --success-soft: rgba(8,122,84,.13); --success-fg: #087a54;
  --warning: #e0a100;  --warning-soft: rgba(200,120,0,.16); --warning-fg: #8a4a00;
  --danger:  #b3261e;  --danger-soft:  rgba(179,38,30,.12); --danger-fg:  #b3261e;
  --info:    #1f5fc4;  --info-soft:    rgba(31,111,214,.13); --info-fg:    #1f5fc4;
  --neutral: #8a939d;  --neutral-soft: #eef1f4; --neutral-fg: #4b5563;

  --chart-1: #34a85a; --chart-2: #6495ed; --chart-3: #66d9ef;
  --chart-4: #4682b4; --chart-5: #1a9641;

  --sidebar: rgba(255,255,255,.88);
  --sidebar-foreground: #0c1f1a;
  --sidebar-primary: #087a54;
  --sidebar-primary-foreground: #ffffff;
  --sidebar-accent: rgba(8,122,84,.13);
  --sidebar-accent-foreground: #087a54;
  --sidebar-border: rgba(12,31,26,.11);
  --sidebar-ring: #087a54;

  --shadow-card: var(--glass-shadow);
  --shadow-hover: 0 0 2px 0 rgb(20 28 40 / 0.10), 0 20px 40px -6px rgb(20 28 40 / 0.10);
  --shadow-pop: 0 0 2px 0 rgb(20 28 40 / 0.12), 0 24px 48px -8px rgb(20 28 40 / 0.16);

  /* T-123 Shafaq: glass, aurora, admin ink */
  --admin-ink: #0f2a47;
  --admin-ink-foreground: #ffffff;
  --impersonate: #4b2a99;              /* §11.2: only meaning = on the customer's behalf */
  --impersonate-foreground: #ffffff;
  --impersonate-soft: rgba(75,42,153,.12);
  --glass-fill: linear-gradient(150deg, rgba(255,255,255,.68), rgba(255,255,255,.24) 55%, rgba(255,255,255,.44));
  --glass-border: rgba(255,255,255,.85);
  --glass-shadow: inset 0 1px 0 rgba(255,255,255,.95), 0 30px 60px -34px rgba(8,60,45,.42), 0 2px 6px -2px rgba(8,60,45,.08);
  --glass-sheen: rgba(255,255,255,.55);
  --aurora-opacity: 0.15;
}

/* ---------- Dark ---------- */
[data-theme="dark"] {
  color-scheme: dark;

  --background: #06120f;
  --foreground: #e9f5f0;
  --card: rgba(22,36,32,.92);
  --card-foreground: #e9f5f0;
  --popover: rgba(22,36,32,.92);
  --popover-foreground: #e9f5f0;
  --surface-2: rgba(255,255,255,.10);
  --surface-tonal: #20252c;

  --primary: #34e0a1;
  --primary-foreground: #04130e;
  --primary-strong: #34e0a1;
  --primary-soft: rgba(52,224,161,.16);

  --secondary: #6fb4ff;
  --secondary-strong: #6fb4ff;
  --secondary-foreground: #04121f;
  --accent: #3fe0e6;
  --accent-foreground: #0f1a1f;

  --muted: rgba(255,255,255,.10);
  --muted-foreground: #9db5ac;

  --destructive: #ff8a7a;
  --destructive-foreground: #2a0a05;

  --border: rgba(255,255,255,.14);
  --input: rgba(255,255,255,.45);
  --ring: #34e0a1;

  --success: #34e0a1;  --success-soft: rgba(52,224,161,.16); --success-fg: #34e0a1;
  --warning: #e0a100;  --warning-soft: rgba(255,180,84,.16); --warning-fg: #ffb454;
  --danger:  #ff8a7a;  --danger-soft:  rgba(255,138,122,.16); --danger-fg:  #ff8a7a;
  --info:    #6fb4ff;  --info-soft:    rgba(111,180,255,.18); --info-fg:    #6fb4ff;
  --neutral: #6b7480;  --neutral-soft: #2a2f36; --neutral-fg: #b8c0ca;

  --chart-1: #34a85a; --chart-2: #4682b4; --chart-3: #6495ed;
  --chart-4: #66d9ef; --chart-5: #1a9641;

  --sidebar: rgba(22,36,32,.92);
  --sidebar-foreground: #e9f5f0;
  --sidebar-primary: #34e0a1;
  --sidebar-primary-foreground: #04130e;
  --sidebar-accent: rgba(52,224,161,.16);
  --sidebar-accent-foreground: #34e0a1;
  --sidebar-border: rgba(255,255,255,.14);
  --sidebar-ring: #34e0a1;

  /* T-123: dark depth comes from the glass shadow too */
  --shadow-card: var(--glass-shadow);
  --shadow-hover: 0 0 0 1px #343a43;
  --shadow-pop: 0 0 0 1px #343a43, 0 24px 48px -8px rgb(0 0 0 / 0.5);

  /* T-123 Shafaq: glass, aurora, admin ink */
  --admin-ink: #6fb4ff;
  --admin-ink-foreground: #04121f;
  --impersonate: #b79cff;              /* §11.2: only meaning = on the customer's behalf */
  --impersonate-foreground: #160b33;
  --impersonate-soft: rgba(183,156,255,.18);
  --glass-fill: linear-gradient(150deg, rgba(255,255,255,.14), rgba(255,255,255,.035) 55%, rgba(255,255,255,.08));
  --glass-border: rgba(255,255,255,.17);
  --glass-shadow: inset 0 1px 0 rgba(255,255,255,.26), 0 30px 60px -30px rgba(0,0,0,.8);
  --glass-sheen: rgba(255,255,255,.12);
  --aurora-opacity: 0.6;
}

/* No cookie yet: follow the OS. (Duplicate of the dark block on purpose —
   no build step to share it.) Only the lines that differ are needed if you
   prefer; kept in full for grep-ability in T-041. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --background: #06120f; --foreground: #e9f5f0;
    --card: rgba(22,36,32,.92); --card-foreground: #e9f5f0;
    --popover: rgba(22,36,32,.92); --popover-foreground: #e9f5f0;
    --surface-2: rgba(255,255,255,.10); --surface-tonal: #20252c;
    --primary-strong: #34e0a1; --primary-soft: rgba(52,224,161,.16);
    --secondary-strong: #6fb4ff; --secondary-foreground: #04121f;
    --muted: rgba(255,255,255,.10); --muted-foreground: #9db5ac;
    --destructive: #ff8a7a;
    --border: rgba(255,255,255,.14); --input: rgba(255,255,255,.45);
    --success-soft: rgba(52,224,161,.16); --success-fg: #34e0a1;
    --warning-soft: rgba(255,180,84,.16); --warning-fg: #ffb454;
    --danger: #ff8a7a; --danger-soft: rgba(255,138,122,.16); --danger-fg: #ff8a7a;
    --info-soft: rgba(111,180,255,.18); --info-fg: #6fb4ff;
    --neutral: #6b7480; --neutral-soft: #2a2f36; --neutral-fg: #b8c0ca;
    --chart-2: #4682b4; --chart-3: #6495ed; --chart-4: #66d9ef;
    --sidebar: rgba(22,36,32,.92); --sidebar-foreground: #e9f5f0;
    --sidebar-accent: rgba(52,224,161,.16); --sidebar-accent-foreground: #34e0a1;
    --sidebar-border: rgba(255,255,255,.14);
    --shadow-card: var(--glass-shadow);
    --shadow-hover: 0 0 0 1px #343a43;
    --shadow-pop: 0 0 0 1px #343a43, 0 24px 48px -8px rgb(0 0 0 / 0.5);

    /* T-123 Shafaq */
    --primary: #34e0a1;
    --ring: #34e0a1;
    --success: #34e0a1;
    --sidebar-primary: #34e0a1;
    --sidebar-ring: #34e0a1;
    --primary-foreground: #04130e;
    --sidebar-primary-foreground: #04130e;
    --secondary: #6fb4ff;
    --info: #6fb4ff;
    --accent: #3fe0e6;
    --destructive-foreground: #2a0a05;
    --admin-ink: #6fb4ff;
    --admin-ink-foreground: #04121f;
    --impersonate: #b79cff; --impersonate-foreground: #160b33; --impersonate-soft: rgba(183,156,255,.18);
    --glass-fill: linear-gradient(150deg, rgba(255,255,255,.14), rgba(255,255,255,.035) 55%, rgba(255,255,255,.08));
    --glass-border: rgba(255,255,255,.17);
    --glass-shadow: inset 0 1px 0 rgba(255,255,255,.26), 0 30px 60px -30px rgba(0,0,0,.8);
    --glass-sheen: rgba(255,255,255,.12);
    --aurora-opacity: 0.6;
  }
}

/* Direction multiplier for translateX (§6): mirrors when a LTR language arrives. */
:root { --dir: 1; }
[dir="rtl"] { --dir: -1; }

/* ---------- Type (Yekan Bakh VF, one file, weights 1–1000) ----------
   @font-face lives in fonts.css (relative URL, no inline <style>). */
:root {
  --font-sans: "Yekan Bakh", "Vazirmatn", Tahoma, system-ui, sans-serif;

  --text-xs: 12px;   --lh-xs: 18px;
  --text-sm: 13px;   --lh-sm: 20px;
  --text-md: 14px;   --lh-md: 22px;
  --text-lg: 16px;   --lh-lg: 26px;
  --text-xl: 18px;   --lh-xl: 28px;
  --text-2xl: 22px;  --lh-2xl: 32px;
  --text-3xl: 28px;  --lh-3xl: 40px;
  --text-4xl: 36px;  --lh-4xl: 50px;
  --text-5xl: 48px;  --lh-5xl: 64px;

  --weight-light: 300;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 620;
  --weight-bold: 720;

  /* Headings follow the surface: Minimal = semibold, SaasAble = light */
  --weight-heading: var(--weight-semibold);
  --weight-display: var(--weight-bold);

  /* ---------- Space (4px grid) ---------- */
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px;
  --space-12: 48px; --space-16: 64px;

  /* ---------- Radius ---------- */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-pill: 999px;
  --radius: var(--radius-md);          /* shadcn alias */
  --radius-card: 28px;                 /* T-123 Shafaq */
  --radius-button: var(--radius-pill);

  /* ---------- Motion (CSS transitions only) ---------- */
  --dur-fast: 120ms;
  --dur: 200ms;
  --dur-slow: 320ms;
  --dur-flash: 1200ms;                 /* a number that actually changed */
  --dur-exit: 140ms;                   /* exits ~70% of enter */
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);   /* entering */
  --ease-in: cubic-bezier(0.4, 0, 1, 1);       /* exiting  */
  /* T-123 Shafaq: soft, slow, never springy */
  --ease-soft: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-soft: 450ms;                   /* button hover, switches */
  --dur-lift: 600ms;                   /* card lift, drawer      */
  --dur-enter: 950ms;                  /* card entrance          */

  /* Aurora blobs (shell.css, bare.css); strength is --aurora-opacity per theme */
  --aurora-1: #1fd48f;
  --aurora-2: #2f7bff;
  --aurora-3: #22d3ee;

  /* ---------- Icons (one outline set, one stroke) ---------- */
  --icon-sm: 14px;
  --icon-md: 18px;
  --icon-lg: 24px;
  --icon-stroke: 1.75;

  /* ---------- Layers ---------- */
  --z-base: 0;
  --z-sticky: 10;      /* table header, top bar  */
  --z-sidebar: 20;
  --z-alertbar: 30;
  --z-popover: 40;
  --z-drawer: 50;      /* mobile nav drawer      */
  --z-modal: 100;
  --z-toast: 1000;

  /* ---------- Breakpoints (container queries on .tl) ----------
     sm 600 · md 900 · lg 1200 — CSS vars can't be used in @container,
     so these are documentation; components.css hard-codes the same values. */
}

[data-surface="tonal"] {
  --weight-heading: var(--weight-light);
  --weight-display: var(--weight-light);
  --radius-card: var(--radius-xl);
  --radius-button: var(--radius-pill);
  --shadow-card: none;
  --shadow-hover: none;
}

/* ---------- Density profiles (§19.3) ---------- */
:root,
[data-density="compact"] {           /* admin dashboard */
  --control-h: 32px;
  --row-h: 44px;
  --cell-px: 12px;
  --card-pad: 20px;
  --section-gap: 20px;
  --text-body: var(--text-md);
  --text-table: var(--text-sm);
  --numerals: latin;                  /* informational; see §19.5 */
}
[data-density="comfortable"] {       /* customer panel */
  --control-h: 44px;
  --row-h: 56px;
  --cell-px: 16px;
  --card-pad: 28px;
  --section-gap: 28px;
  --text-body: var(--text-lg);
  --text-table: var(--text-md);
  --numerals: persian;
}

/* Touch devices: compact density keeps its spacing, but every control
   grows to a 44px hit area (tablet/phone are the design baseline, §19.2). */
@media (pointer: coarse) {
  /* :not(...) so this never shrinks the comfortable profile's 56px rows */
  :root:not([data-density="comfortable"]) { --control-h: 44px; --row-h: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  :root { --dur-fast: 0ms; --dur: 0ms; --dur-slow: 0ms; --dur-flash: 0ms; --dur-exit: 0ms;
          --dur-soft: 0ms; --dur-lift: 0ms; --dur-enter: 0ms; }
}
