@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600&family=Inter:wght@300;400;500&display=swap');

:root {
  --bg:      #1C1A18;
  --bg2:     #252320;
  --bg3:     #2E2B27;
  --gold:    #C9A96E;
  --gold2:   #A8865A;
  --text:    #E8E0D4;
  --muted:   #9A9080;
  --border:  #3A3530;
  --danger:  #C06060;
  --radius:  10px;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-weight: 400;
  min-height: 100vh;
  line-height: 1.6;
}

/* ── TEMA CLARO ── */
body.tema-claro {
  --bg:     #f5f3f0;
  --bg2:    #ffffff;
  --bg3:    #ede9e4;
  --gold:   #8B6914;
  --gold2:  #7A5A10;
  --text:   #111111;
  --muted:  #666666;
  --border: #d4cfc9;
  --danger: #cc3333;
}
body.tema-claro #topbar {
  background: rgba(245,243,240,0.96);
}
body.tema-claro #stepnav {
  background: rgba(237,233,228,0.98);
}

/* ── TOPBAR ── */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: rgba(28,26,24,0.95);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1.5rem;
  height: 56px;
}
#topbar .logo-small img { height: 32px; }
#topbar .progress-bar-wrap {
  flex: 1; margin: 0 2rem;
  height: 3px; background: var(--border); border-radius: 2px;
  overflow: hidden;
}
#topbar .progress-bar-fill {
  height: 100%; background: var(--gold);
  border-radius: 2px;
  transition: width 0.4s ease;
}
#topbar .progress-label {
  font-size: 0.72rem; color: var(--muted); white-space: nowrap;
  letter-spacing: 0.05em;
}
.btn-tema {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 20px;
  padding: 0.2rem 0.7rem;
  font-size: 0.75rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
  font-family: inherit;
}
.btn-tema:hover { border-color: var(--gold); color: var(--gold); }

/* ── STEP NAV ── */
#stepnav {
  position: fixed; top: 56px; left: 0; right: 0;
  z-index: 98; height: 44px;
  background: rgba(20,18,16,0.98);
  backdrop-filter: blur(4px);
  border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none;
}
#stepnav::-webkit-scrollbar { display: none; }
.stepnav-inner {
  display: flex; align-items: center;
  gap: 2px; padding: 0 0.75rem;
  min-width: max-content; height: 44px;
}
.step-item {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.28rem 0.65rem; border-radius: 16px; flex-shrink: 0;
  font-size: 0.73rem; letter-spacing: 0.01em;
  transition: all 0.15s; color: var(--muted);
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
}
.step-item.current {
  color: var(--gold); background: rgba(201,169,110,0.12);
  border-color: rgba(201,169,110,0.28); cursor: default;
}
.step-item.done { color: var(--text); }
.step-item.done:hover { color: var(--gold); background: rgba(201,169,110,0.07); }
.step-item.upcoming { color: var(--muted); }
.step-item.upcoming:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.step-item.locked { opacity: 0.3; cursor: not-allowed; }
.step-check { font-size: 0.62rem; color: var(--gold); }
.step-sep { color: var(--border); font-size: 0.75rem; padding: 0 0.3rem; flex-shrink: 0; user-select: none; }
.step-lbl { } /* visible by default, hidden on small screens */

/* ── MAIN WRAPPER ── */
#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 72px 1.25rem 4rem;
  min-height: 100vh;
}
#app.with-stepnav { padding-top: 112px; }

