/**
 * ChatBot Styles
 * Estilos modernos y responsive para el chatbot con IA
 */

/* ==================== Variables CSS ==================== */
:root {
  /* Colores principales del negocio */
  --chatbot-primary: #E9491F;
  --chatbot-primary-dark: #C73D19;
  --chatbot-dark: #191917;
  --chatbot-cream: #FFF4EC;
  --chatbot-success: #4ADE80;
  --chatbot-error: #EF4444;

  /* Colores del chatbot */
  --chatbot-bg: #FFFFFF;
  --chatbot-text: #1F2937;
  --chatbot-text-light: #6B7280;
  --chatbot-border: #E5E7EB;
  --chatbot-shadow: rgba(0, 0, 0, 0.1);
  --chatbot-shadow-lg: rgba(0, 0, 0, 0.15);

  /* Mensajes */
  --chatbot-user-bg: #E9491F;
  --chatbot-user-text: #FFFFFF;
  --chatbot-bot-bg: #F3F4F6;
  --chatbot-bot-text: #1F2937;

  /* Animaciones */
  --chatbot-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --chatbot-transition-fast: 0.15s ease;

  /* Z-index */
  --chatbot-z-index: 9999;
}

/* ==================== Botón Flotante ==================== */
.chatbot-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--chatbot-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px var(--chatbot-shadow-lg);
  z-index: var(--chatbot-z-index);
  transition: transform var(--chatbot-transition), box-shadow var(--chatbot-transition);
  color: white;
}

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

.chatbot-toggle:active {
  transform: scale(0.95);
}

/* Animación de pulso */
@keyframes chatbot-pulse {
  0%, 100% {
    box-shadow: 0 4px 12px var(--chatbot-shadow-lg), 0 0 0 0 rgba(233, 73, 31, 0.4);
  }
  50% {
    box-shadow: 0 4px 12px var(--chatbot-shadow-lg), 0 0 0 10px rgba(233, 73, 31, 0);
  }
}

.chatbot-toggle {
  animation: chatbot-pulse 2s infinite;
}

/* Iconos */
.chatbot-icon {
  width: 28px;
  height: 28px;
  transition: opacity var(--chatbot-transition), transform var(--chatbot-transition);
}

.chatbot-icon-hidden {
  opacity: 0;
  transform: scale(0);
  position: absolute;
}

/* Punto de notificación */
.chatbot-notification-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 12px;
  height: 12px;
  background: var(--chatbot-success);
  border-radius: 50%;
  border: 2px solid white;
  transition: opacity var(--chatbot-transition), transform var(--chatbot-transition);
}

.chatbot-notification-hidden {
  opacity: 0;
  transform: scale(0);
}

/* ==================== Ventana del Chat ==================== */
.chatbot-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  height: 540px;
  background: var(--chatbot-bg);
  border-radius: 20px;
  box-shadow: 0 8px 32px var(--chatbot-shadow-lg);
  z-index: var(--chatbot-z-index);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity var(--chatbot-transition), transform var(--chatbot-transition);
}

.chatbot-window-hidden {
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
}

/* ==================== Header ==================== */
.chatbot-header {
  background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chatbot-avatar {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.chatbot-header-text h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
}

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

.chatbot-status-dot {
  width: 8px;
  height: 8px;
  background: var(--chatbot-success);
  border-radius: 50%;
  animation: chatbot-pulse-status 2s infinite;
}

@keyframes chatbot-pulse-status {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

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

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

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

/* ==================== Área de Mensajes ==================== */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

/* Scrollbar personalizado */
.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-light);
}

/* ==================== Mensajes ==================== */
.chatbot-message {
  display: flex;
  animation: chatbot-message-slide-in 0.3s ease;
}

@keyframes chatbot-message-slide-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

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

/* Mensajes del usuario */
.chatbot-message-user .chatbot-message-content {
  background: var(--chatbot-user-bg);
  color: var(--chatbot-user-text);
  border-bottom-right-radius: 4px;
}

/* Mensajes del bot */
.chatbot-message-assistant .chatbot-message-content {
  background: var(--chatbot-bot-bg);
  color: var(--chatbot-bot-text);
  border-bottom-left-radius: 4px;
}

