/* ════════════════════════════════════════════════════════════
   POS-V2 — Design Tokens (Enterprise Pro)
   ════════════════════════════════════════════════════════════ */
:root {
  /* ── Colors ── */
  --c-rail:           #2C2C2A;   /* dark icon rail */
  --c-rail-hover:     #3A3A37;
  --c-rail-active:    #042C53;
  --c-rail-fg:        #E5E4DF;
  --c-rail-fg-muted:  #8A8A85;

  --c-sidebar:        #FAFAF7;   /* off-white inner sidebar */
  --c-sidebar-border: #E8E7E1;
  --c-sidebar-hover:  #F1F0EA;
  --c-sidebar-active: #E6EEF7;

  --c-bg:             #FFFFFF;
  --c-bg-muted:       #F5F5F1;
  --c-surface:        #FFFFFF;
  --c-border:         #E5E4DF;
  --c-border-strong:  #C9C8C2;

  --c-text:           #1A1A19;
  --c-text-muted:     #6B6B66;
  --c-text-soft:      #9B9B95;

  --c-primary:        #042C53;   /* dark navy */
  --c-primary-hover:  #063C72;
  --c-primary-fg:     #FFFFFF;
  --c-primary-soft:   #E6EEF7;
  /* [Feature ThemeDeep-20261026] สีเน้น (ลิงก์/เลขที่เอกสาร/ปุ่มที่เลือก) — เดิมไม่มีค่าตั้งต้น ⇒ ~120 จุดที่ใช้ var(--c-accent) ไม่มีสีจนกว่าจะเลือกธีม
     · หน้าตั้งค่าธีม (app.js loadTheme) ตั้งทับแบบ inline บน <html> */
  --c-accent:         #2563EB;

  --c-success-bg:     #9FE1CB;   /* teal credit */
  --c-success-fg:     #04342C;
  --c-warn-bg:        #FFE9B0;
  --c-warn-fg:        #5A3F00;
  --c-danger-bg:      #FFD4D4;
  --c-danger-fg:      #5A0E0E;
  --c-info-bg:        #D9E8F8;
  --c-info-fg:        #042C53;

  /* ── Font sizes ── */
  --fs-11: 11px;
  --fs-12: 12px;
  --fs-13: 13px;
  --fs-14: 14px;
  --fs-15: 15px;
  --fs-18: 18px;
  --fs-22: 22px;

  --ff-base: system-ui, -apple-system, "Segoe UI", Sarabun, "Noto Sans Thai", Roboto, Arial, sans-serif;

  /* ── Spacing ── */
  --sp-4:  4px;
  --sp-8:  8px;
  --sp-12: 12px;
  --sp-16: 16px;
  --sp-20: 20px;
  --sp-24: 24px;
  --sp-32: 32px;

  /* ── Radius ── */
  --r-4:  4px;
  --r-6:  6px;
  --r-8:  8px;
  --r-12: 12px;

  /* ── Shadows ── */
  --sh-sm: 0 1px 2px rgba(0,0,0,0.05);
  --sh-md: 0 2px 6px rgba(0,0,0,0.08);
  --sh-lg: 0 8px 24px rgba(0,0,0,0.12);
  --sh-card: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);

  /* ── Layout ── */
  --rail-w:    56px;
  --sidebar-w: 220px;
  --topbar-h:  52px;
  --tabbar-h:  60px;

  /* ── Breakpoints (reference only) ── */
  --bp-tablet:  768px;
  --bp-desktop: 1024px;

  /* ── Transitions ── */
  --t-fast: 120ms ease;
  --t-base: 180ms ease;
}

/* ════════════════════════════════════════════════════════════════
   [Phase Theme-DarkMode-CSS-20260510] Dark Mode rules
   Activated by body.theme-dark (set via app.js loadTheme()) OR
   body.theme-auto when OS prefers dark.

   IMPORTANT — does NOT override:
     --c-primary / --c-primary-hover / --c-primary-fg / --c-primary-soft
     --c-rail-active   (uses --c-primary effectively)
   These are user-customizable per-company (via #/settings/theme).

   Status colors (success/warn/danger/info) get dark-tinted backgrounds with
   readable foregrounds. Yellow/amber pills (used for "เชื่อ"/warning chips
   inline-styled across pages) are NOT touched — yellow on dark looks fine.
   ════════════════════════════════════════════════════════════════ */
