/* =============================================================
   CoreIQ POS — Design Tokens
   Light + dark, both first-class. Every token resolves in both.
   ============================================================= */

/* -------------------------------------------------------------
   Söhne — Buch 400, Kräftig 500, Halbfett 600.
   Italic Buch only (transactional UI avoids italics by policy).
   ------------------------------------------------------------- */
@font-face {
  font-family: "Söhne";
  src: url("fonts/Sohne-Buch.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Söhne";
  src: url("fonts/Sohne-BuchKursiv.otf") format("opentype");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Söhne";
  src: url("fonts/Sohne-Kraftig.otf") format("opentype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Söhne";
  src: url("fonts/Sohne-Halbfett.otf") format("opentype");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  /* -----------------------------------------------------------
     Primitive palette — raw hues. Never reference directly in
     components; always go through the semantic role tokens.
     ----------------------------------------------------------- */

  /* Navy / slate — structural spine. Shared with healthbookings. */
  --navy-50:  #f1f5fa;
  --navy-100: #e2ebf3;
  --navy-200: #c4d6e8;
  --navy-300: #99b9d8;
  --navy-400: #6e9bc7;
  --navy-500: #4a7eb0;
  --navy-600: #356694;
  --navy-700: #25527c;
  --navy-800: #1b3a5b;
  --navy-900: #102a43;  /* anchor */
  --navy-950: #081828;

  /* Teal — POS accent. Front-of-shop only. */
  --teal-50:  #ecfaf8;
  --teal-100: #d2f3ee;
  --teal-200: #a7e6dd;
  --teal-300: #74d3c7;
  --teal-400: #3fb9ac;
  --teal-500: #1ea596;
  --teal-600: #128a7e;
  --teal-700: #0d9488;  /* anchor */
  --teal-800: #0b6f66;
  --teal-900: #0a554f;

  /* Warm neutrals — humanises the clinical base. */
  --stone-50:  #fafaf9;
  --stone-100: #f5f5f4;
  --stone-200: #e7e5e4;
  --stone-300: #d6d3d1;
  --stone-400: #a8a29e;
  --stone-500: #78716c;
  --stone-600: #57534e;
  --stone-700: #44403c;
  --stone-800: #292524;
  --stone-900: #1c1917;
  --stone-950: #0c0a09;

  /* Semantic primitives — LOCKED meanings.
     emerald = paid / dispensed only
     rose    = void / refund / error
     amber   = hold / verify
     violet  = S8 / scheduling                        */
  --emerald-50:  #ecfdf5;
  --emerald-100: #d1fae5;
  --emerald-200: #a7f3d0;
  --emerald-500: #10b981;
  --emerald-600: #059669;
  --emerald-700: #047857;
  --emerald-800: #065f46;

  --rose-50:  #fef2f2;
  --rose-100: #fee2e2;
  --rose-200: #fecaca;
  --rose-500: #ef4444;
  --rose-600: #dc2626;
  --rose-700: #b91c1c;
  --rose-800: #991b1b;

  --amber-50:  #fffbeb;
  --amber-100: #fef3c7;
  --amber-200: #fde68a;
  --amber-500: #f59e0b;
  --amber-600: #d97706;
  --amber-700: #b45309;
  --amber-800: #92400e;

  --violet-50:  #f5f3ff;
  --violet-100: #ede9fe;
  --violet-200: #ddd6fe;
  --violet-500: #8b5cf6;
  --violet-600: #7c3aed;
  --violet-700: #6d28d9;
  --violet-800: #5b21b6;

  /* -----------------------------------------------------------
     Type system
     ----------------------------------------------------------- */
  --font-sans: "Söhne", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --fw-body:   400;   /* Buch */
  --fw-label:  500;   /* Kräftig */
  --fw-title:  600;   /* Halbfett */

  --fs-11: 11px;
  --fs-12: 12px;
  --fs-13: 13px;
  --fs-14: 14px;
  --fs-15: 15px;
  --fs-16: 16px;
  --fs-18: 18px;
  --fs-20: 20px;
  --fs-24: 24px;
  --fs-30: 30px;
  --fs-36: 36px;
  --fs-48: 48px;
  --fs-60: 60px;

  --lh-tight:  1.15;
  --lh-snug:   1.3;
  --lh-normal: 1.5;

  --tracking-tight:  -0.02em;
  --tracking-snug:   -0.01em;
  --tracking-normal: 0;
  --tracking-wide:   0.02em;
  --tracking-caps:   0.06em;

  /* -----------------------------------------------------------
     Spacing — 4px base
     ----------------------------------------------------------- */
  --space-0:  0;
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-7:  28px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-14: 56px;
  --space-16: 64px;
  --space-20: 80px;
  --space-24: 96px;

  /* -----------------------------------------------------------
     Radii — soft corners, never pill except status & avatars
     ----------------------------------------------------------- */
  --radius-xs:  4px;
  --radius-sm:  6px;
  --radius-md:  8px;
  --radius-lg:  12px;
  --radius-xl:  16px;
  --radius-2xl: 20px;
  --radius-full: 999px;

  /* -----------------------------------------------------------
     Touch sizing — 48px floor (never sub-44)
     ----------------------------------------------------------- */
  --touch-min: 44px;
  --touch:     48px;
  --touch-lg:  56px;

  /* -----------------------------------------------------------
     Motion
     ----------------------------------------------------------- */
  --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-fast:   120ms;
  --dur-base:   180ms;
  --dur-slow:   280ms;

  /* -----------------------------------------------------------
     Z-index ladder
     ----------------------------------------------------------- */
  --z-sticky:  10;
  --z-drawer:  40;
  --z-overlay: 50;
  --z-modal:   60;
  --z-toast:   70;
  --z-tooltip: 80;
}

/* =============================================================
   LIGHT MODE — bright retail floor
   ============================================================= */
:root,
[data-theme="light"] {
  /* Surfaces */
  --bg:               #ffffff;
  --bg-subtle:        var(--stone-50);
  --bg-muted:         var(--stone-100);
  --surface:          #ffffff;
  --surface-raised:   #ffffff;
  --surface-sunken:   var(--stone-50);

  /* Structure (sidebar/topbar — the "navy spine") */
  --structure-bg:     var(--navy-900);
  --structure-bg-2:   var(--navy-800);
  --structure-fg:     var(--navy-50);
  --structure-fg-muted: var(--navy-300);
  --structure-border: var(--navy-800);

  /* Borders & dividers */
  --border:           var(--stone-200);
  --border-strong:    var(--stone-300);
  --border-subtle:    var(--stone-100);
  --divider:          var(--stone-200);

  /* Text */
  --text:             var(--navy-900);
  --text-muted:       var(--stone-600);
  --text-subtle:      var(--stone-500);
  --text-inverse:     #ffffff;
  --text-on-brand:    #ffffff;
  --text-link:        var(--teal-700);

  /* Brand — POS accent */
  --brand:            var(--teal-700);
  --brand-hover:      var(--teal-800);
  --brand-active:     var(--teal-900);
  --brand-fg:         #ffffff;
  --brand-bg:         var(--teal-50);
  --brand-bg-strong:  var(--teal-100);
  --brand-border:     var(--teal-200);
  --focus-ring:       var(--teal-500);

  /* Semantic — paid / dispensed */
  --paid:             var(--emerald-700);
  --paid-fg:          #ffffff;
  --paid-bg:          var(--emerald-50);
  --paid-border:      var(--emerald-200);
  --paid-text:        var(--emerald-800);

  /* Semantic — void / refund / error */
  --void:             var(--rose-700);
  --void-fg:          #ffffff;
  --void-bg:          var(--rose-50);
  --void-border:      var(--rose-200);
  --void-text:        var(--rose-700);

  /* Semantic — hold / verify */
  --hold:             var(--amber-700);
  --hold-fg:          #ffffff;
  --hold-bg:          var(--amber-50);
  --hold-border:      var(--amber-200);
  --hold-text:        var(--amber-800);

  /* Semantic — S8 / scheduling */
  --sched:            var(--violet-700);
  --sched-fg:         #ffffff;
  --sched-bg:         var(--violet-50);
  --sched-border:     var(--violet-200);
  --sched-text:       var(--violet-800);

  /* Shadows — restrained, no decorative depth */
  --shadow-xs: 0 1px 1px rgba(16, 42, 67, 0.04);
  --shadow-sm: 0 1px 2px rgba(16, 42, 67, 0.06), 0 1px 1px rgba(16, 42, 67, 0.04);
  --shadow-md: 0 2px 4px rgba(16, 42, 67, 0.06), 0 4px 8px rgba(16, 42, 67, 0.04);
  --shadow-lg: 0 4px 8px rgba(16, 42, 67, 0.06), 0 12px 24px rgba(16, 42, 67, 0.06);
  --shadow-xl: 0 8px 16px rgba(16, 42, 67, 0.08), 0 24px 48px rgba(16, 42, 67, 0.10);

  /* Focus ring */
  --ring: 0 0 0 3px color-mix(in srgb, var(--focus-ring) 35%, transparent);

  color-scheme: light;
}

/* =============================================================
   DARK MODE — evening dispensary, glare reduction
   ============================================================= */
[data-theme="dark"] {
  /* Surfaces — deep, warm-leaning navy */
  --bg:               #0a1624;
  --bg-subtle:        #0f2034;
  --bg-muted:         #142841;
  --surface:          #122538;
  --surface-raised:   #16304a;
  --surface-sunken:   #0a1624;

  /* Structure */
  --structure-bg:     #061321;
  --structure-bg-2:   #0a1c30;
  --structure-fg:     var(--navy-100);
  --structure-fg-muted: var(--navy-400);
  --structure-border: #0e2438;

  /* Borders */
  --border:           #1f3a55;
  --border-strong:    #2a4a6a;
  --border-subtle:    #173049;
  --divider:          #1f3a55;

  /* Text */
  --text:             #e7eef6;
  --text-muted:       #94a8c0;
  --text-subtle:      #6f8298;
  --text-inverse:     var(--navy-900);
  --text-on-brand:    #ffffff;
  --text-link:        var(--teal-400);

  /* Brand */
  --brand:            var(--teal-500);
  --brand-hover:      var(--teal-400);
  --brand-active:     var(--teal-300);
  --brand-fg:         var(--navy-950);
  --brand-bg:         rgba(45, 193, 180, 0.10);
  --brand-bg-strong:  rgba(45, 193, 180, 0.18);
  --brand-border:     rgba(45, 193, 180, 0.30);
  --focus-ring:       var(--teal-400);

  /* Semantic — paid */
  --paid:             var(--emerald-500);
  --paid-fg:          var(--navy-950);
  --paid-bg:          rgba(16, 185, 129, 0.10);
  --paid-border:      rgba(16, 185, 129, 0.30);
  --paid-text:        var(--emerald-200);

  /* Semantic — void */
  --void:             var(--rose-500);
  --void-fg:          #ffffff;
  --void-bg:          rgba(239, 68, 68, 0.10);
  --void-border:      rgba(239, 68, 68, 0.30);
  --void-text:        #fca5a5;

  /* Semantic — hold */
  --hold:             var(--amber-500);
  --hold-fg:          var(--navy-950);
  --hold-bg:          rgba(245, 158, 11, 0.10);
  --hold-border:      rgba(245, 158, 11, 0.30);
  --hold-text:        var(--amber-200);

  /* Semantic — scheduling */
  --sched:            var(--violet-500);
  --sched-fg:         #ffffff;
  --sched-bg:         rgba(139, 92, 246, 0.12);
  --sched-border:     rgba(139, 92, 246, 0.32);
  --sched-text:       var(--violet-200);

  /* Shadows — softer, just for layering */
  --shadow-xs: 0 1px 1px rgba(0, 0, 0, 0.25);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.30), 0 1px 1px rgba(0, 0, 0, 0.20);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.30), 0 4px 8px rgba(0, 0, 0, 0.20);
  --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.30), 0 12px 24px rgba(0, 0, 0, 0.30);
  --shadow-xl: 0 8px 16px rgba(0, 0, 0, 0.35), 0 24px 48px rgba(0, 0, 0, 0.40);

  --ring: 0 0 0 3px color-mix(in srgb, var(--focus-ring) 30%, transparent);

  color-scheme: dark;
}

/* =============================================================
   Universal base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-weight: var(--fw-body);
  font-size: var(--fs-15);
  line-height: var(--lh-normal);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "cv01";
  transition: background-color var(--dur-base) var(--ease-out),
              color var(--dur-base) var(--ease-out);
}

/* Tabular numerals everywhere prices, quantities, totals appear.
   Stylistic sets ss01/cv01 are kept so the type voice doesn't change. */
.tabular,
.price, .qty, .total, .num,
[data-numeric],
input[type="number"],
table td.num, table th.num {
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "ss01", "cv01", "tnum", "lnum";
}

/* Selection */
::selection { background: var(--brand-bg-strong); color: var(--text); }

/* Focus visible */
:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--radius-sm);
}

/* Form controls don't inherit the page font by default — make every input,
   select, textarea and button use Söhne so nothing falls back to the browser
   font. (.input sets `font: inherit` too; this also catches raw + ad-hoc
   controls.) */
input, select, textarea, button { font-family: inherit; }