/* Links en mensajes */
.chatbot-message-content a {
  color: var(--chatbot-primary);
  text-decoration: underline;
  font-weight: 500;
}

.chatbot-message-user .chatbot-message-content a {
  color: white;
}

/* ==================== Indicador de Escritura ==================== */
.chatbot-typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}

.chatbot-typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--chatbot-text-light);
  border-radius: 50%;
  animation: chatbot-typing-bounce 1.4s infinite;
}

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

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

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

/* ==================== Opciones Rápidas ==================== */
.chatbot-quick-options {
  padding: 12px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-top: 1px solid var(--chatbot-border);
  background: var(--chatbot-bg);
  transition: opacity var(--chatbot-transition), max-height var(--chatbot-transition);
  max-height: 120px;
  overflow-y: auto;
}

.chatbot-quick-options-hidden {
  opacity: 0;
  max-height: 0;
  padding: 0 20px;
}

.chatbot-quick-option {
  padding: 8px 14px;
  background: white;
  border: 1.5px solid var(--chatbot-border);
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--chatbot-transition-fast);
  color: var(--chatbot-text);
  font-weight: 500;
  white-space: nowrap;
}

.chatbot-quick-option:hover {
  background: var(--chatbot-primary);
  border-color: var(--chatbot-primary);
  color: white;
  transform: translateY(-1px);
}

.chatbot-quick-option:active {
  transform: translateY(0);
}

/* ==================== Input ==================== */
.chatbot-input-container {
  padding: 16px 20px;
  border-top: 1px solid var(--chatbot-border);
  display: flex;
  gap: 8px;
  background: var(--chatbot-bg);
  flex-shrink: 0;
}

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

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

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

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

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

.chatbot-send-btn:active {
  transform: scale(0.95);
}

.chatbot-send-btn svg {
  width: 20px;
  height: 20px;
}

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

  .chatbot-icon {
    width: 24px;
    height: 24px;
  }

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

  .chatbot-message-content {
    max-width: 85%;
    font-size: 15px;
  }

  .chatbot-quick-option {
    font-size: 14px;
    padding: 10px 16px;
  }
}

@media (max-width: 380px) {
  .chatbot-quick-options {
    gap: 6px;
  }

  .chatbot-quick-option {
    font-size: 12px;
    padding: 8px 12px;
  }
}

/* ==================== Reducción de Movimiento ==================== */
@media (prefers-reduced-motion: reduce) {
  .chatbot-toggle,
  .chatbot-window,
  .chatbot-icon,
  .chatbot-notification-dot,
  .chatbot-message,
  .chatbot-quick-option,
  .chatbot-send-btn,
  .chatbot-clear-btn {
    animation: none;
    transition: none;
  }

  .chatbot-status-dot {
    animation: none;
  }

  .chatbot-typing-indicator span {
    animation: none;
  }
}

/* ==================== Tema Oscuro (Opcional) ==================== */
@media (prefers-color-scheme: dark) {
  :root {
    --chatbot-bg: #1F2937;
    --chatbot-text: #F9FAFB;
    --chatbot-text-light: #9CA3AF;
    --chatbot-border: #374151;
    --chatbot-bot-bg: #374151;
    --chatbot-bot-text: #F9FAFB;
  }

  .chatbot-input {
    background: #374151;
    color: #F9FAFB;
  }

  .chatbot-quick-option {
    background: #374151;
    color: #F9FAFB;
  }

  .chatbot-messages::-webkit-scrollbar-thumb {
    background: #4B5563;
  }
}

/* ==================== Estados de Carga ==================== */
.chatbot-loading .chatbot-send-btn {
  opacity: 0.6;
  cursor: not-allowed;
}

.chatbot-loading .chatbot-input {
  opacity: 0.6;
}

/* ==================== Accesibilidad ==================== */
.chatbot-toggle:focus,
.chatbot-send-btn:focus,
.chatbot-clear-btn:focus,
.chatbot-quick-option:focus,
.chatbot-input:focus {
  outline: 2px solid var(--chatbot-primary);
  outline-offset: 2px;
}

/* ==================== Animaciones de Entrada ==================== */
@keyframes chatbot-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Aplicar a los elementos iniciales */
.chatbot-toggle,
.chatbot-window {
  animation: chatbot-fade-in 0.5s ease;
}
