/* ============================================================
   AI Chat Widget — Estilos
   Asistente Conversacional IA para sitio de parcelaciones
   ============================================================ */

/* ── Variables ───────────────────────────────────────────── */
:root {
  --ai-primary:      #6366f1;
  --ai-primary-dark: #4f46e5;
  --ai-white:        #ffffff;
  --ai-bg-bot:       #f3f4f6;
  --ai-text-dark:    #111827;
  --ai-text-muted:   #6b7280;
  --ai-border:       #e5e7eb;
  --ai-shadow:       0 8px 32px rgba(99, 102, 241, 0.18), 0 2px 8px rgba(0,0,0,0.10);
  --ai-shadow-btn:   0 4px 16px rgba(99, 102, 241, 0.35);
  --ai-radius-panel: 16px;
  --ai-radius-msg:   12px;
  --ai-z-btn:        9998;
  --ai-z-panel:      9999;
}

/* ── Botón flotante ──────────────────────────────────────── */
.ai-chat-btn {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: var(--ai-primary);
  color: var(--ai-white);
  border: none;
  cursor: pointer;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--ai-shadow-btn);
  z-index: var(--ai-z-btn);
  transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
  line-height: 1;
  padding: 0;
}

.ai-chat-btn:hover,
.ai-chat-btn:focus-visible {
  background-color: var(--ai-primary-dark);
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
  outline: 2px solid var(--ai-white);
  outline-offset: 2px;
}

.ai-chat-btn:active {
  transform: scale(0.97);
}

/* ── Panel principal ─────────────────────────────────────── */
.ai-chat-panel {
  position: fixed;
  bottom: 5.5rem;      /* justo encima del botón */
  left: 1.5rem;
  width: 320px;
  height: 460px;
  background: var(--ai-white);
  border-radius: var(--ai-radius-panel);
  box-shadow: var(--ai-shadow);
  z-index: var(--ai-z-panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;

  /* Oculto por defecto */
  opacity: 0;
  pointer-events: none;
  transform: translateY(24px) scale(0.97);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.ai-chat-panel--open {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0) scale(1);
}

/* ── Header ──────────────────────────────────────────────── */
.ai-chat-header {
  background-color: var(--ai-primary);
  color: var(--ai-white);
  padding: 12px 16px;
  border-radius: var(--ai-radius-panel) var(--ai-radius-panel) 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.ai-chat-title {
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
}

.ai-chat-close {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 6px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.ai-chat-close:hover,
.ai-chat-close:focus-visible {
  background-color: rgba(255, 255, 255, 0.2);
  color: var(--ai-white);
  outline: none;
}

/* ── Área de mensajes ────────────────────────────────────── */
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}

.ai-chat-messages::-webkit-scrollbar {
  width: 4px;
}
.ai-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.ai-chat-messages::-webkit-scrollbar-thumb {
  background: var(--ai-border);
  border-radius: 4px;
}

/* ── Burbujas de mensaje ─────────────────────────────────── */
.ai-msg {
  max-width: 85%;
  padding: 9px 13px;
  border-radius: var(--ai-radius-msg);
  font-size: 0.875rem;
  line-height: 1.5;
  word-break: break-word;
  animation: ai-msg-in 0.2s ease;
}

@keyframes ai-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg-bot {
  background-color: var(--ai-bg-bot);
  color: var(--ai-text-dark);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.msg-user {
  background-color: var(--ai-primary);
  color: var(--ai-white);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

/* ── Indicador de typing ─────────────────────────────────── */
.ai-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  width: fit-content;
}

.ai-typing span {
  display: inline-block;
  width: 7px;
  height: 7px;
  background-color: var(--ai-text-muted);
  border-radius: 50%;
  animation: ai-dot-pulse 1.3s infinite ease-in-out;
}

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

@keyframes ai-dot-pulse {
  0%, 60%, 100% { transform: translateY(0);   opacity: 0.4; }
  30%            { transform: translateY(-5px); opacity: 1; }
}

/* ── Chips de sugerencias ────────────────────────────────── */
.ai-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 12px 8px;
  flex-shrink: 0;
  border-top: 1px solid var(--ai-border);
  min-height: 0;
}

.ai-suggestions:empty {
  display: none;
}

.ai-suggestion-chip {
  background: transparent;
  border: 1px solid var(--ai-primary);
  color: var(--ai-primary);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
  line-height: 1.4;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-suggestion-chip:hover,
.ai-suggestion-chip:focus-visible {
  background-color: var(--ai-primary);
  color: var(--ai-white);
  outline: none;
}

/* ── Input de texto + botón enviar ──────────────────────── */
.ai-chat-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--ai-border);
  flex-shrink: 0;
  background: var(--ai-white);
}

.ai-chat-input-field {
  flex: 1;
  border: 1px solid var(--ai-border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s ease;
  min-width: 0;
  color: var(--ai-text-dark);
  background: var(--ai-white);
}

.ai-chat-input-field:focus {
  border-color: var(--ai-primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.ai-chat-input-field:disabled {
  background-color: var(--ai-bg-bot);
  cursor: not-allowed;
}

.ai-chat-input-field::placeholder {
  color: var(--ai-text-muted);
}

.ai-chat-send-btn {
  flex-shrink: 0;
  background-color: var(--ai-primary);
  color: var(--ai-white);
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
  white-space: nowrap;
}

.ai-chat-send-btn:hover,
.ai-chat-send-btn:focus-visible {
  background-color: var(--ai-primary-dark);
  outline: none;
}

.ai-chat-send-btn:active {
  transform: scale(0.96);
}

.ai-chat-send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ── Responsive: móvil ───────────────────────────────────── */
@media (max-width: 480px) {
  .ai-chat-panel {
    width: 100vw;
    height: 100dvh;
    bottom: 0;
    left: 0;
    border-radius: 0;
  }

  .ai-chat-header {
    border-radius: 0;
  }

  .ai-chat-btn {
    bottom: 1rem;
    left: 1rem;
  }
}

/* ── Animación slideUp para apertura ─────────────────────── */
@keyframes ai-slide-up {
  from { opacity: 0; transform: translateY(30px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
