/* ==========================================================================
   Widget de chatbot — "Dani", asistente IA de DIDI Inversiones
   ========================================================================== */

.chat-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 90;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 16px 32px -12px rgba(16, 42, 87, 0.5);
  transition: transform 0.2s ease;
}
.chat-launcher:hover { transform: scale(1.06); }
.chat-launcher svg { width: 26px; height: 26px; }
.chat-launcher .icon-close { display: none; }
.chat-launcher.is-open .icon-open { display: none; }
.chat-launcher.is-open .icon-close { display: block; }

.chat-launcher .ping {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--cream);
}

.chat-panel {
  position: fixed;
  right: 20px;
  bottom: 92px;
  z-index: 89;
  width: min(370px, calc(100vw - 40px));
  height: min(560px, calc(100vh - 140px));
  background: var(--cream);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 60px -20px rgba(16, 42, 87, 0.45);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

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

.chat-header {
  background: var(--navy);
  color: var(--cream);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-header .avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-header .avatar svg { width: 20px; height: 20px; color: var(--navy); }

.chat-header .name { font-weight: 700; font-size: 0.98rem; }
.chat-header .status {
  font-size: 0.76rem;
  color: rgba(250, 248, 243, 0.62);
  display: flex;
  align-items: center;
  gap: 6px;
}
.chat-header .status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3ecf6e;
}

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-msg {
  max-width: 84%;
  padding: 11px 15px;
  border-radius: 16px;
  font-size: 0.92rem;
  line-height: 1.45;
}

.chat-msg--bot {
  align-self: flex-start;
  background: var(--white);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.chat-msg--user {
  align-self: flex-end;
  background: var(--navy);
  color: var(--cream);
  border-bottom-right-radius: 4px;
}

.chat-msg--bot a { color: var(--gold-dark); font-weight: 700; text-decoration: underline; }

.chat-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 18px 14px;
}

.chat-quick-replies button {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--white);
  font-size: 0.82rem;
  font-weight: 600;
}
.chat-quick-replies button:hover { border-color: var(--gold); color: var(--gold-dark); }

.chat-typing {
  display: inline-flex;
  gap: 4px;
  padding: 12px 15px;
}
.chat-typing span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--gray-soft);
  animation: chat-typing 1.2s 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-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.chat-form {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--border);
  background: var(--white);
}

.chat-form input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 11px 16px;
  font-size: 0.9rem;
  background: var(--cream);
}
.chat-form input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }

.chat-form button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-form button svg { width: 18px; height: 18px; }
.chat-form button:disabled { opacity: 0.5; }

.chat-disclaimer {
  font-size: 0.68rem;
  color: var(--gray-soft);
  text-align: center;
  padding: 0 14px 12px;
}

@media (max-width: 420px) {
  .chat-panel { right: 10px; left: 10px; width: auto; bottom: 84px; }
  .chat-launcher { right: 14px; bottom: 14px; }
}
