/* ESTILOS WIDGET FLOTANTE - JUAMPI IA */
:root {
  --widget-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --widget-chat-bg: #ffffff;
  --widget-user-msg-bg: #667eea;
  --widget-bot-msg-bg: #f3f4f6;
}

#juampi-chat-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 11000;
  font-family: 'Segoe UI', sans-serif;
}

/* Animación de latido para el botón */
@keyframes pulse-glow {
  0% { box-shadow: 0 4px 15px rgba(118, 75, 162, 0.4); transform: scale(1); }
  50% { box-shadow: 0 0 25px rgba(102, 126, 234, 0.7); transform: scale(1.05); }
  100% { box-shadow: 0 4px 15px rgba(118, 75, 162, 0.4); transform: scale(1); }
}

/* Botón Flotante */
#chat-toggle-btn {
  background: var(--widget-gradient);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(118, 75, 162, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse-glow 3s infinite; /* Late infinitamente cada 3 segundos */
  touch-action: manipulation;
  z-index: 11002;
}

/* Pausar animación cuando pasas el mouse por encima para no marear */
#chat-toggle-btn:hover {
  animation: none;
  transform: scale(1.1);
}

/* Ventana Principal */
#chat-window {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 360px;
  max-width: calc(100vw - 40px);
  height: 520px;
  max-height: 75vh;
  background: var(--widget-chat-bg);
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.3s ease;
  transform-origin: bottom right;
  z-index: 11001;
}

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

/* Cabecera */
.chat-header {
  background: var(--widget-gradient);
  padding: 15px 20px;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-info { display: flex; align-items: center; gap: 10px; }
.avatar { background: rgba(255,255,255,0.2); width: 35px; height: 35px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.chat-header h3 { margin: 0; font-size: 16px; font-weight: 600; }
.chat-header small { opacity: 0.9; font-size: 12px; }
.status-dot { display: inline-block; width: 8px; height: 8px; background: #2ecc71; border-radius: 50%; margin-right: 3px; }
.close-btn { background: none; border: none; color: white; font-size: 20px; cursor: pointer; opacity: 0.8; }

/* Área de Mensajes */
#chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: #fdfdfd;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Burbujas */
#juampi-chat-widget .message {
  max-width: 80%;
  padding: 10px 15px;
  border-radius: 15px;
  font-size: 14px;
  line-height: 1.4;
  position: relative;
  word-wrap: break-word;
  animation: widgetFadeIn 0.3s ease;
}

#juampi-chat-widget .bot-message {
  background: var(--widget-bot-msg-bg);
  color: #333;
  border-bottom-left-radius: 2px;
  align-self: flex-start;
}

#juampi-chat-widget .user-message {
  background: var(--widget-user-msg-bg);
  color: white;
  border-bottom-right-radius: 2px;
  align-self: flex-end;
  box-shadow: 0 2px 5px rgba(102, 126, 234, 0.3);
}

/* Input */
.chat-input-area {
  padding: 15px;
  border-top: 1px solid #eee;
  display: flex;
  gap: 10px;
  background: white;
}

#user-input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 25px;
  padding: 10px 15px;
  outline: none;
  transition: border 0.3s;
  font-size: 14px;
}

#user-input:focus { border-color: #667eea; }

#send-btn {
  background: var(--widget-user-msg-bg);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s;
}

#send-btn:hover { transform: scale(1.05); }

/* Animaciones */
@keyframes widgetFadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Loading Dots */
.typing-indicator { display: flex; gap: 4px; padding: 5px 10px; background: #f3f4f6; border-radius: 15px; align-self: flex-start; width: fit-content; }
.dot { width: 6px; height: 6px; background: #999; border-radius: 50%; animation: bounce 1.4s infinite ease-in-out both; }
.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }
/* Mobile Responsive */
@media (max-width: 768px) {
  #juampi-chat-widget {
    bottom: calc(12px + env(safe-area-inset-bottom));
    right: 12px;
    left: 12px;
  }

  #chat-toggle-btn {
    width: 56px;
    height: 56px;
    box-shadow: 0 4px 18px rgba(118, 75, 162, 0.45);
    position: relative;
  }

  #chat-window {
    width: calc(100vw - 24px);
    max-width: none;
    height: 70vh;
    max-height: calc(100vh - 160px);
    bottom: calc(84px + env(safe-area-inset-bottom));
    right: 12px;
    left: 12px;
    border-radius: 18px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }
}

@media (min-width: 769px) {
  #chat-window { width: 360px; }
  #juampi-chat-widget { bottom: 20px; right: 20px; left: auto; }
}
