/* ===== Base ===== */
body {
  font-feature-settings: "liga", "calt";
  -webkit-font-smoothing: antialiased;
}
.whitespace-pre-wrap {
  word-break: normal;
  overflow-wrap: break-word;
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ===== HTMX indicators ===== */
.htmx-indicator { opacity: 0; transition: opacity 0.2s ease; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* ===== Historique session (chips sous l'input) ===== */
#history-chips { min-height: 24px; }
#history-chips .chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  margin: 2px;
  background: white;
  border: 1px solid #e0ddd5;
  border-radius: 999px;
  font-size: 11px;
  color: #6b7280;
  cursor: pointer;
  max-width: 260px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  transition: all 0.15s ease;
}
#history-chips .chip:hover {
  background: #ecf5ef;
  border-color: #2d6a4f;
  color: #2d6a4f;
}

/* ===== Feedback bouton copier ===== */
.btn-copied {
  background: #2d6a4f !important;
  color: white !important;
  border-color: #2d6a4f !important;
}

/* ===== Rendu markdown arabe (.prose-ar) ===== */
.prose-ar {
  direction: rtl;
  text-align: right;
  line-height: 2;
  font-size: 15.5px;
  color: #2a2a2a;
}
.prose-ar > :first-child { margin-top: 0; }
.prose-ar > :last-child  { margin-bottom: 0; }

/* Titres */
.prose-ar h1, .prose-ar h2, .prose-ar h3, .prose-ar h4, .prose-ar h5 {
  font-weight: 800;
  line-height: 1.5;
  color: #1f4d39;
  margin-top: 1.4em;
  margin-bottom: 0.5em;
}
.prose-ar h1 { font-size: 1.4rem; }
.prose-ar h2 { font-size: 1.25rem; border-bottom: 2px solid #d7e7dd; padding-bottom: 4px; }
.prose-ar h3 { font-size: 1.1rem;  color: #2d6a4f; }
.prose-ar h4 {
  font-size: 1rem;
  color: #5a2d82;
  background: linear-gradient(to right, #f6efff 0%, transparent 60%);
  padding: 4px 10px;
  border-right: 3px solid #a578d6;
  border-radius: 4px;
}
.prose-ar h5 { font-size: 0.95rem; color: #8a7000; }

/* Paragraphes */
.prose-ar p { margin: 0.6em 0; }

/* Emphase */
.prose-ar strong, .prose-ar b {
  color: #1f4d39;
  font-weight: 700;
  background: linear-gradient(180deg, transparent 62%, #d7e7dd 62%, #d7e7dd 92%, transparent 92%);
  padding: 0 2px;
}
.prose-ar em, .prose-ar i { color: #5a2d82; font-style: normal; font-weight: 600; }

/* Listes */
.prose-ar ul, .prose-ar ol {
  padding-right: 1.4em;
  padding-left: 0;
  margin: 0.6em 0;
}
.prose-ar ul { list-style: disc; }
.prose-ar ol { list-style: arabic-indic; }
.prose-ar li { margin: 0.35em 0; padding-right: 0.2em; }
.prose-ar li::marker { color: #2d6a4f; font-weight: 700; }
.prose-ar li > ul, .prose-ar li > ol { margin: 0.25em 0; }

/* Citations (versets / blockquotes markdown) */
.prose-ar blockquote {
  border-right: 4px solid #2d6a4f;
  border-left: 0;
  background: #f4faf6;
  padding: 10px 14px;
  margin: 0.8em 0;
  border-radius: 6px;
  color: #1f3d2e;
  font-size: 1.02em;
  line-height: 2.1;
}
.prose-ar blockquote p { margin: 0.3em 0; }

/* Code inline (pour références type [1]) */
.prose-ar code {
  background: #eef5f0;
  color: #1f4d39;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.88em;
  font-family: "Menlo", "Consolas", monospace;
  direction: ltr;
  display: inline-block;
}

/* Séparateurs */
.prose-ar hr {
  border: 0;
  height: 1px;
  background: linear-gradient(to left, transparent, #cfd6c8, transparent);
  margin: 1.2em 0;
}

/* Tableaux (rare mais possible) */
.prose-ar table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.8em 0;
  font-size: 0.95em;
}
.prose-ar th, .prose-ar td {
  border: 1px solid #e0ddd5;
  padding: 6px 10px;
  text-align: right;
}
.prose-ar th { background: #f4faf6; color: #1f4d39; font-weight: 700; }

/* Variantes de couleur */
.prose-ar-purple h1, .prose-ar-purple h2, .prose-ar-purple h3 { color: #5a2d82; }
.prose-ar-purple h2 { border-bottom-color: #e0d0f0; }
.prose-ar-purple strong, .prose-ar-purple b {
  color: #5a2d82;
  background: linear-gradient(180deg, transparent 62%, #efe1fb 62%, #efe1fb 92%, transparent 92%);
}
.prose-ar-purple li::marker { color: #5a2d82; }
.prose-ar-purple blockquote {
  border-right-color: #8b5fbf;
  background: #faf5ff;
  color: #3f1f66;
}

.prose-ar-gold h1, .prose-ar-gold h2, .prose-ar-gold h3 { color: #8a7000; }
.prose-ar-gold strong, .prose-ar-gold b {
  color: #6a5600;
  background: linear-gradient(180deg, transparent 62%, #fdf3c4 62%, #fdf3c4 92%, transparent 92%);
}
.prose-ar-gold li::marker { color: #8a7000; }
.prose-ar-gold blockquote {
  border-right-color: #b8a000;
  background: #fffdf0;
  color: #5c4a00;
}
