/**
 * RC slate/gray theme map (5.2.20)
 * Remaps all Tailwind slate/gray/zinc text & surface utilities to theme tokens.
 * Load LAST after app.css / contrast-lock so every tab inherits readable contrast.
 * Does not alter brand accent colours (blue/emerald/rose/amber).
 */

/* ========== DARK ========== */
html[data-theme="dark"],
html.dark {
  --tw-slate-ink: #f1f5f9;
  --tw-slate-soft: #e2e8f0;
  --tw-slate-muted: #cbd5e1;
  --tw-slate-faint: #94a3b8;
  --tw-slate-surface: #1e293b;
  --tw-slate-surface-2: #0f172a;
  --tw-slate-border: #475569;
}

html[data-theme="dark"] #rc-main-content,
html[data-theme="dark"] #rc-content,
html[data-theme="dark"] main,
html.dark #rc-main-content,
html.dark #rc-content,
html.dark main {
  color: var(--tw-slate-soft);
}

/* text-slate / text-gray / text-zinc — dark */
html[data-theme="dark"] :is(
  .text-slate-950, .text-slate-900, .text-slate-800, .text-slate-700,
  .text-gray-950, .text-gray-900, .text-gray-800, .text-gray-700,
  .text-zinc-950, .text-zinc-900, .text-zinc-800, .text-zinc-700,
  .text-neutral-900, .text-neutral-800, .text-black
),
html.dark :is(
  .text-slate-950, .text-slate-900, .text-slate-800, .text-slate-700,
  .text-gray-950, .text-gray-900, .text-gray-800, .text-gray-700,
  .text-zinc-900, .text-zinc-800, .text-black
) {
  color: var(--tw-slate-ink) !important;
}

html[data-theme="dark"] :is(
  .text-slate-600, .text-slate-500,
  .text-gray-600, .text-gray-500,
  .text-zinc-600, .text-zinc-500,
  .text-neutral-600, .text-neutral-500
),
html.dark :is(
  .text-slate-600, .text-slate-500,
  .text-gray-600, .text-gray-500,
  .text-zinc-600, .text-zinc-500
) {
  color: var(--tw-slate-muted) !important;
}

html[data-theme="dark"] :is(
  .text-slate-400, .text-slate-300, .text-slate-200, .text-slate-100,
  .text-gray-400, .text-gray-300, .text-gray-200,
  .text-zinc-400, .text-zinc-300
),
html.dark :is(
  .text-slate-400, .text-slate-300, .text-slate-200,
  .text-gray-400, .text-gray-300
) {
  color: var(--tw-slate-faint) !important;
}

/* Attribute fallback for arbitrary/combined classes */
html[data-theme="dark"] [class*="text-slate-9"],
html[data-theme="dark"] [class*="text-slate-8"],
html[data-theme="dark"] [class*="text-slate-7"],
html[data-theme="dark"] [class*="text-gray-9"],
html[data-theme="dark"] [class*="text-gray-8"],
html[data-theme="dark"] [class*="text-gray-7"],
html.dark [class*="text-slate-9"],
html.dark [class*="text-slate-8"],
html.dark [class*="text-slate-7"] {
  color: var(--tw-slate-ink) !important;
}
html[data-theme="dark"] [class*="text-slate-6"],
html[data-theme="dark"] [class*="text-slate-5"],
html[data-theme="dark"] [class*="text-gray-6"],
html[data-theme="dark"] [class*="text-gray-5"],
html.dark [class*="text-slate-6"],
html.dark [class*="text-slate-5"] {
  color: var(--tw-slate-muted) !important;
}
html[data-theme="dark"] [class*="text-slate-4"],
html[data-theme="dark"] [class*="text-slate-3"],
html[data-theme="dark"] [class*="text-slate-2"],
html[data-theme="dark"] [class*="text-slate-1"],
html[data-theme="dark"] [class*="text-gray-4"],
html[data-theme="dark"] [class*="text-gray-3"],
html.dark [class*="text-slate-4"],
html.dark [class*="text-slate-3"] {
  color: var(--tw-slate-faint) !important;
}

