/* Assistant virtuel Mezanmi — widget flottant.
   Reprend les variables de style.css : aucune couleur codée en dur. */

.mz-chat {
  position: fixed;
  z-index: 90;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  font-family: var(--sans, system-ui, sans-serif);
}

/* ── Bouton ── */
.mz-chat__bouton {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border: 0;
  border-radius: 999px;
  background: var(--crimson, #C8102E);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow, 0 14px 40px rgba(60, 30, 20, .13));
  transition: transform .18s ease, background .18s ease;
}
.mz-chat__bouton:hover { background: var(--crimson-dark, #9C0B22); transform: translateY(-2px); }
.mz-chat__bouton:focus-visible { outline: 3px solid var(--gold, #D9A24A); outline-offset: 3px; }
.mz-chat__bouton svg { width: 20px; height: 20px; flex: none; }

/* ── Panneau ── */
.mz-chat__panneau {
  position: absolute;
  right: 0;
  bottom: 68px;
  width: 372px;
  max-width: calc(100vw - 36px);
  height: 520px;
  max-height: calc(100dvh - 120px);
  display: flex;
  flex-direction: column;
  background: var(--cream, #FDF8F3);
  border: 1px solid var(--line, rgba(32, 26, 23, .12));
  border-radius: var(--r, 18px);
  box-shadow: var(--shadow-lg, 0 30px 80px rgba(60, 30, 20, .2));
  overflow: hidden;
}

.mz-chat__tete {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--crimson, #C8102E);
  color: #fff;
}
.mz-chat__tete strong { font-size: 15px; line-height: 1.2; }
.mz-chat__tete small { display: block; font-size: 12px; opacity: .85; font-weight: 400; }
.mz-chat__fermer {
  margin-left: auto;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  color: #fff; font-size: 18px; line-height: 1; cursor: pointer;
}
.mz-chat__fermer:hover { background: rgba(255, 255, 255, .3); }

/* ── Fil ── */
.mz-chat__fil {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
}
.mz-chat__msg {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.mz-chat__msg--bot {
  align-self: flex-start;
  background: #fff;
  color: var(--ink, #201A17);
  border: 1px solid var(--line, rgba(32, 26, 23, .12));
  border-bottom-left-radius: 5px;
}
.mz-chat__msg--moi {
  align-self: flex-end;
  background: var(--crimson, #C8102E);
  color: #fff;
  border-bottom-right-radius: 5px;
}
.mz-chat__msg--erreur {
  align-self: flex-start;
  background: var(--blush, #F5E2DC);
  color: var(--crimson-dark, #9C0B22);
  border: 1px solid rgba(200, 16, 46, .25);
}

/* Indicateur de frappe */
.mz-chat__frappe { display: flex; gap: 4px; align-items: center; }
.mz-chat__frappe span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ink-soft, #4A423C);
  opacity: .35;
  animation: mzPulse 1.1s infinite;
}
.mz-chat__frappe span:nth-child(2) { animation-delay: .18s; }
.mz-chat__frappe span:nth-child(3) { animation-delay: .36s; }
@keyframes mzPulse { 0%, 60%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: .9; transform: translateY(-3px); } }

/* ── Suggestions ── */
.mz-chat__idees {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 10px;
}
.mz-chat__idees button {
  padding: 8px 13px;
  border: 1px solid var(--line, rgba(32, 26, 23, .12));
  border-radius: 999px;
  background: var(--cream-2, #F7EDE4);
  color: var(--ink, #201A17);
  font: inherit; font-size: 13px; cursor: pointer;
}
.mz-chat__idees button:hover { border-color: var(--crimson, #C8102E); color: var(--crimson, #C8102E); }

/* ── Saisie ── */
.mz-chat__saisie {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line, rgba(32, 26, 23, .12));
  background: #fff;
}
.mz-chat__saisie input {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  border: 1px solid var(--line, rgba(32, 26, 23, .12));
  border-radius: 999px;
  font: inherit; font-size: 15px;
  background: var(--cream, #FDF8F3);
  color: var(--ink, #201A17);
}
.mz-chat__saisie input:focus { outline: 2px solid var(--crimson, #C8102E); outline-offset: 1px; }
.mz-chat__saisie button {
  flex: none;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: var(--crimson, #C8102E);
  color: #fff; cursor: pointer;
}
.mz-chat__saisie button:disabled { opacity: .45; cursor: not-allowed; }
.mz-chat__saisie button svg { width: 18px; height: 18px; }

.mz-chat__note {
  padding: 0 16px 12px;
  font-size: 11.5px;
  color: var(--ink-soft, #4A423C);
  opacity: .75;
  text-align: center;
}

/* ── Mobile : feuille plein écran ── */
@media (max-width: 640px) {
  .mz-chat { right: 14px; bottom: 14px; }
  .mz-chat__bouton { padding: 13px 17px; font-size: 14px; }
  .mz-chat__panneau {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100dvh;
    max-height: none;
    max-width: none;
    border-radius: 0;
    border: 0;
  }
  .mz-chat__msg { max-width: 90%; }
}

@media (prefers-reduced-motion: reduce) {
  .mz-chat__bouton, .mz-chat__frappe span { transition: none; animation: none; }
}
