/**
 * Legacy Tailwind Dark-Mode Shim (2026-09 dark theme audit)
 *
 * Most of the app is still "unconverted legacy views" per CLAUDE.md: raw
 * Tailwind CDN utility classes (bg-gray-100, text-red-800, border-indigo-500,
 * etc.) with literal light-mode hex values baked in by the CDN's JIT compiler.
 * Tailwind's default dark strategy is `media` (prefers-color-scheme), so it
 * never reacts to this app's own <html data-theme="dark"> toggle - the
 * utility classes just sit there unchanged. Result: a light card background
 * (e.g. bg-indigo-50) paired with this app's dark-mode body text color
 * (near-white, inherited from tokens.css) reads as near-white text on a
 * near-white background. That is the deck discussion-prompt bug reported
 * 2026-09-02, and the same pattern recurs anywhere a legacy view combines a
 * light Tailwind background/text utility with the app's dark theme.
 *
 * Rather than hand-converting ~120 legacy view files to ui/ classes (a much
 * larger, separate redesign effort), this file re-tones the Tailwind color
 * utilities actually used in the codebase when dark mode is active, using
 * the same Material tokens from tokens.css. The mapping preserves each
 * utility's ROLE, not its literal shade:
 *   - light background shades (50-300ish)  -> dark surface/container tokens
 *   - dark/medium text shades (500-900)    -> light on-surface/accent tokens
 *   - borders, rings, divides              -> outline / accent tokens
 * Because backgrounds and texts are remapped independently by role, any
 * light-bg/dark-text pairing self-corrects into a dark-bg/light-text pairing
 * regardless of which hues a given view happened to combine.
 *
 * Solid, already-vivid utilities meant to carry white text (bg-blue-600
 * buttons, bg-green-700 badges, etc.) and already-dark utilities (bg-gray-800
 * headers, bg-black overlays) are intentionally left alone: they already
 * contrast correctly against white OR dark surrounding content.
 *
 * Load this AFTER the Tailwind CDN <script> and AFTER ui/tokens.css (for the
 * var(--md-*) tokens) in any layout that sets Theme::htmlAttr(). !important
 * is used throughout because Tailwind's CDN styles are injected via a single
 * atomic class selector per utility and this file must always win regardless
 * of DOM insertion order.
 */

/* ── Neutrals: white / gray / black ─────────────────────────────────── */
[data-theme="dark"] .bg-white,
[data-theme="dark"] .bg-gray-50,
[data-theme="dark"] .bg-gray-100 { background-color: var(--md-surface-container-low) !important; }

[data-theme="dark"] .bg-gray-200,
[data-theme="dark"] .bg-gray-300 { background-color: var(--md-surface-container-high) !important; }

[data-theme="dark"] .bg-gray-400 { background-color: var(--md-surface-container-highest) !important; }

[data-theme="dark"] .from-gray-50,
[data-theme="dark"] .from-gray-100 { --tw-gradient-from: var(--md-surface-container-low) var(--tw-gradient-from-position) !important; }
[data-theme="dark"] .to-gray-100,
[data-theme="dark"] .to-gray-200 { --tw-gradient-to: var(--md-surface-container-high) var(--tw-gradient-to-position) !important; }

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

[data-theme="dark"] .border-gray-50,
[data-theme="dark"] .border-gray-100,
[data-theme="dark"] .border-gray-200,
[data-theme="dark"] .border-gray-300,
[data-theme="dark"] .border-gray-400,
[data-theme="dark"] .divide-gray-100 > :not([hidden]) ~ :not([hidden]),
[data-theme="dark"] .divide-gray-200 > :not([hidden]) ~ :not([hidden]) { border-color: var(--md-outline-variant) !important; }
[data-theme="dark"] .border-gray-500,
[data-theme="dark"] .border-gray-600 { border-color: var(--md-outline) !important; }

[data-theme="dark"] .ring-gray-200,
[data-theme="dark"] .ring-gray-400 { --tw-ring-color: var(--md-outline-variant) !important; }

/* ── Semantic color families: light-tint bg + dark-shade text pairs.
   Grouped by nearest existing token (error / warning / success / info /
   ela-purple), so a dark-mode reader still gets the same warning-vs-error
   -vs-success distinction the light design intended. ──────────────────── */

/* red, rose, pink -> error */
[data-theme="dark"] .bg-red-50,   [data-theme="dark"] .bg-red-100,   [data-theme="dark"] .bg-red-200,
[data-theme="dark"] .bg-rose-100, [data-theme="dark"] .bg-pink-100 { background-color: var(--md-error-container) !important; }
[data-theme="dark"] .text-red-400, [data-theme="dark"] .text-red-500, [data-theme="dark"] .text-red-600,
[data-theme="dark"] .text-red-700, [data-theme="dark"] .text-red-800, [data-theme="dark"] .text-red-900,
[data-theme="dark"] .text-rose-800, [data-theme="dark"] .text-pink-800 { color: var(--md-error) !important; }
[data-theme="dark"] .border-red-200, [data-theme="dark"] .border-red-300, [data-theme="dark"] .border-red-500,
[data-theme="dark"] .border-red-700 { border-color: var(--md-error) !important; }
[data-theme="dark"] .ring-red-500 { --tw-ring-color: var(--md-error) !important; }

