/* ============================================================
   CHATBOT WIDGET — erwanjegou.com
   Cohérent avec le design system (variables CSS de style.css)
   ============================================================ */

/* ─── Bouton flottant ─────────────────────────────────────── */

.chatbot-toggle {
  position: fixed;
  bottom: 100px; /* Au-dessus du bouton WhatsApp */
  right: 28px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--accent, #C06A28);
  border: none;
  cursor: pointer;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(212, 117, 46, 0.4);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.chatbot-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 28px rgba(212, 117, 46, 0.5);
}

.chatbot-toggle:focus-visible {
  outline: 2px solid var(--accent-light, #E8A04A);
  outline-offset: 3px;
}

.chatbot-toggle svg {
  width: 28px;
  height: 28px;
  fill: #fff;
  transition: opacity 0.2s ease;
}

.chatbot-toggle .chatbot-icon-close {
  display: none;
}

.chatbot-toggle.active .chatbot-icon-chat {
  display: none;
}

.chatbot-toggle.active .chatbot-icon-close {
  display: block;
}

/* ─── Fenêtre de chat ─────────────────────────────────────── */

.chatbot-window {
  position: fixed;
  bottom: 172px;
  right: 28px;
  width: 380px;
  max-height: 520px;
  background: var(--bg-secondary, #16213E);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.chatbot-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ─── Header ──────────────────────────────────────────────── */

.chatbot-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px 12px 0 0;
  background: var(--bg-primary, #1A1A2E);
}

.chatbot-header__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent, #C06A28);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  flex-shrink: 0;
}

.chatbot-header__info {
  flex: 1;
}

.chatbot-header__name {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary, #F0F0F0);
  line-height: 1.2;
}

.chatbot-header__status {
  font-family: 'Outfit', sans-serif;
  font-weight: 400;
  font-size: 12px;
  color: var(--text-secondary, #A0A0B0);
}

.chatbot-header__close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s ease;
}

.chatbot-header__close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.chatbot-header__close svg {
  width: 18px;
  height: 18px;
}

/* ─── Messages ────────────────────────────────────────────── */

.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 280px;
  max-height: 340px;
}

.chatbot-messages::-webkit-scrollbar {
  width: 4px;
}

.chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

/* Message bulle */
.chatbot-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  animation: chatbot-fadeIn 0.3s ease;
}

.chatbot-msg--bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary, #F0F0F0);
  border-bottom-left-radius: 4px;
}

.chatbot-msg--user {
  align-self: flex-end;
  background: var(--accent, #C06A28);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Liens dans les messages bot */
.chatbot-msg--bot a {
  color: var(--accent-light, #E8A04A);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.chatbot-msg--bot a:hover {
  color: var(--accent, #C06A28);
}

/* Indicateur "typing" */
.chatbot-typing {
  display: flex;
  gap: 4px;
  padding: 12px 14px;
  align-self: flex-start;
}

.chatbot-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-secondary, #A0A0B0);
  animation: chatbot-bounce 1.4s ease-in-out infinite;
}

.chatbot-typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.chatbot-typing span:nth-child(3) {
  animation-delay: 0.4s;
}

/* ─── Quick replies (boutons cliquables) ──────────────────── */

.chatbot-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chatbot-quick-reply {
  padding: 8px 16px;
  border-radius: 20px;
  background: transparent;
  border: 1px solid var(--accent, #C06A28);
  color: var(--accent-light, #E8A04A);
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chatbot-quick-reply:hover {
  background: var(--accent, #C06A28);
  color: #fff;
  transform: scale(1.03);
}

.chatbot-quick-reply--selected {
  background: var(--accent, #C06A28);
  color: #fff;
}

.chatbot-quick-reply--used {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

/* ─── Créneaux RDV ────────────────────────────────────────── */

.chatbot-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.chatbot-slot {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(212, 117, 46, 0.15);
  border: 1px solid rgba(212, 117, 46, 0.3);
  color: var(--accent-light, #E8A04A);
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.2s ease, transform 0.2s ease;
}

.chatbot-slot:hover {
  background: rgba(212, 117, 46, 0.25);
  transform: scale(1.03);
}

/* ─── Zone de saisie ──────────────────────────────────────── */

.chatbot-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.chatbot-input__field {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 10px 14px;
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  color: var(--text-primary, #F0F0F0);
  outline: none;
  transition: border-color 0.3s ease;
}

.chatbot-input__field::placeholder {
  color: var(--text-secondary, #A0A0B0);
}

.chatbot-input__field:focus {
  border-color: var(--accent, #C06A28);
  box-shadow: 0 0 0 3px rgba(212, 117, 46, 0.1);
}

.chatbot-input__send {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--accent, #C06A28);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
  flex-shrink: 0;
}

.chatbot-input__send:hover {
  background: var(--accent-light, #E8A04A);
  transform: scale(1.05);
}

.chatbot-input__send:focus-visible {
  outline: 2px solid var(--accent-light, #E8A04A);
  outline-offset: 2px;
}

.chatbot-input__send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.chatbot-input__send svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

/* ─── Animations ──────────────────────────────────────────── */

@keyframes chatbot-fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes chatbot-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-4px);
  }
}

/* ─── Responsive ──────────────────────────────────────────── */

@media (max-width: 768px) {
  .chatbot-toggle {
    bottom: 92px;
    right: 16px;
    width: 52px;
    height: 52px;
  }

  .chatbot-toggle svg {
    width: 24px;
    height: 24px;
  }

  .chatbot-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
  }

  .chatbot-window.open {
    height: 100vh;
    height: 100dvh;
  }

  .chatbot-header {
    border-radius: 0;
    padding-top: calc(var(--topbar-height, 36px) + 12px);
  }

  .chatbot-messages {
    max-height: none;
    flex: 1;
  }

  .chatbot-input {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
}