/* Surfaces */
html[data-theme="dark"] :is(
  .bg-white, .bg-slate-50, .bg-slate-100, .bg-slate-200,
  .bg-gray-50, .bg-gray-100, .bg-zinc-50, .bg-zinc-100
),
html.dark :is(
  .bg-white, .bg-slate-50, .bg-slate-100, .bg-gray-50, .bg-gray-100
) {
  background-color: var(--tw-slate-surface) !important;
  color: var(--tw-slate-soft) !important;
}
html[data-theme="dark"] [class*="bg-white"],
html[data-theme="dark"] [class*="bg-slate-50"],
html[data-theme="dark"] [class*="bg-slate-100"],
html[data-theme="dark"] [class*="bg-gray-50"],
html.dark [class*="bg-white"],
html.dark [class*="bg-slate-50"] {
  background-color: var(--tw-slate-surface) !important;
}
html[data-theme="dark"] :is(
  .bg-slate-800, .bg-slate-900, .bg-gray-800, .bg-gray-900, .bg-zinc-900
),
html.dark :is(.bg-slate-800, .bg-slate-900, .bg-gray-900) {
  background-color: var(--tw-slate-surface-2) !important;
}

html[data-theme="dark"] :is(
  .border-slate-100, .border-slate-200, .border-slate-300,
  .border-gray-100, .border-gray-200, .border-gray-300,
  .border-zinc-200
),
html.dark :is(
  .border-slate-100, .border-slate-200, .border-slate-300,
  .border-gray-200
) {
  border-color: var(--tw-slate-border) !important;
}
html[data-theme="dark"] [class*="border-slate-1"],
html[data-theme="dark"] [class*="border-slate-2"],
html[data-theme="dark"] [class*="border-slate-3"],
html[data-theme="dark"] [class*="border-gray-1"],
html[data-theme="dark"] [class*="border-gray-2"],
html.dark [class*="border-slate-1"],
html.dark [class*="border-slate-2"] {
  border-color: var(--tw-slate-border) !important;
}

/* Dividers / rings */
html[data-theme="dark"] :is(.divide-slate-100, .divide-slate-200, .divide-gray-200) > :not([hidden]) ~ :not([hidden]),
html.dark :is(.divide-slate-200) > :not([hidden]) ~ :not([hidden]) {
  border-color: var(--tw-slate-border) !important;
}

/* Placeholder */
html[data-theme="dark"] :is(
  .placeholder-slate-400, .placeholder-slate-500, .placeholder-gray-400
)::placeholder,
html.dark .placeholder-slate-400::placeholder {
  color: var(--tw-slate-faint) !important;
}

/* ========== LIGHT ========== */
html[data-theme="light"] :is(
  .text-slate-500, .text-slate-400, .text-gray-500, .text-gray-400, .text-zinc-500
),
html[data-theme="light"] [class*="text-slate-5"],
html[data-theme="light"] [class*="text-slate-4"],
html[data-theme="light"] [class*="text-gray-5"],
html[data-theme="light"] [class*="text-gray-4"] {
  color: #334155 !important;
}
html[data-theme="light"] :is(
  .text-slate-300, .text-gray-300, .text-zinc-300
),
html[data-theme="light"] [class*="text-slate-3"] {
  color: #475569 !important;
}
html[data-theme="light"] :is(
  .text-slate-900, .text-slate-800, .text-slate-700, .text-gray-900, .text-gray-800
) {
  color: #0f172a !important;
}

