/* =====================================================================
   PSICO_APP — estilos base
   Paleta calida-neutra para reducir ansiedad: azules profundos + crema +
   acento amber.
   ===================================================================== */

* { box-sizing: border-box; }

:root {
  --bg:        #0f1419;
  --bg-soft:   #1a2029;
  --bg-card:   #232a35;
  --fg:        #e8e2d4;
  --fg-soft:   #b8b1a3;
  --fg-dim:    #7a7468;
  --accent:    #e0a96d;
  --accent-2:  #8fb8a0;
  --danger:    #d96363;
  --border:    #353d49;
  --radius:    14px;
  --shadow:    0 4px 20px rgba(0,0,0,0.25);
  --font:      -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

/* =============== BOTONES =============== */
button {
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  padding: 12px 22px;
  font-weight: 600;
  transition: transform 0.08s ease, opacity 0.15s ease, background 0.15s ease;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #1a0f00;
}
.btn-primary:hover { background: #efb47a; }

.btn-secondary {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-soft); }

.btn-ghost {
  background: transparent;
  color: var(--fg-soft);
  padding: 8px 14px;
  font-size: 0.9rem;
}
.btn-ghost:hover { color: var(--fg); background: var(--bg-soft); }

/* =============== LANDING =============== */
body.landing { background: var(--bg); }

.hero {
  min-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  background:
    radial-gradient(ellipse at top, rgba(224,169,109,0.08), transparent 60%),
    radial-gradient(ellipse at bottom right, rgba(143,184,160,0.06), transparent 50%),
    var(--bg);
}
.hero-inner {
  max-width: 720px;
  text-align: center;
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 700;
  line-height: 1.15;
  margin: 0 0 24px;
  letter-spacing: -0.02em;
}
.hero h1 .accent {
  color: var(--accent);
  font-weight: 400;
  font-style: italic;
}
.lede {
  font-size: 1.25rem;
  color: var(--fg-soft);
  margin: 0 0 16px;
}
.micro {
  font-size: 0.95rem;
  color: var(--fg-dim);
  margin: 0 0 36px;
}
.cta-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.disclaimer-mini {
  font-size: 0.8rem;
  color: var(--fg-dim);
  margin-top: 18px;
}

.how {
  padding: 80px 24px;
  background: var(--bg-soft);
}
.how-grid {
  max-width: 960px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
}
.how-item h3 {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 1.05rem;
}
.how-item p {
  margin: 0;
  color: var(--fg-soft);
}

/* =============== MODAL =============== */
dialog.dlg {
  border: none;
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--fg);
  padding: 0;
  max-width: 480px;
  width: calc(100% - 32px);
  box-shadow: var(--shadow);
}
dialog.dlg::backdrop {
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
}
.dlg-form {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
}
.dlg-form h2 {
  margin: 0 0 4px;
  font-size: 1.5rem;
}
.dlg-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--fg-soft);
}
.dlg-form input[type="email"],
.dlg-form input[type="password"],
.dlg-form input[type="text"],
.dlg-form select,
.dlg-form textarea {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--fg);
  padding: 11px 12px;
  font-size: 1rem;
  font-family: inherit;
}
.dlg-form input:focus,
.dlg-form select:focus,
.dlg-form textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.dlg-form label.checkbox {
  flex-direction: row;
  gap: 10px;
  align-items: flex-start;
  font-size: 0.85rem;
  color: var(--fg-soft);
}
.dlg-form label.checkbox input {
  margin-top: 3px;
}
.dlg-form .error {
  background: rgba(217,99,99,0.12);
  color: #f0a8a8;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.9rem;
  margin: 0;
}
.dlg-switch {
  text-align: center;
  font-size: 0.9rem;
  color: var(--fg-dim);
  margin: 0;
}
.dlg-close {
  position: absolute;
  top: 12px; right: 12px;
  background: transparent;
  color: var(--fg-dim);
  font-size: 1.4rem;
  padding: 0;
  width: 32px; height: 32px;
  border-radius: 50%;
}
.dlg-close:hover { background: var(--bg-soft); color: var(--fg); }

