/* ════════════════════════════════════════════════════════════════════════
   matrix-dark.css — v29.15 optional DARK "WORKSPACE" skin (opt-in).

   Restores the v28.11 dark/lime CRM palette as a token-override layer
   scoped to `html.theme-dark`.  matrix.css stays the DEFAULT Enterprise
   Light theme (and keeps its v29.9 palette-lock contract — no dark hexes
   live there); this file only re-declares the :root tokens plus a handful
   of component tints whose light values don't invert cleanly.

   Activation: the /matrix/profile Appearance toggle writes
   localStorage["wf345_theme"]; a first-paint loader in matrix_base.html
   adds .theme-dark to <html> before the body renders (no flash).  Public
   standalone pages (landing / login / register / terms) never load this
   file, so the marketing surface is always Enterprise Light.

   `html.theme-dark` (type + class) out-specifies `:root` (single pseudo-
   class), so every component that reads the tokens reskins at once.
   ════════════════════════════════════════════════════════════════════════ */

html.theme-dark {
  /* ── Dark "WORKSPACE" palette (v28.11 heritage) ────────────────────────── */
  --bg-app: #0b0b0d;            /* near-black workspace canvas               */
  --bg-surface: #18181b;        /* elevated content card                     */
  --bg-elevated: #1f1f23;       /* nested surface inside a card              */
  --bg-elevated-hi: #27272a;    /* hover / higher elevation                  */
  --text-main: #f4f4f5;         /* crisp primary text                        */
  --text-strong: #ffffff;       /* headline emphasis                         */
  --text-muted: #a1a1aa;        /* secondary / ancillary labels              */
  --border-color: #2a2a30;      /* low-opacity divider stroke                */
  --border-light: rgba(255, 255, 255, 0.07);

  /* Bright lime-green accent (the deck's signature colour) + supports        */
  --primary: #f97316;
  --primary-hover: #fb923c;
  --primary-ink: #ffffff;       /* near-black text ON the lime accent        */
  --accent-cyan: #38bdf8;
  --danger: #f26b5e;
  --success: #4ade80;

  /* Legacy inline-template vars remapped to the dark skin.                   */
  /* v59.0 — softened one step (the zinc-500 dim read too faint against
     the charcoal canvas; ancillary copy now sits at a comfortable
     contrast without competing with primary text). */
  --matrix-text-dim: #85858e;
  --matrix-blue-hi: #38bdf8;
  --matrix-cyan: #38bdf8;

  /* App-shell surfaces + dark-depth shadows.                                 */
  --bg-shell: #101013;
  --bg-topbar: rgba(11, 11, 13, 0.82);
  /* v59.0 "Kinetic & Organic" — dark elevation reads through a FAINT
     AMBIENT RING (surfaces glow softly apart from the charcoal canvas)
     plus deep diffused drops; --shadow-lg was previously MISSING here,
     so the drawer/modals fell back to the pale light-theme token. */
  --shadow-sm: 0 0 0 1px rgb(255 255 255 / 0.045),
               0 1px 2px 0 rgb(0 0 0 / 0.40),
               0 4px 14px -6px rgb(0 0 0 / 0.45);
  --shadow-md: 0 0 0 1px rgb(255 255 255 / 0.05),
               0 8px 24px -6px rgb(0 0 0 / 0.55),
               0 2px 6px -2px rgb(0 0 0 / 0.40);
  --shadow-lg: 0 0 0 1px rgb(255 255 255 / 0.06),
               0 12px 32px -8px rgb(0 0 0 / 0.62),
               0 28px 64px -16px rgb(0 0 0 / 0.55);
}

/* ── Component tints whose LIGHT values don't invert via tokens ──────────── */

/* Neutral pill badge: white-alpha wash instead of slate-alpha. */
html.theme-dark .mx-badge { background: rgba(255, 255, 255, 0.08); }
html.theme-dark .mx-compliance-unknown { background: rgba(255, 255, 255, 0.06); }

