/* ==========================================================================
   Assistant de discussion — Fêtez-Moi
   --------------------------------------------------------------------------
   Reprend les jetons posés par fm-ui.css (rayons, ombres, courbe d'animation,
   palette dorée). Les valeurs de repli permettent au module de rester
   présentable si le thème change ou si la couche fm-ui n'est pas chargée.
   ========================================================================== */

.fmchatbot {
  --fmc-accent: var(--fm-accent, #b08d57);
  --fmc-accent-deep: var(--fm-accent-deep, #967542);
  --fmc-ink: var(--fm-ink, #292929);
  --fmc-ink-2: var(--fm-ink-2, #57534e);
  --fmc-ivory: var(--fm-ivory, #fdfaf6);
  --fmc-ivory-2: var(--fm-ivory-2, #f6f1e9);
  --fmc-line: var(--fm-line, #e8e2d9);
  --fmc-radius: var(--fm-r-lg, 26px);
  --fmc-radius-sm: var(--fm-r-sm, 12px);
  --fmc-shadow: var(--fm-sh-3, 0 4px 12px rgba(41, 35, 30, .06), 0 30px 60px -32px rgba(41, 35, 30, .32));
  --fmc-ease: var(--fm-ease, cubic-bezier(.22, .61, .36, 1));
  --fmc-dur: var(--fm-dur, .28s);

  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1040;
  font-size: 15px;
  line-height: 1.5;
  color: var(--fmc-ink);
}

/* --------------------------------------------------------------- Lanceur */

.fmchatbot__launcher {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 0 22px 0 18px;
  border: 0;
  border-radius: var(--fm-r-pill, 999px);
  background: var(--fmc-accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--fmc-shadow);
  transition: background var(--fmc-dur) var(--fmc-ease), transform var(--fmc-dur) var(--fmc-ease);
}

.fmchatbot__launcher:hover,
.fmchatbot__launcher:focus-visible {
  background: var(--fmc-accent-deep);
  transform: translateY(-2px);
}

.fmchatbot__launcher-icon {
  display: inline-flex;
}

.fmchatbot--open .fmchatbot__launcher {
  display: none;
}

/* --------------------------------------------------------------- Panneau */

.fmchatbot__panel {
  display: flex;
  flex-direction: column;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 48px);
  overflow: hidden;
  border: 1px solid var(--fmc-line);
  border-radius: var(--fmc-radius);
  background: #fff;
  box-shadow: var(--fmc-shadow);
}

.fmchatbot__panel[hidden] {
  display: none;
}

.fmchatbot__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--fmc-line);
  background: var(--fmc-ivory-2);
}

.fmchatbot__title {
  margin: 0;
  font-family: var(--fm-serif, Georgia, serif);
  font-size: 17px;
  font-weight: 600;
}

.fmchatbot__subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--fmc-ink-2);
}

.fmchatbot__close {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--fmc-ink-2);
  cursor: pointer;
  transition: background var(--fmc-dur) var(--fmc-ease);
}

.fmchatbot__close:hover,
.fmchatbot__close:focus-visible {
  background: rgba(41, 35, 30, .07);
}

/* ------------------------------------------------------------ Fil de discussion */

.fmchatbot__thread {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--fmc-ivory);
  overscroll-behavior: contain;
}

.fmchatbot__message {
  display: flex;
}

.fmchatbot__message--visitor {
  justify-content: flex-end;
}

.fmchatbot__bubble {
  max-width: 86%;
  padding: 11px 15px;
  border-radius: 18px;
  background: #fff;
  border: 1px solid var(--fmc-line);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.fmchatbot__message--visitor .fmchatbot__bubble {
  background: var(--fmc-accent);
  border-color: var(--fmc-accent);
  color: #fff;
}

.fmchatbot__bubble a {
  color: inherit;
  text-decoration: underline;
}

.fmchatbot__message--bot .fmchatbot__bubble a {
  color: var(--fmc-accent-deep);
}

/* Trois points d'attente pendant l'appel à l'API. */
.fmchatbot__typing {
  display: inline-flex;
  gap: 5px;
  padding: 4px 2px;
}

.fmchatbot__typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--fmc-ink-2);
  opacity: .35;
  animation: fmchatbot-pulse 1.2s infinite var(--fmc-ease);
}

.fmchatbot__typing span:nth-child(2) { animation-delay: .18s; }
.fmchatbot__typing span:nth-child(3) { animation-delay: .36s; }

@keyframes fmchatbot-pulse {
  0%, 60%, 100% { opacity: .25; transform: translateY(0); }
  30%           { opacity: .8;  transform: translateY(-3px); }
}

/* ------------------------------------------------------------------ Saisie */

.fmchatbot__notice {
  margin: 0;
  padding: 10px 20px;
  border-top: 1px solid var(--fmc-line);
  background: #fdf3f0;
  color: #8a3a26;
  font-size: 13px;
}

.fmchatbot__notice[hidden] {
  display: none;
}

.fmchatbot__form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--fmc-line);
  background: #fff;
}

.fmchatbot__label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.fmchatbot__input {
  flex: 1 1 auto;
  min-height: 44px;
  max-height: 132px;
  padding: 11px 14px;
  border: 1px solid var(--fmc-line);
  border-radius: var(--fmc-radius-sm);
  background: var(--fmc-ivory);
  font: inherit;
  color: inherit;
  resize: none;
}

.fmchatbot__input:focus {
  outline: 2px solid var(--fmc-accent);
  outline-offset: 1px;
}

.fmchatbot__send {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--fmc-accent);
  color: #fff;
  cursor: pointer;
  transition: background var(--fmc-dur) var(--fmc-ease);
}

.fmchatbot__send:hover:not(:disabled),
.fmchatbot__send:focus-visible:not(:disabled) {
  background: var(--fmc-accent-deep);
}

.fmchatbot__send:disabled {
  opacity: .45;
  cursor: default;
}

.fmchatbot__legal {
  margin: 0;
  padding: 0 16px 14px;
  background: #fff;
  color: var(--fmc-ink-2);
  font-size: 11.5px;
  line-height: 1.4;
}

/* ------------------------------------------------------------------ Mobile */

@media (max-width: 575px) {
  .fmchatbot {
    right: 16px;
    bottom: 16px;
  }

  .fmchatbot--open {
    inset: 0;
    right: 0;
    bottom: 0;
  }

  .fmchatbot--open .fmchatbot__panel {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    border: 0;
    border-radius: 0;
  }

  .fmchatbot__launcher-label {
    display: none;
  }

  .fmchatbot__launcher {
    padding: 0;
    width: 56px;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fmchatbot__launcher,
  .fmchatbot__close,
  .fmchatbot__send {
    transition: none;
  }

  .fmchatbot__typing span {
    animation: none;
  }
}
