/* ===== BOT CONVERSACIONAL — widget de chat ===== */

/* Panel del bot */
.bot-panel {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 380px;
  max-width: calc(100vw - 48px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: var(--paper);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(20, 42, 71, 0.28), 0 2px 8px rgba(20, 42, 71, 0.10);
  border: 1px solid var(--line);
  z-index: 300;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(24px) scale(0.98);
  transform-origin: bottom right;
  transition: opacity 0.32s var(--ease), transform 0.32s var(--ease), visibility 0s linear 0.32s;
}
.bot-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  transition: opacity 0.32s var(--ease), transform 0.32s var(--ease), visibility 0s;
}

/* Header del bot */
.bot-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(135deg, #1B3556 0%, #142A47 100%);
  color: var(--paper);
  flex-shrink: 0;
}
.bot-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--orange);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.bot-header-info { flex: 1; min-width: 0; }
.bot-header-name {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
}
.bot-header-status {
  font-family: var(--sans);
  font-size: 12px;
  color: rgba(250, 248, 243, 0.75);
  display: flex;
  align-items: center;
  gap: 6px;
}
.bot-header-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--whatsapp);
  display: inline-block;
}
.bot-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(250, 248, 243, 0.12);
  border: none;
  color: var(--paper);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s var(--ease);
  flex-shrink: 0;
}
.bot-close:hover { background: rgba(250, 248, 243, 0.24); }
.bot-close svg { width: 16px; height: 16px; }

/* Cuerpo scrolleable con mensajes */
.bot-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  background:
    radial-gradient(60% 40% at 90% 5%, rgba(150, 182, 220, 0.10), transparent 70%),
    var(--paper);
}
.bot-body::-webkit-scrollbar { width: 6px; }
.bot-body::-webkit-scrollbar-thumb { background: rgba(20, 42, 71, 0.18); border-radius: 3px; }

/* Burbujas de mensaje */
.bot-msg {
  max-width: 82%;
  padding: 11px 14px;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  border-radius: 14px;
  animation: botMsgIn 0.3s var(--ease);
}
@keyframes botMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
/* Mensaje del bot (izquierda) */
.bot-msg.bot {
  align-self: flex-start;
  background: var(--surface-cool);
  color: var(--navy);
  border-bottom-left-radius: 4px;
}
.bot-msg.bot strong { font-weight: 700; }
.bot-msg.bot a { color: var(--orange); font-weight: 700; text-decoration: underline; }
/* Nota de privacidad en el mensaje de bienvenida */
.bot-privacy { display: inline-block; font-size: 12px; opacity: 0.72; line-height: 1.4; }
/* Mensaje del usuario (derecha) */
.bot-msg.user {
  align-self: flex-end;
  background: var(--orange);
  color: var(--paper);
  border-bottom-right-radius: 4px;
}

/* Indicador "escribiendo" */
.bot-typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 4px;
  padding: 13px 14px;
  background: var(--surface-cool);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}
.bot-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(20, 42, 71, 0.4);
  animation: botTyping 1.2s infinite ease-in-out;
}
.bot-typing span:nth-child(2) { animation-delay: 0.15s; }
.bot-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes botTyping {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* Zona de opciones (botones de respuesta) e inputs */
.bot-footer {
  flex-shrink: 0;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--paper);
}
.bot-option {
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--navy);
  background: transparent;
  border: 1px solid var(--line-strong, rgba(20,42,71,0.24));
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease), color 0.2s var(--ease);
}
.bot-option:hover {
  background: var(--navy);
  border-color: var(--navy);
  color: var(--paper);
}
.bot-option.primary {
  background: var(--orange);
  border-color: var(--orange);
  color: var(--paper);
  font-weight: 600;
}
.bot-option.primary:hover {
  background: var(--orange-light);
  border-color: var(--orange-light);
}
.bot-option.back {
  border: none;
  color: var(--text-soft);
  font-size: 13px;
  padding: 6px 14px;
  text-align: center;
}
.bot-option.back:hover { background: transparent; color: var(--orange); }

/* Input del formulario conversacional */
.bot-input-row { display: flex; gap: 8px; }
.bot-input {
  flex: 1;
  padding: 11px 14px;
  border: 1px solid var(--line-strong, rgba(20,42,71,0.24));
  border-radius: 10px;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--navy);
  background: var(--paper);
  outline: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.bot-input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.12); }
.bot-input.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.12); }
.bot-input-send {
  width: 44px;
  flex-shrink: 0;
  border: none;
  border-radius: 10px;
  background: var(--orange);
  color: var(--paper);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s var(--ease);
}
.bot-input-send:hover { background: var(--orange-light); }
.bot-input-send svg { width: 18px; height: 18px; }
.bot-input-error {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--danger);
  padding: 0 2px;
  min-height: 0;
}
.bot-input-error:empty { display: none; }

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