/* ════════════════════════════════════════════════════════════
   MINI-CHAT (en bas à droite)
   ════════════════════════════════════════════════════════════ */
.chat { position: fixed; right: clamp(0.9rem, 0.5rem + 1vw, 1.5rem); bottom: calc(clamp(0.9rem, 0.5rem + 1vw, 1.5rem) + env(safe-area-inset-bottom, 0px)); z-index: 70; display: flex; flex-direction: column; align-items: flex-end; gap: 0.75rem; transition: transform 400ms cubic-bezier(0.2, 0.7, 0.2, 1); }

/* Lanceur */
.chat__lanceur {
  position: relative; width: 62px; height: 62px; border-radius: 50%; border: 0; cursor: pointer;
  background: linear-gradient(145deg, var(--terracotta-500), var(--terracotta-700)); color: var(--blanc);
  box-shadow: 0 14px 30px rgba(94, 38, 23, 0.35); transition: transform var(--transition), box-shadow var(--transition);
}
.chat__lanceur:hover { transform: translateY(-3px) scale(1.04); box-shadow: 0 18px 36px rgba(94, 38, 23, 0.42); }
.chat__lanceur:focus-visible { box-shadow: var(--focus), 0 14px 30px rgba(94, 38, 23, 0.35); border-radius: 50%; }
.chat__lanceur::after {
  content: ""; position: absolute; top: 4px; right: 4px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--or-400); border: 2px solid var(--blanc);
}
.chat.est-ouvert .chat__lanceur::after { display: none; }
.chat__icone { position: absolute; left: 50%; top: 50%; width: 28px; height: 28px; margin: -14px 0 0 -14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform 300ms ease, opacity 300ms ease; }
.chat__icone--fermer { opacity: 0; transform: rotate(-90deg) scale(0.6); }
.chat.est-ouvert .chat__icone--ouvrir { opacity: 0; transform: rotate(90deg) scale(0.6); }
.chat.est-ouvert .chat__icone--fermer { opacity: 1; transform: none; }

