/* Styles globaux pour intégrer Quill avec le thème Tailwind */
/* Quill génère ses propres éléments DOM qui nécessitent des styles CSS directs */

/* Styles pour l'éditeur Quill */
[id*="-editor"] .ql-editor,
.quill-editor .ql-editor {
  background: white;
  color: #1e293b;
  min-height: 250px;
}

.dark [id*="-editor"] .ql-editor,
.dark .quill-editor .ql-editor {
  background: #1e293b; /* dark-surface */
  color: #f1f5f9; /* dark-text */
  min-height: 250px;
}

/*
 * IA / collage : spans ou blocs avec fond blanc/clair conservé dans le HTML sauvegardé.
 * Sans correctif, la couleur hérite du thème dark (clair) → illisible sur pastille blanche.
 */
.dark [id*="-editor"] .ql-editor *[style*="background-color: rgb(255, 255, 255)"],
.dark .quill-editor .ql-editor *[style*="background-color: rgb(255, 255, 255)"],
.dark [id*="-editor"] .ql-editor *[style*="background-color:rgb(255, 255, 255)"],
.dark .quill-editor .ql-editor *[style*="background-color:rgb(255, 255, 255)"],
.dark [id*="-editor"] .ql-editor *[style*="background-color: rgb(255,255,255)"],
.dark .quill-editor .ql-editor *[style*="background-color: rgb(255,255,255)"],
.dark [id*="-editor"] .ql-editor *[style*="background-color:rgb(255,255,255)"],
.dark .quill-editor .ql-editor *[style*="background-color:rgb(255,255,255)"],
.dark [id*="-editor"] .ql-editor *[style*="background-color: #ffffff"],
.dark .quill-editor .ql-editor *[style*="background-color: #ffffff"],
.dark [id*="-editor"] .ql-editor *[style*="background-color:#ffffff"],
.dark .quill-editor .ql-editor *[style*="background-color:#ffffff"],
.dark [id*="-editor"] .ql-editor *[style*="background-color: #fff"],
.dark .quill-editor .ql-editor *[style*="background-color: #fff"],
.dark [id*="-editor"] .ql-editor *[style*="background-color:#fff"],
.dark .quill-editor .ql-editor *[style*="background-color:#fff"],
.dark [id*="-editor"] .ql-editor *[style*="background-color: #FFF"],
.dark .quill-editor .ql-editor *[style*="background-color: #FFF"],
.dark [id*="-editor"] .ql-editor *[style*="background-color:#FFF"],
.dark .quill-editor .ql-editor *[style*="background-color:#FFF"],
.dark [id*="-editor"] .ql-editor *[style*="background-color: white"],
.dark .quill-editor .ql-editor *[style*="background-color: white"],
.dark [id*="-editor"] .ql-editor *[style*="background-color:white"],
.dark .quill-editor .ql-editor *[style*="background-color:white"],
.dark [id*="-editor"] .ql-editor *[style*="background:#ffffff"],
.dark .quill-editor .ql-editor *[style*="background:#ffffff"],
.dark [id*="-editor"] .ql-editor *[style*="background:#fff"],
.dark .quill-editor .ql-editor *[style*="background:#fff"],
.dark [id*="-editor"] .ql-editor *[style*="background:#FFF"],
.dark .quill-editor .ql-editor *[style*="background:#FFF"],
.dark [id*="-editor"] .ql-editor *[style*="background: rgb(255, 255, 255)"],
.dark .quill-editor .ql-editor *[style*="background: rgb(255, 255, 255)"],
.dark [id*="-editor"] .ql-editor *[style*="background:rgb(255, 255, 255)"],
.dark .quill-editor .ql-editor *[style*="background:rgb(255, 255, 255)"],
.dark [id*="-editor"] .ql-editor *[style*="background: rgb(255,255,255)"],
.dark .quill-editor .ql-editor *[style*="background: rgb(255,255,255)"],
.dark [id*="-editor"] .ql-editor *[style*="background:rgb(255,255,255)"],
.dark .quill-editor .ql-editor *[style*="background:rgb(255,255,255)"],
.dark [id*="-editor"] .ql-editor *[style*="background: white"],
.dark .quill-editor .ql-editor *[style*="background: white"],
.dark [id*="-editor"] .ql-editor *[style*="background:white"],
.dark .quill-editor .ql-editor *[style*="background:white"],
.dark [id*="-editor"] .ql-editor *[style*="hsl(0, 0%, 100%)"],
.dark .quill-editor .ql-editor *[style*="hsl(0, 0%, 100%)"] {
  color: #0f172a !important;
}

