/* ============================================
   TradiEco Chatbot Widget - Styles
   ============================================ */

/* Variables CSS - Design Tokens TradiEco */
:root {
  --chatbot-primary: #029A8B;
  --chatbot-primary-dark: #027d71;
  --chatbot-cta: #FA7601;
  --chatbot-cta-hover: #e06a00;
  --chatbot-dark: #000000;
  --chatbot-light: #FFFFFF;
  --chatbot-text-secondary: #BFC7C7;
  --chatbot-bg-light: #f5f7f7;
  --chatbot-border: #e0e5e5;
  --chatbot-shadow: rgba(0, 0, 0, 0.15);
  --chatbot-radius: 16px;
  --chatbot-radius-sm: 8px;
  --chatbot-transition: 0.3s ease;
}

/* Reset pour le widget */
.tradieco-chatbot *,
.tradieco-chatbot *::before,
.tradieco-chatbot *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ============================================
   Bouton flottant
   ============================================ */
.chatbot-toggle-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--chatbot-primary);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px var(--chatbot-shadow);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--chatbot-transition);
}

.chatbot-toggle-btn:hover {
  background: var(--chatbot-primary-dark);
  transform: scale(1.05);
  box-shadow: 0 6px 20px var(--chatbot-shadow);
}

.chatbot-toggle-btn svg {
  width: 28px;
  height: 28px;
  fill: var(--chatbot-light);
  transition: transform var(--chatbot-transition);
}

.chatbot-toggle-btn.is-open svg {
  transform: rotate(180deg);
}

/* Notification badge */
.chatbot-toggle-btn .chatbot-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  background: var(--chatbot-cta);
  color: var(--chatbot-light);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: chatbot-pulse 2s infinite;
}

@keyframes chatbot-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* ============================================
   Fenetre principale du chatbot
   ============================================ */
.chatbot-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 48px);
  height: 550px;
  max-height: calc(100vh - 140px);
  background: var(--chatbot-light);
  border-radius: var(--chatbot-radius);
  box-shadow: 0 8px 32px var(--chatbot-shadow);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: all var(--chatbot-transition);
}

.chatbot-window.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* ============================================
   Header
   ============================================ */
.chatbot-header {
  background: var(--chatbot-primary);
  color: var(--chatbot-light);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.chatbot-header-avatar {
  width: 44px;
  height: 44px;
  background: #203434;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chatbot-header-avatar img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.chatbot-header-info {
  flex: 1;
  min-width: 0;
}

.chatbot-header-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 2px;
}

.chatbot-header-status {
  font-size: 12px;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chatbot-header-status::before {
  content: '';
  width: 8px;
  height: 8px;
  background: #4ade80;
  border-radius: 50%;
}

.chatbot-close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--chatbot-transition);
}

.chatbot-close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.chatbot-close-btn svg {
  width: 18px;
  height: 18px;
  stroke: var(--chatbot-light);
  stroke-width: 2;
}

/* ============================================
   Zone de messages
   ============================================ */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--chatbot-bg-light);
}

/* Scrollbar personnalisee */
.chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

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

.chatbot-messages::-webkit-scrollbar-thumb {
  background: var(--chatbot-border);
  border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: var(--chatbot-text-secondary);
}

/* Message de base */
.chatbot-message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: var(--chatbot-radius);
  font-size: 14px;
  line-height: 1.5;
  animation: chatbot-fadeIn 0.3s ease;
}

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

/* Message du bot */
.chatbot-message.is-bot {
  background: var(--chatbot-light);
  color: var(--chatbot-dark);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* Message de l'utilisateur */
.chatbot-message.is-user {
  background: var(--chatbot-primary);
  color: var(--chatbot-light);
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}

/* Liens dans les messages */
.chatbot-message-links {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chatbot-message-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--chatbot-cta);
  color: var(--chatbot-light);
  text-decoration: none;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--chatbot-transition);
}

.chatbot-message-link:hover {
  background: var(--chatbot-cta-hover);
  transform: translateY(-1px);
}

.chatbot-message-link svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

/* Indicateur de frappe */
.chatbot-typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: var(--chatbot-light);
  border-radius: var(--chatbot-radius);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

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

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

@keyframes chatbot-typingDot {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ============================================
   Questions rapides
   ============================================ */
.chatbot-quick-questions {
  padding: 12px 16px;
  background: var(--chatbot-light);
  border-top: 1px solid var(--chatbot-border);
  flex-shrink: 0;
}

.chatbot-quick-questions-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--chatbot-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.chatbot-quick-questions-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 80px;
  overflow-y: auto;
}

.chatbot-quick-btn {
  background: var(--chatbot-bg-light);
  border: 1px solid var(--chatbot-border);
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12px;
  color: var(--chatbot-dark);
  cursor: pointer;
  transition: all var(--chatbot-transition);
  white-space: nowrap;
}

.chatbot-quick-btn:hover {
  background: var(--chatbot-primary);
  border-color: var(--chatbot-primary);
  color: var(--chatbot-light);
}

/* ============================================
   Zone de saisie
   ============================================ */
.chatbot-input-area {
  padding: 12px 16px;
  background: var(--chatbot-light);
  border-top: 1px solid var(--chatbot-border);
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
}

.chatbot-input {
  flex: 1;
  border: 1px solid var(--chatbot-border);
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 14px;
  outline: none;
  transition: border-color var(--chatbot-transition);
  font-family: inherit;
}

.chatbot-input:focus {
  border-color: var(--chatbot-primary);
}

.chatbot-input::placeholder {
  color: var(--chatbot-text-secondary);
}

.chatbot-send-btn {
  width: 42px;
  height: 42px;
  background: var(--chatbot-primary);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--chatbot-transition);
  flex-shrink: 0;
}

.chatbot-send-btn:hover {
  background: var(--chatbot-primary-dark);
  transform: scale(1.05);
}

.chatbot-send-btn:disabled {
  background: var(--chatbot-border);
  cursor: not-allowed;
  transform: none;
}

.chatbot-send-btn svg {
  width: 20px;
  height: 20px;
  fill: var(--chatbot-light);
}

/* ============================================
   Responsive - Mobile
   ============================================ */
@media (max-width: 480px) {
  .chatbot-toggle-btn {
    bottom: 16px;
    right: 16px;
    width: 56px;
    height: 56px;
  }

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

  .chatbot-header {
    padding: 14px 16px;
  }

  .chatbot-messages {
    padding: 12px;
  }

  .chatbot-quick-questions {
    padding: 10px 12px;
  }

  .chatbot-quick-questions-list {
    max-height: 70px;
  }

  .chatbot-input-area {
    padding: 10px 12px;
  }
}

/* ============================================
   Animation d'entree initiale
   ============================================ */
.chatbot-window.is-visible .chatbot-message:first-child {
  animation-delay: 0.2s;
}

/* ============================================
   Message fallback special
   ============================================ */
.chatbot-message.is-fallback {
  background: #fef3e2;
  border-left: 3px solid var(--chatbot-cta);
}

.chatbot-fallback-email {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--chatbot-bg-light);
  border-radius: var(--chatbot-radius-sm);
  font-weight: 500;
}

.chatbot-fallback-email a {
  color: var(--chatbot-primary);
  text-decoration: none;
}

.chatbot-fallback-email a:hover {
  text-decoration: underline;
}
