/**
 * chat.css — widget de chat du site (bulle + panneau), charte dotflo.
 * Mobile-first : panneau plein écran < 640 px, fenêtre 22.5rem au-delà.
 * Scoping .df-chat ; s'appuie sur tokens.css (variables --color-*, --font-*).
 */

.df-chat {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 60; /* bulle fermée : sous le bandeau cookies — le consentement d'abord */
}
.df-chat--open { z-index: 999; } /* panneau ouvert (action volontaire) : au-dessus de tout */

/* ── Bulle ─────────────────────────────────────────────────────── */
.df-chat__bubble {
  position: relative;
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  border: none;
  border-radius: 999px;
  background: var(--color-accent);
  color: #0B0E10;
  cursor: pointer;
  box-shadow: 0 10px 30px -8px rgba(0, 0, 0, 0.6);
  transition: transform var(--duration-fast) var(--ease-out);
}
.df-chat__bubble:hover { transform: scale(1.06); }
.df-chat__bubble:focus-visible { outline: 2px solid var(--color-text); outline-offset: 3px; }
.df-chat__bubble svg { width: 1.6rem; height: 1.6rem; }
.df-chat__icon-close { display: none; }
.df-chat--open .df-chat__icon-open { display: none; }
.df-chat--open .df-chat__icon-close { display: block; }

.df-chat__badge {
  position: absolute;
  top: -0.25rem;
  right: -0.25rem;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: #e5484d;
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.25rem;
  text-align: center;
}

/* ── Relance proactive (teaser) ────────────────────────────────── */
.df-chat__teaser {
  position: absolute;
  right: 0;
  bottom: 4.25rem;
  display: flex;
  align-items: flex-start;
  gap: 0.25rem;
  width: max-content;
  max-width: min(17rem, calc(100vw - 2rem));
  background: var(--color-surface);
  border: 1px solid var(--color-neutral-2);
  border-radius: var(--radius-lg);
  border-bottom-right-radius: 0.4rem;
  box-shadow: 0 18px 40px -14px rgba(0, 0, 0, 0.7);
  opacity: 0;
  transform: translateY(0.5rem) scale(0.96);
  transform-origin: bottom right;
  transition: opacity var(--duration-normal) var(--ease-out), transform var(--duration-normal) var(--ease-out);
  pointer-events: none;
}
.df-chat__teaser.is-visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.df-chat__teaser-text {
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
  color: var(--color-neutral-1);
  font-family: var(--font-body);
  font-size: 0.85rem;
  line-height: 1.45;
  padding: 0.8rem 0 0.8rem 1rem;
}
.df-chat__teaser-text strong { color: var(--color-text); font-weight: var(--font-weight-bold); }
.df-chat__teaser-close {
  flex: none;
  display: grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  margin: 0.35rem 0.35rem 0 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--color-neutral-1);
  cursor: pointer;
}
.df-chat__teaser-close:hover { color: var(--color-text); background: var(--color-surface-2); }
.df-chat__teaser-close svg { width: 0.8rem; height: 0.8rem; }
@media (prefers-reduced-motion: reduce) {
  .df-chat__teaser { transition: none; }
}

/* ── Panneau ───────────────────────────────────────────────────── */
.df-chat__panel {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font-body);
  overflow: hidden;
}

@media (min-width: 640px) {
  .df-chat__panel {
    inset: auto 0 4.5rem auto;
    width: 22.5rem;
    height: min(34rem, calc(100vh - 6.5rem));
    border: 1px solid var(--color-neutral-2);
    border-radius: var(--radius-lg);
    box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.8);
  }
}

