/* =========================================================
   ASESOR FINANCIERO IA (Google Gemini) - Estilos
========================================================= */

/* Botón flotante Asesor IA (Fijo abajo a la izquierda en Escritorio, Arrastrable en Móvil) */
.btn-asesor-ia-float {
  position: fixed;
  bottom: 24px;
  left: 24px;
  right: auto;
  z-index: 10005;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 55%, #1d4ed8 100%);
  color: #ffffff;
  border: 1px solid rgba(147, 197, 253, 0.28);
  border-radius: 999px;
  padding: 11px 20px;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.4), 0 2px 6px rgba(30, 58, 138, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.btn-asesor-ia-float:hover {
  transform: translateY(-2px);
  background: linear-gradient(135deg, #1e293b 0%, #1e40af 55%, #2563eb 100%);
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.5), 0 3px 10px rgba(30, 58, 138, 0.35);
}

.btn-asesor-ia-float:active {
  transform: scale(0.96);
}

.btn-asesor-ia-float .ia-sparkle-icon {
  font-size: 1.15rem;
  line-height: 1;
  display: inline-block;
  pointer-events: none;
  opacity: 0.95;
}

.btn-asesor-ia-float .ia-btn-text {
  pointer-events: none;
  white-space: nowrap;
}

/* En Móvil: Circulito elegante y compacto con sólo las estrellitas, arrastrable a los costados */
@media (max-width: 768px) {
  .btn-asesor-ia-float {
    width: 50px;
    height: 50px;
    min-width: 50px;
    min-height: 50px;
    padding: 0;
    border-radius: 50%;
    bottom: 90px;
    left: 14px;
    cursor: grab;
    touch-action: none;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.45), 0 2px 8px rgba(30, 58, 138, 0.3);
  }

  .btn-asesor-ia-float.is-dragging {
    cursor: grabbing;
    transform: scale(1.08);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.6), 0 4px 12px rgba(30, 58, 138, 0.4);
    transition: none !important;
  }

  .btn-asesor-ia-float .ia-btn-text {
    display: none !important;
  }

  .btn-asesor-ia-float .ia-sparkle-icon {
    font-size: 1.35rem;
  }
}

/* Modal Backdrop del Asesor IA */
.asesor-ia-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10020;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  padding: 16px;
  box-sizing: border-box;
}

.asesor-ia-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

/* Contenedor Principal del Chat */
.asesor-ia-modal {
  width: 100%;
  max-width: 580px;
  height: 82vh;
  max-height: 720px;
  background: linear-gradient(175deg, rgba(15, 23, 42, 0.98) 0%, rgba(2, 6, 23, 0.98) 100%);
  border: 1px solid rgba(56, 189, 248, 0.28);
  border-radius: 24px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7), 0 0 35px rgba(14, 165, 233, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95) translateY(15px);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.asesor-ia-backdrop.open .asesor-ia-modal {
  transform: scale(1) translateY(0);
}

@media (max-width: 768px) {
  .asesor-ia-backdrop {
    padding: 0;
    align-items: flex-end;
  }
  .asesor-ia-modal {
    max-width: 100%;
    height: 92vh;
    max-height: 92vh;
    border-radius: 24px 24px 0 0;
    transform: translateY(100%);
    border-left: none;
    border-right: none;
    border-bottom: none;
  }
  .asesor-ia-backdrop.open .asesor-ia-modal {
    transform: translateY(0);
  }
}

/* Header del Chat */
.asesor-ia-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: rgba(15, 23, 42, 0.85);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(8px);
}

.asesor-ia-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.asesor-ia-avatar {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  box-shadow: 0 4px 15px rgba(14, 165, 233, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.asesor-ia-title-box h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 6px;
}

.asesor-ia-badge {
  font-size: 0.65rem;
  text-transform: uppercase;
  background: rgba(14, 165, 233, 0.2);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.4);
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.asesor-ia-status {
  font-size: 0.78rem;
  color: #22c55e;
  margin: 2px 0 0 0;
  display: flex;
  align-items: center;
  gap: 5px;
}

.asesor-ia-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px #22c55e;
}

.asesor-ia-close {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #94a3b8;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
}

