/*
 * Widget de démonstration du Chat IA.
 *
 * Partagé par toutes les pages vitrine qui incluent
 * templates/frontend/_demo_chat.html.twig : une seule feuille, pour qu'un
 * correctif s'applique partout à la fois.
 */

.demo-card {
  background: #fff;
  border: 1px solid #e8e0f5;
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(102, 58, 173, 0.06);
}
/* En-tête de la carte : un avatar, un nom et un état, pour que la conversation
   se reconnaisse au premier coup d'œil plutôt qu'après lecture du formulaire. */
.demo-entete {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding-bottom: 0.85rem;
  margin-bottom: 0.9rem;
  border-bottom: 1px solid #f0ecf9;
}
.demo-avatar {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 9999px;
  background: var(--brand-gradient);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.demo-avatar svg { width: 1.15rem; height: 1.15rem; }
.demo-titre { display: block; font-size: 0.85rem; font-weight: 600; color: #3e3e3e; line-height: 1.2; }
.demo-etat { display: flex; align-items: center; gap: 0.3rem; font-size: 0.7rem; color: #6b7280; }
.demo-etat .pastille { width: 0.4rem; height: 0.4rem; border-radius: 9999px; background: #22c55e; }

.demo-messages {
  max-height: 26rem;
  overflow-y: auto;
  margin-bottom: 1rem;
}
.demo-messages:empty { display: none; }
.demo-bubble-user {
  background: #f3f0fb;
  border-radius: 0.75rem;
  padding: 0.6rem 0.9rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  color: #3e3e3e;
}
.demo-bubble-assistant {
  border: 1px solid #eee;
  border-radius: 0.75rem;
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: #3e3e3e;
}
/* Attente de la réponse.
 *
 * Une requête prend couramment de 6 à 17 secondes, le temps que le modèle
 * choisisse un outil, interroge la base et rédige. Pendant ce délai, la bulle
 * d'assistant restait un rectangle vide et le seul signe de vie était une ligne
 * grise de 0,7 rem sous le formulaire — invisible en pratique. L'attente se
 * montre donc là où la réponse va apparaître, et elle dit ce qui se passe :
 * le nom de l'outil consulté remplace « interrogation » dès qu'il est connu.
 */
.demo-attente {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: #6b7280;
  font-size: 0.8rem;
}
.demo-points { display: inline-flex; align-items: center; gap: 0.22rem; flex-shrink: 0; }
.demo-points i {
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 9999px;
  background: var(--brand-primary);
  opacity: 0.35;
  animation: demo-rebond 1.4s infinite ease-in-out;
}
.demo-points i:nth-child(2) { animation-delay: 0.18s; }
.demo-points i:nth-child(3) { animation-delay: 0.36s; }
@keyframes demo-rebond {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30% { transform: translateY(-0.3rem); opacity: 1; }
}

/* La bulle en attente se distingue d'une réponse terminée. */
.demo-bubble-assistant.est-en-attente {
  border-color: #ddd0f5;
  background: #fdfcff;
}

/* Le bouton désactivé doit se voir : sans cela, on le reclique. */
#demoSend:disabled { opacity: 0.55; cursor: not-allowed; }

@media (prefers-reduced-motion: reduce) {
  .demo-points i { animation: none; opacity: 0.6; }
}

.demo-source {
  font-size: 0.7rem;
  color: #9ca3af;
  margin-bottom: 1rem;
}
/* Les questions d'exemple, en une ligne ou deux : affichées en entier, elles
   occupaient six lignes et repoussaient le champ de saisie hors de vue. */
.demo-exemples {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.6rem;
}
/* Le message d'accueil porte les exemples : il ne se comporte plus tout à fait
   comme une bulle de réponse. */
.demo-accueil { margin-bottom: 0.75rem; }
.demo-accueil p { margin: 0; }
.demo-exemples-libelle {
  font-size: 0.7rem;
  color: #9ca3af;
  margin-right: 0.1rem;
}
.demo-suggestion {
  font-size: 0.72rem;
  border: 1px solid #e5e7eb;
  border-radius: 9999px;
  padding: 0.28rem 0.7rem;
  color: #6b7280;
  white-space: nowrap;
  transition: border-color 0.2s, color 0.2s, background-color 0.2s;
}
.demo-suggestion:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  background: #faf8ff;
}
/* Champ piège : hors écran, jamais atteint par un humain. */
.demo-trap {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.demo-cta {
  border-top: 1px solid #eee;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  text-align: center;
}

/* ── Rendu Markdown des réponses ── */
.chat-markdown table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0;
  font-size: 0.8rem;
}
.chat-markdown th,
.chat-markdown td {
  border: 1px solid #e5e7eb;
  padding: 0.35rem 0.5rem;
  text-align: left;
  vertical-align: top;
}
.chat-markdown th { background: #f9fafb; font-weight: 600; }
.chat-markdown .table-scroll { overflow-x: auto; }
.chat-markdown h2, .chat-markdown h3 { font-weight: 600; margin: 0.6rem 0 0.3rem; }
.chat-markdown ul, .chat-markdown ol { margin: 0.3rem 0 0.3rem 1.1rem; list-style: revert; }
.chat-markdown p + p { margin-top: 0.5rem; }