.dark [id*="-editor"] .ql-editor *[style*="background-color: rgb(255, 255, 255)"] *,
.dark .quill-editor .ql-editor *[style*="background-color: rgb(255, 255, 255)"] *,
.dark [id*="-editor"] .ql-editor *[style*="background-color:rgb(255, 255, 255)"] *,
.dark .quill-editor .ql-editor *[style*="background-color:rgb(255, 255, 255)"] *,
.dark [id*="-editor"] .ql-editor *[style*="background-color: rgb(255,255,255)"] *,
.dark .quill-editor .ql-editor *[style*="background-color: rgb(255,255,255)"] *,
.dark [id*="-editor"] .ql-editor *[style*="background-color:rgb(255,255,255)"] *,
.dark .quill-editor .ql-editor *[style*="background-color:rgb(255,255,255)"] *,
.dark [id*="-editor"] .ql-editor *[style*="background-color: #ffffff"] *,
.dark .quill-editor .ql-editor *[style*="background-color: #ffffff"] *,
.dark [id*="-editor"] .ql-editor *[style*="background-color:#ffffff"] *,
.dark .quill-editor .ql-editor *[style*="background-color:#ffffff"] *,
.dark [id*="-editor"] .ql-editor *[style*="background-color: #fff"] *,
.dark .quill-editor .ql-editor *[style*="background-color: #fff"] *,
.dark [id*="-editor"] .ql-editor *[style*="background-color:#fff"] *,
.dark .quill-editor .ql-editor *[style*="background-color:#fff"] *,
.dark [id*="-editor"] .ql-editor *[style*="background:#ffffff"] *,
.dark .quill-editor .ql-editor *[style*="background:#ffffff"] *,
.dark [id*="-editor"] .ql-editor *[style*="background:#fff"] *,
.dark .quill-editor .ql-editor *[style*="background:#fff"] *,
.dark [id*="-editor"] .ql-editor *[style*="background: rgb(255, 255, 255)"] *,
.dark .quill-editor .ql-editor *[style*="background: rgb(255, 255, 255)"] *,
.dark [id*="-editor"] .ql-editor *[style*="background:rgb(255, 255, 255)"] *,
.dark .quill-editor .ql-editor *[style*="background:rgb(255, 255, 255)"] *,
.dark [id*="-editor"] .ql-editor *[style*="background: rgb(255,255,255)"] *,
.dark .quill-editor .ql-editor *[style*="background: rgb(255,255,255)"] *,
.dark [id*="-editor"] .ql-editor *[style*="background:rgb(255,255,255)"] *,
.dark .quill-editor .ql-editor *[style*="background:rgb(255,255,255)"] *,
.dark [id*="-editor"] .ql-editor *[style*="background: white"] *,
.dark .quill-editor .ql-editor *[style*="background: white"] *,
.dark [id*="-editor"] .ql-editor *[style*="background:white"] *,
.dark .quill-editor .ql-editor *[style*="background:white"] *,
.dark [id*="-editor"] .ql-editor *[style*="background-color: white"] *,
.dark .quill-editor .ql-editor *[style*="background-color: white"] *,
.dark [id*="-editor"] .ql-editor *[style*="background-color:white"] *,
.dark .quill-editor .ql-editor *[style*="background-color:white"] *,
.dark [id*="-editor"] .ql-editor *[style*="background-color: #FFF"] *,
.dark .quill-editor .ql-editor *[style*="background-color: #FFF"] *,
.dark [id*="-editor"] .ql-editor *[style*="background-color:#FFF"] *,
.dark .quill-editor .ql-editor *[style*="background-color:#FFF"] *,
.dark [id*="-editor"] .ql-editor *[style*="background:#FFF"] *,
.dark .quill-editor .ql-editor *[style*="background:#FFF"] *,
.dark [id*="-editor"] .ql-editor *[style*="hsl(0, 0%, 100%)"] *,
.dark .quill-editor .ql-editor *[style*="hsl(0, 0%, 100%)"] * {
  color: inherit !important;
}