/* Navy-tinted chips → lime-tinted on dark (text already follows --primary). */
html.theme-dark .mx-credit-pill,
html.theme-dark .mx-credit-nav,
html.theme-dark .mx-sigcard-badge,
html.theme-dark .mx-feature-ico { background: rgba(195, 245, 60, 0.10); }
html.theme-dark .mx-input:focus,
html.theme-dark .mx-select:focus { box-shadow: 0 0 0 3px rgba(195, 245, 60, 0.25); }

/* Status chips tuned for dark surfaces (light-ink variants). */
html.theme-dark .mx-status-processing { background: rgba(99, 102, 241, 0.20); color: #a5b4fc; }
html.theme-dark .mx-status-draft { background: rgba(245, 166, 35, 0.18); }

/* PDF verification iframe letterbox reads better dark. */
html.theme-dark .mx-iframe-container { background: #1f1f23; }

/* NOTE — deliberately UNCHANGED in dark mode (established contracts):
   .mx-input/.mx-select white fields, the .mx-progress-container and
   .mx-error forced-light callouts, and the Super Admin red control-plane
   chrome (its hardcoded red surfaces are theme-independent by design). */

/* ── v42.0 — DARK SIDENAV (the operator's "dark mode is inconsistent"):
   the v33 warm-light sidebar token family was never re-pointed here, so
   dark mode kept a #fafaf9 rail beside a near-black canvas. ───────────── */
html.theme-dark {
  --bg-sidenav: #101013;
  --bg-sidenav-edge: #26262b;
  --sidenav-ink: #a1a1aa;
  --sidenav-ink-active: #ffffff;
  --sidenav-hover: rgb(255 255 255 / 0.06);
  --sidenav-active: #f97316;
  --chip-slate-bg: #27272a;
  --chip-slate-ink: #d4d4d8;
}

/* ── v56.0 — MODAL-CHROME LIGHT-LEAK SWEEP: the inline-styled #f8fafc
   header/footer strips inside modals (roster, cabinet, superadmin ×6)
   rendered as bright bands on the dark skin.  The attribute selector
   catches every inline instance; nothing else in the product uses
   #f8fafc inline.  (The .mx-input white-field contract, the progress /
   error callouts, the signature pad and the document-viewer stage stay
   deliberately light — those are documented theme-independent surfaces.) */
html.theme-dark [style*="background:#f8fafc"],
html.theme-dark [style*="background: #f8fafc"] {
  background: #232120 !important;
  border-color: #292524 !important;
  color: #d6d3d1 !important;
}

/* ── v42.0 — LOGO LEGIBILITY LAW: the full-colour lockup's navy wordmark
   vanishes on dark chrome; every band placement renders as the white
   silhouette in dark mode (the auth square handles itself per-template). */
html.theme-dark .mx-navbar img[src^="/images/logo/"],
html.theme-dark .mx-footer img[src^="/images/logo/"],
html.theme-dark .mx-sidebar-brand img[src^="/images/logo/"] {
  filter: brightness(0) invert(1);
}


/* v400 — dark inks for the badge state variants.  Without these the dark
   theme killed the badge BACKGROUND (above) while leaving the light-mode
   ink, so every semantic badge sat below the contrast floor on the default
   theme.  Values are the audited [data-ink] dark palette: 9.39 / 9.92 /
   7.54:1 on the white-alpha pill. */
html.theme-dark .mx-badge.ok,
html.theme-dark .mx-badge.success,
html.theme-dark .mx-badge.green,
html.theme-dark .mx-badge.mx-badge-ok      { color: #6ee7b7; }
html.theme-dark .mx-badge.warn,
html.theme-dark .mx-badge.pending,
html.theme-dark .mx-badge.amber,
html.theme-dark .mx-badge.mx-badge-warning,
html.theme-dark .mx-badge.mx-badge-notice  { color: #fcd34d; }
html.theme-dark .mx-badge.err,
html.theme-dark .mx-badge.danger,
html.theme-dark .mx-badge.red,
html.theme-dark .mx-badge.mx-badge-critical { color: #fca5a5; }