body.theme-dark {
  /* Page bg + surfaces */
  --c-bg:             #0f172a;   /* slate-900 — page bg */
  --c-bg-muted:       #1e293b;   /* slate-800 — page muted */
  --c-surface:        #1e293b;   /* slate-800 — cards / modals / tabbar */
  --c-border:         #334155;   /* slate-700 */
  --c-border-strong:  #475569;   /* slate-600 */

  /* Text */
  --c-text:           #f1f5f9;   /* slate-100 */
  --c-text-muted:     #94a3b8;   /* slate-400 */
  --c-text-soft:      #64748b;   /* slate-500 */

  /* Sidebar — slightly darker rail to maintain elevation hierarchy */
  --c-rail:           #020617;   /* slate-950 */
  --c-rail-hover:     #1e293b;
  --c-rail-fg:        #cbd5e1;
  --c-rail-fg-muted:  #64748b;

  --c-sidebar:        #0f172a;   /* same as bg, blends into page */
  --c-sidebar-border: #334155;
  --c-sidebar-hover:  #1e293b;
  --c-sidebar-active: #1e3a5f;   /* tinted with primary feel */

  /* Status — backgrounds tinted, foregrounds bright enough for AA contrast */
  --c-success-bg:     #064e3b;   /* emerald-900 */
  --c-success-fg:     #6ee7b7;   /* emerald-300 */
  --c-warn-bg:        #78350f;   /* amber-900 */
  --c-warn-fg:        #fcd34d;   /* amber-300 */
  --c-danger-bg:      #7f1d1d;   /* red-900 */
  --c-danger-fg:      #fca5a5;   /* red-300 */
  --c-info-bg:        #1e3a8a;   /* blue-900 */
  --c-info-fg:        #93c5fd;   /* blue-300 */

  /* Shadows — slightly stronger on dark to maintain elevation */
  --sh-sm:  0 1px 2px rgba(0,0,0,0.4);
  --sh-md:  0 2px 6px rgba(0,0,0,0.5);
  --sh-lg:  0 8px 24px rgba(0,0,0,0.6);
  --sh-card: 0 1px 3px rgba(0,0,0,0.5), 0 1px 2px rgba(0,0,0,0.3);

  /* Tells browser to render native form controls + scrollbars dark */
  color-scheme: dark;
}

/* Auto mode — follow OS preference. Class set by app.js loadTheme() when
   theme_mode='auto'. Same overrides as .theme-dark. */
@media (prefers-color-scheme: dark) {
  body.theme-auto {
    --c-bg:             #0f172a;
    --c-bg-muted:       #1e293b;
    --c-surface:        #1e293b;
    --c-border:         #334155;
    --c-border-strong:  #475569;
    --c-text:           #f1f5f9;
    --c-text-muted:     #94a3b8;
    --c-text-soft:      #64748b;
    --c-rail:           #020617;
    --c-rail-hover:     #1e293b;
    --c-rail-fg:        #cbd5e1;
    --c-rail-fg-muted:  #64748b;
    --c-sidebar:        #0f172a;
    --c-sidebar-border: #334155;
    --c-sidebar-hover:  #1e293b;
    --c-sidebar-active: #1e3a5f;
    --c-success-bg:     #064e3b;
    --c-success-fg:     #6ee7b7;
    --c-warn-bg:        #78350f;
    --c-warn-fg:        #fcd34d;
    --c-danger-bg:      #7f1d1d;
    --c-danger-fg:      #fca5a5;
    --c-info-bg:        #1e3a8a;
    --c-info-fg:        #93c5fd;
    --sh-sm:  0 1px 2px rgba(0,0,0,0.4);
    --sh-md:  0 2px 6px rgba(0,0,0,0.5);
    --sh-lg:  0 8px 24px rgba(0,0,0,0.6);
    --sh-card: 0 1px 3px rgba(0,0,0,0.5), 0 1px 2px rgba(0,0,0,0.3);
    color-scheme: dark;
  }
}

/* Print pages MUST be light (paper is white). Reset dark overrides under @media print. */
@media print {
  body.theme-dark, body.theme-auto {
    --c-bg:             #FFFFFF;
    --c-bg-muted:       #F5F5F1;
    --c-surface:        #FFFFFF;
    --c-border:         #E5E4DF;
    --c-border-strong:  #C9C8C2;
    --c-text:           #1A1A19;
    --c-text-muted:     #6B6B66;
    --c-text-soft:      #9B9B95;
    --c-rail:           #2C2C2A;
    --c-rail-hover:     #3A3A37;
    --c-rail-fg:        #E5E4DF;
    --c-rail-fg-muted:  #8A8A85;
    --c-sidebar:        #FAFAF7;
    --c-sidebar-border: #E8E7E1;
    --c-sidebar-hover:  #F1F0EA;
    --c-sidebar-active: #E6EEF7;
    --c-success-bg:     #9FE1CB;
    --c-success-fg:     #04342C;
    --c-warn-bg:        #FFE9B0;
    --c-warn-fg:        #5A3F00;
    --c-danger-bg:      #FFD4D4;
    --c-danger-fg:      #5A0E0E;
    --c-info-bg:        #D9E8F8;
    --c-info-fg:        #042C53;
    color-scheme: light;
  }
}