/*
 * Quill Snow définit `.ql-editor .ql-color-white { color: #fff }` (voir quill.snow.css).
 * En dark, cette couleur peut l'emporter sur nos correctifs lorsque le même span (ou un
 * enfant) a un fond blanc issu du collage ou de l’IA — texte blanc sur fond blanc.
 */
.dark [id*="-editor"] .ql-editor .ql-color-white,
.dark .quill-editor .ql-editor .ql-color-white {
  color: inherit !important;
}

/* Ancêtres fond blanc (inline / Word) → texte “white” forcé lisible */
.dark [id*="-editor"] .ql-editor :is(
  [style*="background-color: rgb(255, 255, 255)"],
  [style*="background-color:rgb(255, 255, 255)"],
  [style*="background-color: rgb(255,255,255)"],
  [style*="background-color:rgb(255,255,255)"],
  [style*="background-color: #ffffff"],
  [style*="background-color:#ffffff"],
  [style*="background-color: #fff"],
  [style*="background-color:#fff"],
  [style*="background-color: #FFF"],
  [style*="background-color:#FFF"],
  [style*="background-color: white"],
  [style*="background-color:white"],
  [style*="background:#ffffff"],
  [style*="background:#fff"],
  [style*="background:#FFF"],
  [style*="background: rgb(255, 255, 255)"],
  [style*="background:rgb(255, 255, 255)"],
  [style*="background: rgb(255,255,255)"],
  [style*="background:rgb(255,255,255)"],
  [style*="background: white"],
  [style*="background:white"],
  [style*="Background-color"][style*="255"],
  [style*="hsl(0, 0%, 100%)"],
  [bgcolor="#ffffff"],
  [bgcolor="#FFFFFF"],
  [bgcolor="#fff"],
  [bgcolor="#FFF"],
  [bgcolor="white"]) .ql-color-white,
.dark .quill-editor .ql-editor :is(
  [style*="background-color: rgb(255, 255, 255)"],
  [style*="background-color:rgb(255, 255, 255)"],
  [style*="background-color: rgb(255,255,255)"],
  [style*="background-color:rgb(255,255,255)"],
  [style*="background-color: #ffffff"],
  [style*="background-color:#ffffff"],
  [style*="background-color: #fff"],
  [style*="background-color:#fff"],
  [style*="background-color: #FFF"],
  [style*="background-color:#FFF"],
  [style*="background-color: white"],
  [style*="background-color:white"],
  [style*="background:#ffffff"],
  [style*="background:#fff"],
  [style*="background:#FFF"],
  [style*="background: rgb(255, 255, 255)"],
  [style*="background:rgb(255, 255, 255)"],
  [style*="background: rgb(255,255,255)"],
  [style*="background:rgb(255,255,255)"],
  [style*="background: white"],
  [style*="background:white"],
  [style*="Background-color"][style*="255"],
  [style*="hsl(0, 0%, 100%)"],
  [bgcolor="#ffffff"],
  [bgcolor="#FFFFFF"],
  [bgcolor="#fff"],
  [bgcolor="#FFF"],
  [bgcolor="white"]) .ql-color-white {
  color: #0f172a !important;
}

