/* ════════════════════════════════════════════════════════════════
   CHATBOT WIDGET (AirCloud) — Sélection par thème sans texte
   ════════════════════════════════════════════════════════════════ */
#chatbotBtn {
  position: fixed;
  /* Placé sous l'icône WhatsApp (qui est remontée à bottom:98px) : le chatbot
     est le bouton le plus bas, son panneau s'ouvre donc vers le haut avec toute
     la hauteur disponible et reste entièrement visible. */
  bottom: 28px;
  right: 28px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #fff;
  border: 0;
  cursor: pointer;
  box-shadow: 0 10px 32px rgba(79, 70, 229, 0.4);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition: transform .2s, box-shadow .2s;
}
#chatbotBtn:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 14px 40px rgba(79, 70, 229, 0.5);
}
#chatbotBtn.is-open i::before {
  content: "\f00d";
}
#chatbotBtn .chatbot-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid #4f46e5;
  opacity: 0;
  animation: chatbotPulse 2.2s infinite;
}
@keyframes chatbotPulse {
  0% { transform: scale(.9); opacity: .7; }
  100% { transform: scale(1.25); opacity: 0; }
}

#chatbotPanel {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: min(420px, calc(100vw - 32px));
  max-height: min(640px, calc(100vh - 130px));
  background: #fff;
  border: 1px solid #ececec;
  border-radius: 20px;
  box-shadow: 0 30px 80px rgba(15, 23, 42, .25);
  z-index: 998;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity .25s, transform .25s;
  pointer-events: none;   /* couvre aussi la fenêtre d'animation de fermeture (200ms) */
}
#chatbotPanel.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
/* L'attribut [hidden] doit réellement masquer le panneau : sans cette règle, le
   `display:flex` ci-dessus l'emporte sur le display:none par défaut de [hidden],
   laissant un panneau invisible (opacity:0) qui interceptait les clics du bouton
   WhatsApp placé juste au-dessus. */
#chatbotPanel[hidden] { display: none !important; }

.chatbot__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #fff;
  flex-shrink: 0;
}
.chatbot__head-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.chatbot__head-text {
  flex: 1;
  min-width: 0;
}
.chatbot__head-text strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
}
.chatbot__head-text span {
  font-size: 11px;
  opacity: .9;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.chatbot__head-text span i {
  font-size: 6px;
  color: #4ade80;
}
.chatbot__head-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .15);
  color: #fff;
  border: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.chatbot__head-btn:hover {
  background: rgba(255, 255, 255, .25);
}
#chatbotClose {
  font-size: 22px;
  line-height: 1;
}

