/* =================================================================
   Dark theme
   Activated by <html data-theme="dark"> (set by assets/js/theme.js).
   1) Redefine design tokens  2) Patch component colors that are not
   token-based (status badges)  3) Map Tailwind utility classes used
   in the markup to dark equivalents.
   ================================================================= */

/* ---------- 1. Tokens ---------- */
[data-theme="dark"] {
  color-scheme: dark;

  --primary: #FF5A1F;
  --primary-dark: #FC4805;
  --primary-light: rgba(252, 72, 5, .14);

  --bg: #0B0D10;
  --surface: #14171C;
  --surface-hover: #1B1F26;
  --surface-muted: #20252D;
  --row-hover: #181C22;
  --glass: rgba(20, 23, 28, .88);

  --border: #252A32;
  --border-soft: #1E232A;
  --border-strong: #353B45;

  --text: #EDEFF3;
  --text-2: #C9CED6;
  --text-3: #A3AAB5;
  --muted: #8A929E;
  --text-faint: #6B7380;

  --toast-bg: #EDEFF3;
  --toast-text: #0B0D10;
}

/* ---------- 2. Components ---------- */
[data-theme="dark"] .badge-green { color: #6EE7B7; background: rgba(16, 185, 129, .12); border-color: rgba(16, 185, 129, .35); }
[data-theme="dark"] .badge-blue  { color: #93C5FD; background: rgba(59, 130, 246, .12); border-color: rgba(59, 130, 246, .35); }
[data-theme="dark"] .badge-amber { color: #FCD34D; background: rgba(245, 158, 11, .12); border-color: rgba(245, 158, 11, .35); }
[data-theme="dark"] .badge-red   { color: #FCA5A5; background: rgba(239, 68, 68, .12);  border-color: rgba(239, 68, 68, .35); }
[data-theme="dark"] .badge-gray  { color: #C9CED6; background: rgba(148, 163, 184, .1); border-color: rgba(148, 163, 184, .3); }

[data-theme="dark"] .trend-up   { color: #6EE7B7; background: rgba(16, 185, 129, .12); border-color: rgba(16, 185, 129, .35); }
[data-theme="dark"] .trend-down { color: #FCA5A5; background: rgba(239, 68, 68, .12);  border-color: rgba(239, 68, 68, .35); }

[data-theme="dark"] .kpi-body,
[data-theme="dark"] .chart-tip,
[data-theme="dark"] .dropdown,
[data-theme="dark"] .form-bar { box-shadow: 0 1px 2px rgba(0, 0, 0, .4); }

[data-theme="dark"] .dropdown-item.text-red-600:hover { background: rgba(239, 68, 68, .12); }
[data-theme="dark"] .icon-btn-sm:hover { color: #F87171; }

/* Logo: swap to the white version where available */
[data-theme="dark"] .logo-light { display: none; }
[data-theme="dark"] .logo-dark  { display: block; }

/* Native form controls (date pickers, selects) */
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea { background-color: var(--surface); color: var(--text); }
[data-theme="dark"] ::placeholder { color: var(--text-faint); }

/* ---------- 3. Tailwind utilities used in markup ---------- */
[data-theme="dark"] .bg-white      { background-color: var(--surface) !important; }
[data-theme="dark"] .bg-gray-50,
[data-theme="dark"] .bg-gray-50\/60 { background-color: var(--surface-hover) !important; }

[data-theme="dark"] .text-gray-900 { color: var(--text) !important; }
[data-theme="dark"] .text-gray-800,
[data-theme="dark"] .text-gray-700 { color: var(--text-2) !important; }
[data-theme="dark"] .text-gray-600 { color: var(--text-3) !important; }
[data-theme="dark"] .text-gray-500 { color: var(--muted) !important; }
[data-theme="dark"] .text-gray-400 { color: var(--text-faint) !important; }

[data-theme="dark"] .border-gray-100,
[data-theme="dark"] .border-gray-200,
[data-theme="dark"] .border-gray-300 { border-color: var(--border) !important; }

[data-theme="dark"] .text-green-600,
[data-theme="dark"] .text-green-700 { color: #6EE7B7 !important; }
[data-theme="dark"] .text-red-600   { color: #F87171 !important; }
[data-theme="dark"] .text-amber-600 { color: #FBBF24 !important; }

[data-theme="dark"] .border-red-200 { border-color: rgba(239, 68, 68, .35) !important; }
[data-theme="dark"] .bg-red-50      { background-color: rgba(239, 68, 68, .1) !important; }
[data-theme="dark"] .text-red-700   { color: #FCA5A5 !important; }

/* ---------- Login page (style.css) ---------- */
[data-theme="dark"] .form-input { background: var(--surface); border-color: var(--border); color: var(--text); }

/* Delete confirmation & row actions */
[data-theme="dark"] .confirm-icon { background: rgba(239, 68, 68, .14); color: #F87171; box-shadow: 0 0 0 8px rgba(239, 68, 68, .06); }
[data-theme="dark"] .icon-btn-danger:hover { color: #F87171; border-color: rgba(239, 68, 68, .4); background: rgba(239, 68, 68, .1); }