.df-chat__head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.85rem 1rem;
  background: var(--color-bg-2);
  border-bottom: 1px solid var(--color-neutral-2);
}
.df-chat__dot { width: 0.6rem; height: 0.6rem; border-radius: 999px; background: #6b7280; flex: none; }
.df-chat--online .df-chat__dot { background: #22c55e; }
.df-chat__who { display: grid; line-height: 1.25; min-width: 0; }
.df-chat__who strong { font-size: 0.95rem; font-weight: var(--font-weight-bold); }
.df-chat__who small { color: var(--color-neutral-1); font-size: 0.75rem; }
.df-chat__close {
  margin-left: auto;
  display: grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-neutral-1);
  cursor: pointer;
}
.df-chat__close:hover { color: var(--color-text); background: var(--color-surface-2); }
.df-chat__close svg { width: 1.1rem; height: 1.1rem; }

/* ── Contenus ──────────────────────────────────────────────────── */
.df-chat__offline,
.df-chat__start {
  display: grid;
  gap: 0.9rem;
  padding: 1.25rem 1rem;
  overflow-y: auto;
}
.df-chat__offline p { margin: 0; }
.df-chat__muted { color: var(--color-neutral-1); font-size: 0.85rem; margin: 0; }
.df-chat__cta { justify-self: start; }

.df-chat__field { display: grid; gap: 0.3rem; font-size: 0.85rem; }
.df-chat__field span { color: var(--color-neutral-1); }
.df-chat__field em { font-style: normal; font-size: 0.78rem; }
.df-chat__field input,
.df-chat__field textarea {
  width: 100%;
  border: 1px solid var(--color-neutral-2);
  border-radius: var(--radius-md);
  background: var(--color-bg-2);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 16px; /* évite le zoom iOS au focus */
  padding: 0.55rem 0.7rem;
  resize: vertical;
}
.df-chat__field input:focus,
.df-chat__field textarea:focus,
.df-chat__send textarea:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}
.df-chat__hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.df-chat__error { color: #ff8a8e; font-size: 0.82rem; margin: 0; }

.df-chat__conv { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.df-chat__messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 1rem;
  overscroll-behavior: contain;
}
.df-chat__msg {
  max-width: 82%;
  padding: 0.5rem 0.75rem;
  border-radius: 0.85rem;
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.df-chat__msg--visitor {
  align-self: flex-end;
  background: var(--color-accent);
  color: #0B0E10;
  border-bottom-right-radius: 0.25rem;
}
.df-chat__msg--admin {
  align-self: flex-start;
  background: var(--color-surface-2);
  border-bottom-left-radius: 0.25rem;
}
.df-chat__msg time { display: block; margin-top: 0.15rem; font-size: 0.65rem; opacity: 0.6; }

.df-chat__end {
  align-self: center;
  margin: 0 0 0.4rem;
  background: none;
  border: none;
  color: var(--color-neutral-1);
  font-family: var(--font-body);
  font-size: 0.72rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 0.2rem 0.6rem;
}
.df-chat__end:hover { color: var(--color-text); }
.df-chat__end[data-armed="1"] { color: #ff8a8e; text-decoration: none; font-weight: 600; }

.df-chat__notice {
  margin: 0;
  padding: 0.5rem 1rem;
  font-size: 0.78rem;
  color: var(--color-neutral-1);
  border-top: 1px solid var(--color-neutral-2);
}

/* Hors ligne sans email connu : proposition d'en laisser un */
.df-chat__emailform {
  display: grid;
  gap: 0.45rem;
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--color-neutral-2);
}
.df-chat__emailrow { display: flex; gap: 0.5rem; }
.df-chat__emailrow input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--color-neutral-2);
  border-radius: var(--radius-md);
  background: var(--color-bg-2);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 16px;
  padding: 0.45rem 0.65rem;
}
.df-chat__emailrow input:focus { outline: 2px solid var(--color-accent); outline-offset: 1px; }
.df-chat__emailrow .btn { padding: 0.45rem 0.9rem; }

.df-chat__send {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.65rem 0.65rem calc(0.65rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--color-neutral-2);
  background: var(--color-bg-2);
}
@media (min-width: 640px) {
  .df-chat__send { padding-bottom: 0.65rem; }
}
.df-chat__send textarea {
  flex: 1;
  max-height: 7rem;
  border: 1px solid var(--color-neutral-2);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 16px;
  padding: 0.55rem 0.7rem;
  resize: none;
}
.df-chat__sendbtn {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border: none;
  border-radius: var(--radius-md);
  background: var(--color-accent);
  color: #0B0E10;
  cursor: pointer;
}
.df-chat__sendbtn:hover { filter: brightness(1.1); }
.df-chat__sendbtn svg { width: 1.25rem; height: 1.25rem; }

@media (prefers-reduced-motion: reduce) {
  .df-chat__bubble { transition: none; }
}
