/* ============================================
   CDS — Estilo amigable (inspirado en mockups)
   ============================================ */

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

:root {
  --teal-900: #1f5f5b;
  --teal-700: #2c8378;
  --teal-500: #3aa494;
  --teal-300: #7ec8b9;
  --mint-100: #d8f0e8;
  --bg-100:   #eef3f3;
  --bg-200:   #e2eceb;
  --text-900: #1c2a2a;
  --text-700: #4a5d5d;
  --text-500: #7d8c8c;
  --white:    #ffffff;
  --shadow-lg: 0 25px 50px -12px rgba(28, 90, 80, 0.25);
  --shadow-md: 0 10px 30px -10px rgba(28, 90, 80, 0.2);
  --radius-lg: 28px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

html, body {
  height: 100%;
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-900);
  background: linear-gradient(135deg, #f0f5f4 0%, #e2eceb 50%, #d8f0e8 100%);
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  align-items: safe center; /* en pantallas largas no recorta el contenido por arriba */
  justify-content: center;
  padding: 32px 24px;
  position: relative;
}

/* Manchas decorativas de fondo */
.bg-shape {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.45;
  z-index: 0;
  pointer-events: none;
}
.shape-1 { width: 400px; height: 400px; background: var(--teal-300); top: -100px; left: -100px; }
.shape-2 { width: 350px; height: 350px; background: #c4e4dc; bottom: -100px; right: -100px; }
.shape-3 { width: 250px; height: 250px; background: #b4dbd0; top: 50%; left: 60%; }

.container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1100px;
}

/* ============================================
   Card y pantallas
   ============================================ */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.card:not(.card-single) { min-height: 580px; }

.card.card-single { grid-template-columns: 1fr; max-width: 820px; margin: 0 auto; }

.screen { display: none; animation: fadeIn 0.5s ease; }
.screen.active { display: grid; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Lado izquierdo decorativo (welcome) */
.card-left {
  position: relative;
  background: linear-gradient(160deg, #a8dccc 0%, #6cb5a3 50%, #2c8378 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.card-left::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 20% 80%, rgba(255,255,255,0.2) 0%, transparent 30%),
    radial-gradient(circle at 80% 20%, rgba(255,255,255,0.15) 0%, transparent 40%);
}
.welcome-text {
  position: relative;
  text-align: center;
  color: var(--white);
  padding: 40px;
}
.welcome-text h2 {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 4px;
  margin-bottom: 14px;
}
.welcome-text p {
  font-size: 16px;
  font-weight: 300;
  opacity: 0.95;
  line-height: 1.6;
}

/* Lado derecho (formularios) */
.card-right {
  padding: 48px 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* En pantallas con mucho contenido (resultados) no centrar verticalmente */
.card-single .card-right { justify-content: flex-start; padding: 44px 44px; }

.step-tag {
  display: inline-block;
  background: var(--mint-100);
  color: var(--teal-700);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 16px;
  letter-spacing: 0.5px;
}

/* Botón flecha de regreso */
.btn-back {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  color: var(--teal-700);
  border: 1.5px solid #d4e2e0;
  border-radius: 999px;
  padding: 8px 16px 8px 12px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 18px;
}
.btn-back:hover {
  background: var(--mint-100);
  border-color: var(--teal-500);
  transform: translateX(-3px);
}
.btn-back svg { transition: transform 0.2s; }
.btn-back:hover svg { transform: translateX(-2px); }

h1 {
  font-size: 32px;
  font-weight: 600;
  color: var(--text-900);
  margin-bottom: 8px;
}

h3.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-900);
  margin: 28px 0 14px;
}

.subtitle {
  font-size: 15px;
  color: var(--text-500);
  margin-bottom: 28px;
}

.footnote {
  font-size: 12px;
  color: var(--text-500);
  margin-top: 16px;
}

/* ============================================
   Forms
   ============================================ */
.form { display: flex; flex-direction: column; gap: 18px; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; }

.hidden { display: none !important; }

.section-divider {
  font-size: 11px;
  font-weight: 600;
  color: var(--teal-700);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 8px 0 4px;
  padding-bottom: 6px;
  border-bottom: 1px dashed #d4e2e0;
}

/* Selector de tipo (Niño / Adulto) */
.type-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 22px;
}
.type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 12px;
  background: #f6faf9;
  border: 2px solid #e0e7e6;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.18s;
  text-align: center;
}
.type-card:hover { border-color: var(--teal-500); transform: translateY(-2px); }
.type-card.active {
  border-color: var(--teal-500);
  background: linear-gradient(135deg, #d8f0e8, #b8e0d4);
  box-shadow: 0 8px 20px -8px rgba(58, 164, 148, 0.5);
}
.type-card .type-emoji { font-size: 32px; }
.type-card .type-title { font-weight: 600; color: var(--text-900); font-size: 14px; }
.type-card .type-desc { font-size: 11px; color: var(--text-500); }

/* Pantalla "lo lograste" / "gracias" */
.big-emoji {
  font-size: 80px;
  line-height: 1;
  margin-bottom: 12px;
  animation: pop 0.6s ease;
}
@keyframes pop {
  0%   { transform: scale(0.3); opacity: 0; }
  60%  { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}
.finish-text {
  font-size: 16px;
  color: var(--text-700);
  line-height: 1.7;
  margin-bottom: 12px;
}

.field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-700);
}

.field input, .field select {
  padding: 14px 18px;
  border: 1.5px solid #e0e7e6;
  border-radius: 999px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-900);
  background: var(--white);
  outline: none;
  transition: all 0.2s;
}