/* ── SCREEN: HOME ── */
.screen-home {
  display: flex; flex-direction: column;
  align-items: center; text-align: center;
  gap: 2rem; padding-top: 3rem;
}
.screen-home .logo-home img { width: min(260px, 80vw); }
.screen-home h1 {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  color: var(--gold); letter-spacing: 0.05em; font-weight: 400;
}
.screen-home .tagline {
  font-size: clamp(0.75rem, 2.5vw, 0.85rem);
  letter-spacing: 0.25em; text-transform: uppercase;
  color: var(--muted);
}
.home-splash {
  width: 100%; max-width: 520px;
  border-radius: 14px; overflow: hidden;
  position: relative; line-height: 0;
}
.home-splash img {
  width: 100%; height: 260px;
  object-fit: cover; object-position: center 40%;
  display: block;
  border-radius: 14px;
}
.home-splash-overlay {
  position: absolute; inset: 0; border-radius: 14px;
  background: linear-gradient(
    to bottom,
    rgba(28,26,24,0.05) 0%,
    rgba(28,26,24,0.35) 100%
  );
  pointer-events: none;
}
body.tema-claro .home-splash-overlay {
  background: linear-gradient(
    to bottom,
    rgba(245,243,240,0.0) 0%,
    rgba(245,243,240,0.25) 100%
  );
}

.screen-home .intro-text {
  max-width: 520px;
  font-size: 0.95rem; color: var(--text); line-height: 1.8;
}
.screen-home .intro-text strong { color: var(--gold); }
.principios {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem; width: 100%; max-width: 580px; text-align: left;
}
.principio {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.25rem;
  font-size: 0.85rem; color: var(--muted); line-height: 1.5;
}
.principio strong { display: block; color: var(--text); margin-bottom: 0.25rem; font-size: 0.8rem; letter-spacing: 0.05em; }

.como-funciona {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 1rem; width: 100%; max-width: 520px;
}
.como-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem; text-align: left;
}
.como-card .como-icon { font-size: 1.4rem; color: var(--gold); margin-bottom: 0.6rem; }
.como-card h3 { font-size: 0.88rem; font-weight: 500; color: var(--text); margin-bottom: 0.4rem; }
.como-card p  { font-size: 0.8rem; color: var(--muted); line-height: 1.5; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.75rem 2rem; border-radius: 50px;
  font-family: 'Inter', sans-serif; font-size: 0.88rem;
  font-weight: 500; letter-spacing: 0.06em; cursor: pointer;
  border: none; text-decoration: none; transition: all 0.2s ease;
  white-space: nowrap;
}
.btn-primary {
  background: var(--gold); color: var(--bg);
}
.btn-primary:hover { background: #D4B880; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(201,169,110,0.3); }
.btn-secondary {
  background: transparent; color: var(--gold);
  border: 1px solid var(--gold);
}
.btn-secondary:hover { background: rgba(201,169,110,0.08); }
.btn-ghost {
  background: transparent; color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none !important; }
.btn-lg { padding: 1rem 2.5rem; font-size: 0.95rem; }

/* ── CARD ── */
.card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.75rem;
  margin-bottom: 1.25rem;
}

/* ── SCREEN: CREAR ── */
.screen-crear h2, .screen-quiz h2, .screen-extras h2 {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.3rem, 4vw, 1.7rem); font-weight: 400;
  color: var(--gold); margin-bottom: 0.4rem;
}
.screen-crear .subtitle { font-size: 0.85rem; color: var(--muted); margin-bottom: 2rem; }

.modo-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 2rem; }
.modo-card {
  background: var(--bg2); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem 1.25rem;
  cursor: pointer; transition: all 0.2s ease; text-align: center;
}
.modo-card:hover { border-color: var(--gold2); background: var(--bg3); }
.modo-card.selected { border-color: var(--gold); background: var(--bg3); }
.modo-card .modo-icon { font-size: 1.8rem; margin-bottom: 0.75rem; color: var(--gold); }
.modo-card h3 { font-size: 0.95rem; font-weight: 500; color: var(--text); margin-bottom: 0.4rem; }
.modo-card p { font-size: 0.78rem; color: var(--muted); line-height: 1.5; }