.asesor-ia-close:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

/* Área de Mensajes del Chat */
.asesor-ia-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.asesor-ia-messages::-webkit-scrollbar {
  width: 6px;
}
.asesor-ia-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 10px;
}

/* Mensajes individuales */
.ia-msg {
  display: flex;
  gap: 10px;
  max-width: 86%;
  animation: iaMsgFadeIn 0.3s ease forwards;
}

@keyframes iaMsgFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.ia-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.ia-msg.bot {
  align-self: flex-start;
}

.ia-msg-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 0.94rem;
  line-height: 1.5;
  word-break: break-word;
}

.ia-msg.user .ia-msg-bubble {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.25);
}

.ia-msg.bot .ia-msg-bubble {
  background: rgba(30, 41, 59, 0.7);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom-left-radius: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.ia-msg.bot .ia-msg-bubble p {
  margin: 0 0 8px 0;
}
.ia-msg.bot .ia-msg-bubble p:last-child {
  margin-bottom: 0;
}

.ia-msg.bot .ia-msg-bubble ul,
.ia-msg.bot .ia-msg-bubble ol {
  margin: 6px 0 8px 18px;
  padding: 0;
}

.ia-msg.bot .ia-msg-bubble li {
  margin-bottom: 4px;
}

.ia-msg.bot .ia-msg-bubble strong {
  color: #38bdf8;
  font-weight: 700;
}

/* Indicador de "Pensando..." */
.ia-typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.ia-typing-dot {
  width: 7px;
  height: 7px;
  background: #38bdf8;
  border-radius: 50%;
  animation: iaTypingBounce 1.4s infinite ease-in-out both;
}

.ia-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.ia-typing-dot:nth-child(2) { animation-delay: -0.16s; }
.ia-typing-dot:nth-child(3) { animation-delay: 0s; }

@keyframes iaTypingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Sugerencias Rápidas (Chips) */
.asesor-ia-suggestions {
  padding: 10px 20px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  white-space: nowrap;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(15, 23, 42, 0.5);
  cursor: grab;
  scrollbar-width: thin;
  scrollbar-color: rgba(56, 189, 248, 0.3) transparent;
  -webkit-overflow-scrolling: touch;
}

.asesor-ia-suggestions.dragging {
  cursor: grabbing;
  user-select: none;
}

.asesor-ia-suggestions::-webkit-scrollbar {
  height: 4px;
  display: block;
}

.asesor-ia-suggestions::-webkit-scrollbar-track {
  background: transparent;
}

.asesor-ia-suggestions::-webkit-scrollbar-thumb {
  background: rgba(56, 189, 248, 0.25);
  border-radius: 999px;
}

.asesor-ia-suggestions::-webkit-scrollbar-thumb:hover {
  background: rgba(56, 189, 248, 0.5);
}

.ia-chip {
  background: rgba(14, 165, 233, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: #cbd5e1;
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.ia-chip:hover {
  background: rgba(14, 165, 233, 0.22);
  border-color: rgba(56, 189, 248, 0.5);
  color: #ffffff;
  transform: translateY(-1px);
}

/* Input y Botón de Enviar */
.asesor-ia-input-area {
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom, 0px));
  background: rgba(15, 23, 42, 0.95);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  gap: 10px;
  align-items: center;
}

.asesor-ia-input-wrapper {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  display: flex;
  align-items: center;
  padding: 2px 14px;
  transition: all 0.2s ease;
}

.asesor-ia-input-wrapper:focus-within {
  border-color: #38bdf8;
  background: rgba(15, 23, 42, 0.9);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.25);
}

.asesor-ia-input,
.asesor-ia-input:focus,
.asesor-ia-input:active,
.asesor-ia-input:hover {
  width: 100% !important;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  transform: none !important;
  color: #f8fafc !important;
  padding: 10px 0 !important;
  font-size: 0.94rem !important;
  line-height: 1.4 !important;
}

.asesor-ia-input::placeholder {
  color: #64748b;
}

.asesor-ia-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  border: none;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.35);
  flex-shrink: 0;
}

.asesor-ia-send-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(14, 165, 233, 0.5);
}

.asesor-ia-send-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
