/* ============================================================
   ONGLET "CRÉATEUR IA" — styles spécifiques
   ============================================================
   Réutilise .panel / .btn / .btn-ghost / .field / .exam-card-head /
   .sub / .empty-state / .auth-error / .auth-success déjà définis dans
   styles.css. N'ajoute que ce qui est propre à cet onglet.

   --ai-ink-blue reprend le bleu déjà utilisé pour les en-têtes de PDF
   (rgb(31,78,140) dans new-exam.js/corrections.js) ; --ai-ink-red est
   l'équivalent "encre rouge de correction". Si styles.css définit déjà
   des variables équivalentes, remplacez les deux lignes ci-dessous par
   var(--votre-variable) pour rester parfaitement cohérent.
   ============================================================ */

#tab-ai-creator {
  --ai-ink-blue: #1f4e8c;
  --ai-ink-red: #a8342a;
  --ai-ink-green: #2f6b3a;
  --ai-paper-line: #d8d2c4;
}

/* ---------------- Zone de dépôt ---------------- */

.ai-drop-zone {
  border: 2px dashed var(--ai-paper-line);
  border-radius: 8px;
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease;
  margin: 14px 0;
}

.ai-drop-zone:hover,
.ai-drop-zone.is-dragover {
  border-color: var(--ai-ink-blue);
  background: rgba(31, 78, 140, 0.04);
}

.ai-drop-icon {
  font-size: 28px;
  color: var(--ai-ink-blue);
  margin-bottom: 6px;
}

.ai-drop-text {
  font-weight: 600;
}

.ai-drop-hint {
  font-size: 12px;
  opacity: .65;
  margin-top: 4px;
}

.ai-file-name {
  margin-top: 10px;
  font-family: monospace;
  font-size: 13px;
}

/* ---------------- Durée de l'épreuve ---------------- */

.ai-duration-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ai-duration-row input {
  width: 90px;
}

.ai-file-error {
  color: var(--ai-ink-red);
  font-size: 13px;
  margin: 6px 0 14px;
}

/* ---------------- Chargement ---------------- */

.ai-loading-panel {
  text-align: center;
  padding: 48px 20px;
}

.ai-spinner-lg {
  width: 34px;
  height: 34px;
  margin: 0 auto 16px;
  border: 3px solid var(--ai-paper-line);
  border-top-color: var(--ai-ink-blue);
  border-radius: 50%;
  animation: ai-spin 0.8s linear infinite;
}

@keyframes ai-spin {
  to { transform: rotate(360deg); }
}

/* ---------------- Badges ---------------- */

.ai-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.ai-badge-green {
  background: rgba(47, 107, 58, 0.12);
  color: var(--ai-ink-green);
}

.ai-badge-orange {
  background: rgba(196, 130, 30, 0.14);
  color: #a56417;
}

/* ---------------- Sections de révision ---------------- */

#ai-review-sections {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin: 16px 0;
}

.ai-section-card {
  border: 1px solid var(--ai-paper-line);
  border-radius: 8px;
  padding: 16px;
}

.ai-section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
  gap: 10px;
  flex-wrap: wrap;
}

.ai-section-title {
  font-weight: 700;
  font-family: Georgia, "Times New Roman", serif;
}

.ai-section-type {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  opacity: .6;
}

.ai-score-editor {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 14px;
  font-size: 13px;
}

.ai-score-editor .ai-total-input {
  width: 70px;
}

.ai-schreiben-editor {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 0;
}

.ai-schreiben-editor input {
  width: 80px;
}

.ai-writing-block {
  font-size: 13px;
  line-height: 1.6;
}

/* ---------------- Questions ---------------- */

.ai-questions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-question-row {
  display: grid;
  grid-template-columns: 28px 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px dotted var(--ai-paper-line);
  font-size: 13px;
}

.ai-question-row:last-child {
  border-bottom: none;
}

.ai-qnum {
  font-family: monospace;
  opacity: .6;
}

.ai-qtext {
  overflow-wrap: anywhere;
}

.ai-answer-select,
.ai-answer-input {
  font-size: 13px;
  max-width: 220px;
}

.ai-qanswer-readonly {
  font-size: 13px;
  color: var(--ai-ink-blue);
  font-weight: 600;
  text-align: right;
}

.ai-tf-toggle {
  display: flex;
  gap: 4px;
}

.ai-tf-btn {
  font-size: 12px;
  padding: 4px 10px;
  border: 1px solid var(--ai-paper-line);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}

.ai-tf-btn.active {
  background: var(--ai-ink-blue);
  border-color: var(--ai-ink-blue);
  color: #fff;
}

/* ---------------- Audio ---------------- */

.ai-audio-block {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 13px;
}

.ai-audio-missing {
  background: rgba(168, 52, 42, 0.08);
  color: var(--ai-ink-red);
}

.ai-audio-ok {
  background: rgba(47, 107, 58, 0.06);
}

.ai-audio-ok audio {
  height: 32px;
  max-width: 260px;
}

.ai-audio-script {
  font-size: 12px;
  max-width: 100%;
}

.ai-audio-script p {
  white-space: pre-wrap;
}

/* ---------------- Liste des examens existants ---------------- */

.ai-existing-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--ai-paper-line);
  font-size: 13px;
}
.ai-existing-row .btn-ghost {
  width: auto;
  min-height: 34px;
  padding: 6px 12px;
  font-size: 12px;
}

/* Bouton "Supprimer" — mode admin uniquement (voir refreshAiExamCreatorList
   dans ai-exam-creator.js), pour une épreuve officielle visible par
   toutes les écoles. Rouge pour bien le distinguer de "Lire l'épreuve". */
.ai-delete-exam-btn {
  color: var(--ai-ink-red);
  border-color: var(--ai-ink-red);
}
.ai-delete-exam-btn:hover {
  background: rgba(168, 52, 42, 0.08);
}

.ai-existing-row:last-child {
  border-bottom: none;
}

/* ---------------- Modale audio ---------------- */

.ai-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 20, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}

.ai-modal {
  background: #fff;
  border-radius: 10px;
  padding: 22px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
}

.ai-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  margin-bottom: 6px;
}

.ai-modal-close {
  border: none;
  background: transparent;
  font-size: 16px;
  cursor: pointer;
  opacity: .6;
}

.ai-modal-close:hover {
  opacity: 1;
}

.ai-audio-modal-error {
  color: var(--ai-ink-red);
  font-size: 13px;
  margin-bottom: 10px;
}

.ai-modal-option {
  margin: 16px 0;
  padding-top: 14px;
  border-top: 1px dotted var(--ai-paper-line);
}

.ai-modal-option:first-of-type {
  border-top: none;
  padding-top: 0;
}

.ai-modal-option > label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  opacity: .75;
}

.ai-modal-option-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ai-modal-option-row input[type="file"] {
  flex: 1;
  font-size: 12px;
}

/* ---------------- Responsive ---------------- */

@media (max-width: 640px) {
  .ai-question-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .ai-answer-select, .ai-answer-input {
    max-width: 100%;
  }
}