/* ============================================================
   CLARTÉ — Assistant conversationnel (chatbot)
   ------------------------------------------------------------
   Ce fichier est volontairement séparé de style.css : tout ce qui
   concerne le chatbot (apparence) vit ici. Si un jour vous voulez
   retirer le chatbot du site, il suffit de retirer ce fichier et
   js/chatbot.js, sans toucher au reste.

   Sommaire :
   1. Bouton flottant (bulle)
   2. Fenêtre de conversation (panneau)
   3. En-tête du panneau
   4. Zone des messages + bulles
   5. Indicateur "en train d'écrire"
   6. Suggestions rapides
   7. Zone de saisie
   8. Responsive (plein écran sur mobile)
   ============================================================ */

/* -------------------- 1. BOUTON FLOTTANT -------------------- */
/*
  position: fixed => le bouton reste toujours au même endroit à l'écran,
  même quand on fait défiler la page (contrairement à "absolute" qui suit
  le contenu, ou "static" le comportement par défaut).
*/
#chatbot-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;           /* cercle parfait */
  background: var(--blue);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  z-index: 998;                  /* passe au-dessus du reste du contenu */
  transition: transform 0.2s ease, background 0.2s ease;
}
#chatbot-toggle:hover {
  transform: scale(1.06);
  background: var(--blue-dark);
}
#chatbot-toggle svg { width: 26px; height: 26px; }

/* Icône "message" et icône "fermer" (X) sont superposées l'une sur
   l'autre ; on affiche l'une ou l'autre selon l'état ouvert/fermé */
#chatbot-toggle .icon-close { display: none; }
#chatbot-toggle.is-open .icon-chat { display: none; }
#chatbot-toggle.is-open .icon-close { display: block; }

/* Petit point rouge de notification (affiché une fois, avant le premier clic) */
#chatbot-toggle .ping {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--yellow);
  border: 2px solid #fff;
}
#chatbot-toggle.is-open .ping,
#chatbot-toggle.was-opened .ping {
  display: none;
}

/* -------------------- 2. PANNEAU DE CONVERSATION -------------------- */
#chatbot-panel {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 370px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 140px);
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 997;

  /* État fermé : invisible et légèrement décalé vers le bas.
     On anime l'ouverture avec opacity + transform plutôt que
     "display: none", ce qui permet une transition en douceur. */
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;          /* on ne peut pas cliquer "à travers" quand caché */
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#chatbot-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* -------------------- 3. EN-TÊTE DU PANNEAU -------------------- */
.chatbot-header {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 100%);
  color: #fff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;                /* ne se rétrécit jamais, même si les messages débordent */
}
.chatbot-header img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fff;
  padding: 2px;
}
.chatbot-header-text strong {
  display: block;
  font-family: var(--font-display);
  font-size: 0.98rem;
  color: #fff; /* sans ça, la règle globale "strong { color: bleu }" du
                  site prend le dessus, illisible sur ce fond bleu foncé */
}
.chatbot-header-text span {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.8);
}
.chatbot-header-text span::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6ee7a0;           /* petit point vert "en ligne" */
}

/* -------------------- 4. ZONE DES MESSAGES -------------------- */
.chatbot-messages {
  flex: 1;                       /* prend tout l'espace restant entre header et input */
  overflow-y: auto;              /* scroll si la conversation dépasse */
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--cream);
}

/* Une bulle de message : commune aux deux (bot et utilisateur),
   puis on ajuste position/couleur selon qui parle */
.chat-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.92rem;
  line-height: 1.45;
  animation: msg-in 0.25s ease;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-msg.bot {
  align-self: flex-start;        /* aligné à gauche */
  background: #fff;
  border: 1px solid var(--border);
  color: var(--ink);
  border-bottom-left-radius: 4px; /* petit "pincement" façon bulle de BD */
}
.chat-msg.user {
  align-self: flex-end;          /* aligné à droite */
  background: var(--blue);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg a { color: inherit; text-decoration: underline; }
.chat-msg.bot a { color: var(--blue); }

/* -------------------- 5. INDICATEUR "EN TRAIN D'ÉCRIRE" -------------------- */
.chat-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}
.chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-soft);
  opacity: 0.6;
  animation: typing-bounce 1.2s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

/* -------------------- 6. SUGGESTIONS RAPIDES -------------------- */
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.chat-suggestion-btn {
  background: var(--blue-soft-15);
  color: var(--blue);
  border: none;
  border-radius: var(--radius-full);
  padding: 7px 14px;
  font-size: 0.82rem;
  font-family: var(--font-display);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}
.chat-suggestion-btn:hover { background: var(--blue-soft); }

/* -------------------- 7. ZONE DE SAISIE -------------------- */
#chatbot-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: #fff;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
#chatbot-input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  padding: 10px 16px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--ink);
  min-width: 0;                  /* évite que le flex-item ne déborde du conteneur */
}
#chatbot-input:focus { outline: none; border-color: var(--blue-soft); }

#chatbot-form button[type="submit"] {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  border: none;
  background: var(--blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease;
}
#chatbot-form button[type="submit"]:hover { background: var(--blue-dark); }
#chatbot-form button[type="submit"] svg { width: 18px; height: 18px; }

/* -------------------- 8. RESPONSIVE -------------------- */
@media (max-width: 480px) {
  #chatbot-panel {
    right: 16px;
    left: 16px;
    bottom: 88px;
    width: auto;
    max-width: none;
    height: calc(100vh - 120px);
  }
  #chatbot-toggle { right: 16px; bottom: 16px; }
}