:root {
  --primary-color: #ff6b35;     /* Naranja Halloween */
  --secondary-color: #ff8c42;   /* Naranja claro */
  --accent-color: #ffd166;      /* Amarillo/naranja */
  --halloween-purple: #8a2be2;  /* Púrpura para detalles */
  --light-color: #f5f5f5;
  --dark-color: #2d1b00;        /* Marrón oscuro Halloween */
}

.chat-toggle {
  position: fixed; 
  bottom: 20px; 
  right: 20px; 
  z-index: 9999;
  width: 64px; 
  height: 64px; 
  border-radius: 50%;
  display:flex;
  align-items:center;
  justify-content:center;
  background: linear-gradient(135deg, var(--primary-color), var(--halloween-purple)); 
  color:#fff; 
  font-size:28px;
  box-shadow:0 8px 24px rgba(255, 107, 53, 0.3); 
  cursor:pointer; 
  transition:transform .16s;
  animation: halloweenPulse 3s ease-in-out infinite;
}

.chat-toggle:hover{ 
  transform: scale(1.06); 
  animation: none;
}

.chat-toggle.has-notification::after {
  content: '';
  position: absolute;
  top: 8px;
  right: 8px;
  width: 12px;
  height: 12px;
  background: var(--accent-color);
  border-radius: 50%;
  border: 2px solid white;
}

@keyframes halloweenPulse {
  0%, 100% { 
    transform: scale(1);
    box-shadow: 0 8px 24px rgba(255, 107, 53, 0.3);
  }
  50% { 
    transform: scale(1.05);
    box-shadow: 0 12px 32px rgba(255, 107, 53, 0.5);
  }
}

.chat-container {
  position: fixed; 
  bottom: 100px; 
  right: 20px; 
  z-index: 9998;
  width: 380px; 
  height: 560px; 
  max-height: 90vh;
  display: none; 
  flex-direction: column; 
  border-radius: 14px;
  box-shadow: 
    0 12px 40px rgba(255, 107, 53, 0.3),
    0 0 20px rgba(255, 107, 53, 0.2),
    inset 0 0 15px rgba(255, 107, 53, 0.1);
  overflow: hidden; 
  background: #fff;
  animation: popup .24s ease;
  border: 2px solid #ff6b35;
}

@keyframes popup { 
  from { transform: translateY(12px); opacity: .0; } 
  to { transform: translateY(0); opacity: 1; } 
}

/* ========== ANIMACIÓN DE BIENVENIDA ========== */
.welcome-animation {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, #1a1a1a, #2d1b00);
  z-index: 20;
  justify-content: center;
  align-items: center;
  animation: welcomeFadeIn 0.6s ease-out;
}

.animation-container {
  text-align: center;
  padding: 30px;
  animation: containerSlideUp 0.8s ease-out;
}

.welcome-gif {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  margin-bottom: 20px;
  animation: welcomeBounce 2s infinite;
  border: 4px solid rgba(255, 107, 53, 0.3);
  box-shadow: 0 8px 32px rgba(255, 107, 53, 0.3);
}

.welcome-text {
  font-size: 18px;
  font-weight: 600;
  color: #ff6b35;
  text-shadow: 0 0 10px #ff6b35, 0 0 20px #ff6b35;
  animation: textGlow 2s ease-in-out infinite alternate;
}

@keyframes welcomeFadeIn {
  from { 
    opacity: 0; 
    transform: scale(0.9);
  }
  to { 
    opacity: 1; 
    transform: scale(1);
  }
}

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

@keyframes welcomeBounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0) scale(1);
  }
  40% {
    transform: translateY(-15px) scale(1.05);
  }
  60% {
    transform: translateY(-7px) scale(1.02);
  }
}

@keyframes textGlow {
  from {
    text-shadow: 0 0 10px #ff6b35, 0 0 20px #ff6b35;
  }
  to {
    text-shadow: 0 0 15px #ff6b35, 0 0 30px #ff6b35, 0 0 40px #ff6b35;
  }
}

.welcome-animation.fade-out {
  animation: welcomeFadeOut 0.5s ease-in forwards;
}