/* ========== RESERVE ========== */
html[data-theme="reserve"] :is(
  .text-slate-500, .text-slate-400, .text-gray-500, .text-gray-400
),
html[data-theme="reserve"] [class*="text-slate-5"],
html[data-theme="reserve"] [class*="text-slate-4"] {
  color: #5c5248 !important;
}
html[data-theme="reserve"] :is(
  .text-slate-300, .text-gray-300
) {
  color: #78716c !important;
}
html[data-theme="reserve"] :is(
  .text-slate-900, .text-slate-800, .text-slate-700
) {
  color: #1f1b16 !important;
}
html[data-theme="reserve"] :is(
  .bg-white, .bg-slate-50, .bg-slate-100
) {
  background-color: #fffbf5 !important;
  color: #1f1b16 !important;
}
html[data-theme="reserve"] :is(
  .border-slate-100, .border-slate-200, .border-slate-300
) {
  border-color: #e5d9c5 !important;
}

/* ========== REPORT / NUMEROLOGY CONTAINERS ========== */
html[data-theme="dark"] #report-container,
html[data-theme="dark"] .nr-report,
html[data-theme="dark"] .rc-numero-shell,
html.dark #report-container,
html.dark .rc-numero-shell {
  color: var(--tw-slate-soft) !important;
}
html[data-theme="dark"] #report-container :is(
  .text-slate-900, .text-slate-800, .text-slate-700, .text-slate-600, .text-slate-500,
  .text-slate-400, .text-slate-300, h1, h2, h3, h4, p, li, td, th, label
),
html.dark #report-container :is(h1, h2, h3, p, li, td, th) {
  color: var(--tw-slate-soft) !important;
}
html[data-theme="dark"] #report-container :is(.bg-white, .bg-slate-50, .nr-card, .nr-growth-card, .card),
html.dark #report-container :is(.bg-white, .nr-card, .card) {
  background-color: var(--tw-slate-surface) !important;
  border-color: var(--tw-slate-border) !important;
  color: var(--tw-slate-ink) !important;
}

/* ========== MAINTENANCE SHELL ========== */
html[data-theme="dark"] .rc-cc-shell,
html.dark .rc-cc-shell {
  background: var(--tw-slate-surface) !important;
  border-color: var(--tw-slate-border) !important;
  color: var(--tw-slate-soft) !important;
}
html[data-theme="dark"] .rc-cc-shell [class*="text-slate"],
html.dark .rc-cc-shell [class*="text-slate"] {
  color: var(--tw-slate-muted) !important;
}
html[data-theme="dark"] .rc-cc-shell [class*="text-slate-9"],
html[data-theme="dark"] .rc-cc-shell [class*="text-slate-8"],
html[data-theme="dark"] .rc-cc-shell [class*="text-slate-7"] {
  color: var(--tw-slate-ink) !important;
}

/* ========== MODALS / FIXED OVERLAYS ========== */
html[data-theme="dark"] .fixed :is(.bg-white, .bg-slate-50, [class*="bg-white"]),
html.dark .fixed :is(.bg-white, .bg-slate-50) {
  background-color: var(--tw-slate-surface) !important;
  color: var(--tw-slate-soft) !important;
}
html[data-theme="dark"] .fixed [class*="text-slate-5"],
html[data-theme="dark"] .fixed [class*="text-slate-4"],
html.dark .fixed [class*="text-slate-5"] {
  color: var(--tw-slate-muted) !important;
}

/* ========== NEVER invert pure white text on accent buttons ========== */
html[data-theme] :is(
  .bg-emerald-600, .bg-blue-600, .bg-rose-600, .bg-indigo-600, .bg-\\[\\#1B75D0\\],
  [class*="bg-emerald-"], [class*="bg-blue-6"], [class*="bg-rose-"]
) .text-white,
html[data-theme] :is(button, a).text-white {
  color: #fff !important;
}

/* ========== PRINT: force dark ink ========== */
@media print {
  html, body, #rc-content, #report-container {
    color: #000 !important;
    background: #fff !important;
  }
  [class*="text-slate"], [class*="text-gray"] {
    color: #111 !important;
  }
}
