/* =========================
   VARIABLES (unique :root)
   ========================= */
:root {
  --bot-gutter: 56px;
  --msg-user-size: 14px;
  --msg-bot-size: 14px;
  --msg-user-lh: 1.45;
  --msg-bot-lh: 1.45;
  --dot-size: 6px;
  --dot-gap: 6px;
  --dot-green: #f8a866d7; /* user */
  --dot-red: #659efa9d; /* bot  */
}

/* =========================
   CADRE & LAYOUT
   ========================= */
.faq-frame {
  width: 420px;
  max-width: 100%;
  /* Hauteur plus souple pour éviter double scroll */
  min-height: 520px;
  max-height: 80vh;
  margin: 30px auto 10px;
  border-radius: 15px;
  background: #fff;
  overflow: hidden;
  box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;
}

.faq-widget {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  border: 0;
  border-radius: 0;
  box-sizing: border-box;
  font: 14px/1.4 system-ui, sans-serif;
}

/* zone messages */
#faq-log {
  background: linear-gradient(180deg, #acacac 0%, #e7e7e7 100%);
  flex: 1;
  overflow: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* formulaire */
#faq-form {
  display: flex;
  gap: 8px;
  padding: 8px;
  border-top: 1px solid #ddd;
  align-items: center;
}
#faq-form input {
  flex: 1 1 auto;
  padding: 8px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  outline: none;
}
#faq-form input:focus-visible {
  border-color: #2a2a2b;
  box-shadow: 0 0 0 3px rgba(114, 114, 117, 0.25);
}

/* bouton envoyer (version unique) */
#faq-send {
  appearance: none;
  flex: 0 0 auto;
  width: auto !important;
  min-width: 88px;
  max-width: 140px;
  padding: 8px 12px;
  border: 0;
  border-radius: 10px;
  font: 600 14px/1 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: #111;
  background: linear-gradient(180deg, #e5e7eb 0%, #d1d5db 100%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.45) inset, 0 8px 16px -6px rgba(0, 0, 0, 0.15);
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.06s ease, box-shadow 0.2s ease, background 0.2s ease, opacity 0.2s ease;
}
@media (hover: hover) {
  #faq-send:hover {
    transform: translateY(-1px);
    background: linear-gradient(180deg, #d8dbe0 0%, #c5c9cf 100%);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.45) inset, 0 10px 18px -6px rgba(0, 0, 0, 0.18);
  }
}
#faq-send:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.9), 0 0 0 6px rgba(31, 41, 55, 0.35), 0 8px 16px -6px rgba(0, 0, 0, 0.15);
}
#faq-send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* =========================
   BULLES & TYPO
   ========================= */
.msg {
  max-width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 14px;
  word-wrap: break-word;
  white-space: pre-wrap;
  font-weight: 500; /* lisibilité */
}

/* user (gauche) */
.msg.user {
  align-self: flex-start;
  background: #f3f4f6;
  border-color: #e5e7eb;
  box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;
  border-top-left-radius: 1px;
  font-size: var(--msg-user-size);
  line-height: var(--msg-user-lh);
  font-weight: 600; /* user un peu plus marqué */
}

/* bot (droite) */
.msg.bot {
  align-self: flex-end;
  background: #eef2ff;
  border-color: #333;
  box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;
  border-top-right-radius: 1px;
  margin-left: var(--bot-gutter);
  margin-right: 0;
  font-size: var(--msg-bot-size);
  line-height: var(--msg-bot-lh);
}

/* liens dans la bulle bot */
.msg.bot .links {
  list-style: none;
  margin: 0.35rem 0 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.msg.bot .links li {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #fff;
  border-radius: 10px;
  padding: 6px 8px; /* corrigé */
  margin-left: 20px;
}
.msg.bot .links a {
  color: #1f2937;
  text-decoration: none;
  outline: none;
}
.msg.bot .links a:hover {
  text-decoration: underline;
}
.msg.bot .links a:focus-visible {
  box-shadow: 0 0 0 3px rgba(23, 23, 24, 0.25);
  border-radius: 6px;
}
@media (hover: hover) {
  .msg.bot .links li:hover {
    background: rgba(255, 255, 255, 0.35);
  }
}

/* points indicateurs (fixes par défaut) */
.msg::before {
  content: "";
  display: inline-block;
  width: var(--dot-size);
  height: var(--dot-size);
  border-radius: 50%;
  margin-right: var(--dot-gap);
  vertical-align: middle;
  animation: none;
  opacity: 1;
}
.msg.user::before {
  background: var(--dot-green);
}
.msg.bot::before {
  background: var(--dot-red);
}

/* accessibilité: pas d'usage de :has(), animation déjà coupée */

/* =========================
   ACCESSIBILITÉ OUTILS
   ========================= */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* =========================
   HABILLAGE PAGE (optionnel)
   ========================= */
.page-section .faq-frame {
  display: flex;
  justify-content: center;
}

/* carte 2 colonnes (si utilisée) */
.chat-card {
  margin: 40px auto;
  background: #fff;
  border-radius: 15px;
  overflow: hidden;
  box-shadow: rgba(0, 0, 0, 0.35) 0 5px 15px;
}
.about-frame {
  width: 90%;
  height: 600px;
  box-sizing: border-box;
}
.about-inner {
  height: 100%;
  width: 100%;
  padding: 16px;
  overflow: auto;
  border-left: 1px solid #eee;
  font: 14px/1.5 system-ui, sans-serif;
}

/* =========================
   RESPONSIVE
   ========================= */
@media (max-width: 991.98px) {
  .faq-frame,
  .about-frame {
    width: 100%;
    height: auto;
    max-height: none;
  }
  .about-inner {
    border-left: none;
    border-top: 1px solid #eee;
  }
}

@media (max-width: 480px) {
  :root {
    --mobile-bottom-gap: calc(30px + env(safe-area-inset-bottom, 0px));
    --msg-user-size: 14px;
    --msg-bot-size: 14px;
  }
  .faq-frame {
    width: 100%;
    height: calc(100svh - var(--mobile-bottom-gap));
    max-height: none;
    margin: 24px auto var(--mobile-bottom-gap);
    border-radius: 12px;
  }
}
/* =====================================================================
   ZONE DIALOGUE - Raffinements visuels zen (sō web)
   ===================================================================== */

/* fond doux, respiration générale */
.faq-frame {
  background: #fafafa;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

/* bulles plus légères */
.msg.user {
  background: #f8f8f8;
  border-color: #e1e1e1;
  color: #222;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.msg.bot {
  background: #f4f7fb;
  border-color: #cfd9e4;
  color: #222;
  font-weight: 500;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* animation d'apparition douce */
.msg {
  animation: fadeInUp 0.25s ease both;
}
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* scrollbar minimaliste */
#faq-log::-webkit-scrollbar {
  width: 8px;
}
#faq-log::-webkit-scrollbar-thumb {
  background-color: #636363;
  border-radius: 6px;
}
#faq-log::-webkit-scrollbar-thumb:hover {
  background-color: #b3bcc2;
}

