/* ============================================================
   CHAT D'AIDE + BOUTON WHATSAPP  (fichier chat.css)
   -> Complète style.css : il réutilise ses couleurs (var(--ink),
      var(--accent), var(--border)...), donc le mode sombre
      fonctionne automatiquement.
   -> Tout est préfixé "rbchat-" pour ne jamais entrer en
      conflit avec le reste du site.
   -> Le contenu (questions, réponses) est dans chat.js.
   ============================================================ */

/* ------------------------------------------------------------
   1. BOUTONS FLOTTANTS (chat + WhatsApp)
   -> Deux boutons ronds fixes en bas à droite de l'écran
      (le chat au-dessus, WhatsApp en dessous).
   -> L'ancien bouton d'appel flottant (.float-call) est masqué
      dans style.css : ces deux boutons prennent sa place.
   ------------------------------------------------------------ */
.rbchat-fabs {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;   /* les boutons restent collés à droite, même si l'un est plus large */
  gap: 12px;
  z-index: 60;
}
.rbchat-fab {
  height: 56px;
  min-width: 56px;
  border-radius: 28px;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #FFFFFF;
  text-decoration: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
}
.rbchat-fab svg {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}
/* Bouton de chat : couleur d'encre du site (bleu marine / clair en mode sombre) */
.rbchat-fab--chat {
  background: var(--ink);
  color: var(--bg-alt);
}
/* Bouton WhatsApp : vert reconnaissable */
.rbchat-fab--wa {
  background: #1EA952;
}
/* Le texte "Une question ?" n'apparaît que sur grand écran :
   sur mobile, on garde un simple rond pour ne pas encombrer */
.rbchat-fab__label {
  display: none;
}
@media (min-width: 861px) {
  .rbchat-fab--chat {
    padding: 0 20px 0 16px;
  }
  .rbchat-fab__label {
    display: inline;
  }
}
.rbchat-fab:focus-visible,
.rbchat-option:focus-visible,
.rbchat-action:focus-visible,
.rbchat-back:focus-visible,
.rbchat-close:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ------------------------------------------------------------
   2. FENÊTRE DE CHAT
   -> Cachée par défaut ; la classe "is-open" (ajoutée par
      chat.js) la rend visible.
   -> Sur ordinateur : une carte de 370px en bas à droite.
   -> Sur mobile : presque tout l'écran.
   ------------------------------------------------------------ */
.rbchat-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 370px;
  max-width: calc(100vw - 24px);
  height: min(620px, calc(100vh - 40px));
  display: none;
  flex-direction: column;
  background: var(--bg-alt);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  overflow: hidden;
  z-index: 90;             /* au-dessus du header (50) et des boutons flottants (60) */
  font-family: var(--font-body);
}
.rbchat-panel.is-open {
  display: flex;
}
.rbchat-panel:focus {
  outline: none;
}
@media (max-width: 480px) {
  .rbchat-panel {
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    max-width: none;
    height: calc(100vh - 16px);
    height: calc(100dvh - 16px); /* "dvh" = tient compte de la barre d'adresse mobile (ignoré si non supporté) */
  }
}

/* En-tête de la fenêtre : titre + bouton fermer */
.rbchat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--ink);
  color: var(--bg-alt);
}
.rbchat-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.2;
}
.rbchat-subtitle {
  font-size: 12px;
  opacity: 0.85;
  margin-top: 2px;
}
.rbchat-close {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
}
.rbchat-close svg {
  width: 22px;
  height: 22px;
}

/* Zone des messages : défile quand la conversation devient longue */
.rbchat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg);
}

/* Petit rappel en bas de la fenêtre */
.rbchat-foot {
  padding: 9px 14px;
  font-size: 12px;
  color: var(--ink-soft);
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
}

/* ------------------------------------------------------------
   3. MESSAGES (bulles)
   ------------------------------------------------------------ */
.rbchat-msg {
  max-width: 90%;
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
}
.rbchat-msg p {
  margin: 0 0 6px;
}
.rbchat-msg p:last-child {
  margin-bottom: 0;
}
/* Bulle de RB.Technique : à gauche, fond clair */
.rbchat-msg--bot {
  align-self: flex-start;
  background: var(--bg-alt);
  border: 1px solid var(--border);
}
/* Bulle du visiteur (la question choisie) : à droite, fond foncé */
.rbchat-msg--user {
  align-self: flex-end;
  background: var(--ink);
  color: var(--bg-alt);
}
/* Message d'urgence (odeur de gaz) : bordure rouge */
.rbchat-msg--urgent {
  border-left: 4px solid #C0392B;
}

/* Animation "RB.Technique écrit..." (trois points) */
.rbchat-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 12px 14px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.rbchat-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-soft);
  animation: rbchat-bounce 1s infinite ease-in-out;
}
.rbchat-typing span:nth-child(2) { animation-delay: 0.15s; }
.rbchat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes rbchat-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30%           { transform: translateY(-4px); opacity: 1; }
}
/* Respect du réglage "réduire les animations" du visiteur */
@media (prefers-reduced-motion: reduce) {
  .rbchat-typing span { animation: none; }
}

/* ------------------------------------------------------------
   4. LISTE DES QUESTIONS (les 10 boutons)
   ------------------------------------------------------------ */
.rbchat-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rbchat-option {
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-alt);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.35;
  cursor: pointer;
}
.rbchat-option:hover {
  border-color: var(--accent);
}
/* Question d'urgence : trait rouge à gauche pour la repérer */
.rbchat-option--urgent {
  border-left: 4px solid #C0392B;
}

/* ------------------------------------------------------------
   5. BOUTONS DE CONTACT (appeler / WhatsApp / formulaire / 112)
   ------------------------------------------------------------ */
.rbchat-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rbchat-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.rbchat-action svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.rbchat-action--call      { background: var(--ink); color: var(--bg-alt); }
.rbchat-action--wa        { background: #1B7F46; color: #FFFFFF; }
.rbchat-action--form      { background: transparent; color: var(--ink); border-color: var(--ink); }
.rbchat-action--emergency { background: #B3261E; color: #FFFFFF; }

/* Lien "Voir les autres questions" */
.rbchat-back {
  align-self: flex-start;
  background: none;
  border: none;
  padding: 4px 0;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}