/* ========================================
   CHAT DEL DIAGNÓSTICO IA — jonatand.com
   Usa los tokens globales de /style.css (ver DESIGN.md).
   ======================================== */

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  display: flex;
  justify-content: center;
  overflow: hidden;
}

.wrap {
  width: 100%;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding: 0 20px;
}

/* ---------- Cabecera ---------- */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 2px 16px;
}
.brand img { height: 22px; width: auto; display: block; }
.reset {
  background: none;
  border: none;
  color: var(--faint);
  font: 500 13px var(--sans);
  cursor: pointer;
  padding: 6px 2px;
  transition: color .15s ease;
}
.reset:hover { color: var(--ink); }

/* ---------- Progreso ---------- */
.progress {
  height: 2px;
  background: var(--line);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.progress__bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width .4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---------- Área de chat ---------- */
#chat {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 28px 2px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.bubble {
  max-width: 86%;
  padding: 15px 18px;
  border-radius: var(--radius-lg);
  font-size: 16px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: bubbleIn .25s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* Bot: card blanca con borde fino (sin sombra, como las cards del sitio).
   Preguntas y acks comparten tipografía (Hanken): en un chat el cambio de
   familia entre burbujas despista; las preguntas solo ganan peso. */
.bubble--bot {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
  color: var(--ink);
}
.bubble--bot.question { font-weight: 600; }
.serif-accent {
  font-family: var(--serif);
  font-style: italic;
  color: var(--accent);
}

.bubble--user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  font-weight: 500;
  border-bottom-right-radius: 6px;
}

.bubble--error {
  align-self: flex-start;
  background: var(--accent-tint);
  border: 1px solid rgba(255, 90, 31, .35);
  color: #8a2f0e;
  font-size: 14px;
}

.typing {
  align-self: flex-start;
  display: flex;
  gap: 5px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: 6px;
}
.typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--faint);
  animation: blink 1.2s infinite;
}
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 70%, 100% { opacity: .25; } 35% { opacity: 1; } }

/* ---------- Composer ---------- */
footer { padding: 10px 0 max(18px, env(safe-area-inset-bottom)); }

.warning {
  font-size: 12.5px;
  color: var(--faint);
  margin-bottom: 10px;
  line-height: 1.5;
}

.options {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  padding-bottom: 10px;
}
.options button {
  font: 500 15px var(--sans);
  color: var(--soft);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease;
}
.options button:hover { border-color: var(--ink); color: var(--ink); }

.inputrow {
  display: flex;
  gap: 9px;
  align-items: stretch;
}
.inputrow textarea,
.inputrow input {
  flex: 1;
  font: 400 16px var(--sans);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  outline: none;
  resize: none;
  transition: border-color .15s ease;
}
.inputrow textarea:hover,
.inputrow input:hover { border-color: var(--ink); }
.inputrow textarea:focus,
.inputrow input:focus { border-color: var(--accent); }
.inputrow button {
  font: 600 17px var(--sans);
  flex-shrink: 0;
  width: 54px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(255, 90, 31, .18);
  transition: background .15s ease, transform .12s ease, opacity .15s ease;
}
.inputrow button:hover:not(:disabled) { background: var(--accent-press); }
.inputrow button:disabled { opacity: .45; cursor: default; }
.inputrow button:not(:disabled):active { transform: scale(.96); }

/* Bloque de email (cierre) */
.emailblock {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.rgpd {
  display: flex;
  gap: 9px;
  font-size: 13px;
  color: var(--soft);
  line-height: 1.55;
  align-items: flex-start;
  cursor: pointer;
}
.rgpd input {
  margin-top: 3px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

/* Honeypot anti-bots */
.hp {
  position: absolute;
  left: -9999px;
  opacity: 0;
  height: 0;
  overflow: hidden;
}

[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  .bubble { animation: none; }
  .progress__bar { transition: none; }
}
