/**
 * @file
 * Styles pour le chat D-Bot.
 * 
 * Design moderne et responsive avec support du mode démonstration.
 */

/* ========================================
   CONTENEUR PRINCIPAL
   ======================================== */

.dbot-chat-container {
  position: fixed;
  bottom: 20px;
  right: 100px;
  width: 380px;
  max-width: calc(100vw - 40px);
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  max-height: 600px;
  z-index: 1000;
  overflow: hidden;
  transition: box-shadow 0.3s ease;
}

.dbot-chat-container:hover {
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15), 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Mode démo - bordure distinctive */
.dbot-chat-container.dbot-demo-mode {
  border: 2px solid #f59e0b;
}

/* ========================================
   EN-TÊTE
   ======================================== */

.dbot-chat-header {
  background: linear-gradient(135deg, #0B19DA 0%, #00FFFF 100%);
  color: white;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.dbot-chat-title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.dbot-title-icon,
.dbot-avatar-icon {
  display: inline-block;
  background-color: currentColor;
  -webkit-mask-image: url("../icons/dbot-chatbot.svg");
  -webkit-mask-position: center;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  mask-image: url("../icons/dbot-chatbot.svg");
  mask-position: center;
  mask-repeat: no-repeat;
  mask-size: contain;
}

.dbot-title-icon {
  width: 32px;
  height: 32px;
  opacity: 0.95;
  flex-shrink: 0;
}

/* Indicateur mode démo dans le titre */
.dbot-mode-indicator {
  background: #f59e0b;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 10px;
  letter-spacing: 0.5px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.dbot-chat-toggle {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.2s;
}

.dbot-chat-toggle:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

/* ========================================
   BANNIÈRE MODE DÉMO
   ======================================== */

.dbot-demo-banner {
  background: linear-gradient(90deg, #fef3c7 0%, #fde68a 100%);
  color: #92400e;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-bottom: 1px solid #fcd34d;
}

.dbot-demo-icon {
  font-size: 14px;
}

.dbot-demo-text {
  letter-spacing: 0.3px;
}

/* ========================================
   CORPS DU CHAT
   ======================================== */

.dbot-chat-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  background: #fafbfc;
}

.dbot-chat-body.collapsed {
  display: none;
}

.dbot-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 350px;
  min-height: 200px;
}

/* ========================================
   MESSAGES
   ======================================== */

.dbot-message {
  display: flex;
  animation: messageSlide 0.3s ease-out;
}

@keyframes messageSlide {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dbot-message-user {
  justify-content: flex-end;
}

.dbot-message-assistant {
  justify-content: flex-start;
}

.dbot-message-content {
  padding: 12px 16px;
  border-radius: 18px;
  max-width: 85%;
  word-wrap: break-word;
  line-height: 1.5;
  font-size: 14px;
}

/* Message utilisateur */
.dbot-message-user .dbot-message-content {
  background: linear-gradient(135deg, #0B19DA 0%, #0B19DA 100%);
  color: white;
  border-bottom-right-radius: 6px;
}

/* Message assistant - layout avec avatar */
.dbot-message-assistant {
  align-items: flex-end;
  gap: 8px;
}

/* Avatar du bot */
.dbot-message-avatar {
  width: 32px;
  height: 32px;
  min-width: 32px;
  background: linear-gradient(135deg, #0B19DA 0%, #00FFFF 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.dbot-avatar-icon {
  width: 20px;
  height: 20px;
  color: white;
}

/* Message assistant */
.dbot-message-assistant .dbot-message-content {
  background: white;
  color: #071049;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Message d'erreur */
.dbot-message-error .dbot-message-content {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

/* Message système */
.dbot-message-system .dbot-message-content {
  background: #f3f4f6;
  color: #07104999;
  font-style: italic;
  font-size: 13px;
  text-align: center;
  max-width: 100%;
  border-radius: 8px;
}

/* ========================================
   ZONE DE SAISIE
   ======================================== */

.dbot-chat-input-wrapper {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  background: white;
  border-top: 1px solid #e5e7eb;
  align-items: flex-end;
}

.dbot-chat-input {
  flex: 1;
  border: 2px solid #e5e7eb;
  border-radius: 24px;
  padding: 12px 18px;
  font-size: 14px;
  resize: none;
  max-height: 100px;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #f9fafb;
}

.dbot-chat-input:focus {
  outline: none;
  border-color: #0B19DA;
  background: white;
  box-shadow: 0 0 0 3px rgba(11, 25, 218, 0.1);
}

.dbot-chat-input::placeholder {
  color: #07104999;
}

.dbot-chat-send {
  background: linear-gradient(135deg, #0B19DA 0%, #0B19DA 100%);
  border: none;
  color: white;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, opacity 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(11, 25, 218, 0.3);
}

.dbot-chat-send:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(11, 25, 218, 0.4);
}

.dbot-chat-send:active {
  transform: scale(0.95);
}

.dbot-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.dbot-chat-send svg {
  width: 20px;
  height: 20px;
}

/* ========================================
   ACTIONS
   ======================================== */

.dbot-chat-actions {
  padding: 0 20px 16px;
  text-align: center;
  background: white;
}

.dbot-chat-clear {
  background: transparent;
  border: 1px solid #e5e7eb;
  color: #07104999;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.dbot-chat-clear:hover {
  background: #f3f4f6;
  border-color: #0B19DA;
  color: #071049;
}

.dbot-chat-clear svg {
  opacity: 0.7;
}

/* ========================================
   LOADING
   ======================================== */

.dbot-chat-loading {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-radius: 16px;
  z-index: 10;
}

.dbot-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e5e7eb;
  border-top: 3px solid #0B19DA;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.dbot-loading-text {
  color: #07104999;
  font-size: 13px;
  font-weight: 500;
}

/* ========================================
   SCROLLBAR
   ======================================== */

.dbot-chat-messages::-webkit-scrollbar {
  width: 6px;
}

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

.dbot-chat-messages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

.dbot-chat-messages::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
  .dbot-chat-container {
    width: calc(100vw - 20px);
    bottom: 10px;
    right: 10px;
    max-height: calc(100vh - 80px);
    border-radius: 12px;
  }
  
  .dbot-chat-messages {
    max-height: calc(100vh - 280px);
    padding: 16px;
  }
  
  .dbot-chat-header {
    padding: 14px 16px;
  }
  
  .dbot-chat-input-wrapper {
    padding: 12px 16px;
  }
  
  .dbot-chat-actions {
    padding: 0 16px 12px;
  }
}

/* Mode sombre (optionnel, suit les préférences système) */
@media (prefers-color-scheme: dark) {
  .dbot-chat-container {
    /* Décommenter pour activer le mode sombre automatique */
    /* background: #1f2937;
    color: #f9fafb; */
  }
}

/* ========================================
   ANIMATIONS SUPPLÉMENTAIRES
   ======================================== */

/* Animation d'entrée du chat */
.dbot-chat-container {
  animation: chatAppear 0.4s ease-out;
}

@keyframes chatAppear {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