@keyframes welcomeFadeOut {
  from { 
    opacity: 1; 
    transform: scale(1);
  }
  to { 
    opacity: 0; 
    transform: scale(0.95);
    display: none;
  }
}

/* HEADER HALLOWEEN */
.chat-header {
  padding: 14px 16px; 
  color: #fff; 
  font-weight: 600;
  background: linear-gradient(135deg, var(--primary-color), var(--halloween-purple));
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.chat-header::before {
  content: '🎃';
  position: absolute;
  top: 5px;
  left: 10px;
  font-size: 16px;
  opacity: 0.3;
}

.chat-header::after {
  content: '👻';
  position: absolute;
  bottom: 5px;
  right: 10px;
  font-size: 14px;
  opacity: 0.3;
}

.header-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.chat-header .title { 
  font-size: 16px; 
  font-weight: 600;
}

.chat-header .sub { 
  font-size: 12px; 
  opacity: 0.9; 
}

/* BOTÓN CERRAR ELEGANTE */
.chat-close-btn {
  background: transparent;
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  color: white;
  cursor: pointer;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  opacity: 0.7;
  padding: 0;
  margin-left: 15px;
  font-size: 14px;
  font-weight: 300;
  line-height: 1;
}

.chat-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.8);
  opacity: 1;
  transform: scale(1.1);
}

.chat-close-btn:active {
  transform: scale(0.95);
}

.chat-messages {
  padding:12px; 
  overflow-y:auto; 
  flex:1; 
  background: 
    linear-gradient(180deg, #1a1a1a, #2d1b00),
    url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><text x="10" y="20" font-size="8" fill="%23ff6b35" opacity="0.1">🎃</text><text x="80" y="60" font-size="6" fill="%23ff6b35" opacity="0.1">👻</text></svg>');
  background-blend-mode: overlay;
  display: none;
}

.message { 
  max-width:78%; 
  padding:10px 12px; 
  margin:8px 0; 
  border-radius:14px; 
  white-space:pre-wrap; 
  font-size:14px; 
  line-height:1.3; 
}

.bot-message { 
  background:#2d1b00; 
  color:#ffd166; 
  align-self:flex-start; 
  border-bottom-left-radius:4px; 
  border: 1px solid #ff6b35;
}

.user-message { 
  background:linear-gradient(135deg, var(--primary-color), var(--halloween-purple)); 
  color:#fff; 
  align-self:flex-end; 
  border-bottom-right-radius:4px; 
}

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

.chatbot-option-btn {
  background: linear-gradient(135deg, var(--primary-color), var(--halloween-purple));
  color:white; 
  border: 1px solid #ff8c42;
  padding:8px 12px; 
  border-radius:20px;
  cursor:pointer; 
  font-weight:600; 
  box-shadow: 0 4px 10px rgba(255, 107, 53, 0.3); 
  transition:transform .12s;
  font-size: 13px;
}

.chatbot-option-btn:hover{ 
  transform: translateY(-2px); 
  background: linear-gradient(135deg, #e55a2b, #7b1fa2);
  box-shadow: 0 6px 15px rgba(255, 107, 53, 0.5);
}

.chat-input { 
  display:none;
  gap:8px; 
  padding:10px; 
  border-top:1px solid #ff6b35; 
  background:#2d1b00; 
}

.chat-input input { 
  flex:1; 
  padding:10px 12px; 
  border-radius:10px; 
  border:1px solid #ff6b35; 
  outline:none; 
  font-size:14px; 
  background: #1a1a1a;
  color: #ffd166;
}

.chat-input input::placeholder {
  color: #ff8c42;
  opacity: 0.7;
}

.chat-input button { 
  background:linear-gradient(135deg, var(--primary-color), var(--halloween-purple)); 
  color:#fff; 
  border:none; 
  padding:10px 14px; 
  border-radius:10px; 
  cursor:pointer; 
  font-weight:700; 
}

.chat-input button:hover {
  background: linear-gradient(135deg, #e55a2b, #7b1fa2);
}

.data-request {
  background-color: #2d1b00;
  border-left: 4px solid var(--accent-color);
  padding: 10px;
  border-radius: 4px;
  margin: 5px 0;
  font-size: 13px;
  color: #ffd166;
  border: 1px solid #ff6b35;
}

.success-message {
  background-color: #1a2a1a;
  border-left: 4px solid #4caf50;
  padding: 10px;
  border-radius: 4px;
  margin: 5px 0;
  font-size: 13px;
  color: #a5d6a7;
  border: 1px solid #4caf50;
}

.typing-indicator {
  display: flex;
  padding: 8px;
  align-items: center;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background-color: #ff6b35;
  border-radius: 50%;
  margin: 0 2px;
  animation: typingAnimation 1.4s infinite ease-in-out;
}

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

@keyframes typingAnimation {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-3px); }
}

/* Responsive */
@media (max-width: 480px) {
  .chat-container {
    width: 90vw;
    height: 70vh;
    right: 5vw;
    bottom: 80px;
  }
  
  .chat-toggle {
    bottom: 15px;
    right: 15px;
    width: 56px;
    height: 56px;
    font-size: 24px;
  }
  
  .chat-close-btn {
    width: 22px;
    height: 22px;
    font-size: 13px;
    margin-left: 12px;
  }
  
  .chat-header {
    padding: 12px 14px;
  }
  
  .chat-header .title {
    font-size: 15px;
  }
  
  .chat-header .sub {
    font-size: 11px;
  }
  
  .message {
    max-width: 85%;
    font-size: 13px;
    padding: 8px 10px;
  }
  
  .chatbot-option-btn {
    font-size: 12px;
    padding: 6px 10px;
  }
  
  .chat-input input {
    padding: 8px 10px;
    font-size: 13px;
  }
  
  .chat-input button {
    padding: 8px 12px;
    font-size: 13px;
  }
  
  .welcome-gif {
    width: 100px;
    height: 100px;
  }
  
  .welcome-text {
    font-size: 16px;
  }
  
  .animation-container {
    padding: 20px;
  }
}

/* Mejoras de scroll para mensajes */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: #2d1b00;
  border-radius: 3px;
}

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

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: #ff8c42;
}