.chatbot__msgs {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  background: #f9f9f6;
}
.chatbot__msg {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  max-width: 100%;
}
.chatbot__msg--user {
  flex-direction: row-reverse;
}
.chatbot__av {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  color: #fff;
}
.chatbot__av.bot {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
}
.chatbot__av.user {
  background: linear-gradient(135deg, #111, #333);
  font-size: 11px;
}
.chatbot__bubble-wrap {
  display: flex;
  flex-direction: column;
  max-width: calc(100% - 44px);
  min-width: 0;
  gap: 4px;
}
.chatbot__msg--user .chatbot__bubble-wrap {
  align-items: flex-end;
}
.chatbot__bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  max-width: 100%;
  word-break: break-word;
}
.chatbot__msg--bot .chatbot__bubble {
  background: #fff;
  color: #111;
  border-bottom-left-radius: 4px;
  border: 1px solid #ececec;
}
.chatbot__msg--user .chatbot__bubble {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chatbot__bubble a {
  color: #4f46e5;
  font-weight: 600;
}
.chatbot__msg--user .chatbot__bubble a {
  color: #fff;
  text-decoration: underline;
}
.chatbot__bubble p { margin: 0 0 6px; color: inherit; }
.chatbot__bubble p:last-child { margin: 0; }
.chatbot__bubble ul, .chatbot__bubble ol { margin: 4px 0 4px 18px; padding: 0; }
.chatbot__bubble li, .chatbot__bubble strong, .chatbot__bubble em { color: inherit; }
.chatbot__bubble strong { font-weight: 700; }
.chatbot__bubble code { background: rgba(79,70,229,.12); color: #4f46e5; padding: 1px 6px; border-radius: 6px; font-size: .9em; font-family: ui-monospace, Menlo, Consolas, monospace; }
.chatbot__msg--user .chatbot__bubble code { background: rgba(255,255,255,.25); color: #fff; }

/* ── Rendu riche du markdown dans les bulles ────────────────────────────── */
/* Titres */
.chatbot__bubble .chatbot__h { margin: 10px 0 6px; line-height: 1.3; font-weight: 700; color: inherit; }
.chatbot__bubble .chatbot__h:first-child { margin-top: 0; }
.chatbot__bubble h1.chatbot__h { font-size: 1.18em; }
.chatbot__bubble h2.chatbot__h { font-size: 1.1em; }
.chatbot__bubble h3.chatbot__h { font-size: 1.02em; }
.chatbot__bubble h4.chatbot__h,
.chatbot__bubble h5.chatbot__h,
.chatbot__bubble h6.chatbot__h { font-size: .96em; text-transform: none; opacity: .9; }

/* Tableaux — scroll horizontal pour ne jamais déborder de la bulle */
.chatbot__table-wrap { width: 100%; overflow-x: auto; margin: 8px 0; -webkit-overflow-scrolling: touch; border-radius: 10px; border: 1px solid #e6e6ef; }
.chatbot__table-wrap table { border-collapse: collapse; width: 100%; font-size: 12px; background: #fff; }
.chatbot__table-wrap th,
.chatbot__table-wrap td { border: 1px solid #e6e6ef; padding: 6px 10px; text-align: left; vertical-align: top; white-space: normal; word-break: break-word; }
.chatbot__table-wrap thead th { background: #f3f2fb; color: #2b2740; font-weight: 700; position: sticky; top: 0; }
.chatbot__table-wrap tbody tr:nth-child(even) td { background: #faf9ff; }
.chatbot__msg--user .chatbot__table-wrap { border-color: rgba(255,255,255,.35); }
.chatbot__msg--user .chatbot__table-wrap table,
.chatbot__msg--user .chatbot__table-wrap th,
.chatbot__msg--user .chatbot__table-wrap td { background: transparent; color: #fff; border-color: rgba(255,255,255,.3); }
.chatbot__msg--user .chatbot__table-wrap thead th { background: rgba(255,255,255,.18); }
.chatbot__table-wrap::-webkit-scrollbar { height: 6px; }
.chatbot__table-wrap::-webkit-scrollbar-thumb { background: #cfcde0; border-radius: 3px; }

/* Images & fichiers */
.chatbot__bubble img { max-width: 100%; height: auto; border-radius: 10px; margin: 6px 0; display: block; border: 1px solid #ececec; }
.chatbot__bubble a i { margin-right: 2px; }

/* Bloc de code */
.chatbot__bubble pre { background: #1e1e2e; color: #e6e6f0; padding: 10px 12px; border-radius: 10px; overflow-x: auto; margin: 8px 0; font-size: 12px; }
.chatbot__bubble pre code { background: none; color: inherit; padding: 0; font-size: inherit; }

/* Citation & séparateur */
.chatbot__bubble blockquote { margin: 6px 0; padding: 4px 12px; border-left: 3px solid #4f46e5; background: rgba(79,70,229,.06); border-radius: 0 8px 8px 0; color: inherit; }
.chatbot__msg--user .chatbot__bubble blockquote { border-left-color: rgba(255,255,255,.7); background: rgba(255,255,255,.12); }
.chatbot__bubble hr { border: 0; border-top: 1px solid #e6e6ef; margin: 10px 0; }
.chatbot__bubble del { opacity: .7; }
.chatbot__ts {
  font-size: 10px;
  color: #999;
}
.chatbot__typing {
  display: inline-flex;
  gap: 5px;
  align-items: center;
}
.chatbot__typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f59e0b;
  animation: chatbotBounce 1.2s infinite;
}
.chatbot__typing span:nth-child(2) {
  animation-delay: .15s;
}
.chatbot__typing span:nth-child(3) {
  animation-delay: .3s;
}
@keyframes chatbotBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .5; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* Thèmes et Questions */
.chatbot__themes {
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  border-top: 1px solid #ececec;
  background: #fff;
  flex-shrink: 0;
}
.chatbot__theme-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 0;
}
.chatbot__theme-row small {
  font-size: 11px;
  color: #999;
  font-weight: 600;
  padding: 0 4px;
}
.chatbot__theme {
  border: 1.5px solid #ececec;
  background: #fff;
  color: #555;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all .15s;
  font-family: inherit;
  text-align: left;
}
.chatbot__theme:hover {
  border-color: #4f46e5;
  color: #4f46e5;
  background: #f0f4ff;
}
.chatbot__question {
  border: 1px solid #e5e7eb;
  background: #f3f4f6;
  color: #374151;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all .15s;
  font-family: inherit;
  text-align: left;
  width: 100%;
}
.chatbot__question:hover {
  background: #e5e7eb;
  color: #111;
  border-color: #4f46e5;
}
.chatbot__back {
  background: none;
  border: 0;
  cursor: pointer;
  color: #4f46e5;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 0;
  display: inline-flex;
  gap: 4px;
  align-items: center;
  margin-bottom: 4px;
}

.chatbot__foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px 12px;
  font-size: 11px;
  color: #999;
  gap: 8px;
  background: #fff;
  border-top: 1px solid #ececec;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.chatbot__contact {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding: 5px 10px;
  border: 1px solid #ececec;
  border-radius: 999px;
  color: #4f46e5;
  font-weight: 600;
  font-size: 11px;
  text-decoration: none;
}
.chatbot__contact:hover {
  background: #f0f4ff;
}

@media (max-width: 500px) {
  #chatbotBtn {
    bottom: 20px;
    right: 16px;
    width: 54px;
    height: 54px;
    font-size: 22px;
  }
  #chatbotPanel {
    bottom: 90px;
    right: 8px;
    left: 8px;
    width: auto;
    max-height: calc(100vh - 110px);
  }
}

/* Saisie libre (envoi vers le RAG central) */
.chatbot__form { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid #ececec; background: #fff; flex-shrink: 0; }
.chatbot__form input { flex: 1; border: 1.5px solid #ececec; border-radius: 999px; padding: 10px 14px; font-size: 13px; outline: none; transition: border-color .15s; font-family: inherit; }
.chatbot__form input:focus { border-color: #4f46e5; }
.chatbot__form button { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg, #4f46e5, #6366f1); color: #fff; border: 0; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; transition: transform .15s; }
.chatbot__form button:hover { transform: scale(1.08); }
.chatbot__form button:disabled { opacity: .5; cursor: not-allowed; }
