/* ============================================================================
   CONTRASTE FINO — camada GLOBAL de correção de tema (claro/escuro).
   Conserta os "detalhes" que escapam: modais/overlays/cards construídos com
   COR FIXA inline (background/color #hex) que não viravam no tema oposto —
   texto claro em fundo claro, layout escuro no tema claro, etc.

   Como funciona: no body.theme-light, vira a PALETA ESCURA recorrente -> clara
   e os TEXTOS claros/mutados -> escuros, via seletor [style*=] (estilo inline).
   É um FALLBACK: as regras por-módulo (escopadas a #id/.classe) são mais
   específicas e continuam vencendo onde já acertam — aqui só pega o que ficou
   órfão. Tema ESCURO fica 100% intocado (tudo é body.theme-light).

   ⚠️ As PROTEÇÕES no fim re-afirmam texto branco nas superfícies COLORIDAS de
   marca (roxo/gradiente/verde/vermelho/azul), que continuam escuras nos 2 temas
   — sem isso, o flip de color:#fff apagaria o texto dos botões. A ordem importa:
   o flip vem ANTES, as proteções DEPOIS (mesma especificidade -> a última vence).
   ============================================================================ */

/* ---------- A) FUNDOS escuros recorrentes -> claros ---------- */

/* quase-preto / mais escuros -> branco */
body.theme-light [style*="background:#020617"],
body.theme-light [style*="background:#0b1020"],
body.theme-light [style*="background:#0f1117"],
body.theme-light [style*="background:#111827"],
body.theme-light [style*="background:#120c1c"],
body.theme-light [style*="background:#13101c"],
body.theme-light [style*="background:#14161D"],
body.theme-light [style*="background:#14161d"],
body.theme-light [style*="background:#15101f"],
body.theme-light [style*="background:#171221"],
body.theme-light [style*="background:#0d0a14"]{ background:#ffffff !important; }

/* superfícies escuras (cards, inputs, modais) -> lilás muito claro */
body.theme-light [style*="background:#1a1228"],
body.theme-light [style*="background:#1a1428"],
body.theme-light [style*="background:#1b1228"],
body.theme-light [style*="background:#1b1e27"],
body.theme-light [style*="background:#1d1630"],
body.theme-light [style*="background:#1e293b"],
body.theme-light [style*="background:#1f2230"],
body.theme-light [style*="background:#1f2937"],
body.theme-light [style*="background:#23262F"],
body.theme-light [style*="background:#23262f"],
body.theme-light [style*="background:#262a37"],
body.theme-light [style*="background:#3a2330"]{ background:#F4F1F8 !important; }

/* elevações / badges escuros -> lilás claro */
body.theme-light [style*="background:#241830"],
body.theme-light [style*="background:#334155"],
body.theme-light [style*="background:#2a2440"],
body.theme-light [style*="background:#3a2a48"]{ background:#EBE3F3 !important; }

/* status escuros (toast/avisos) -> tinta clara semântica */
body.theme-light [style*="background:#14532d"],
body.theme-light [style*="background:#1f3a2a"]{ background:#dcfce7 !important; color:#14532d !important; }
body.theme-light [style*="background:#450a0a"],
body.theme-light [style*="background:#7a2418"]{ background:#fee2e2 !important; color:#991b1b !important; }
body.theme-light [style*="background:#3a2710"],
body.theme-light [style*="background:#422006"]{ background:#fef3c7 !important; color:#854d0e !important; }

/* ---------- B) TEXTOS claros/mutados -> escuros ---------- */

/* texto quase-branco -> tinta */
body.theme-light [style*="color:#e2e8f0"],
body.theme-light [style*="color:#f1f5f9"],
body.theme-light [style*="color:#f3f4f6"],
body.theme-light [style*="color:#f4f1fa"],
body.theme-light [style*="color:#E6DBF0"],
body.theme-light [style*="color:#e6dbf0"],
body.theme-light [style*="color:#e5e7eb"]{ color:#1F1F1F !important; }

/* mutados claros (cinza/lilás secundário) -> cinza-tinta legível */
body.theme-light [style*="color:#9a90b0"],
body.theme-light [style*="color:#9aa0aa"],
body.theme-light [style*="color:#9a8fb3"],
body.theme-light [style*="color:#9a8aa8"],
body.theme-light [style*="color:#9aa3b2"],
body.theme-light [style*="color:#9a9aa3"],
body.theme-light [style*="color:#8a909c"],
body.theme-light [style*="color:#8A909C"],
body.theme-light [style*="color:#8b83a0"],
body.theme-light [style*="color:#8a78a8"],
body.theme-light [style*="color:#7a5e93"],
body.theme-light [style*="color:#6b577f"],
body.theme-light [style*="color:#6b7280"],
body.theme-light [style*="color:#9ca3af"],
body.theme-light [style*="color:#94a3b8"],
body.theme-light [style*="color:#cbd5e1"],
body.theme-light [style*="color:#c9c2d8"],
body.theme-light [style*="color:#cbbfe0"],
body.theme-light [style*="color:#cabfe0"]{ color:#6b6480 !important; }

/* lilás claro (roxo secundário) -> roxo escuro (mantém identidade) */
body.theme-light [style*="color:#b79ad6"],
body.theme-light [style*="color:#c9bfda"],
body.theme-light [style*="color:#c4b5fd"],
body.theme-light [style*="color:#d8b4fe"],
body.theme-light [style*="color:#b9a7d4"],
body.theme-light [style*="color:#D9C2F0"],
body.theme-light [style*="color:#9b6fd4"]{ color:#7c3ab7 !important; }

/* ---------- C) color:#fff / branco -> tinta (com proteções abaixo) ---------- */
body.theme-light [style*="color:#fff"],
body.theme-light [style*="color:#ffffff"],
body.theme-light [style*="color:#FFF"],
body.theme-light [style*="color:white"]{ color:#1F1F1F !important; }

/* ---------- PROTEÇÕES: superfícies COLORIDAS mantêm texto branco ----------
   (vêm DEPOIS do flip de #fff — mesma especificidade, a última regra vence) */
body.theme-light [style*="background:#5B1F7E"],
body.theme-light [style*="background:#5b1f7e"],
body.theme-light [style*="background:#3C1457"],
body.theme-light [style*="background:#3c1457"],
body.theme-light [style*="background:#6c2796"],
body.theme-light [style*="background:#7C3AB7"],
body.theme-light [style*="background:#7c3ab7"],
body.theme-light [style*="background:#2a1140"],
body.theme-light [style*="background:linear-gradient"],
body.theme-light [style*="background:#16a34a"],
body.theme-light [style*="background:#15803d"],
body.theme-light [style*="background:#22c55e"],
body.theme-light [style*="background:#dc2626"],
body.theme-light [style*="background:#ef4444"],
body.theme-light [style*="background:#b91c1c"],
body.theme-light [style*="background:#0ea5e9"],
body.theme-light [style*="background:#2563eb"],
body.theme-light [style*="background:#1d4ed8"],
body.theme-light [style*="background:#ec4899"]{ color:#ffffff !important; }

/* ouro (#D4AF37) como FUNDO usa texto escuro (já é o padrão do app) */
body.theme-light [style*="background:#D4AF37"],
body.theme-light [style*="background:#d4af37"]{ color:#3a2b06 !important; }

/* ============================================================================
   D) Correções ESTRUTURAIS dos modais core (100% inline, sem cobertura):
   modalSistemaPlataforma (confirm/aviso branded), toast, loading overlay.
   ============================================================================ */
body.theme-light #modalSistemaPlataforma [style*="color:#94a3b8"]{ color:#51455A !important; }
body.theme-light #modalSistemaCancelar{ color:#51455A !important; border-color:#D8CDDF !important; }
body.theme-light #modalSistemaCancelar:hover{ background:#EFE7F5 !important; color:#1F1F1F !important; }
body.theme-light #avance-loading-overlay [style*="color:#6b7280"],
body.theme-light #avance-loading-overlay p{ color:#51455A !important; }

/* ---------- E) Stragglers (tema claro): fundos e textos-acento que escaparam ---------- */
body.theme-light [style*="background:#16111c"],
body.theme-light [style*="background:#120e17"],
body.theme-light [style*="background:#16161d"]{ background:#ffffff !important; }
body.theme-light [style*="color:#cfc7de"],
body.theme-light [style*="color:#d1d5db"],
body.theme-light [style*="color:#cabfe0"]{ color:#6b6480 !important; }
/* textos de STATUS claros -> versão escura legível no claro */
body.theme-light [style*="color:#6ee7b7"],
body.theme-light [style*="color:#46d39a"],
body.theme-light [style*="color:#34d399"],
body.theme-light [style*="color:#86efac"]{ color:#15803d !important; }
body.theme-light [style*="color:#fca5a5"],
body.theme-light [style*="color:#f87171"]{ color:#b91c1c !important; }
body.theme-light [style*="color:#fde68a"],
body.theme-light [style*="color:#fcd34d"],
body.theme-light [style*="color:#eab308"],
body.theme-light [style*="color:#E6C158"],
body.theme-light [style*="color:#e6c158"]{ color:#8a6d12 !important; }
body.theme-light [style*="color:#93c5fd"],
body.theme-light [style*="color:#60a5fa"]{ color:#1d4ed8 !important; }

/* ============================================================================
   F) DIREÇÃO REVERSA — TEMA ESCURO: texto ESCURO fixo -> claro
   (conserta "letras escuras quase ilegíveis no tema escuro"). NÃO mexe em
   fundos (pra não quebrar páginas brancas legítimas, tipo e-book/canvas);
   só vira o TEXTO escuro -> claro, e PROTEGE superfícies claras (cards brancos)
   re-afirmando texto escuro nelas.
   ============================================================================ */
body:not(.theme-light) [style*="color:#111827"],
body:not(.theme-light) [style*="color:#1F1F1F"],
body:not(.theme-light) [style*="color:#1f1f1f"],
body:not(.theme-light) [style*="color:#0f172a"],
body:not(.theme-light) [style*="color:#1e293b"],
body:not(.theme-light) [style*="color:#334155"],
body:not(.theme-light) [style*="color:#374151"],
body:not(.theme-light) [style*="color:#000000"],
body:not(.theme-light) [style*="color:black"]{ color:#ECE8F2 !important; }
/* PROTEÇÃO: superfícies CLARAS mantêm texto escuro (cards brancos, e-book, prévia de lista) */
body:not(.theme-light) [style*="background:#fff"],
body:not(.theme-light) [style*="background:#ffffff"],
body:not(.theme-light) [style*="background:white"],
body:not(.theme-light) [style*="background:#f9fafb"],
body:not(.theme-light) [style*="background:#f8fafc"],
body:not(.theme-light) [style*="background:#f3f4f6"],
body:not(.theme-light) [style*="background:#f4f4f5"],
body:not(.theme-light) [style*="background:#e5e7eb"],
body:not(.theme-light) [style*="background:#e2e8f0"],
body:not(.theme-light) [style*="background:#faf5ff"],
body:not(.theme-light) [style*="background:#F4F1F8"],
body:not(.theme-light) [style*="background:#FBF8FE"],
body:not(.theme-light) [style*="background:#F6F1FB"],
body:not(.theme-light) [style*="background:#EEEDFE"],
body:not(.theme-light) [style*="background:#fef3c7"],
body:not(.theme-light) [style*="background:#dcfce7"],
body:not(.theme-light) [style*="background:#fee2e2"]{ color:#1F1F1F !important; }