/* Efectos de hover mejorados */
.chatbot-option-btn:active {
  transform: translateY(0);
}

/* Mejoras de accesibilidad */
.chat-close-btn:focus {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

.chat-input input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(255, 209, 102, 0.2);
}

/* Animaciones suaves para mensajes nuevos */
.message {
  animation: messageAppear 0.3s ease-out;
}

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

/* Estados de carga mejorados */
.typing-indicator {
  animation: pulse 2s infinite;
}

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

/* Mejoras visuales para botones deshabilitados */
.chat-input button:disabled {
  background: #cccccc;
  cursor: not-allowed;
  transform: none !important;
}

/* ========== ESTILOS PARA ASISTENTE VIRTUAL ANIMADO ========== */
.header-info {
    display: flex;
    align-items: center;
    flex: 1;
}

.header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    margin-right: 12px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
    position: relative;
}

.assistant-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    animation: breathe 4s ease-in-out infinite;
}

.header-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

@keyframes breathe {
    0%, 100% { 
        transform: scale(1);
    }
    50% { 
        transform: scale(1.05);
    }
}

/* Estado en línea */
.header-avatar::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background: var(--accent-color);
    border: 2px solid white;
    border-radius: 50%;
    animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
    0%, 100% { 
        opacity: 1;
        transform: scale(1);
    }
    50% { 
        opacity: 0.7;
        transform: scale(1.1);
    }
}

/* Responsive para el avatar */
@media (max-width: 480px) {
    .header-avatar {
        width: 36px;
        height: 36px;
        margin-right: 10px;
    }
}

/* Efecto de aparición suave para el chat */
.chat-container[style*="display: flex"] {
    animation: chatAppear 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Efecto de telaraña sutil */
.chat-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(circle at 20% 80%, transparent 50%, rgba(255, 107, 53, 0.03) 80%),
    radial-gradient(circle at 80% 20%, transparent 50%, rgba(139, 0, 139, 0.03) 80%);
  pointer-events: none;
  z-index: 1;
}
