/* ============================================================
   Assistant RAG AFRIN3XUS -- widget flottant
   ============================================================ */

.afr-chat {
  position: fixed;
  right: 22px;
  bottom: 96px;                 /* au-dessus du bouton WhatsApp (.wa a bottom:22px) */
  z-index: 95;
  font-family: var(--ff-body, system-ui, sans-serif);
  color: var(--ink, #0b1d22);
}
.afr-chat * { box-sizing: border-box; }

/* -- FAB (bulle flottante) ------------------------------------ */
.afr-chat__fab {
  width: 60px; height: 60px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--gold, #f4b740), var(--coral, #ec6b5d));
  color: var(--ink, #0b1d22);
  display: grid; place-items: center;
  cursor: pointer;
  box-shadow: 0 18px 36px -12px rgba(5, 22, 27, .45), inset 0 0 0 1px rgba(255, 255, 255, .25);
  transition: transform .35s ease, box-shadow .35s ease;
  position: relative;
}
.afr-chat__fab:hover { transform: translateY(-3px) scale(1.04); box-shadow: 0 24px 46px -14px rgba(5, 22, 27, .55); }
.afr-chat__fab svg { width: 26px; height: 26px; }
.afr-chat__dot {
  position: absolute; top: 10px; right: 10px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--teal, #33a7a4);
  box-shadow: 0 0 0 2px #fff;
  animation: afr-pulse 2s ease-in-out infinite;
}
@keyframes afr-pulse {
  0%, 100% { transform: scale(1);   opacity: 1; }
  50%      { transform: scale(1.3); opacity: .55; }
}
.afr-chat--open .afr-chat__fab { opacity: 0; pointer-events: none; transform: scale(.7); }

/* Le bouton WhatsApp .wa reste à sa position (bottom:22px). */

/* -- Panneau ---------------------------------------------------- */
.afr-chat__panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 500px;                /* taille compacte a l'ouverture */
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 40px 80px -20px rgba(5, 22, 27, .45), inset 0 0 0 1px rgba(11, 29, 34, .06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: afr-pop .35s cubic-bezier(.22,.9,.3,1);
  transition: width .35s cubic-bezier(.22,.9,.3,1), height .35s cubic-bezier(.22,.9,.3,1);
}
/* L'attribut hidden doit gagner contre display:flex */
.afr-chat__panel[hidden] { display: none; }
/* Agrandissement progressif au premier message envoye */
.afr-chat--active .afr-chat__panel {
  width: 440px;
  height: 640px;
}
@keyframes afr-pop {
  from { opacity: 0; transform: translateY(16px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

/* -- En-tête ---------------------------------------------------- */
.afr-chat__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: linear-gradient(135deg, #061a1f, #0e3238);
  color: #fff;
  gap: 12px;
}
.afr-chat__brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.afr-chat__brand strong { display: block; font: 700 15px/1.2 var(--ff-display, serif); letter-spacing: -.01em; }
.afr-chat__brand small  { display: block; font-size: 11.5px; color: #9cbcb9; margin-top: 2px; letter-spacing: .02em; }
.afr-chat__avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--gold, #f4b740), var(--coral, #ec6b5d));
  color: var(--ink, #0b1d22);
  display: grid; place-items: center;
  font: 800 13px/1 var(--ff-display, sans-serif);
  letter-spacing: .04em;
  flex: none;
}
.afr-chat__close {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
  color: #fff; border: 0; cursor: pointer;
  display: grid; place-items: center;
  transition: background .3s;
}
.afr-chat__close:hover { background: rgba(255, 255, 255, .18); }
.afr-chat__close svg { width: 18px; height: 18px; }

/* -- Fil de messages ------------------------------------------- */
.afr-chat__log {
  flex: 1;
  overflow-y: auto;
  padding: 18px 18px 6px;
  background: var(--paper, #f6efe3);
  display: flex; flex-direction: column; gap: 14px;
}
.afr-chat__log::-webkit-scrollbar { width: 6px; }
.afr-chat__log::-webkit-scrollbar-thumb { background: rgba(11, 29, 34, .18); border-radius: 999px; }

.afr-msg { display: flex; flex-direction: column; gap: 8px; animation: afr-msg-in .3s ease both; }
@keyframes afr-msg-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.afr-msg__body {
  padding: 12px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  max-width: 85%;
  word-wrap: break-word;
}
.afr-msg--bot  .afr-msg__body { background: #fff; color: var(--ink, #0b1d22); border-top-left-radius: 6px; align-self: flex-start; box-shadow: inset 0 0 0 1px rgba(11, 29, 34, .06); }
.afr-msg--user .afr-msg__body { background: linear-gradient(135deg, var(--ink, #0b1d22), var(--deep, #064751)); color: #fff; border-top-right-radius: 6px; align-self: flex-end; }

.afr-ans__lead { font-size: 12.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted, #6a8588); margin: 0 0 8px; }
.afr-snip { display: flex; gap: 10px; margin: 6px 0 0; font-size: 14px; line-height: 1.5; }
.afr-snip__n { flex: none; width: 22px; height: 22px; border-radius: 999px; background: var(--ink, #0b1d22); color: var(--gold, #f4b740); display: grid; place-items: center; font: 800 11px/1 var(--ff-display, sans-serif); }

/* -- Sources sous une réponse --------------------------------- */
.afr-sources {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding-left: 6px;
}
.afr-sources__label {
  font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted, #6a8588); margin-right: 4px;
}
.afr-src {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(11, 29, 34, .14);
  color: var(--ink, #0b1d22);
  text-decoration: none;
  transition: background .25s, color .25s, box-shadow .25s;
}
.afr-src:hover { background: var(--ink, #0b1d22); color: var(--gold, #f4b740); box-shadow: none; }

/* -- Suggestions ---------------------------------------------- */
.afr-chat__suggest {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 0 18px 10px;
  background: var(--paper, #f6efe3);
}
.afr-chip {
  border: 0; cursor: pointer;
  padding: 7px 12px;
  border-radius: 999px;
  font: 700 12.5px var(--ff-body, system-ui);
  background: #fff;
  color: var(--deep, #064751);
  box-shadow: inset 0 0 0 1px rgba(11, 29, 34, .1);
  transition: background .25s, color .25s;
}
.afr-chip:hover { background: var(--teal, #33a7a4); color: #fff; box-shadow: none; }

/* -- Formulaire ----------------------------------------------- */
.afr-chat__form {
  display: flex;
  gap: 8px;
  padding: 12px 14px 14px;
  background: #fff;
  border-top: 1px solid rgba(11, 29, 34, .08);
}
.afr-chat__input {
  flex: 1;
  border: 0; outline: 0;
  padding: 11px 14px;
  border-radius: 999px;
  background: var(--paper, #f6efe3);
  font-size: 14px; color: var(--ink, #0b1d22);
  box-shadow: inset 0 0 0 1px rgba(11, 29, 34, .1);
}
.afr-chat__input:focus { box-shadow: inset 0 0 0 2px var(--teal, #33a7a4); background: #fff; }
.afr-chat__send {
  width: 42px; height: 42px; border: 0; cursor: pointer;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold, #f4b740), var(--coral, #ec6b5d));
  color: var(--ink, #0b1d22);
  display: grid; place-items: center;
  transition: transform .25s;
}
.afr-chat__send:hover { transform: scale(1.06); }
.afr-chat__send svg { width: 18px; height: 18px; }

/* -- Indicateur de saisie ------------------------------------- */
.afr-dots { display: inline-flex; gap: 4px; padding: 2px 0; }
.afr-dots i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted, #6a8588); opacity: .45;
  animation: afr-blink 1.1s infinite ease-in-out;
}
.afr-dots i:nth-child(2) { animation-delay: .18s; }
.afr-dots i:nth-child(3) { animation-delay: .36s; }
@keyframes afr-blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }

/* -- Responsive ------------------------------------------------ */
@media (max-width: 480px) {
  /* On reste cale sur le bouton WhatsApp (.wa bottom:22px) et on garde Nexa au-dessus */
  .afr-chat { right: 22px; bottom: 92px; }
  .afr-chat__panel { width: calc(100vw - 28px); height: 72vh; }
  .afr-chat--active .afr-chat__panel { width: calc(100vw - 28px); height: 80vh; }
}