.field { margin-bottom: 1.25rem; }
.field label { display: block; font-size: 0.78rem; letter-spacing: 0.06em; color: var(--muted); text-transform: uppercase; margin-bottom: 0.5rem; }
.field input {
  width: 100%; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.75rem 1rem;
  color: var(--text); font-family: 'Inter', sans-serif; font-size: 0.95rem;
  outline: none; transition: border-color 0.2s;
}
.field input:focus { border-color: var(--gold); }
.field input::placeholder { color: var(--muted); }

/* ── SCREEN: CUESTIONARIO ── */
.afinidad-header {
  display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem;
}
.afinidad-icono {
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(201,169,110,0.1); border: 1px solid var(--gold2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; color: var(--gold); flex-shrink: 0;
}
.afinidad-header h2 { margin-bottom: 0; }
.afinidad-header .afinidad-sub { font-size: 0.8rem; color: var(--muted); }

.fase-banner {
  background: rgba(201,169,110,0.08); border: 1px solid rgba(201,169,110,0.2);
  border-radius: 8px; padding: 0.75rem 1.25rem;
  font-size: 0.83rem; color: var(--gold); margin-bottom: 1.5rem;
  line-height: 1.5;
}

.question-block {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}
.question-text {
  font-size: 0.93rem; color: var(--text); margin-bottom: 1.1rem; line-height: 1.6;
}
.scale-wrap {
  display: flex; flex-direction: column; gap: 0.4rem;
}
.scale-labels {
  display: flex; justify-content: space-between;
  font-size: 0.68rem; color: var(--muted); letter-spacing: 0.03em;
  padding: 0 2px;
}
.scale-btns {
  display: flex; gap: 0.4rem;
}
.scale-btn {
  flex: 1; height: 40px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg3);
  color: var(--muted); font-size: 0.88rem; font-weight: 500;
  cursor: pointer; transition: all 0.15s ease;
  display: flex; align-items: center; justify-content: center;
}
.scale-btn:hover { border-color: var(--gold2); color: var(--text); }
.scale-btn.active {
  background: var(--gold); border-color: var(--gold);
  color: var(--bg); font-weight: 600;
}
.question-block.answered { border-color: rgba(201,169,110,0.3); }

.atributo-sep {
  font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); margin: 1.75rem 0 0.75rem;
  display: flex; align-items: center; gap: 0.75rem;
}
.atributo-sep::before, .atributo-sep::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

.nav-btns { display: flex; gap: 1rem; justify-content: flex-end; margin-top: 2rem; }

/* ── SCREEN: EXTRAS ── */
.extra-q {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.25rem;
}
.extra-q .eq-label { font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold2); margin-bottom: 0.75rem; }
.extra-q .eq-text { font-size: 0.95rem; color: var(--text); margin-bottom: 0.5rem; line-height: 1.6; }
.extra-q .eq-nota { font-size: 0.78rem; color: var(--muted); margin-bottom: 1.25rem; }
.extra-q .scale-opts {
  display: flex; flex-direction: column; gap: 0.5rem;
}
.scale-opt {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.65rem 1rem;
  cursor: pointer; font-size: 0.88rem; color: var(--muted);
  transition: all 0.15s ease; display: flex; align-items: center; gap: 0.75rem;
}
.scale-opt:hover { border-color: var(--gold2); color: var(--text); }
.scale-opt.active { border-color: var(--gold); color: var(--text); background: rgba(201,169,110,0.08); }
.scale-opt .opt-num {
  width: 26px; height: 26px; border-radius: 50%;
  border: 1px solid currentColor; display: flex; align-items: center;
  justify-content: center; font-size: 0.78rem; font-weight: 600; flex-shrink: 0;
}

/* ── SCREEN: COMPARTIR ── */
.share-box {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 2rem; text-align: center;
}
.share-code {
  font-family: 'Playfair Display', serif;
  font-size: 2rem; letter-spacing: 0.15em; color: var(--gold);
  margin: 1rem 0;
}
.share-url {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.75rem 1rem;
  font-size: 0.85rem; color: var(--text); word-break: break-all;
  margin: 1rem 0;
}
.copy-feedback { font-size: 0.78rem; color: var(--gold); height: 1rem; }