/* harmonisation du champ et du bouton */
#faq-form input {
  font-size: 15px;
  border-radius: 10px;
}
#faq-send {
  background: linear-gradient(180deg, #f5f5f5, #dcdcdc);
  color: #222;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}
#faq-send:hover {
  background: linear-gradient(180deg, #e0e0e0, #c8c8c8);
}

/* effet "..." animé pour les réponses */
.msg.bot.thinking::after {
  content: "…";
  animation: dots 1s steps(4, end) infinite;
}
@keyframes dots {
  0%,
  20% {
    content: "";
  }
  40% {
    content: ".";
  }
  60% {
    content: "..";
  }
  80%,
  100% {
    content: "...";
  }
}
/* =====================================================================
   FIXE LA HAUTEUR DU CHAT - pas d’expansion dynamique
   ===================================================================== */

/* Hauteur fixe de la fenêtre (scroll interne seulement) */
.faq-frame {
  height: 520px; /* hauteur stable */
  max-height: 520px;
  overflow: hidden;
}

/* zone de messages scrollable interne */
#faq-log {
  flex: 1;
  height: calc(520px - 70px);
  overflow-y: auto;
  overflow-x: hidden;
}

/* empêche le double scroll global */
html,
body {
  overflow: hidden;
}
/* Icône lecture vocale */
.speak-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  cursor: pointer;
  color: #666;
  font-size: 15px;
  vertical-align: middle;
}
.speak-btn:hover {
  color: #111;
}
/* Alignement du sélecteur de voix sur la fenêtre de chat */
#voice-select-box {
  margin: 8px 0 0; /* plus de auto => plus de centrage */
  text-align: left;
  width: 100%; /* suit exactement la largeur du chat */
  padding-left: 0; /* bord aligné sur le chat */
  box-sizing: border-box;
}

#voice-select-box label {
  font-size: 13px;
  color: #555;
  margin-right: 6px;
}

#voiceSelect {
  font-size: 13px;
  padding: 3px 10px 3px 12px; /* léger padding-left */
  border-radius: 6px;
  border: 1px solid #ccc;
  width: 220px; /* ajuste si besoin */
  max-width: 100%;
  background: #fff;
  color: #222;
  box-sizing: border-box;
}
/* Choix de voix (deux boutons) */
#voice-chooser {
  margin: 8px 0 0;
  text-align: left;
}
#voice-chooser .vc-label {
  font-size: 13px;
  color: #555;
  margin-right: 8px;
}
#voice-chooser .vc-group {
  display: inline-flex;
  gap: 6px;
  vertical-align: middle;
}

/* Choix de voix (boutons compacts) */
/* Choix de voix (boutons compacts) */
#voice-chooser {
  margin: 8px 0 0;
  text-align: left;
}

#voice-chooser .vc-label {
  font-size: 13px;
  color: #555;
  margin-right: 8px;
}

#voice-chooser .vc-group {
  display: inline-flex;
  gap: 6px;
  vertical-align: middle;
}

.voice-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 20px; /* légèrement plus haut pour respirer */
  margin-top: 6px !important;
  padding: 0 10px;
  padding-bottom: 1px;
  width: 100px;
  font-size: 13px;
  line-height: 1;
  border: 1px solid #ccc;
  border-radius: 12px;
  background: #fff;
  color: #222;
  cursor: pointer;
  user-select: none;
  vertical-align: middle; /* aligne avec le texte “Voix :” */
}

.voice-btn.active {
  background: rgba(45, 126, 247, 0.25);
  border-color: #2d7ef7;
  color: #333;
}

.voice-btn:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(45, 126, 247, 0.25);
}
