/* ═══════════════════════════════════════════════
   BAUDCHON.EU — Widget chatbot Camille
   Front-end vanilla — cohérent avec le design system
   ═══════════════════════════════════════════════ */

/* Variables fallback si chargé avant style.css */
.chatbot-root {
  --cb-ink: var(--ink, #1a1a1a);
  --cb-ink-light: var(--ink-light, #3d3d3d);
  --cb-ink-muted: var(--ink-muted, #636363);
  --cb-cream: var(--cream, #f5f2ed);
  --cb-cream-dark: var(--cream-dark, #ebe6de);
  --cb-white: #ffffff;
  --cb-accent: var(--accent, #8b6914);
  --cb-accent-light: var(--accent-light, #c49b2a);
  --cb-red: #b53a3a;
  --cb-radius: 12px;
  --cb-font: var(--sans, 'Outfit', -apple-system, 'Segoe UI', sans-serif);
}

/* ─── BOUTON FLOTTANT ─── */
.chatbot-button {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--cb-ink);
  border: none;
  cursor: pointer;
  z-index: 9998;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--cb-font);
  color: var(--cb-accent-light);
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1;
  padding: 0;
}
.chatbot-button:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.24);
}
.chatbot-button:focus-visible {
  outline: 2px solid var(--cb-accent-light);
  outline-offset: 3px;
}
.chatbot-button .chatbot-button-icon {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
  pointer-events: none;
}
.chatbot-button.is-open {
  background: var(--cb-accent);
  color: var(--cb-white);
}
.chatbot-button.is-open .chatbot-button-icon {
  display: none;
}
.chatbot-button .chatbot-button-close {
  display: none;
  font-size: 1.4rem;
  font-weight: 400;
}
.chatbot-button.is-open .chatbot-button-close {
  display: inline;
}

/* ─── FENÊTRE ─── */
.chatbot-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  height: 560px;
  background: var(--cb-white);
  border-radius: var(--cb-radius);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.2);
  z-index: 9999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--cb-font);
  color: var(--cb-ink);
  border: 1px solid var(--cb-cream-dark);
}
.chatbot-window.is-open {
  display: flex;
  animation: chatbot-open 0.25s ease forwards;
}
@keyframes chatbot-open {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── HEADER ─── */
.chatbot-header {
  height: 70px;
  background: var(--cb-ink);
  color: var(--cb-white);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 12px;
  flex-shrink: 0;
}
.chatbot-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--cb-accent);
  color: var(--cb-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif, 'Cormorant Garamond', Georgia, serif);
  font-style: italic;
  font-size: 1.3rem;
  font-weight: 600;
  flex-shrink: 0;
  overflow: hidden;
}
.chatbot-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.chatbot-identity {
  flex: 1;
  min-width: 0;
  line-height: 1.2;
}
.chatbot-identity strong {
  display: block;
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.chatbot-identity span {
  display: block;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.65);
  margin-top: 2px;
}
.chatbot-close {
  background: transparent;
  border: none;
  color: var(--cb-white);
  font-size: 1.4rem;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s ease;
  padding: 0;
  line-height: 1;
}
.chatbot-close:hover { background: rgba(255, 255, 255, 0.1); }
.chatbot-close:focus-visible {
  outline: 2px solid var(--cb-accent-light);
  outline-offset: 1px;
}

/* ─── ZONE MESSAGES ─── */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--cb-white);
  scroll-behavior: smooth;
}
.chatbot-messages::-webkit-scrollbar { width: 6px; }
.chatbot-messages::-webkit-scrollbar-thumb {
  background: var(--cb-cream-dark);
  border-radius: 3px;
}