/* ── SCREEN: RESULTADOS ── */

/* Logo solo visible en PDF / impresión */
.result-logo-pdf { display: none; }
.afinia-pdf .result-logo-pdf { display: block; text-align: center; padding: 0.5rem 0 1.5rem; }
.afinia-pdf .result-logo-pdf img { height: 52px; display: block; margin: 0 auto 0.5rem; }
.afinia-pdf .result-logo-pdf-sub {
  font-family: 'Playfair Display', serif; font-size: 1rem;
  letter-spacing: 0.1em; color: #8B6914; font-weight: 400;
}

.result-hero {
  text-align: center; padding: 2rem 1rem 1.5rem;
  border-bottom: 1px solid var(--border); margin-bottom: 2rem;
}
.result-hero .iga-num {
  font-family: 'Playfair Display', serif;
  font-size: clamp(4rem, 18vw, 6rem); font-weight: 600;
  color: var(--gold); line-height: 1;
}
.result-hero .iga-label {
  font-size: 0.72rem; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--muted); margin-top: 0.25rem;
}
.result-hero .iga-etiqueta {
  font-family: 'Playfair Display', serif; font-size: 1.4rem;
  color: var(--text); margin-top: 0.75rem;
}
.result-hero .nombres {
  font-size: 0.85rem; color: var(--muted); margin-top: 0.5rem;
}

.estimado-banner {
  background: rgba(192, 96, 96, 0.08);
  border: 1px solid rgba(192, 96, 96, 0.28);
  border-left: 3px solid rgba(192, 96, 96, 0.55);
  border-radius: 8px; padding: 1rem 1.25rem;
  font-size: 0.83rem; color: #B87878;
  margin-bottom: 1.75rem; line-height: 1.6;
}
.estimado-banner .estimado-titulo {
  font-size: 0.88rem; font-weight: 600;
  color: #C08080; margin-bottom: 0.5rem;
}
.estimado-banner .estimado-nota {
  margin-top: 0.5rem; font-size: 0.78rem;
  color: #A06060; font-style: italic;
}

.indices-row {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 1rem; margin-bottom: 2rem;
}
.index-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem; text-align: center;
}
.index-card .idx-val {
  font-family: 'Playfair Display', serif;
  font-size: 2rem; color: var(--gold);
}
.index-card .idx-name {
  font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); margin-top: 0.25rem;
}
.index-card .idx-desc { font-size: 0.78rem; color: var(--muted); margin-top: 0.4rem; }

.radar-wrap {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem; margin-bottom: 2rem;
}
.radar-wrap h3 {
  font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 1.25rem;
}
.radar-wrap canvas { max-width: 100%; }

.afinidades-list { margin-bottom: 2rem; }
.afinidades-list h3 {
  font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 1rem;
}
.af-row {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 0; border-bottom: 1px solid var(--border);
}
.af-row:last-child { border-bottom: none; }
.af-icono { font-size: 1rem; color: var(--gold2); width: 20px; text-align: center; flex-shrink: 0; }
.af-nombre { flex: 1; font-size: 0.9rem; }
.af-bar-wrap { width: 120px; height: 6px; background: var(--bg3); border-radius: 3px; overflow: hidden; flex-shrink: 0; }
.af-bar-fill { height: 100%; border-radius: 3px; background: var(--gold); transition: width 0.6s ease; }
.af-score { font-size: 0.88rem; font-weight: 500; color: var(--gold); width: 36px; text-align: right; flex-shrink: 0; }

.fortalezas-section { margin-bottom: 2rem; }
.section-label {
  font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 1rem;
}
.fortalezas-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.fortaleza-card {
  background: var(--bg2); border: 1px solid rgba(201,169,110,0.2);
  border-radius: var(--radius); padding: 1rem;
}
.fortaleza-card.oportunidad { border-color: rgba(180,140,100,0.15); }
.fortaleza-card .fc-label {
  font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--gold2); margin-bottom: 0.5rem;
}
.fortaleza-card .fc-nombre { font-size: 0.9rem; color: var(--text); }
.fortaleza-card .fc-score { font-size: 0.78rem; color: var(--muted); margin-top: 0.25rem; }