/* orange, amber, yellow -> warning */
[data-theme="dark"] .bg-orange-50,  [data-theme="dark"] .bg-orange-100,
[data-theme="dark"] .bg-amber-50,   [data-theme="dark"] .bg-amber-100,  [data-theme="dark"] .bg-amber-200,
[data-theme="dark"] .bg-yellow-50,  [data-theme="dark"] .bg-yellow-100, [data-theme="dark"] .bg-yellow-200 {
    background-color: var(--md-warning-container) !important;
}
[data-theme="dark"] .text-orange-600, [data-theme="dark"] .text-orange-700, [data-theme="dark"] .text-orange-800,
[data-theme="dark"] .text-amber-500,  [data-theme="dark"] .text-amber-600,  [data-theme="dark"] .text-amber-700,
[data-theme="dark"] .text-amber-800,  [data-theme="dark"] .text-amber-900,
[data-theme="dark"] .text-yellow-400, [data-theme="dark"] .text-yellow-500, [data-theme="dark"] .text-yellow-600,
[data-theme="dark"] .text-yellow-700, [data-theme="dark"] .text-yellow-800, [data-theme="dark"] .text-yellow-900 {
    color: var(--md-warning) !important;
}
[data-theme="dark"] .border-orange-300, [data-theme="dark"] .border-orange-500,
[data-theme="dark"] .border-amber-200,  [data-theme="dark"] .border-amber-300, [data-theme="dark"] .border-amber-400,
[data-theme="dark"] .border-yellow-200, [data-theme="dark"] .border-yellow-300, [data-theme="dark"] .border-yellow-500 {
    border-color: var(--md-warning) !important;
}
[data-theme="dark"] .ring-yellow-500 { --tw-ring-color: var(--md-warning) !important; }

/* green, emerald, teal -> success */
[data-theme="dark"] .bg-green-50,  [data-theme="dark"] .bg-green-100, [data-theme="dark"] .bg-green-200,
[data-theme="dark"] .bg-emerald-100, [data-theme="dark"] .bg-teal-100 { background-color: var(--md-success-container) !important; }
[data-theme="dark"] .text-green,     [data-theme="dark"] .text-green-100, [data-theme="dark"] .text-green-200,
[data-theme="dark"] .text-green-400, [data-theme="dark"] .text-green-500, [data-theme="dark"] .text-green-600,
[data-theme="dark"] .text-green-700, [data-theme="dark"] .text-green-800, [data-theme="dark"] .text-green-900,
[data-theme="dark"] .text-emerald-800, [data-theme="dark"] .text-teal-600, [data-theme="dark"] .text-teal-700,
[data-theme="dark"] .text-teal-800 { color: var(--md-success) !important; }
[data-theme="dark"] .border-green-200, [data-theme="dark"] .border-green-300, [data-theme="dark"] .border-green-400,
[data-theme="dark"] .border-green-500, [data-theme="dark"] .border-green-600 { border-color: var(--md-success) !important; }
[data-theme="dark"] .ring-green-500 { --tw-ring-color: var(--md-success) !important; }

/* blue, cyan, sky -> info */
[data-theme="dark"] .bg-blue-50, [data-theme="dark"] .bg-blue-100, [data-theme="dark"] .bg-blue-200,
[data-theme="dark"] .bg-cyan-100, [data-theme="dark"] .bg-sky-50, [data-theme="dark"] .bg-sky-100 {
    background-color: var(--md-info-container) !important;
}
[data-theme="dark"] .text-blue-200, [data-theme="dark"] .text-blue-400, [data-theme="dark"] .text-blue-500,
[data-theme="dark"] .text-blue-600, [data-theme="dark"] .text-blue-700, [data-theme="dark"] .text-blue-800,
[data-theme="dark"] .text-blue-900, [data-theme="dark"] .text-cyan-700, [data-theme="dark"] .text-cyan-800,
[data-theme="dark"] .text-sky-600, [data-theme="dark"] .text-sky-700, [data-theme="dark"] .text-sky-900 {
    color: var(--md-info) !important;
}
[data-theme="dark"] .border-blue-200, [data-theme="dark"] .border-blue-300, [data-theme="dark"] .border-blue-400,
[data-theme="dark"] .border-blue-500 { border-color: var(--md-info) !important; }
[data-theme="dark"] .ring-blue-300, [data-theme="dark"] .ring-blue-500 { --tw-ring-color: var(--md-info) !important; }

/* indigo, violet, purple -> ela-purple (existing dark-safe purple pair) */
[data-theme="dark"] .bg-indigo-50, [data-theme="dark"] .bg-indigo-100,
[data-theme="dark"] .bg-purple-50, [data-theme="dark"] .bg-purple-100, [data-theme="dark"] .bg-violet-100 {
    background-color: var(--ela-c) !important;
}
[data-theme="dark"] .text-indigo-200, [data-theme="dark"] .text-indigo-500, [data-theme="dark"] .text-indigo-700,
[data-theme="dark"] .text-indigo-800, [data-theme="dark"] .text-indigo-900,
[data-theme="dark"] .text-purple-600, [data-theme="dark"] .text-purple-700, [data-theme="dark"] .text-purple-800,
[data-theme="dark"] .text-purple-900, [data-theme="dark"] .text-violet-800 { color: var(--ela) !important; }
[data-theme="dark"] .border-indigo-200, [data-theme="dark"] .border-indigo-500,
[data-theme="dark"] .border-purple-200, [data-theme="dark"] .border-purple-300, [data-theme="dark"] .border-purple-400,
[data-theme="dark"] .border-purple-500 { border-color: var(--ela) !important; }
[data-theme="dark"] .ring-purple-500 { --tw-ring-color: var(--ela) !important; }
