/* Extrait de teacher-dashboard.html. Ordre historique : 18. */
/* ── Bouton déclencheur flottant ── */
#ai-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(99,102,241,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  z-index: 9990;
  transition: transform 0.2s, box-shadow 0.2s;
}
#ai-fab:hover { transform: scale(1.1); box-shadow: 0 12px 40px rgba(99,102,241,0.6); }

/* ── LA PULSATION, RÉÉCRITE — 21/09/2026 ──────────────────────────────────
   ELLE ANIMAIT `box-shadow`, et box-shadow ne se compose pas sur le GPU : le
   navigateur repeignait le bouton ET son ombre à CHAQUE IMAGE, en permanence,
   sur toutes les pages du tableau de bord. Mesuré au navigateur, pointeur
   ailleurs, bouton au repos : 23 images distinctes sur 24 captures.

   Au survol, `transform: scale(1.1)` agrandit la surface à repeindre pendant
   que la lueur change : c'est là que ce repeint permanent devient visible, et
   c'est le scintillement signalé le 21/09. Le défaut ne datait pas de ce
   jour-là — seule sa visibilité en datait.

   L'anneau vit maintenant dans un pseudo-élément animé en `transform` et
   `opacity`, les deux seules propriétés que le compositeur sait traiter sans
   repeindre. Le bouton, lui, garde une ombre FIXE.

   `position: relative` n'est pas décoratif : la pastille ✦ et cet anneau s'y
   accrochent tous les deux. Sans lui, ils vont chercher l'ancêtre positionné
   suivant — et se posent ailleurs sur la page. */
#ai-fab { position: fixed; }
#ai-fab::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(99,102,241,0.5);
  pointer-events: none;
  animation: ai-pulse 4s ease-out infinite;
}
/* Le survol arrête l'invitation : elle a été acceptée. */
#ai-fab:hover::after { animation: none; opacity: 0; }
#ai-fab .ai-fab-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: #ef4444;
  color: white;
  font-size: 9px;
  font-weight: 800;
  padding: 2px 5px;
  border-radius: 10px;
  border: 2px solid white;
  display: none;
}
@keyframes ai-pulse {
  0%   { transform: scale(1);    opacity: .55; }
  70%  { transform: scale(1.42); opacity: 0; }
  100% { transform: scale(1.42); opacity: 0; }
}

/* Une pulsation sans fin est exactement ce qu'un « moins d'animations »
   demande d'arrêter. Le bouton reste lui-même : seule l'invitation se tait. */
@media (prefers-reduced-motion: reduce) {
  #ai-fab::after { animation: none; opacity: 0; }
  #ai-fab { transition: none; }
}

