/* Démo de Bast' : un widget de chat posé sur une page blanche, comme sur un vrai site. */
:root {
  --nuit: #10294a;
  --nuit-2: #17365f;
  --framboise: #b3214a;
  --texte: #1c2433;
  --doux: #6b7689;
  --bulle: #f1f3f7;
  --bord: #e2e6ee;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--texte);
}

body { margin: 0; min-height: 100vh; background: #fff; }

/* Icônes en trait (sauf celles qui ont leur propre remplissage) */
svg path { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg path.plein { fill: currentColor; stroke: none; }

/* --- Bulle qui ouvre le chat --- */
.lanceur {
  position: fixed; right: 24px; bottom: 24px; z-index: 10;
  width: 60px; height: 60px; border: 0; border-radius: 50%;
  background: var(--nuit); color: #fff; cursor: pointer;
  box-shadow: 0 8px 24px rgba(16, 41, 74, .35);
  display: grid; place-items: center;
  transition: transform .2s ease, background .2s ease;
}
.lanceur:hover { transform: scale(1.06); background: var(--nuit-2); }
.lanceur svg { width: 28px; height: 28px; grid-area: 1 / 1; transition: opacity .2s, transform .2s; }
.lanceur .icone-fermer { opacity: 0; transform: rotate(-45deg); }
.lanceur[aria-expanded="true"] .icone-chat { opacity: 0; transform: rotate(45deg); }
.lanceur[aria-expanded="true"] .icone-fermer { opacity: 1; transform: none; }

/* --- Panneau --- */
.panneau {
  position: fixed; right: 24px; bottom: 96px; z-index: 10;
  width: 400px; height: min(640px, calc(100vh - 120px));
  display: flex; flex-direction: column;
  background: #fff; border-radius: 18px; overflow: hidden;
  box-shadow: 0 18px 50px rgba(16, 41, 74, .28);
  transform-origin: bottom right;
  animation: ouvrir .22s ease;
}
.panneau[hidden] { display: none; }
@keyframes ouvrir { from { opacity: 0; transform: translateY(12px) scale(.96); } }

.entete {
  display: flex; align-items: center; gap: .7rem;
  padding: .8rem .8rem .8rem 1rem; background: var(--nuit); color: #fff;
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700; background: var(--framboise);
}
.identite { flex: 1; min-width: 0; }
.identite h1 { margin: 0; font-size: 1rem; }
.identite p { margin: .1rem 0 0; font-size: .72rem; opacity: .75; }

/* Boutons-icônes (en-tête et sous les réponses) */
.icone {
  width: 34px; height: 34px; border: 0; border-radius: 50%; flex: none;
  display: grid; place-items: center; cursor: pointer;
  background: transparent; color: inherit; position: relative;
}
.icone:hover { background: rgba(255, 255, 255, .14); }
.icone svg { width: 20px; height: 20px; }
.lire-tout[aria-pressed="false"] .ondes { opacity: .35; }
.lire-tout[aria-pressed="true"] { background: var(--framboise); }

/* Pendant le téléchargement du modèle vocal : un anneau tourne autour du bouton. */
.icone.charge::after {
  content: ''; position: absolute; inset: -2px; border-radius: 50%;
  border: 2px solid transparent; border-top-color: var(--framboise); border-right-color: var(--framboise);
  animation: tourne .8s linear infinite;
}
.entete .icone.charge::after { border-top-color: #fff; border-right-color: #fff; }
@keyframes tourne { to { transform: rotate(360deg); } }

/* --- Messages --- */
.messages {
  list-style: none; margin: 0; padding: 1rem; flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; gap: .75rem; background: #fafbfd;
}
.message { max-width: 86%; line-height: 1.45; font-size: .92rem; }
.message .texte { display: block; padding: .65rem .85rem; border-radius: 14px; background: var(--bulle); white-space: pre-wrap; }
.message.bast .texte { border-bottom-left-radius: 4px; }
.message.visiteur { align-self: flex-end; }
.message.visiteur .texte { background: var(--nuit); color: #fff; border-bottom-right-radius: 4px; }
.message.systeme { align-self: center; max-width: 92%; text-align: center; color: var(--doux); font-size: .78rem; }

/* Barre d'outils sous une réponse : lire, autre voix */
.outils { display: flex; align-items: center; gap: .15rem; margin-top: .3rem; color: var(--doux); }
.outils .icone { width: 30px; height: 30px; }
.outils .icone:hover { background: var(--bulle); color: var(--nuit); }
.outils .icone svg { width: 17px; height: 17px; }
.outils .icone[aria-pressed="true"] { color: var(--framboise); }
.outils .nom-voix { font-size: .72rem; margin-left: .2rem; }

/* Message de téléchargement du modèle vocal, dans la conversation */
.telechargement .barre { display: block; width: 180px; height: 4px; margin: .4rem auto 0; border-radius: 4px; background: var(--bord); overflow: hidden; }
.telechargement .barre i { display: block; height: 100%; width: 0; background: var(--framboise); transition: width .3s; }

/* Liens des sources */
.liens { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .45rem; }
.liens a {
  font-size: .76rem; color: var(--nuit); text-decoration: none;
  border: 1px solid var(--bord); border-radius: 99px; padding: .15rem .6rem; background: #fff;
}
.liens a:hover { border-color: var(--nuit); }

/* Bulle en cours : points animés, étape en direct, curseur clignotant */
.etape { display: block; color: var(--doux); font-size: .75rem; margin-top: .25rem; white-space: normal; }
.etape:empty { display: none; }
.curseur { display: inline-block; width: .45ch; height: 1.05em; margin-left: 1px; vertical-align: text-bottom; background: var(--texte); animation: clignote 1s steps(1) infinite; }
@keyframes clignote { 50% { opacity: 0; } }
.points { display: inline-flex; gap: 4px; padding: .25rem 0; }
.points i { width: 6px; height: 6px; border-radius: 50%; background: var(--doux); animation: saute 1.2s infinite ease-in-out; }
.points i:nth-child(2) { animation-delay: .15s; }
.points i:nth-child(3) { animation-delay: .3s; }
@keyframes saute { 0%, 80%, 100% { transform: translateY(0); opacity: .4; } 40% { transform: translateY(-4px); opacity: 1; } }
.points:not(:empty) ~ .curseur { display: none; }

/* « Comment j'ai répondu » */
.processus { margin-top: .35rem; font-size: .72rem; color: var(--doux); }
.processus summary { cursor: pointer; }
.processus dl { display: grid; grid-template-columns: max-content 1fr; gap: .2rem .7rem; margin: .45rem 0 0; }
.processus dd { margin: 0; color: var(--texte); overflow-wrap: anywhere; }
.processus ul { margin: 0; padding-left: 1rem; }

/* Faux formulaire de contact */
.contact { display: flex; flex-direction: column; gap: .4rem; margin-top: .5rem; }
.contact .titre { margin: 0; color: var(--doux); font-size: .75rem; }
.contact input, .contact textarea {
  font: inherit; font-size: .85rem; padding: .5rem .6rem; border: 1px solid var(--bord); border-radius: 8px; resize: vertical;
}

/* --- Saisie --- */
.saisie { display: flex; align-items: flex-end; gap: .5rem; padding: .7rem; border-top: 1px solid var(--bord); background: #fff; }
.saisie textarea {
  flex: 1; resize: none; font: inherit; font-size: .92rem; max-height: 120px;
  padding: .6rem .75rem; border: 1px solid var(--bord); border-radius: 12px; outline: none;
}
.saisie textarea:focus { border-color: var(--nuit); }
button.envoyer, .contact button { border: 0; border-radius: 12px; cursor: pointer; color: #fff; background: var(--framboise); font: inherit; }
button.envoyer { width: 42px; height: 42px; display: grid; place-items: center; flex: none; }
button.envoyer svg { width: 20px; height: 20px; }
.contact button { align-self: flex-start; padding: .45rem .9rem; font-size: .85rem; }
button:disabled, textarea:disabled { opacity: .5; cursor: not-allowed; }
.piege { position: absolute; left: -9999px; }

/* --- Téléphone : le panneau prend tout l'écran --- */
@media (max-width: 520px) {
  .panneau { inset: 0; width: auto; height: auto; border-radius: 0; }
  .lanceur[aria-expanded="true"] { display: none; }
  .entete .fermer { display: grid; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::after { animation: none !important; transition: none !important; }
}

/* Questions proposées avant la première question */
.suggestions { display: flex; flex-wrap: wrap; gap: .4rem; }
.suggestions button {
  font: inherit; font-size: .8rem; color: var(--nuit); background: #fff; cursor: pointer;
  border: 1px solid var(--bord); border-radius: 99px; padding: .35rem .75rem; text-align: left;
}
.suggestions button:hover { border-color: var(--nuit); background: var(--bulle); }

/* Démo : simulateur de page (n'existe pas sur le vrai site) */
.simulation { position: fixed; top: 16px; left: 16px; display: flex; flex-direction: column; gap: .3rem; font-size: .8rem; color: var(--doux); }
.simulation select { font: inherit; padding: .35rem .5rem; border: 1px solid var(--bord); border-radius: 8px; background: #fff; color: var(--texte); }
