/* DespedidoPorIA — chat widget (refresh visual, contrato con chat.js intacto)
 *
 * Cambios respecto al diseño anterior:
 *   - FAB navy-800 con icono Lucide message-circle blanco (NO verde WhatsApp)
 *   - Panel white con sombra premium y bordes redondeados
 *   - Header navy-800 con avatar amber-500
 *   - Burbujas: bot beige-200 / user amber-500 (con texto navy-900)
 *   - Input: border-2 beige-300 → focus amber-500
 *   - Botón enviar: amber-500 circular
 *
 * Selectores y clases preservados 1:1 para que chat.js no requiera cambios:
 *   #chat-fab, #chat-panel, #chat-tooltip, #chat-close, #chat-messages,
 *   #chat-input, #chat-send, .chat-header*, .status-dot, .chat-bubble.{bot,user,error,typing},
 *   .typing-dot, .chat-input-area, .hidden
 */

/* ============================================================ */
/* FAB (Floating Action Button) — navy con icon Lucide          */
/* ============================================================ */
.chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 64px;
  height: 64px;
  background: var(--navy-800);
  color: white;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-2xl);
  transition: transform var(--transition-base), box-shadow var(--transition-base), background var(--transition-base);
  z-index: 999;
}
.chat-fab:hover {
  transform: scale(1.05);
  background: var(--navy-900);
}
.chat-fab.hidden { display: none; }

/* ============================================================ */
/* Tooltip "👋 ¿Podemos ayudarte?"                              */
/* ============================================================ */
#chat-tooltip {
  position: fixed;
  bottom: 104px;
  right: 24px;
  background: white;
  color: var(--navy-900);
  padding: 12px 18px;
  border-radius: var(--radius-2xl) var(--radius-2xl) var(--radius-sm) var(--radius-2xl);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  cursor: pointer;
  user-select: none;
  border: 1px solid rgba(10,22,40,0.06);
  animation: tooltip-in 300ms cubic-bezier(0.4,0,0.2,1);
}
#chat-tooltip.hidden { display: none; }
@keyframes tooltip-in {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============================================================ */
/* Panel del chat                                                */
/* ============================================================ */
.chat-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 380px;
  height: 580px;
  max-height: calc(100vh - 48px);
  background: white;
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-2xl);
  border: 1px solid var(--navy-100);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1000;
  animation: panel-open 280ms cubic-bezier(0.4,0,0.2,1);
}
.chat-panel.hidden { display: none; }
@keyframes panel-open {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Mobile: full-screen */
@media (max-width: 640px) {
  .chat-panel {
    bottom: 0; right: 0; left: 0; top: 0;
    width: 100%; height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }
}

/* ============================================================ */
/* Header                                                        */
/* ============================================================ */
.chat-header {
  background: var(--navy-800);
  color: white;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.chat-header-avatar {
  width: 40px;
  height: 40px;
  background: var(--amber-500);
  color: var(--navy-900);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 8px rgba(232,163,61,0.25);
}
.chat-header-info {
  flex: 1;
  min-width: 0;
}
.chat-header-name {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-weight: 700;
  font-size: 15px;
}
.chat-header-status {
  font-size: 12px;
  opacity: 0.8;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}
.status-dot {
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 0 rgba(22,163,74,0.55);
  animation: pulse-glow 2s infinite;
}
.chat-close {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 6px;
  opacity: 0.7;
  border-radius: var(--radius-md);
  transition: opacity var(--transition-base), background var(--transition-base);
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-close:hover {
  opacity: 1;
  background: rgba(255,255,255,0.08);
}

/* ============================================================ */
/* Messages area                                                 */
/* ============================================================ */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--beige-100);
  min-height: 0;
}

.chat-bubble {
  max-width: 82%;
  padding: 11px 15px;
  border-radius: var(--radius-2xl);
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
  animation: bubble-in 220ms cubic-bezier(0.4,0,0.2,1);
}
@keyframes bubble-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.chat-bubble.bot {
  background: var(--beige-200);
  color: var(--navy-900);
  align-self: flex-start;
  border-bottom-left-radius: var(--radius-sm);
  box-shadow: 0 1px 2px rgba(10,22,40,0.04);
}
.chat-bubble.user {
  background: var(--amber-500);
  color: var(--navy-900);
  align-self: flex-end;
  border-bottom-right-radius: var(--radius-sm);
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(10,22,40,0.06);
}
.chat-bubble.error {
  background: rgba(220,38,38,0.08);
  color: var(--warning);
  align-self: center;
  font-size: 12px;
  text-align: center;
  max-width: 90%;
  border: 1px solid rgba(220,38,38,0.15);
  font-weight: 500;
}

/* Typing indicator: 3 dots amber bouncing */
.chat-bubble.typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 14px 16px;
  width: fit-content;
}
.typing-dot {
  width: 7px;
  height: 7px;
  background: var(--amber-500);
  border-radius: 50%;
  display: inline-block;
  animation: typing-bounce 1.2s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.30s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0);   opacity: 0.4; }
  30%          { transform: translateY(-6px); opacity: 1;   }
}

/* ============================================================ */
/* Input area                                                    */
/* ============================================================ */
.chat-input-area {
  background: white;
  padding: 12px 14px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  border-top: 1px solid var(--beige-300);
  flex-shrink: 0;
}
#chat-input {
  flex: 1;
  border: 2px solid var(--beige-300);
  border-radius: var(--radius-2xl);
  padding: 10px 16px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  resize: none;
  max-height: 100px;
  outline: none;
  line-height: 1.4;
  color: var(--navy-900);
  background: white;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}
#chat-input::placeholder { color: rgba(10,22,40,0.4); }
#chat-input:focus {
  border-color: var(--amber-500);
  box-shadow: 0 0 0 4px rgba(232,163,61,0.12);
}
#chat-send {
  background: var(--amber-500);
  color: var(--navy-900);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition-base), transform var(--transition-base);
  box-shadow: 0 2px 6px rgba(232,163,61,0.35);
}
#chat-send:hover {
  background: var(--amber-600);
  transform: translateY(-1px);
}
#chat-send:disabled {
  background: var(--beige-300);
  color: rgba(10,22,40,0.4);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}