/* =============== APP (sesion) =============== */
body.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background: var(--bg);
}
body.app.voice-first {
  overflow: hidden;
  background:
    radial-gradient(ellipse at center, rgba(224,169,109,0.06), transparent 70%),
    radial-gradient(ellipse at bottom, rgba(143,184,160,0.04), transparent 60%),
    var(--bg);
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}
.topbar-glass {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 5;
  background: linear-gradient(180deg, rgba(15,20,25,0.85), rgba(15,20,25,0.0));
  border-bottom: none;
  backdrop-filter: blur(8px);
}

/* =============== STAGE (orb full-screen) =============== */
.stage {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
#orb-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}
.stage-content {
  position: relative;
  z-index: 2;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 24px;
  /* sin background — la orb es el fondo visual */
}
.orb-status {
  font-size: clamp(1.05rem, 2.4vw, 1.4rem);
  color: var(--fg);
  margin: 0;
  letter-spacing: 0.01em;
  text-shadow: 0 2px 12px rgba(0,0,0,0.6);
  opacity: 1;
  transition: opacity 0.3s ease;
}
.orb-status.dim { opacity: 0.55; }

.orb-transcript {
  max-width: 720px;
  margin: 0;
  font-size: clamp(1.1rem, 2.6vw, 1.6rem);
  font-weight: 500;
  color: var(--accent);
  text-shadow: 0 2px 14px rgba(0,0,0,0.7);
  padding: 12px 20px;
  line-height: 1.4;
  border-radius: 16px;
  background: rgba(15,20,25,0.4);
  backdrop-filter: blur(6px);
}

.btn-tap {
  background: var(--accent);
  color: #1a0f00;
  border: none;
  border-radius: 999px;
  padding: 18px 28px;
  font-size: 1.05rem;
  font-weight: 600;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  box-shadow: 0 4px 30px rgba(224,169,109,0.4);
  animation: tap-pulse 2s ease-in-out infinite;
}
.btn-tap:hover { background: #efb47a; }
@keyframes tap-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 4px 30px rgba(224,169,109,0.4); }
  50%      { transform: scale(1.04); box-shadow: 0 4px 50px rgba(224,169,109,0.6); }
}

.bottom-controls {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 3;
}
.btn-ghost-soft {
  background: rgba(35,42,53,0.6);
  border: 1px solid rgba(53,61,73,0.5);
  color: var(--fg-soft);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background 0.15s ease, color 0.15s ease;
}
.btn-ghost-soft:hover { background: rgba(35,42,53,0.9); color: var(--fg); }

/* =============== DRAWER (chat log + text input fallback) =============== */
.chat-drawer {
  position: fixed;
  right: 0; top: 0; bottom: 0;
  width: min(420px, 100%);
  background: rgba(15,20,25,0.96);
  backdrop-filter: blur(10px);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 7;
  box-shadow: -8px 0 30px rgba(0,0,0,0.4);
}
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.drawer-head h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--accent);
}
.composer-drawer {
  padding: 12px 14px 18px;
  border-top: 1px solid var(--border);
  background: rgba(15,20,25,0.6);
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.composer-drawer textarea {
  flex: 1 1 auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--fg);
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: inherit;
  resize: none;
  max-height: 160px;
}
.composer-drawer textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.composer-drawer button {
  padding: 10px 16px;
  font-size: 0.9rem;
}
.topbar .brand {
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--accent);
}
.topbar-right {
  display: flex;
  gap: 8px;
  align-items: center;
}
.badge {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(224,169,109,0.18);
  color: var(--accent);
  border: 1px solid rgba(224,169,109,0.4);
}
.badge.warn { background: rgba(217,99,99,0.18); color: #f0a8a8; border-color: rgba(217,99,99,0.4); }

.crisis-banner {
  background: rgba(217,99,99,0.15);
  border-bottom: 1px solid rgba(217,99,99,0.4);
  color: #f8c5c5;
  padding: 12px 18px;
  font-size: 0.92rem;
  text-align: center;
}
.crisis-banner strong { color: #ffb8b8; margin-right: 6px; }

.chat-shell {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.chat-log {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
}
.msg {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 16px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #1a0f00;
  border-bottom-right-radius: 4px;
}
.msg.assistant {
  align-self: flex-start;
  background: var(--bg-card);
  color: var(--fg);
  border-bottom-left-radius: 4px;
}
.msg.thinking {
  align-self: flex-start;
  background: transparent;
  color: var(--fg-dim);
  font-style: italic;
  padding: 4px 16px;
}

.composer {
  display: flex;
  gap: 10px;
  padding: 14px 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  align-items: flex-end;
}
.composer textarea {
  flex: 1 1 auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--fg);
  padding: 12px 14px;
  font-size: 1rem;
  font-family: inherit;
  resize: none;
  max-height: 200px;
}
.composer textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* =============== MIC (Fase 2: voz) =============== */
.mic-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--fg-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s ease, color 0.15s ease, transform 0.08s ease;
}
.mic-btn:hover {
  background: var(--bg);
  color: var(--fg);
}
.mic-btn.disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.mic-btn.listening {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
  animation: mic-pulse 1.4s ease-out infinite;
}
@keyframes mic-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(217, 99, 99, 0.55); }
  70%  { box-shadow: 0 0 0 14px rgba(217, 99, 99, 0); }
  100% { box-shadow: 0 0 0 0 rgba(217, 99, 99, 0); }
}