/* Même nœud : fond blanc + classe Quill « texte blanc » */
.dark [id*="-editor"] .ql-editor .ql-color-white:is(
  [style*="background-color: rgb(255, 255, 255)"],
  [style*="background-color:rgb(255, 255, 255)"],
  [style*="background-color: rgb(255,255,255)"],
  [style*="background-color:rgb(255,255,255)"],
  [style*="background-color: #ffffff"],
  [style*="background-color:#ffffff"],
  [style*="background-color: #fff"],
  [style*="background-color:#fff"],
  [style*="background-color: #FFF"],
  [style*="background-color:#FFF"],
  [style*="background-color: white"],
  [style*="background-color:white"],
  [style*="background:#ffffff"],
  [style*="background:#fff"],
  [style*="background:#FFF"],
  [style*="background: rgb(255, 255, 255)"],
  [style*="background:rgb(255, 255, 255)"],
  [style*="background: rgb(255,255,255)"],
  [style*="background:rgb(255,255,255)"],
  [style*="background: white"],
  [style*="background:white"],
  [style*="Background-color"][style*="255"],
  [style*="hsl(0, 0%, 100%)"],
  [bgcolor="#ffffff"],
  [bgcolor="#FFFFFF"],
  [bgcolor="#fff"],
  [bgcolor="#FFF"],
  [bgcolor="white"]),
.dark .quill-editor .ql-editor .ql-color-white:is(
  [style*="background-color: rgb(255, 255, 255)"],
  [style*="background-color:rgb(255, 255, 255)"],
  [style*="background-color: rgb(255,255,255)"],
  [style*="background-color:rgb(255,255,255)"],
  [style*="background-color: #ffffff"],
  [style*="background-color:#ffffff"],
  [style*="background-color: #fff"],
  [style*="background-color:#fff"],
  [style*="background-color: #FFF"],
  [style*="background-color:#FFF"],
  [style*="background-color: white"],
  [style*="background-color:white"],
  [style*="background:#ffffff"],
  [style*="background:#fff"],
  [style*="background:#FFF"],
  [style*="background: rgb(255, 255, 255)"],
  [style*="background:rgb(255, 255, 255)"],
  [style*="background: rgb(255,255,255)"],
  [style*="background:rgb(255,255,255)"],
  [style*="background: white"],
  [style*="background:white"],
  [style*="Background-color"][style*="255"],
  [style*="hsl(0, 0%, 100%)"],
  [bgcolor="#ffffff"],
  [bgcolor="#FFFFFF"],
  [bgcolor="#fff"],
  [bgcolor="#FFF"],
  [bgcolor="white"]) {
  color: #0f172a !important;
}

/* Conserver du texte blanc sur les pastilles de fond Quill prédéfinies */
.dark [id*="-editor"] .ql-editor :is(
  .ql-bg-black.ql-color-white,
  .ql-bg-blue.ql-color-white,
  .ql-bg-green.ql-color-white,
  .ql-bg-orange.ql-color-white,
  .ql-bg-purple.ql-color-white,
  .ql-bg-red.ql-color-white,
  .ql-bg-yellow.ql-color-white),
.dark .quill-editor .ql-editor :is(
  .ql-bg-black.ql-color-white,
  .ql-bg-blue.ql-color-white,
  .ql-bg-green.ql-color-white,
  .ql-bg-orange.ql-color-white,
  .ql-bg-purple.ql-color-white,
  .ql-bg-red.ql-color-white,
  .ql-bg-yellow.ql-color-white),
.dark [id*="-editor"] .ql-editor :is(.ql-bg-black, .ql-bg-blue, .ql-bg-green, .ql-bg-orange, .ql-bg-purple, .ql-bg-red, .ql-bg-yellow)
  .ql-color-white,
