/* Asistente FAQ — usa los tokens de lavigna.css. FAB a la izquierda; WhatsApp a la derecha. */

.chatbot {
  position: fixed;
  left: max(16px, env(safe-area-inset-left));
  right: auto;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 95;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}
@media (min-width: 768px) {
  .chatbot {
    left: max(24px, env(safe-area-inset-left));
    bottom: max(24px, env(safe-area-inset-bottom));
  }
}

.chat-fab {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 24px rgba(45, 98, 232, 0.42);
  cursor: pointer;
  transition: transform 0.2s var(--ease), background-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
  animation: fab-float 3s ease-in-out infinite;
}
.chat-fab::before,
.chat-fab::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--primary);
  opacity: 0.4;
  z-index: -1;
  animation: fab-pulse 2.4s ease-out infinite;
  pointer-events: none;
}
.chat-fab::after { animation-delay: 1.2s; }
.chat-fab:hover {
  transform: scale(1.1);
  animation: none;
  background: var(--primary-600);
  box-shadow: 0 10px 28px rgba(45, 98, 232, 0.55);
}
.chat-fab:hover::before,
.chat-fab:hover::after { animation: none; opacity: 0; }
.chat-fab .icon { width: 26px; height: 26px; }
.chatbot.is-open .chat-fab {
  background: var(--ink);
  color: var(--bg);
  animation: none;
  transform: none;
}
.chatbot.is-open .chat-fab::before,
.chatbot.is-open .chat-fab::after { display: none; }

.chat-panel {
  display: flex;
  flex-direction: column;
  width: min(360px, calc(100vw - 32px));
  max-height: min(560px, calc(100vh - 180px));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 24px 60px rgba(11, 18, 32, 0.18);
  overflow: hidden;
}
.chat-panel[hidden] { display: none; }

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 14px 18px;
  background: var(--dark);
  color: var(--on-dark);
}
.chat-who strong { display: block; color: #fff; font-family: var(--font-display); font-size: 1rem; letter-spacing: 0.06em; }
.chat-who span { display: block; color: var(--on-dark-muted); font-size: 0.8rem; }
.chat-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--on-dark);
  cursor: pointer;
}
.chat-close:hover { background: rgba(255, 255, 255, 0.08); }

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  overflow-y: auto;
  background: var(--bg);
  overscroll-behavior: contain;
}

.chat-msg {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 0.94rem;
  line-height: 1.5;
}
.chat-msg--bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); border-bottom-left-radius: 4px; }
.chat-msg--user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }

.chat-typing { display: inline-flex; gap: 4px; padding: 13px 14px; }
.chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: chat-dot 1s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chat-dot {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

.chat-options, .chat-actions { display: flex; flex-direction: column; gap: 8px; }

.chat-option, .chat-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease);
}
.chat-option { justify-content: flex-start; text-align: left; }
.chat-option:hover, .chat-action:hover { border-color: var(--primary); color: var(--ink); }
.chat-action--wa { background: var(--primary); border-color: var(--primary); color: #fff; }
.chat-action--wa:hover { background: var(--primary-600); color: #fff; }
.chat-action--ghost { border-color: transparent; background: transparent; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .chat-fab,
  .chat-fab::before,
  .chat-fab::after { animation: none; }
  .chat-typing span { animation: none; }
}