.mic-hint {
  text-align: center;
  font-size: 0.85rem;
  color: var(--fg-dim);
  padding: 0 16px 10px;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
}

/* =============== Settings modal — extras =============== */
.dlg-form .muted {
  font-size: 0.85rem;
  color: var(--fg-dim);
  margin: 0;
}
.dlg-form .row-actions {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  flex-wrap: wrap;
}
.dlg-form .row-actions .btn-secondary {
  padding: 10px 16px;
  font-size: 0.9rem;
  flex: 1 1 auto;
}
.dlg.dlg-wide { max-width: 560px; }
.dlg-section {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.dlg-section:first-of-type {
  border-top: none;
  padding-top: 0;
}
.dlg-section h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--accent);
  font-weight: 600;
}
.dlg-section form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.danger-text { color: #f0a8a8 !important; }
.danger-text:hover { background: rgba(217,99,99,0.12) !important; }
.danger-bg {
  background: var(--danger) !important;
  color: white !important;
}
.danger-bg:hover { background: #e07878 !important; }

/* =============== History list =============== */
.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 50vh;
  overflow-y: auto;
}
.history-item {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.08s ease;
}
.history-item:hover {
  background: var(--bg-card);
}
.history-item:active {
  transform: translateY(1px);
}
.history-item.history-loading {
  text-align: center;
  color: var(--fg-dim);
  cursor: default;
}
.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.history-title {
  font-weight: 600;
  color: var(--fg);
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex: 0 0 auto;
}
.history-badge.open {
  background: rgba(143,184,160,0.18);
  color: var(--accent-2);
  border: 1px solid rgba(143,184,160,0.4);
}
.history-badge.closed {
  background: rgba(184,177,163,0.12);
  color: var(--fg-dim);
  border: 1px solid var(--border);
}
.history-meta {
  font-size: 0.78rem;
  color: var(--fg-dim);
  margin-top: 4px;
}

/* =============== Referidos =============== */
.ref-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.ref-row input {
  flex: 1 1 auto;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--fg);
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
}
.ref-row .btn-secondary { flex: 0 0 auto; padding: 10px 14px; }

/* =============== Onboarding wizard =============== */
.onb-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 60vh;
  overflow-y: auto;
}
.onb-item {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--fg);
  transition: background 0.12s ease, transform 0.08s ease, border-color 0.12s ease;
}
.onb-item:hover {
  background: var(--bg-card);
  border-color: var(--accent);
}
.onb-item:active { transform: translateY(1px); }

/* =============== UTIL =============== */
@media (max-width: 540px) {
  .hero { padding: 40px 18px; min-height: 60vh; }
  .composer { padding: 10px 12px 16px; }
  .chat-log { padding: 14px 10px; }
  .msg { max-width: 90%; }
}
