/* ============================================================
   V83.3 — UX READABILITY GLOBAL FIX (doctrine 16+74+nickel)
   - Bans cream-on-cream, dark-on-dark, white-on-white
   - Standardise contrast WCAG AA minimum on common patterns
   - Idempotent: prefixed selectors targeting only known issues
   ============================================================ */

/* 1. Cards/tiles avec fond clair: forcer texte foncé lisible */
body.theme-light .quick-card,
body.theme-light .vm-card,
body.theme-light .stat-tile,
body.theme-light .wtp-tile,
body.theme-light [data-d441="business-kpi"] > div {
  color: #1f2937 !important;
}
body.theme-light .quick-card .desc,
body.theme-light .vm-card .vm-card-title,
body.theme-light .wtp-tile-title {
  color: #1f2937 !important;
}

/* 2. Pills colorées sur fond clair: garder texte blanc/sombre selon bg */
body.theme-light .alert-chip.warn,
body.theme-light .alert-chip.crit {
  color: #fff !important;
  background: #b45309 !important;
}
body.theme-light .alert-chip.info {
  color: #1e3a8a !important;
  background: #dbeafe !important;
}
body.theme-light .alert-chip.ok {
  color: #064e3b !important;
  background: #d1fae5 !important;
}

/* 3. Status pills/badges: pas de transparent sur fond similaire */
body.theme-light .health-pill {
  background: #fff !important;
  border: 1px solid #d4c8b8 !important;
  color: #1f2937 !important;
}
body.theme-light .health-pill.ok { border-color: #10b981 !important; color: #065f46 !important; }
body.theme-light .health-pill.warn { border-color: #f59e0b !important; color: #92400e !important; background: #fef3c7 !important; }
body.theme-light .health-pill.crit { border-color: #ef4444 !important; color: #991b1b !important; background: #fee2e2 !important; }

/* 4. Source citations subtiles mais lisibles */
body.theme-light [style*="color:#999"],
body.theme-light .wtp-source-cite,
body.theme-light .src-tag {
  color: #6b7280 !important;
}

/* 5. Drilldown rows lisibles */
body.theme-light .dd-status,
body.theme-light .dd-status.warn,
body.theme-light .dd-status.crit {
  color: #1f2937 !important;
}

/* 6. Dark theme: éviter dark-on-dark */
body:not(.theme-light) .alert-chip.info {
  color: #93c5fd !important;
  background: rgba(30, 58, 138, .35) !important;
  border: 1px solid rgba(147, 197, 253, .35) !important;
}
body:not(.theme-light) .quick-card,
body:not(.theme-light) .vm-card,
body:not(.theme-light) .stat-tile {
  color: #e2e8f0 !important;
}

/* 7. Watermark D92 footer: toujours lisible */
#opus-d92-masterdata-tag {
  color: #475569 !important;
  background: rgba(255,255,255,.85) !important;
  border: 1px solid rgba(0,0,0,.08) !important;
}
body:not(.theme-light) #opus-d92-masterdata-tag {
  color: #94a3b8 !important;
  background: rgba(15,23,42,.85) !important;
  border: 1px solid rgba(255,255,255,.1) !important;
}

/* 8. Anti-overlap fixed elements vs content */
[data-d441="business-kpi"] {
  padding-right: 240px !important;
}
@media(max-width:1100px){
  [data-d441="business-kpi"] { padding-right: 32px !important; }
}

/* 9. Tableau drilldown: ne jamais rendre 2 cellules de même couleur */
body.theme-light table tr td,
body.theme-light table tr th {
  color: #1f2937 !important;
}

/* 10. Inputs/buttons: contraste minimal */
body.theme-light input::placeholder { color: #9ca3af !important; }
body.theme-light button { color: inherit !important; }

/* ============================================================
   V83.3.1 — Cognitive Opus cards + sections texte clair sur fond clair
   ============================================================ */

/* Cards Cognitive (gradient sombre) — garder lisible en theme light aussi */
body.theme-light div[style*="rgba(168,85,247,.12)"][style*="rgba(0,0,0,.25)"],
body.theme-light div[style*="rgba(99,102,241,.12)"][style*="rgba(0,0,0,.25)"],
body.theme-light div[style*="rgba(34,197,94,.12)"][style*="rgba(0,0,0,.25)"],
body.theme-light div[style*="rgba(251,146,60,.12)"][style*="rgba(0,0,0,.25)"],
body.theme-light div[style*="rgba(236,72,153,.12)"][style*="rgba(0,0,0,.25)"],
body.theme-light div[style*="rgba(20,184,166,.12)"][style*="rgba(0,0,0,.25)"] {
  background: linear-gradient(135deg, rgba(99,102,241,.06), rgba(99,102,241,.12)) !important;
  border: 1px solid rgba(99,102,241,.30) !important;
  color: #1f2937 !important;
}

/* Forcer les enfants des cards cognitive à etre lisibles en light */
body.theme-light div[style*="rgba(0,0,0,.25)"] > div[style*="color:#fff"] {
  color: #1f2937 !important;
}
body.theme-light div[style*="rgba(0,0,0,.25)"] > div[style*="color:#94a3b8"] {
  color: #4b5563 !important;
}
body.theme-light div[style*="rgba(0,0,0,.25)"] span[style*="color:#94a3b8"] {
  color: #6b7280 !important;
}

/* Live status block (rgba(0,0,0,.30) fond) */
body.theme-light div[style*="rgba(0,0,0,.30)"] {
  background: rgba(241, 245, 249, .9) !important;
  color: #1f2937 !important;
}
body.theme-light div[style*="rgba(0,0,0,.30)"] div[style*="color:#cbd5e1"],
body.theme-light div[style*="rgba(0,0,0,.30)"] [style*="color:#cbd5e1"] {
  color: #1f2937 !important;
}

/* Boutons style sombres en light (Wiki/Bootstrap source/Tips Catalog/Dormants) */
body.theme-light a[style*="background:#1f2937"] {
  background: #f1f5f9 !important;
  color: #1f2937 !important;
  border: 1px solid rgba(0,0,0,.1) !important;
}

/* Labels uppercase pâles dans cards cognitive */
body.theme-light [style*="color:#c4b5fd"] { color: #6d28d9 !important; }
body.theme-light [style*="color:#a5b4fc"] { color: #4338ca !important; }
body.theme-light [style*="color:#86efac"] { color: #047857 !important; }
body.theme-light [style*="color:#fdba74"] { color: #c2410c !important; }
body.theme-light [style*="color:#f9a8d4"] { color: #be185d !important; }
body.theme-light [style*="color:#5eead4"] { color: #0f766e !important; }