.field input:focus, .field select:focus {
  border-color: var(--teal-500);
  box-shadow: 0 0 0 4px rgba(58, 164, 148, 0.15);
}

/* ============================================
   Botones
   ============================================ */
.btn-primary {
  margin-top: 8px;
  padding: 14px 28px;
  background: linear-gradient(135deg, var(--teal-500), var(--teal-700));
  color: var(--white);
  border: none;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.25s;
  box-shadow: var(--shadow-md);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 15px 35px -10px rgba(58, 164, 148, 0.5);
}
.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  padding: 14px 28px;
  background: transparent;
  color: var(--teal-700);
  border: 1.5px solid #d4e2e0;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:hover:not(:disabled) {
  background: var(--mint-100);
  border-color: var(--teal-500);
}
.btn-secondary:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============================================
   Instrucciones
   ============================================ */
.instructions-text {
  font-size: 15px;
  color: var(--text-700);
  line-height: 1.7;
  margin-bottom: 22px;
}

.legend {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 8px;
}
.legend li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #f6faf9;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-700);
}
.legend strong { color: var(--text-900); margin-right: 6px; }

.dot {
  width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0;
}
.dot-5 { background: #2c8378; }
.dot-4 { background: #5fb3a4; }
.dot-3 { background: #a8c8c4; }
.dot-2 { background: #d4a574; }
.dot-1 { background: #c97a6b; }

/* ============================================
   Cuestionario
   ============================================ */
.progress-row { margin-bottom: 24px; }

.progress-bar {
  margin-top: 8px;
  height: 6px;
  background: #e6efee;
  border-radius: 999px;
  overflow: hidden;
}
#progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal-500), var(--teal-700));
  width: 0%;
  border-radius: 999px;
  transition: width 0.4s ease;
}

.question-text {
  font-size: 22px;
  font-weight: 500;
  color: var(--text-900);
  line-height: 1.5;
  margin: 16px 0 28px;
  min-height: 70px;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 28px;
}

.option {
  padding: 16px 22px;
  border: 1.5px solid #e0e7e6;
  border-radius: var(--radius-md);
  background: var(--white);
  cursor: pointer;
  transition: all 0.18s;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 15px;
  color: var(--text-700);
  user-select: none;
}
.option:hover {
  border-color: var(--teal-500);
  background: #f6faf9;
  transform: translateX(2px);
}
.option.selected {
  border-color: var(--teal-500);
  background: linear-gradient(135deg, #d8f0e8, #b8e0d4);
  color: var(--text-900);
  font-weight: 500;
  box-shadow: 0 4px 12px -4px rgba(58, 164, 148, 0.4);
}
.option .radio {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid #c4d3d1;
  flex-shrink: 0;
  display: grid; place-items: center;
  transition: all 0.2s;
}
.option.selected .radio {
  border-color: var(--teal-700);
  background: var(--teal-700);
}
.option.selected .radio::after {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--white);
}

.nav-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}
.nav-row .btn-primary, .nav-row .btn-secondary { margin-top: 0; flex: 1; max-width: 200px; }

/* ============================================
   Resultados
   ============================================ */
.result-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 18px 0 8px;
}

.result-pill {
  padding: 22px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--white);
}
.pill-td { background: linear-gradient(135deg, #c97a6b, #a85a4d); }
.pill-tp { background: linear-gradient(135deg, var(--teal-500), var(--teal-700)); }

.pill-label { font-size: 12px; font-weight: 500; opacity: 0.9; }
.pill-value { font-size: 32px; font-weight: 700; }
.pill-extra { font-size: 13px; opacity: 0.95; }

.subscales {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.sub-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #f6faf9;
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.sub-item .name { color: var(--text-700); font-weight: 500; }
.sub-item .score { color: var(--text-900); font-weight: 600; }
.sub-item .pc { color: var(--teal-700); font-size: 12px; margin-left: 6px; }

.interpretation {
  margin-top: 24px;
  padding: 18px;
  background: #fff8f0;
  border-radius: var(--radius-md);
  border-left: 4px solid #e0a878;
  font-size: 14px;
  color: var(--text-700);
  line-height: 1.6;
}

/* Bloque didáctico: cómo se obtuvo el resultado */
.calc-explainer {
  margin-top: 24px;
  padding: 20px 22px;
  background: #f6faf9;
  border-radius: var(--radius-md);
  border: 1px solid #e1ece9;
  font-size: 13.5px;
  color: var(--text-700);
  line-height: 1.65;
}
.calc-explainer h3 { color: var(--teal-700); font-size: 15px; margin-bottom: 10px; }
.calc-explainer ol { margin: 8px 0 0 18px; }
.calc-explainer ol li { margin-bottom: 6px; }
.calc-explainer .formula {
  display: inline-block;
  background: #fff;
  border: 1px solid #d8e6e3;
  border-radius: 6px;
  padding: 2px 8px;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 12.5px;
  color: var(--teal-700);
  margin: 0 2px;
}
.calc-explainer .scale-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}
.calc-explainer .scale-row > div {
  background: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  border: 1px solid #e1ece9;
}
.calc-explainer .scale-row strong { color: var(--text-900); display: block; margin-bottom: 4px; font-size: 13px; }
.calc-explainer .scale-row small { font-size: 12px; color: var(--text-500); }
@media (max-width: 600px) {
  .calc-explainer .scale-row { grid-template-columns: 1fr; }
}

/* === Detalle paso a paso del cálculo === */
.calc-detail { margin-top: 12px; }

.calc-step {
  margin-top: 18px;
  padding: 14px 16px;
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e1ece9;
}
.calc-step h4 {
  font-size: 14px;
  color: var(--teal-700);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.calc-step .step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--teal-500);
  color: var(--white);
  font-size: 12px;
  font-weight: 700;
}
.calc-step .step-desc { font-size: 12.5px; color: var(--text-700); margin: 6px 0; line-height: 1.55; }
.calc-step .step-list { font-size: 12.5px; color: var(--text-700); line-height: 1.55; padding-left: 22px; margin: 6px 0; }
.calc-step .step-list li { margin: 4px 0; }

.baremo-extra {
  margin-top: 14px;
  padding: 12px;
  background: var(--mint-100);
  border: 1px dashed var(--teal-500);
  border-radius: 8px;
}
.baremo-extra h5 {
  margin: 0 0 6px 0;
  font-size: 13px;
  color: var(--teal-700);
}

.note-box {
  margin-top: 14px;
  padding: 12px 14px;
  background: #fff8e6;
  border: 1px solid #f0c674;
  border-left: 4px solid #d99a2b;
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--text-700);
  line-height: 1.55;
}
.note-box p { margin: 0; }
.note-box code {
  background: #fff;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11.5px;
  color: var(--text-900);
}

.mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  margin: 8px 0;
}
.mini-table th, .mini-table td {
  padding: 7px 9px;
  border-bottom: 1px solid #eef4f3;
  text-align: left;
}
.mini-table th { background: #f6faf9; color: var(--teal-700); font-weight: 600; font-size: 11.5px; }
.mini-table td.num { text-align: center; font-variant-numeric: tabular-nums; }
.mini-table tfoot td { background: #f6faf9; }
.mini-table tr.row-total td { background: #fff8f0; font-weight: 600; }

.pts {
  display: inline-block;
  min-width: 26px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
}
.pts.dep { background: #fde2dc; color: #a85a4d; }
.pts.pos { background: #d8f0e8; color: var(--teal-700); }

.sub-detail {
  margin: 8px 0;
  border: 1px solid #e1ece9;
  border-radius: 10px;
  overflow: hidden;
  background: #fafdfc;
}
.sub-detail summary {
  cursor: pointer;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  list-style: none;
  user-select: none;
}
.sub-detail summary::-webkit-details-marker { display: none; }
.sub-detail summary::before {
  content: '▶';
  font-size: 9px;
  color: var(--teal-500);
  transition: transform 0.2s;
}
.sub-detail[open] summary::before { transform: rotate(90deg); }
.sub-detail summary:hover { background: #f0f7f5; }
.sub-tag-type {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.sub-tag-type.dep { background: #fde2dc; color: #a85a4d; }
.sub-tag-type.pos { background: #d8f0e8; color: var(--teal-700); }
.sub-pd {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-700);
  font-weight: 600;
}
.sub-detail[open] .calc-sub-table { padding: 0 14px 12px; }
.calc-sub-table { width: calc(100% - 28px); margin: 0 14px 8px; }
.calc-sub-table .reactivo { font-size: 12px; color: var(--text-700); }
.sub-detail[open] > p { margin: 0 14px 12px; }

@media (max-width: 600px) {
  .mini-table { font-size: 11.5px; }
  .mini-table th, .mini-table td { padding: 5px 6px; }
  .calc-sub-table .reactivo { font-size: 11px; }
  .sub-detail summary { font-size: 12px; flex-wrap: wrap; }
  .sub-pd { margin-left: 0; }
}

/* ============================================
   Responsive
   ============================================ */

/* Pantallas medianas (laptops 13"-14", ~1366x768) */
@media (max-width: 1200px) {
  .container { max-width: 960px; }
  .card-right { padding: 40px 40px; }
  .card-single .card-right { padding: 36px 36px; }
  h1 { font-size: 26px; }
  .welcome-text h2 { font-size: 32px; letter-spacing: 6px; }
  .pill-value { font-size: 28px; }
  .question-text { font-size: 19px; }
}

/* Tablet / laptop pequeño */
@media (max-width: 980px) {
  body { padding: 16px 12px; }
  .container { max-width: 720px; }
  .card { grid-template-columns: 1fr; min-height: auto; }
  .card-left { min-height: 180px; }
  .card-left .welcome-text { padding: 28px; }
  .welcome-text h2 { font-size: 28px; letter-spacing: 4px; }
  .welcome-text p { font-size: 14px; }
  .card-right { padding: 32px 28px; }
  .card-single .card-right { padding: 28px 24px; }
  .row { grid-template-columns: 1fr; }
  .result-summary { grid-template-columns: 1fr 1fr; gap: 10px; }
  .subscales { grid-template-columns: 1fr 1fr; }
}

/* Móviles */
@media (max-width: 600px) {
  body { padding: 8px 6px; }
  .card { border-radius: 20px; }
  .card-left { display: none; }
  .card-right { padding: 24px 18px; }
  .card-single .card-right { padding: 22px 16px; }
  h1 { font-size: 22px; }
  .subtitle { font-size: 14px; }
  .step-tag { font-size: 11px; padding: 5px 10px; }

  /* Selector de tipo de respondiente: en móvil 1 columna */
  .type-selector { grid-template-columns: 1fr !important; gap: 10px; }
  .type-card { padding: 14px 16px !important; }
  .type-emoji { font-size: 32px !important; }

  /* Pregunta y opciones */
  .question-text { font-size: 17px; line-height: 1.4; }
  .option { padding: 12px 14px; font-size: 14px; }
  .nav-row { flex-direction: column; }
  .nav-row .btn-primary, .nav-row .btn-secondary { max-width: 100%; }

  /* Resultados */
  .result-summary { grid-template-columns: 1fr; }
  .subscales { grid-template-columns: 1fr; }
  .pill-value { font-size: 26px; }
  .sub-item { padding: 10px 14px; font-size: 13px; }
  .interpretation, .calc-explainer { padding: 14px; font-size: 13px; }
  .calc-explainer h3 { font-size: 14px; }
  .calc-explainer ol { padding-left: 18px; }
  .calc-explainer .formula { display: inline-block; margin: 2px 0; }
  .finished-screen .big-emoji { font-size: 60px; }

  /* Inputs táctiles */
  input, select, button { font-size: 16px; }  /* evita zoom auto en iOS */
}

@media (max-width: 380px) {
  .card-right { padding: 20px 14px; }
  h1 { font-size: 20px; }
  .welcome-text h2 { font-size: 22px; letter-spacing: 2px; }
}
