/* ==========================================================================
   tokens.css - design system tokens (single source of truth)
   Light palette on :root. Dark palette overrides under
   @media (prefers-color-scheme: dark) and [data-theme="dark"].
   Explicit [data-theme="light"] wins back for the manual toggle.
   ========================================================================== */

:root {
  /* ---- Brand palette (peekPOS colour template) ---- */
  --paper: #F1EBE1;      /* Warm Paper: background */
  --ink: #221F1C;        /* Warm Ink: text, logo, dark UI */
  --terracotta: #C64F2C; /* Terracotta: accent, buttons, the O */
  --taupe: #7A6F64;      /* Taupe: secondary text, the S */

  /* ---- Brand scale (built around Terracotta at 600) ---- */
  --brand-50:  #FBF0EA;
  --brand-100: #F6DFD4;
  --brand-200: #EDBFAB;
  --brand-300: #E19A7F;
  --brand-400: #D47555;
  --brand-500: #CC5F3B;
  --brand-600: #C64F2C;
  --brand-700: #A63F20;
  --brand-800: #84321A;
  --brand-900: #5F2413;

  /* ---- Neutral scale (warm, anchored on Paper, Taupe and Ink) ---- */
  --gray-0:   #FDFBF7;
  --gray-25:  #FAF6F0;
  --gray-50:  #F6F1E9;
  --gray-100: #F1EBE1;
  --gray-150: #E9E2D6;
  --gray-200: #DFD6C8;
  --gray-300: #CBC0B0;
  --gray-400: #A69B8D;
  --gray-500: #7A6F64;
  --gray-600: #5F564D;
  --gray-700: #494239;
  --gray-800: #33302A;
  --gray-900: #221F1C;
  --gray-950: #181613;

  /* ---- Status hues (muted to sit beside Terracotta) ---- */
  --success-50:  #EAF1E6;
  --success-100: #D6E4CF;
  --success-500: #5B8A5A;
  --success-600: #44744B;
  --success-700: #355C3B;

  --warning-50:  #F8EFD9;
  --warning-100: #F1E0B8;
  --warning-500: #C48A1E;
  --warning-600: #A67214;
  --warning-700: #7F5710;

  --danger-50:  #F8E6E3;
  --danger-100: #F0CDC8;
  --danger-500: #B5382F;
  --danger-600: #9E2B25;
  --danger-700: #7F211C;

  --info-50:  #E7EEF0;
  --info-100: #CFDEE2;
  --info-500: #4E7F8C;
  --info-600: #3D6773;
  --info-700: #2F515B;

  /* ---- Semantic surface / text (LIGHT) ---- */
  --bg-body:        var(--paper);
  --bg-surface:     var(--gray-0);
  --bg-surface-2:   var(--gray-25);
  --bg-surface-3:   var(--gray-50);
  --bg-inset:       var(--gray-50);
  --bg-hover:       #F3EDE3;
  --bg-active:      var(--gray-150);
  --bg-sidebar:     #E9E2D6;
  --bg-sidebar-hover: #DFD6C8;
  --bg-sidebar-active: var(--ink);
  --bg-overlay:     rgba(34, 31, 28, 0.5);
  --bg-skeleton:    linear-gradient(90deg, var(--gray-150) 25%, var(--gray-100) 37%, var(--gray-150) 63%);
  /* the loading look: the app's shapes, softly blurred, with a light sweeping left to right */
  --sk-bar:   var(--gray-200);
  --sk-card:  var(--gray-150);
  --sk-side:  var(--bg-sidebar);
  --shimmer:  rgba(255, 255, 255, 0.72);
  /* each payment method keeps one colour on every screen: the wallets wear their
     own official colour (pages/shared/tenders.js), cash the shop's terracotta */
  --pay-cash: #C64F2C; --pay-bkash: #E2136E; --pay-nagad: #F6921E; --pay-rocket: #8A2890;
  --pay-upay: #0058A8; --pay-card: #1A1F71; --pay-qr: #137833; --pay-bank: #7A6F64; --pay-other: #B7B3AB;

  --text-strong:    var(--ink);
  --text-primary:   #2E2A26;
  --text-secondary: var(--gray-600);
  --text-muted:     #6E6459;
  --text-disabled:  var(--gray-400);
  --text-invert:    var(--gray-0);
  --text-on-brand:  #ffffff;
  --text-sidebar:   #4F473F;
  --text-sidebar-strong: var(--ink);
  --text-sidebar-active: var(--paper);
  --line-sidebar:   rgba(34, 31, 28, 0.1);

  --border:         var(--gray-200);
  --border-strong:  var(--gray-300);
  --border-subtle:  var(--gray-150);
  --border-focus:   var(--brand-600);

  --accent:         var(--brand-600);
  --accent-hover:   var(--brand-700);
  --accent-soft:    var(--brand-50);
  --accent-soft-border: var(--brand-200);
  --accent-text:    var(--brand-700);

  --success-bg: var(--success-50);
  --success-fg: var(--success-700);
  --success-solid: var(--success-600);
  --warning-bg: var(--warning-50);
  --warning-fg: var(--warning-700);
  --warning-solid: var(--warning-600);
  --danger-bg: var(--danger-50);
  --danger-fg: var(--danger-700);
  --danger-solid: var(--danger-600);
  --info-bg: var(--info-50);
  --info-fg: var(--info-700);
  --info-solid: var(--info-600);

  /* Short aliases used by the public site, banners and widgets */
  --logo-std: block;
  --logo-rev: none;
  --bg-ink-panel: var(--ink);

  --bg: var(--bg-body);
  --surface: var(--bg-surface);
  --text: var(--text-primary);
  --ok: var(--success-solid);
  --warn: var(--warning-solid);
  --danger: var(--danger-solid);

  /* ---- Chart palette (categorical) ---- */
  --chart-1: #C64F2C;
  --chart-2: #3D6773;
  --chart-3: #C48A1E;
  --chart-4: #5B8A5A;
  --chart-5: #7A6F64;
  --chart-6: #8E3B46;
  --chart-7: #33302A;
  --chart-8: #D9A38B;
  /* how customers paid (dashboard): five hues checked for colour-blind separation,
     a 15+ normal-vision step and 3:1 on the surface (dataviz validate_palette.js) */
  --mix-1: #C64F2C; --mix-2: #2B6CB0; --mix-3: #A87808; --mix-4: #8350B5; --mix-5: #2F8A5C; --mix-other: #9A9187;
  --chart-grid: var(--gray-200);
  --chart-axis: var(--text-muted);

  /* ---- Typography ---- */
  --font-sans: "Archivo", "Hind Siliguri", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "SFMono-Regular", "Menlo", "Consolas",
    "Liberation Mono", monospace;

  --fs-2xs: 0.6875rem;  /* 11 */
  --fs-xs:  0.75rem;    /* 12 */
  --fs-sm:  0.8125rem;  /* 13 */
  --fs-md:  0.875rem;   /* 14 - base UI */
  --fs-lg:  1rem;       /* 16 */
  --fs-xl:  1.125rem;   /* 18 */
  --fs-2xl: 1.375rem;   /* 22 */
  --fs-3xl: 1.75rem;    /* 28 */
  --fs-4xl: 2.25rem;    /* 36 */

  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  --lh-tight: 1.2;
  --lh-snug: 1.35;
  --lh-normal: 1.5;

  /* ---- Spacing scale (4px base) ---- */
  --sp-0: 0;
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;
  --sp-7: 2rem;
  --sp-8: 2.5rem;
  --sp-9: 3rem;
  --sp-10: 4rem;

  /* ---- Radii ---- */
  --radius-xs: 3px;
  --radius-sm: 5px;
  --radius-md: 7px;
  --radius-lg: 10px;
  --radius-xl: 14px;
  --radius-2xl: 20px;
  --radius-pill: 999px;

  /* ---- Shadows (light) ---- */
  --shadow-xs: 0 1px 1px rgba(34, 31, 28, 0.05);
  --shadow-sm: 0 1px 2px rgba(34, 31, 28, 0.07), 0 0 0 1px rgba(34, 31, 28, 0.015);
  --shadow-md: 0 6px 16px -6px rgba(34, 31, 28, 0.16), 0 1px 2px rgba(34, 31, 28, 0.06);
  --shadow-lg: 0 16px 32px -12px rgba(34, 31, 28, 0.22), 0 2px 6px rgba(34, 31, 28, 0.06);
  --shadow-xl: 0 28px 60px -16px rgba(34, 31, 28, 0.34);
  --ring-focus: 0 0 0 3px rgba(198, 79, 44, 0.24);

  /* ---- Layout metrics ---- */
  --sidebar-w: 248px;
  --sidebar-w-collapsed: 72px;
  --topbar-h: 60px;
  --cart-w: 400px;
  --content-max: 1440px;

  /* ---- 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-mid: 200ms;
  --dur-slow: 320ms;

  --z-base: 1;
  --z-sticky: 100;
  --z-drawer: 900;
  --z-modal: 1000;
  --z-toast: 1100;
  --z-tooltip: 1200;
  --z-net-guard: 2147483000;

  color-scheme: light;
}

/* ---- DARK palette ---- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --logo-std: none;
    --logo-rev: block;
    --bg-ink-panel: #151310;

    --bg-body:      #221F1C;
    --bg-surface:   #2B2824;
    --bg-surface-2: #272420;
    --bg-surface-3: #34302B;
    --bg-inset:     #1C1A17;
    --bg-hover:     #36322C;
    --bg-active:    #413C35;
    --bg-sidebar:   #1A1815;
    --bg-sidebar-hover: #2B2824;
    --bg-sidebar-active: #F1EBE1;
    --bg-overlay:   rgba(15, 13, 11, 0.66);
    --bg-skeleton:  linear-gradient(90deg, #34302B 25%, #3D3832 37%, #34302B 63%);
    --sk-bar: #3D3832;
    --sk-card: #36322C;
    --sk-side: #1A1815;
    --shimmer: rgba(255, 255, 255, 0.07);
    --pay-cash: #DA6A45; --pay-bkash: #F0428B; --pay-nagad: #F7A440; --pay-rocket: #B455BB;
    --pay-upay: #4C93E6; --pay-card: #8E96EC; --pay-qr: #2FA45A; --pay-bank: #A69B8D; --pay-other: #6B665E;

    --text-strong:    #F6F1E9;
    --text-primary:   #E7DFD3;
    --text-secondary: #C2B8AA;
    --text-muted:     #A69B8D;
    --text-disabled:  #766C61;
    --text-invert:    #221F1C;
    --text-sidebar:   #BDB3A5;
    --text-sidebar-strong: #F6F1E9;
    --text-sidebar-active: #221F1C;
    --line-sidebar:   rgba(241, 235, 225, 0.09);

    --border:        #3F3A33;
    --border-strong: #514B43;
    --border-subtle: #36322C;
    --border-focus:  var(--brand-400);

    --accent:       var(--brand-600);
    --accent-hover: var(--brand-500);
    --accent-soft:  #3B2820;
    --accent-soft-border: #6A3A28;
    --accent-text:  #EB9877;

    --success-bg: #26322A; --success-fg: #A8C9A5; --success-solid: var(--success-500);
    --warning-bg: #38301D; --warning-fg: #E2BE72; --warning-solid: var(--warning-500);
    --danger-bg:  #3B2320; --danger-fg:  #EFA59C; --danger-solid:  #C4483E;
    --info-bg:    #233236; --info-fg:    #9FC2CB; --info-solid:    var(--info-500);

    --chart-1: #DA6A45;
    --chart-2: #7FA9B5;
    --chart-3: #DDA63D;
    --chart-4: #8DB48A;
    --chart-5: #A69B8D;
    --chart-6: #C47783;
    --chart-7: #E7DFD3;
    --chart-8: #E5B9A5;
  --mix-1: #D46A42; --mix-2: #4A86D6; --mix-3: #B88A1C; --mix-4: #9C70D2; --mix-5: #3A9F6C; --mix-other: #7D756C;
    --chart-grid: #3F3A33;
    --chart-axis: #A69B8D;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.36);
    --shadow-md: 0 6px 16px -6px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 16px 32px -12px rgba(0, 0, 0, 0.6);
    --shadow-xl: 0 28px 60px -16px rgba(0, 0, 0, 0.7);
    --ring-focus: 0 0 0 3px rgba(212, 117, 85, 0.38);

    color-scheme: dark;
  }
}

/* ---- Explicit manual dark (wins regardless of system) ---- */
:root[data-theme="dark"] {
  --logo-std: none;
  --logo-rev: block;
  --bg-ink-panel: #151310;

  --bg-body:      #221F1C;
  --bg-surface:   #2B2824;
  --bg-surface-2: #272420;
  --bg-surface-3: #34302B;
  --bg-inset:     #1C1A17;
  --bg-hover:     #36322C;
  --bg-active:    #413C35;
  --bg-sidebar:   #1A1815;
  --bg-sidebar-hover: #2B2824;
  --bg-sidebar-active: #F1EBE1;
  --bg-overlay:   rgba(15, 13, 11, 0.66);
  --bg-skeleton:  linear-gradient(90deg, #34302B 25%, #3D3832 37%, #34302B 63%);
  --sk-bar: #3D3832;
  --sk-card: #36322C;
  --sk-side: #1A1815;
  --shimmer: rgba(255, 255, 255, 0.07);
  --pay-cash: #DA6A45; --pay-bkash: #F0428B; --pay-nagad: #F7A440; --pay-rocket: #B455BB;
  --pay-upay: #4C93E6; --pay-card: #8E96EC; --pay-qr: #2FA45A; --pay-bank: #A69B8D; --pay-other: #6B665E;

  --text-strong:    #F6F1E9;
  --text-primary:   #E7DFD3;
  --text-secondary: #C2B8AA;
  --text-muted:     #A69B8D;
  --text-disabled:  #766C61;
  --text-invert:    #221F1C;
  --text-sidebar:   #BDB3A5;
  --text-sidebar-strong: #F6F1E9;
  --text-sidebar-active: #221F1C;
  --line-sidebar:   rgba(241, 235, 225, 0.09);

  --border:        #3F3A33;
  --border-strong: #514B43;
  --border-subtle: #36322C;
  --border-focus:  var(--brand-400);

  --accent:       var(--brand-600);
  --accent-hover: var(--brand-500);
  --accent-soft:  #3B2820;
  --accent-soft-border: #6A3A28;
  --accent-text:  #EB9877;

  --success-bg: #26322A; --success-fg: #A8C9A5; --success-solid: var(--success-500);
  --warning-bg: #38301D; --warning-fg: #E2BE72; --warning-solid: var(--warning-500);
  --danger-bg:  #3B2320; --danger-fg:  #EFA59C; --danger-solid:  #C4483E;
  --info-bg:    #233236; --info-fg:    #9FC2CB; --info-solid:    var(--info-500);

  --chart-1: #DA6A45;
  --chart-2: #7FA9B5;
  --chart-3: #DDA63D;
  --chart-4: #8DB48A;
  --chart-5: #A69B8D;
  --chart-6: #C47783;
  --chart-7: #E7DFD3;
  --chart-8: #E5B9A5;
  --mix-1: #D46A42; --mix-2: #4A86D6; --mix-3: #B88A1C; --mix-4: #9C70D2; --mix-5: #3A9F6C; --mix-other: #7D756C;
  --chart-grid: #3F3A33;
  --chart-axis: #A69B8D;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.36);
  --shadow-md: 0 6px 16px -6px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 16px 32px -12px rgba(0, 0, 0, 0.6);
  --shadow-xl: 0 28px 60px -16px rgba(0, 0, 0, 0.7);
  --ring-focus: 0 0 0 3px rgba(212, 117, 85, 0.38);

  color-scheme: dark;
}