/* ── Panneau latéral IA ── */
#ai-panel {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 420px;
  height: 75vh;
  min-width: 320px;
  min-height: 400px;
  max-width: 90vw;
  max-height: 90vh;
  background: white;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18), 0 0 0 1px rgba(99,102,241,0.15);
  display: flex;
  flex-direction: column;
  z-index: 9989;
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.34,1.56,0.64,1);
  overflow: visible; /* Permet à la poignée de déborder */
}
/* Le contenu interne doit cacher son overflow, pas le panel lui-même */
#ai-panel > *:not(#ai-resize-handle) { overflow: hidden; }
#ai-panel > .ai-panel-header { border-radius: 20px 20px 0 0; overflow: hidden; }
#ai-panel.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}
#ai-panel.ai-dragging {
  transition: none !important;
  box-shadow: 0 28px 80px rgba(0,0,0,0.28), 0 0 0 2px rgba(99,102,241,0.4);
}
/* Poignée de redimensionnement — coin bas-droit, HORS du panel pour visibilité */
#ai-resize-handle {
  position: absolute;
  bottom: -2px; right: -2px;
  width: 24px; height: 24px;
  cursor: nwse-resize;
  z-index: 99999;
  display: flex; align-items: flex-end; justify-content: flex-end;
  padding: 4px;
  border-bottom-right-radius: 20px;
  background: transparent;
}
#ai-resize-handle::after {
  content: '';
  display: block;
  width: 12px; height: 12px;
  border-right: 3px solid #8b5cf6;
  border-bottom: 3px solid #8b5cf6;
  border-radius: 0 0 4px 0;
  opacity: 0.6;
  transition: opacity 0.15s, transform 0.15s;
}
#ai-resize-handle:hover::after { opacity: 1; transform: scale(1.2); }
.ai-panel-header {
  background: linear-gradient(135deg, #1e1b4b, #4c1d95);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  cursor: grab;      /* Indique que le header est draggable */
  user-select: none; /* Empêche la sélection de texte pendant le drag */
}
.ai-panel-header:active { cursor: grabbing; }
.ai-panel-header-left { display: flex; align-items: center; gap: 12px; }
.ai-panel-avatar {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  animation: ai-breathe 3s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes ai-breathe {
  0%,100% { box-shadow: 0 0 0 0 rgba(168,85,247,0.4); }
  50%      { box-shadow: 0 0 0 8px rgba(168,85,247,0); }
}
.ai-panel-title { color: white; font-weight: 800; font-size: 15px; line-height: 1.2; }
.ai-panel-subtitle { color: rgba(255,255,255,0.65); font-size: 11px; }
.ai-panel-close {
  background: rgba(255,255,255,0.15); border: none; color: white;
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
  font-size: 16px; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s; flex-shrink: 0;
}
.ai-panel-close:hover { background: rgba(255,255,255,0.25); }
.ai-quick-modes {
  padding: 10px 14px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  border-bottom: 1px solid #f1f5f9; flex-shrink: 0; background: #fafbff;
}
/* !! IMPORTANT: isolation totale du panneau IA vs CSS global du dashboard !! */
#ai-panel * { box-sizing: border-box; }
/* Surcharger la règle globale "button { color: #fff !important }" — max spécificité */
/* ═══ RÈGLE ANTI-BOUTON-BLANC — solution définitive ═══════════════════════════════ */
/* Tous les boutons sur fond blanc dans les modales */
html body [id*="modal"] button[style*="background:white"],
html body [id*="modal"] button[style*="background: white"],
html body [id*="modal"] button[style*="background:#e2e8f0"],
html body [id*="modal"] button[style*="background: #e2e8f0"],
html body [id*="modal"] button[style*="background:#f"] {
  color: inherit !important;
}
/* Onglets de la modale affectation */
html body #tabAffecterExistant,
html body #tabAffecterNouveau {
  color: #94a3b8 !important;
  background: white !important;
}
html body #tabAffecterExistant {
  color: #6366f1 !important;
}
html body #ai-panel button.ai-action-btn.secondary {
  color: #4f46e5 !important;
  background: #ffffff !important;
  border: 2px solid #6366f1 !important;
}
html body #ai-panel button.ai-mode-btn.active {
  color: #ffffff !important;
}
html body #ai-panel button.ai-mode-btn:not(.active) {
  color: #1e293b !important;
}
.ai-mode-btn {
  padding: 6px 13px !important; border-radius: 20px !important;
  border: 1.5px solid #cbd5e1 !important;
  background: #ffffff !important; cursor: pointer !important;
  white-space: nowrap !important; transition: all 0.2s !important;
  display: inline-flex !important; align-items: center !important; gap: 5px !important;
  font-size: 12px !important; font-weight: 700 !important;
  color: #1e293b !important; line-height: 1.4 !important;
  font-family: inherit !important; text-rendering: auto !important;
}
.ai-mode-btn:hover {
  border-color: #6366f1 !important; background: #eef2ff !important;
  color: #4f46e5 !important; transform: translateY(-1px) !important;
  box-shadow: 0 2px 8px rgba(99,102,241,0.2) !important;
}
.ai-mode-btn.active {
  border-color: #6366f1 !important;
  background: linear-gradient(135deg,#6366f1,#8b5cf6) !important;
  color: #ffffff !important; box-shadow: 0 2px 10px rgba(99,102,241,0.4) !important;
}
.ai-mode-btn .btn-emoji { font-size: 14px !important; line-height: 1 !important; }
.ai-mode-btn .btn-txt {
  font-size: 12px !important; font-weight: 700 !important;
  color: inherit !important; display: inline !important;
  visibility: visible !important; opacity: 1 !important;
  line-height: 1.4 !important;
}

/* ── Bouton info "i" ─────────────────────────────────── */
.ai-info-btn {
  margin-left: auto !important; width: 26px !important; height: 26px !important;
  border-radius: 50% !important; border: 2px solid #94a3b8 !important;
  background: #f8fafc !important; cursor: pointer !important;
  flex-shrink: 0 !important; display: flex !important;
  align-items: center !important; justify-content: center !important;
  font-size: 13px !important; font-weight: 900 !important;
  color: #475569 !important; font-style: italic !important;
  transition: all 0.2s !important; font-family: Georgia, serif !important;
  line-height: 1 !important;
}
.ai-info-btn:hover { border-color: #6366f1 !important; color: #6366f1 !important; background: #eef2ff !important; }
.ai-info-btn.open { border-color: #6366f1 !important; color: white !important; background: #6366f1 !important; }

/* ── Tooltip info (géré par JS, pas hover CSS) ───────── */
#ai-info-popup {
  display: none; position: fixed; z-index: 99999;
  width: 300px; background: #1e293b; color: #f1f5f9 !important;
  border-radius: 14px; padding: 16px 18px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.45);
  font-size: 12.5px !important; line-height: 1.7 !important;
  font-family: inherit !important;
}
#ai-info-popup.show { display: block; animation: fadeInUp2 0.18s ease; }
@keyframes fadeInUp2 { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }
#ai-info-popup .pop-title {
  font-size: 14px !important; font-weight: 800 !important;
  color: #c7d2fe !important; margin-bottom: 10px !important; display: block !important;
}
#ai-info-popup .pop-row {
  display: flex !important; gap: 8px !important; margin-bottom: 6px !important;
  align-items: flex-start !important;
}
#ai-info-popup .pop-row .pop-ico { flex-shrink: 0 !important; font-size: 14px !important; }
#ai-info-popup .pop-row .pop-desc {
  font-size: 12px !important; color: #e2e8f0 !important; line-height: 1.5 !important;
}
#ai-info-popup .pop-row .pop-desc b { color: #a5b4fc !important; font-weight: 700 !important; }
#ai-info-popup .pop-foot {
  margin-top: 10px !important; padding-top: 10px !important;
  border-top: 1px solid rgba(255,255,255,0.12) !important;
  font-size: 11px !important; color: #94a3b8 !important;
}
#ai-info-popup .pop-foot b { color: #a5b4fc !important; }
@keyframes fadeInUp { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:translateY(0); } }
.ai-messages {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 12px; scroll-behavior: smooth;
}
.ai-msg { display: flex; gap: 8px; animation: ai-msg-in 0.3s ease; }
@keyframes ai-msg-in { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
.ai-msg.user { flex-direction: row-reverse; }
.ai-msg-bubble { max-width: 85%; padding: 10px 14px; border-radius: 16px; font-size: 13px; line-height: 1.5; }
.ai-msg.ai .ai-msg-bubble { background: #f8fafc; border: 1.5px solid #e2e8f0; color: #1e293b; border-radius: 4px 16px 16px 16px; }
.ai-msg.user .ai-msg-bubble { background: linear-gradient(135deg,#6366f1,#8b5cf6); color: white; border-radius: 16px 4px 16px 16px; }
.ai-msg-icon { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; margin-top: 2px; }
.ai-msg.ai .ai-msg-icon { background: linear-gradient(135deg,#6366f1,#a855f7); }
.ai-msg.user .ai-msg-icon { background: #e2e8f0; }
.ai-action-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ai-action-btn { padding: 6px 14px; background: linear-gradient(135deg,#6366f1,#8b5cf6); color: #ffffff !important; border: none; border-radius: 8px; font-size: 12px; font-weight: 700; cursor: pointer; transition: opacity 0.15s, transform 0.15s; white-space: nowrap; }
.ai-action-btn:hover { opacity: 0.85; transform: translateY(-1px); }
.ai-action-btn.secondary { background: #ffffff !important; color: #4f46e5 !important; border: 2px solid #6366f1 !important; font-weight: 700 !important; }
.ai-action-btn.secondary:hover { background: #eef2ff !important; }
.ai-typing { display: flex; align-items: center; gap: 4px; padding: 10px 14px; background: #f8fafc; border: 1.5px solid #e2e8f0; border-radius: 4px 16px 16px 16px; width: fit-content; }
.ai-typing span { width: 6px; height: 6px; border-radius: 50%; background: #94a3b8; animation: ai-typing-dot 3s infinite; }
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ai-typing-dot { 0%,60%,100% { transform:translateY(0); opacity:0.4; } 30% { transform:translateY(-4px); opacity:1; } }
.ai-input-area { padding: 12px 16px; border-top: 1px solid #f1f5f9; display: flex; gap: 8px; align-items: flex-end; flex-shrink: 0; background: white; }
#ai-input { flex: 1; border: 2px solid #e2e8f0; border-radius: 12px; padding: 10px 14px; font-size: 13px; resize: none; outline: none; font-family: inherit; max-height: 100px; line-height: 1.4; transition: border-color 0.15s; }
#ai-input:focus { border-color: #6366f1; }
#ai-send { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg,#6366f1,#8b5cf6); border: none; color: white; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: transform 0.15s, opacity 0.15s; }
#ai-send:hover { transform: scale(1.08); }
#ai-send:disabled { opacity: 0.5; cursor: not-allowed; }
.ai-fill-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; background: linear-gradient(135deg,#6366f1,#8b5cf6); color: white; border: none; border-radius: 10px; font-size: 12px; font-weight: 700; cursor: pointer; transition: opacity 0.15s, transform 0.15s; white-space: nowrap; }
.ai-fill-btn:hover { opacity: 0.88; transform: translateY(-1px); }
.ai-mini-panel { background: linear-gradient(135deg,#faf5ff,#f0f4ff); border: 2px solid #c4b5fd; border-radius: 14px; padding: 16px; margin-bottom: 16px; }
.ai-mini-panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.ai-mini-title { font-size: 13px; font-weight: 800; color: #4f46e5; display: flex; align-items: center; gap: 6px; }
.ai-mini-input-row { display: flex; gap: 8px; align-items: center; }
.ai-mini-input { flex: 1; border: 1.5px solid #c4b5fd; border-radius: 8px; padding: 8px 12px; font-size: 12px; background: white; outline: none; font-family: inherit; }
.ai-mini-input:focus { border-color: #6366f1; }
.ai-mini-suggestions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.ai-mini-suggest { padding: 3px 10px; background: white; border: 1.5px solid #c4b5fd; border-radius: 20px; font-size: 10px; font-weight: 700; color: #6d28d9; cursor: pointer; transition: all 0.15s; }
.ai-mini-suggest:hover { background: #6366f1; color: white; border-color: #6366f1; }

/* ══════════════════════════════════════════════════════════════════════════════
   REPRISE DE MAIN SUR LA « RÈGLE BALAI » — 11/09/2026
   ══════════════════════════════════════════════════════════════════════════════

   LE SYMPTÔME
   Dans le panneau IA, les libellés des boutons étaient invisibles : on ne
   voyait que l'emoji des pastilles de mode, le « i » du bouton d'aide avait
   disparu, et les suggestions à fond blanc apparaissaient comme des rectangles
   vides. Le texte redevenait lisible APRÈS un clic — parce que le bouton actif
   reçoit alors un fond violet, sur lequel du blanc se voit.

   LA CAUSE
   dashboard.css (ligne 424) contient une règle balai :

     button:not(.prm-roue):not(.prm-fermer):…:not(#amgrRefreshBtn):…
       { color: #ffffff !important; }

   Elle impose du blanc à TOUS les boutons du tableau de bord, sauf ceux
   inscrits dans une liste d'exceptions qui s'allonge à chaque incident.
   Les boutons du panneau IA n'y figurent pas.

   POURQUOI LES RÈGLES CI-DESSUS NE SUFFISAIENT PAS
   Ce fichier tentait déjà de reprendre la main avec, par exemple :

     html body #ai-panel button.ai-mode-btn:not(.active)  →  spécificité (1, 2, 3)

   Mais la règle balai vaut (1, ~30, 1) : un identifiant, apporté par
   « :not(#amgrRefreshBtn) », et une trentaine de classes apportées par les
   autres :not(). À égalité d'identifiants, c'est le nombre de classes qui
   tranche — 30 contre 2. Les deux règles étant !important, la balai gagnait.
   Aucune des surcharges écrites plus haut n'avait donc d'effet.

   LA PARADE
   Répéter l'identifiant du panneau — #ai-panel#ai-panel — porte la colonne
   « identifiants » à 2. Comme cette colonne est comparée AVANT celle des
   classes, ces règles l'emportent quel que soit le nombre de :not() ajoutés
   plus tard à la balai. C'est volontairement borné à #ai-panel : le reste du
   tableau de bord n'est pas touché.

   Le banc scripts/test-ai-panel-contraste.js recalcule ces spécificités à
   chaque déploiement et échoue si la balai repasse devant.
   ══════════════════════════════════════════════════════════════════════════════ */

/* Défaut du panneau : encre sombre, lisible sur les fonds clairs. */
html body #ai-panel#ai-panel button,
html body #ai-panel#ai-panel button * {
  color: #1e293b !important;
}

/* Boutons à fond coloré : le blanc y est volontaire. */
html body #ai-panel#ai-panel .ai-panel-close,
html body #ai-panel#ai-panel button.ai-mode-btn.active,
html body #ai-panel#ai-panel button.ai-mode-btn.active *,
html body #ai-panel#ai-panel button.ai-info-btn.open,
html body #ai-panel#ai-panel button.ai-action-btn,
html body #ai-panel#ai-panel button.ai-action-btn *,
html body #ai-panel#ai-panel button.ai-fill-btn,
html body #ai-panel#ai-panel button.ai-fill-btn *,
html body #ai-panel#ai-panel button#ai-send {
  color: #ffffff !important;
}

/* Boutons à fond blanc : encre de la charte du panneau. */
html body #ai-panel#ai-panel button.ai-mode-btn:not(.active),
html body #ai-panel#ai-panel button.ai-mode-btn:not(.active) * {
  color: #1e293b !important;
}
html body #ai-panel#ai-panel button.ai-mode-btn:not(.active):hover,
html body #ai-panel#ai-panel button.ai-mode-btn:not(.active):hover * {
  color: #4f46e5 !important;
}
html body #ai-panel#ai-panel button.ai-info-btn:not(.open) {
  color: #475569 !important;
}
html body #ai-panel#ai-panel button.ai-action-btn.secondary,
html body #ai-panel#ai-panel button.ai-action-btn.secondary * {
  color: #4f46e5 !important;
}
html body #ai-panel#ai-panel button.ai-mini-suggest {
  color: #6d28d9 !important;
}
html body #ai-panel#ai-panel button.ai-mini-suggest:hover {
  color: #ffffff !important;
}

/* ── En-tête : le compteur de quota passait sous le bouton de fermeture ──────
   `justify-content: space-between` sans gap, avec un bloc de gauche qui ne
   rétrécit pas : dès que le titre est long, le badge « 50 / 50 restantes » et
   la croix se chevauchent (visible sur les captures du 11/09/2026).
   On laisse le titre se tronquer plutôt que de pousser ses voisins. */
html body #ai-panel#ai-panel .ai-panel-header { gap: 10px; }
html body #ai-panel#ai-panel .ai-panel-header-left { min-width: 0; flex: 1 1 auto; }
html body #ai-panel#ai-panel .ai-panel-title,
html body #ai-panel#ai-panel .ai-panel-subtitle {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
html body #ai-panel#ai-panel #ai-quota-counter { flex: 0 0 auto; }
html body #ai-panel#ai-panel .ai-panel-close { flex: 0 0 auto; }
