:root {
  --bg: #0b1020;
  --card-bg: #0f172a;
  --accent: #8b5cf6;
  --accent-soft: rgba(139, 92, 246, 0.16);
  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --border-subtle: #1f2937;
  --danger: #f97373;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: radial-gradient(circle at top, #111827 0, #020617 50%, #000 100%);
  color: var(--text-main);
}

.page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.card {
  width: 420px;
  max-width: 100%;
  height: 640px;
  max-height: 100vh;            /* 👈 no crece más que la pantalla */
  background: radial-gradient(circle at top, #111827 0, #020617 55%, #020617);
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  box-shadow:
    0 18px 45px rgba(15, 23, 42, 0.8),
    0 0 0 1px rgba(15, 23, 42, 0.9);
  display: flex;
  flex-direction: column;
  overflow: hidden;             /* 👈 evita que se “desborde” */
}

/* Header */

.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: blur(18px);
  background: linear-gradient(
    135deg,
    rgba(76, 29, 149, 0.7),
    rgba(15, 23, 42, 0.7)
  );
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 20%, #f9a8d4, #c4b5fd, #4f46e5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 0 0 1px rgba(248, 250, 252, 0.4),
    0 8px 18px rgba(55, 48, 163, 0.9);
}

.brand-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--text-muted);
}

.badge {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(248, 250, 252, 0.4);
  color: #e5e7eb;
  background: linear-gradient(
    135deg,
    rgba(248, 250, 252, 0.12),
    rgba(148, 163, 184, 0.16)
  );
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

/* Body */

.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px 14px 8px;
  gap: 10px;
  min-height: 0;               /* 👈 clave para que los hijos puedan hacer scroll */
}


.messages {
  flex: 1;
  overflow-y: auto;            /* 👈 aquí va el scroll */
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;               /* 👈 evita que empuje al footer */
}


/* Scrollbar */

.messages::-webkit-scrollbar {
  width: 6px;
}

.messages::-webkit-scrollbar-track {
  background: transparent;
}

.messages::-webkit-scrollbar-thumb {
  background: rgba(75, 85, 99, 0.7);
  border-radius: 999px;
}

/* Mensajes */

.message-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.message-row.user {
  justify-content: flex-end;
}

.message-bubble {
  max-width: 78%;
  border-radius: 14px;
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.45;
  word-wrap: break-word;
}

.message-bubble.bot {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.6);
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.8);
}

.message-bubble.user {
  background: linear-gradient(135deg, #4f46e5, #8b5cf6);
  color: #f9fafb;
  border-bottom-right-radius: 4px;
}

.message-meta {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Avatar simple */

.avatar {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 20%, #f9a8d4, #c4b5fd, #4f46e5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}

.avatar.user {
  background: linear-gradient(135deg, #4f46e5, #22c55e);
}

/* Quick questions */

.quick-questions {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
}

.quick-questions span {
  margin-right: 4px;
}

.chip {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  background: rgba(15, 23, 42, 0.9);
  color: #e5e7eb;
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s ease-out;
}

.chip:hover {
  background: rgba(79, 70, 229, 0.8);
  border-color: rgba(191, 219, 254, 0.9);
}

/* Footer */

.card-footer {
  padding: 8px 12px 12px;
  border-top: 1px solid rgba(31, 41, 55, 0.8);
  background: radial-gradient(circle at top, #020617, #020617);
}

.chat-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chat-form input {
  flex: 1;
  border-radius: 999px;
  border: 1px solid rgba(55, 65, 81, 0.9);
  background: rgba(15, 23, 42, 0.96);
  color: #e5e7eb;
  font-size: 13px;
  padding: 8px 12px;
  outline: none;
}

.chat-form input::placeholder {
  color: rgba(148, 163, 184, 0.85);
}

.chat-form input:focus {
  border-color: rgba(129, 140, 248, 0.9);
  box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.7);
}

.chat-form button {
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, #4f46e5, #8b5cf6);
  color: #f9fafb;
  font-size: 13px;
  padding: 8px 16px;
  cursor: pointer;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 10px 20px rgba(79, 70, 229, 0.7);
  transition: transform 0.08s ease-out, box-shadow 0.08s ease-out,
    opacity 0.08s ease-out;
}

.chat-form button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 14px 26px rgba(79, 70, 229, 0.8);
}

.chat-form button:disabled {
  opacity: 0.6;
  cursor: default;
  box-shadow: none;
}

.status {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
  min-height: 14px;
}

.disclaimer {
  margin-top: 6px;
  font-size: 10px;
  color: rgba(148, 163, 184, 0.9);
}

/* Typing indicator */

.typing {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.typing-dot {
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.9);
  animation: blink 1s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}
.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.2;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

/* Responsive */

@media (max-width: 480px) {
  .card {
    height: 100vh;
    border-radius: 0;
  }
}