.dark .quill-editor .ql-editor :is(.ql-bg-black, .ql-bg-blue, .ql-bg-green, .ql-bg-orange, .ql-bg-purple, .ql-bg-red, .ql-bg-yellow)
  .ql-color-white {
  color: #ffffff !important;
}

/* Styles pour la toolbar Quill */
[id*="-editor"] .ql-toolbar,
.quill-editor .ql-toolbar {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.dark [id*="-editor"] .ql-toolbar,
.dark .quill-editor .ql-toolbar {
  background: #1e293b; /* dark-surface */
  border-color: #334155; /* dark-border */
}

/* Styles pour les icônes SVG de Quill */
[id*="-editor"] .ql-stroke,
.quill-editor .ql-stroke {
  stroke: #475569;
}

.dark [id*="-editor"] .ql-stroke,
.dark .quill-editor .ql-stroke {
  stroke: #cbd5e1; /* dark-text-muted */
}

[id*="-editor"] .ql-fill,
.quill-editor .ql-fill {
  fill: #475569;
}

.dark [id*="-editor"] .ql-fill,
.dark .quill-editor .ql-fill {
  fill: #cbd5e1; /* dark-text-muted */
}

[id*="-editor"] .ql-picker-label,
.quill-editor .ql-picker-label {
  color: #475569;
}

.dark [id*="-editor"] .ql-picker-label,
.dark .quill-editor .ql-picker-label {
  color: #cbd5e1; /* dark-text-muted */
}

/* Tableaux HTML natifs (Quill 2 + Showdown / quill-better-table-plus) */
.quill-editor .ql-editor table.analysis-table,
.quill-editor .ql-editor table.quill-better-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0;
  font-size: 0.9375rem;
  border: 1px solid #e2e8f0;
}
.quill-editor .ql-editor table.analysis-table th,
.quill-editor .ql-editor table.analysis-table td,
.quill-editor .ql-editor table.quill-better-table th,
.quill-editor .ql-editor table.quill-better-table td {
  border: 1px solid #e2e8f0;
  padding: 8px 10px;
  vertical-align: top;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.quill-editor .ql-editor table.analysis-table th,
.quill-editor .ql-editor table.quill-better-table th {
  background: #1e40af;
  color: #fff;
  font-weight: 600;
}
/* Listes dans les cellules : marges compactes (évite chevauchement / colonnes illisibles) */
.quill-editor .ql-editor table.analysis-table td ul,
.quill-editor .ql-editor table.analysis-table td ol,
.quill-editor .ql-editor table.quill-better-table td ul,
.quill-editor .ql-editor table.quill-better-table td ol {
  margin: 0.25rem 0 0.35rem 0;
  padding-left: 1.15rem;
}
.quill-editor .ql-editor table.analysis-table td li,
.quill-editor .ql-editor table.quill-better-table td li {
  margin: 0.12rem 0;
  padding-left: 0.1rem;
}
.quill-editor .ql-editor table.analysis-table td > p:first-child,
.quill-editor .ql-editor table.quill-better-table td > p:first-child {
  margin-top: 0;
}
.quill-editor .ql-editor table.analysis-table td > p:last-child,
.quill-editor .ql-editor table.quill-better-table td > p:last-child {
  margin-bottom: 0;
}
.dark .quill-editor .ql-editor table.analysis-table,
.dark .quill-editor .ql-editor table.quill-better-table {
  border-color: #334155;
}
.dark .quill-editor .ql-editor table.analysis-table th,
.dark .quill-editor .ql-editor table.analysis-table td,
.dark .quill-editor .ql-editor table.quill-better-table th,
.dark .quill-editor .ql-editor table.quill-better-table td {
  border-color: #334155;
}
.dark .quill-editor .ql-editor table.analysis-table th,
.dark .quill-editor .ql-editor table.quill-better-table th {
  background: #1d4ed8;
  color: #fff;
}
.dark .quill-editor .ql-editor table.analysis-table td,
.dark .quill-editor .ql-editor table.quill-better-table td {
  background: #0f172a;
  color: #e2e8f0;
}
.dark .quill-editor .ql-editor table.analysis-table td ul,
.dark .quill-editor .ql-editor table.analysis-table td ol,
.dark .quill-editor .ql-editor table.quill-better-table td ul,
.dark .quill-editor .ql-editor table.quill-better-table td ol {
  color: #e2e8f0;
}

/* Ancien rendu div-table Quill 1 (contenus historiques) */
.quill-editor .ql-editor .gpp-quill-table {
  display: table;
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.quill-editor .ql-editor .gpp-quill-table-row {
  display: table-row;
}
.quill-editor .ql-editor .gpp-quill-table-cell {
  display: table-cell;
  padding: 10px 14px;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: top;
  word-break: break-word;
  color: #1e293b;
  font-size: 0.9375rem;
  line-height: 1.45;
}
.quill-editor .ql-editor .gpp-quill-table-row:last-child .gpp-quill-table-cell {
  border-bottom: none;
}
.quill-editor .ql-editor .gpp-quill-th {
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
  color: #fff !important;
  font-weight: 600;
  border-bottom: 1px solid #2563eb;
}
.quill-editor .ql-editor .gpp-quill-table-row:nth-child(even) .gpp-quill-table-cell:not(.gpp-quill-th) {
  background: #f8fafc;
}

.dark .quill-editor .ql-editor .gpp-quill-table {
  border-color: #334155;
  background: #0f172a;
}
.dark .quill-editor .ql-editor .gpp-quill-table-cell {
  border-bottom-color: #334155;
  color: #e2e8f0 !important;
  background: #0f172a !important;
}
.dark .quill-editor .ql-editor .gpp-quill-table-row:nth-child(even) .gpp-quill-table-cell:not(.gpp-quill-th) {
  background: #1e293b !important;
}
.dark .quill-editor .ql-editor .gpp-quill-th {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  color: #fff !important;
  border-bottom-color: #1d4ed8;
}

/*
 * Inline <code> : Quill Snow/Bubble impose background-color:#f0f0f0.
 * En mode sombre le texte hérite du gris clair → illisible. Fond noir uniquement en .dark.
 */
.dark .ql-editor code,
.dark .ql-snow .ql-editor code,
.dark .ql-bubble .ql-editor code,
.dark [id*="-editor"] .ql-editor code,
.dark .quill-editor .ql-editor code,
.dark .ql-editor kbd,
.dark .ql-snow .ql-editor kbd,
.dark .ql-bubble .ql-editor kbd,
.dark [id*="-editor"] .ql-editor kbd,
.dark .quill-editor .ql-editor kbd,
.dark .ql-editor samp,
.dark .ql-snow .ql-editor samp,
.dark .ql-bubble .ql-editor samp,
.dark [id*="-editor"] .ql-editor samp,
.dark .quill-editor .ql-editor samp {
  background-color: #000 !important;
  color: #e2e8f0 !important;
  border: 1px solid #334155;
}
.dark .ql-editor pre:not(.ql-syntax),
.dark .ql-snow .ql-editor pre:not(.ql-syntax),
.dark .ql-bubble .ql-editor pre:not(.ql-syntax),
.dark [id*="-editor"] .ql-editor pre:not(.ql-syntax),
.dark .quill-editor .ql-editor pre:not(.ql-syntax) {
  background-color: #000 !important;
  color: #e2e8f0 !important;
  border: 1px solid #334155;
  border-radius: 3px;
  padding: 0.5em 0.75em;
}
.dark .ql-editor pre code,
.dark .ql-snow .ql-editor pre code,
.dark .ql-bubble .ql-editor pre code,
.dark [id*="-editor"] .ql-editor pre code,
.dark .quill-editor .ql-editor pre code {
  background: transparent !important;
  border: none;
  padding: 0;
}