.result-actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; margin-top: 2rem; }

/* ── SCREEN: REGISTRO / RECUPERAR ── */
.screen-registro, .screen-recuperar {
  padding-top: 1.5rem;
}
.screen-registro .field input:focus,
.screen-recuperar .field input:focus { border-color: var(--gold); }

/* ── SCREEN: REPORTE (print) ── */
@media print {
  :root {
    --bg:     #ffffff;
    --bg2:    #f8f6f4;
    --bg3:    #ede9e4;
    --gold:   #8B6914;
    --gold2:  #7A5A10;
    --text:   #111111;
    --muted:  #555555;
    --border: #d0ccc8;
    --danger: #cc3333;
  }
  body { background: white !important; }
  #topbar, #stepnav, .result-actions, #guardar-fb,
  .no-print { display: none !important; }
  #app { padding: 0 !important; max-width: 100%; }
  canvas { max-width: 420px; }
  /* Evitar cortes en elementos clave */
  .result-hero, .indices-row, .radar-wrap,
  .index-card, .fortaleza-card, .fortalezas-section,
  .estimado-banner, .result-logo-pdf { break-inside: avoid; }
  /* Logo: visible en impresión */
  .result-logo-pdf { display: block; text-align: center; padding: 0.5rem 0 1.5rem; }
  .result-logo-pdf img { height: 48px; display: block; margin: 0 auto 0.5rem; }
  .result-logo-pdf-sub {
    font-family: 'Playfair Display', serif; font-size: 1rem;
    letter-spacing: 0.1em; color: #8B6914;
  }
}

/* Clase para captura html2pdf con tema claro */
.afinia-pdf {
  --bg:     #ffffff;
  --bg2:    #f8f6f4;
  --bg3:    #ede9e4;
  --gold:   #8B6914;
  --gold2:  #7A5A10;
  --text:   #111111;
  --muted:  #555555;
  --border: #d0ccc8;
  --danger: #cc3333;
  background: #ffffff !important;
  color: #111111 !important;
}
.afinia-pdf .result-actions,
.afinia-pdf #guardar-fb { display: none !important; }

/* ── ESTADOS ── */
.screen-wait { text-align: center; padding: 4rem 1rem; }
.screen-wait .wait-code {
  font-family: 'Playfair Display', serif;
  font-size: 2.5rem; color: var(--gold); letter-spacing: 0.15em; margin: 1rem 0;
}
.spinner {
  width: 36px; height: 36px; border: 3px solid var(--border);
  border-top-color: var(--gold); border-radius: 50%;
  animation: spin 1s linear infinite; margin: 1.5rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.alert {
  background: rgba(201,169,110,0.08); border: 1px solid rgba(201,169,110,0.2);
  border-radius: 8px; padding: 1rem 1.25rem;
  font-size: 0.88rem; color: var(--text); margin-bottom: 1.25rem;
}

/* ── RESPONSIVE ── */
@media (max-width: 480px) {
  #app { padding: 68px 1rem 4rem; }
  #app.with-stepnav { padding-top: 108px; }
  .modo-cards { grid-template-columns: 1fr; }
  .como-funciona { grid-template-columns: 1fr; }
  .indices-row { grid-template-columns: 1fr; }
  .fortalezas-grid { grid-template-columns: 1fr; }
  .scale-btns { gap: 0.25rem; }
  .scale-btn { height: 36px; font-size: 0.83rem; }
  .share-code { font-size: 1.5rem; }
  .step-lbl { display: none; }
  .step-item { padding: 0.28rem 0.5rem; }
}

@media (max-width: 360px) {
  .af-bar-wrap { display: none; }
}