/* Bulle d'accroche */
.chat__accroche {
  position: relative; max-width: 260px; padding: 0.9rem 2.2rem 0.9rem 1rem; cursor: pointer;
  background: var(--blanc); border: 1px solid var(--sable-200); border-radius: 18px 18px 4px 18px; box-shadow: var(--ombre-3);
  font-size: 0.9rem; line-height: 1.45; animation: chat-apparait 450ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.chat__accroche p { margin: 0; }
.chat__accroche-fermer {
  position: absolute; top: 0.35rem; right: 0.35rem; width: 32px; height: 32px; border: 0; border-radius: 50%;
  background: transparent; font-size: 1.3rem; line-height: 1; color: var(--encre-500); cursor: pointer;
}
.chat__accroche-fermer:hover { background: var(--sable-100); color: var(--encre-900); }
@keyframes chat-apparait { from { opacity: 0; transform: translateY(10px) scale(0.96); } to { opacity: 1; transform: none; } }

/* Fenêtre */
.chat__fenetre {
  display: flex; flex-direction: column; width: min(380px, calc(100vw - 2rem)); height: min(580px, calc(100vh - 120px));
  background: var(--sable-50); border: 1px solid var(--sable-200); border-radius: var(--rayon-l); overflow: hidden;
  box-shadow: 0 30px 70px rgba(94, 38, 23, 0.28), 0 8px 20px rgba(94, 38, 23, 0.12);
  transform-origin: bottom right; animation: chat-apparait 350ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.chat__tete {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.95rem 0.9rem 0.95rem 1.1rem;
  background: radial-gradient(18rem 10rem at 100% 0%, rgba(226, 182, 110, 0.3), transparent 60%), var(--terracotta-800); color: var(--sable-50);
}
.chat__avatar { width: 40px; height: 36px; flex: none; border-radius: 12px; }
.chat__tete > div { flex: 1; min-width: 0; }
.chat__titre { margin: 0; font: 500 1.08rem var(--police-titre); }
.chat__statut { margin: 0; font-size: 0.76rem; color: rgba(251, 247, 240, 0.78); }
.chat__fermer { width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent; color: var(--sable-50); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.chat__fermer:hover { background: rgba(251, 247, 240, 0.14); }
.chat__fermer svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.chat__fermer:focus-visible { box-shadow: 0 0 0 3px var(--or-400); border-radius: 50%; }

.chat__fil { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.5rem; overscroll-behavior: contain; }
.chat__bulle { max-width: 86%; padding: 0.7rem 0.95rem; font-size: 0.92rem; line-height: 1.5; animation: chat-message 300ms ease; overflow-wrap: anywhere; }
.chat__bulle a { color: inherit; font-weight: 700; }
.chat__bulle--assistant { align-self: flex-start; background: var(--blanc); border: 1px solid var(--sable-200); border-radius: 4px 18px 18px 18px; }
.chat__bulle--assistant a { color: var(--terracotta-700); }
.chat__bulle--visiteur { align-self: flex-end; background: var(--terracotta-600); color: var(--blanc); border-radius: 18px 4px 18px 18px; }
@keyframes chat-message { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.chat__frappe { display: inline-flex; gap: 4px; padding: 0.2rem 0; }
.chat__frappe span { width: 7px; height: 7px; border-radius: 50%; background: var(--sable-300); animation: chat-point 1s infinite ease-in-out; }
.chat__frappe span:nth-child(2) { animation-delay: 150ms; }
.chat__frappe span:nth-child(3) { animation-delay: 300ms; }
@keyframes chat-point { 0%, 60%, 100% { transform: translateY(0); background: var(--sable-300); } 30% { transform: translateY(-5px); background: var(--terracotta-500); } }

.chat__choix { display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0 1rem; }
.chat__choix:not(:empty) { padding-bottom: 0.75rem; }
.chat__puce {
  min-height: 40px; padding: 0.45rem 0.9rem; border-radius: var(--rayon-pilule); cursor: pointer;
  background: var(--blanc); border: 1.5px solid var(--terracotta-500); color: var(--terracotta-800);
  font: 700 0.86rem var(--police-texte); transition: background-color var(--transition), color var(--transition);
}
.chat__puce:hover { background: var(--terracotta-600); color: var(--blanc); border-color: var(--terracotta-600); }
.chat__puce--discrete { border-color: var(--sable-300); color: var(--encre-700); }

.chat__saisie { display: flex; gap: 0.5rem; padding: 0.75rem; border-top: 1px solid var(--sable-200); background: var(--blanc); }
.chat__champ {
  flex: 1; min-width: 0; min-height: 46px; padding: 0.55rem 0.95rem; border-radius: var(--rayon-pilule);
  border: 1.5px solid var(--sable-300); background: var(--sable-50); font: 500 0.95rem var(--police-texte); color: var(--encre-900);
}
.chat__champ:focus { border-color: var(--terracotta-600); background: var(--blanc); }
.chat__champ:focus-visible { box-shadow: 0 0 0 3px rgba(168, 74, 48, 0.18); border-radius: var(--rayon-pilule); }
.chat__envoyer { width: 46px; height: 46px; flex: none; border: 0; border-radius: 50%; cursor: pointer; background: var(--terracotta-600); color: var(--blanc); display: flex; align-items: center; justify-content: center; }
.chat__envoyer:hover { background: var(--terracotta-700); }
.chat__envoyer svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.chat__envoyer:focus-visible { border-radius: 50%; }

.chat__consentement { align-self: stretch; padding: 0.95rem; background: var(--blanc); border: 1px solid var(--sable-200); border-radius: 18px; animation: chat-message 300ms ease; }
.chat__recap { margin: 0 0 0.75rem; font-weight: 700; font-size: 0.88rem; }
.chat__case { display: flex; gap: 0.6rem; align-items: flex-start; font-size: 0.86rem; line-height: 1.45; }
.chat__case input { width: 20px; height: 20px; margin: 0.1rem 0 0; flex: none; accent-color: var(--terracotta-600); }
.chat__case span { color: var(--encre-500); }
.chat__erreur { margin: 0.4rem 0 0; font-size: 0.82rem; font-weight: 600; color: #B3261E; }
.chat__erreur:empty { display: none; }
.chat__valider { width: 100%; margin-top: 0.75rem; min-height: 44px; font-size: 0.92rem; }
.chat__valider:disabled { opacity: 0.55; cursor: default; transform: none; }
.chat__rgpd { margin: 0.75rem 0 0; font-size: 0.72rem; line-height: 1.5; color: var(--encre-500); }
.chat__rgpd a { color: var(--terracotta-700); }

/* Mobile : la fenêtre occupe le bas de l'écran ; le lanceur remonte au-dessus du bouton collant */
@media (max-width: 760px) {
  .chat.au-dessus-du-collant:not(.est-ouvert) { transform: translateY(-4.4rem); }
  .chat.est-ouvert { left: 0.5rem; right: 0.5rem; bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px)); }
  .chat.est-ouvert .chat__fenetre { width: 100%; height: calc(100dvh - 1rem - env(safe-area-inset-bottom, 0px)); max-height: 720px; }
  .chat.est-ouvert .chat__lanceur { display: none; }
  .chat__accroche { max-width: 230px; }
}

@media (prefers-reduced-motion: reduce) {
  .chat__frappe span { animation: none; }
  .chat__fenetre, .chat__accroche, .chat__bulle, .chat__consentement { animation: none; }
}