.chatbot-msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: var(--cb-radius);
  font-size: 0.92rem;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.chatbot-msg.user {
  align-self: flex-end;
  background: var(--cb-cream);
  color: var(--cb-ink);
  border-bottom-right-radius: 4px;
}
.chatbot-msg.assistant {
  align-self: flex-start;
  background: var(--cb-ink-light);
  color: var(--cb-white);
  border-bottom-left-radius: 4px;
}
.chatbot-msg a {
  color: var(--cb-accent-light);
  text-decoration: underline;
}
.chatbot-msg.user a { color: var(--cb-accent); }

/* ─── ANIMATION TYPING ─── */
.chatbot-typing {
  align-self: flex-start;
  background: var(--cb-ink-light);
  color: var(--cb-white);
  padding: 12px 16px;
  border-radius: var(--cb-radius);
  border-bottom-left-radius: 4px;
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.chatbot-typing span {
  width: 7px;
  height: 7px;
  background: var(--cb-white);
  border-radius: 50%;
  opacity: 0.4;
  animation: chatbot-pulse 1.2s infinite ease-in-out;
}
.chatbot-typing span:nth-child(2) { animation-delay: 0.2s; }
.chatbot-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatbot-pulse {
  0%, 60%, 100% { opacity: 0.4; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ─── ERREUR ─── */
.chatbot-error {
  align-self: stretch;
  background: rgba(181, 58, 58, 0.08);
  color: var(--cb-red);
  border: 1px solid rgba(181, 58, 58, 0.25);
  padding: 10px 14px;
  border-radius: var(--cb-radius);
  font-size: 0.88rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chatbot-error button {
  align-self: flex-start;
  background: var(--cb-red);
  color: var(--cb-white);
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-family: var(--cb-font);
  font-size: 0.82rem;
  cursor: pointer;
}
.chatbot-error button:hover { opacity: 0.9; }

/* ─── ZONE INPUT ─── */
.chatbot-input {
  border-top: 1px solid var(--cb-cream-dark);
  padding: 12px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--cb-white);
  flex-shrink: 0;
}
.chatbot-input textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--cb-cream-dark);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: var(--cb-font);
  font-size: 0.92rem;
  color: var(--cb-ink);
  background: var(--cb-white);
  line-height: 1.4;
  max-height: 80px;
  min-height: 38px;
  outline: none;
  transition: border-color 0.15s ease;
}
.chatbot-input textarea:focus {
  border-color: var(--cb-accent);
}
.chatbot-input textarea::placeholder {
  color: var(--cb-ink-muted);
}
.chatbot-send {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--cb-accent);
  color: var(--cb-white);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
  transition: background 0.15s ease;
}
.chatbot-send:hover:not(:disabled) { background: var(--cb-accent-light); }
.chatbot-send:disabled {
  background: var(--cb-cream-dark);
  color: var(--cb-ink-muted);
  cursor: not-allowed;
}
.chatbot-send:focus-visible {
  outline: 2px solid var(--cb-accent-light);
  outline-offset: 2px;
}

/* ─── FOOTER ─── */
.chatbot-footer {
  padding: 6px 14px 10px;
  font-size: 0.72rem;
  color: var(--cb-ink-muted);
  text-align: center;
  background: var(--cb-white);
  flex-shrink: 0;
}
.chatbot-footer button {
  background: none;
  border: none;
  color: var(--cb-ink-muted);
  text-decoration: underline;
  cursor: pointer;
  font-family: var(--cb-font);
  font-size: 0.72rem;
  padding: 0;
}
.chatbot-footer button:hover { color: var(--cb-ink); }

/* ─── RESPONSIVE MOBILE ─── */
@media (max-width: 600px) {
  .chatbot-window {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 0;
    border: none;
  }
  .chatbot-button {
    bottom: 16px;
    right: 16px;
    width: 54px;
    height: 54px;
  }
}

/* ─── ACCESSIBILITÉ ─── */
@media (prefers-reduced-motion: reduce) {
  .chatbot-window.is-open { animation: none; }
  .chatbot-typing span { animation: none; opacity: 0.7; }
  .chatbot-button { transition: none; }
}
