:root {
  /* Teal de marca (decorativo / texto grande): barra de progreso, anillos de foco, sombras. */
  --brand: #1A92B2;
  --brand-hover: #157A95;
  /* Teal de relleno ACCESIBLE (≥4.5:1 sobre blanco) para superficies con texto blanco
     y para teal sobre fondo blanco (títulos, enlaces). #0F6E86 = 5.84:1 (WCAG AA). */
  --primary: #0F6E86;
  --primary-hover: #0C5468;
  /* Ámbar secundario — SIEMPRE con texto oscuro (blanco sobre ámbar = 1.88:1). */
  --secondary: #F2B062;
  --secondary-hover: #E59A45;
  --bg: #f5f3f7;
  --card: #ffffff;
  --text: #2b2b2b;
  --muted: #6c757d;
  --border: #e0dce6;
  --error: #c62828;
  --success: #2e7d32;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.container { max-width: 880px; margin: 0 auto; padding: 0 16px; }

/* Header / footer */
.site-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #fff;
  padding: 28px 0;
  box-shadow: 0 4px 14px rgba(15, 110, 134, 0.25);
}
.site-title { margin: 0; font-size: 1.6rem; }
.site-subtitle { margin: 6px 0 0; opacity: 0.92; font-size: 0.98rem; }
.site-footer { text-align: center; padding: 28px 16px; color: var(--muted); font-size: 0.9rem; }
.site-footer a { color: var(--primary); }

main.container { padding-top: 24px; padding-bottom: 40px; }
.intro { color: var(--muted); }
.muted { color: var(--muted); }
.center { text-align: center; }

/* Progress + nav */
.progress { position: sticky; top: 0; height: 8px; background: #e2e8ea; border-radius: 6px; margin: 8px 0 14px; z-index: 20; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--brand), var(--primary)); border-radius: 6px; transition: width .3s ease; }
.section-nav { position: sticky; top: 14px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 8px; margin-bottom: 20px; z-index: 19; }
.section-nav ul { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; }
.section-nav a { display: inline-block; padding: 5px 10px; border-radius: 6px; font-size: 0.85rem; color: var(--text); text-decoration: none; }
.section-nav a:hover, .section-nav a.active { background: var(--primary); color: #fff; }

/* Cards / sections */
.form-section, .card, .detail-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.04);
}
.card.narrow { max-width: 420px; margin: 30px auto; }
.card.center { text-align: center; }
.section-title { color: var(--primary); border-bottom: 2px solid var(--primary); padding-bottom: 8px; margin-top: 0; font-size: 1.15rem; }

/* Fields */
.field { margin-bottom: 18px; }
label { display: block; font-weight: 500; margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: #fff;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,146,178,0.25); }
textarea { resize: vertical; }
fieldset { border: none; padding: 0; margin: 0; }
legend { font-weight: 500; margin-bottom: 8px; padding: 0; }
.req-mark { color: var(--error); }

/* Rating — escala 1→5 (izquierda→derecha). Números y leyenda comparten el MISMO
   trazado en grid para que las etiquetas queden bajo el primer y el último número.
   Parametrizado por --rating-cols (5 por defecto; la tarea 09 podrá poner 6 para "N/P"). */
.rating,
.rating-legend {
  display: grid;
  grid-template-columns: repeat(var(--rating-cols, 5), 44px);
  gap: 8px;
  width: max-content;
}
.rating input { position: absolute; opacity: 0; width: 0; height: 0; }
.rating label {
  cursor: pointer; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  background: #e9eef0; border: 2px solid transparent; border-radius: 8px; font-weight: 700; color: var(--muted); margin: 0;
}
/* Selección ÚNICA: resalta solo el botón elegido (input:checked + label, hermano
   adyacente) y el que está bajo el cursor. Sin el combinador `~` de "relleno". */
.rating label:hover,
.rating input:checked + label { background: var(--primary); color: #fff; }
.rating input:focus-visible + label { box-shadow: 0 0 0 3px rgba(26,146,178,0.45); }
.rating-legend { margin-top: 6px; font-size: 0.8rem; color: var(--muted); line-height: 1.2; }
.rating-legend span:first-child { grid-column: 1 / 3; text-align: left; }
.rating-legend span:last-child { grid-column: -3 / -1; text-align: right; }

/* Choice (radio) */
.choice-group .opt { display: inline-flex; align-items: center; gap: 6px; margin-right: 16px; font-weight: 400; }
.choice-group .opt input { width: auto; }
.consent { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.consent input { width: auto; margin-top: 4px; }

/* Errors / alerts */
.has-error input, .has-error textarea { border-color: var(--error); }
.error-text { color: var(--error); font-size: 0.85rem; margin: 6px 0 0; }
.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; }
.alert-error { background: #fdecea; color: var(--error); border: 1px solid #f5c6cb; }

/* Buttons */
.actions { margin-top: 18px; }
.btn-primary, .btn-secondary {
  display: inline-block; padding: 11px 24px; border: none; border-radius: 8px; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--secondary); color: var(--text); }
.btn-secondary:hover { background: var(--secondary-hover); }
.btn-link { background: none; border: none; color: var(--primary); cursor: pointer; font: inherit; text-decoration: underline; }

/* Wizard (mejora progresiva: estos estilos solo aplican cuando el JS construye los
   controles; sin JS se ve el formulario completo con el botón "Enviar"). */
.wizard-step-indicator { font-weight: 600; color: var(--muted); margin: 0 0 12px; }
.wizard-controls { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 22px; }
.wizard-controls .btn-secondary { margin-right: auto; }
.wizard-hidden { display: none !important; }

/* Success */
.success-icon { width: 64px; height: 64px; line-height: 64px; margin: 0 auto 12px; border-radius: 50%; background: var(--success); color: #fff; font-size: 2rem; }

/* Admin */
.admin-bar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.admin-actions { display: flex; gap: 10px; align-items: center; }
.inline { display: inline; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: linear-gradient(135deg, var(--primary), var(--primary-hover)); color: #fff; border-radius: 12px; padding: 18px; text-align: center; }
.stat-num { display: block; font-size: 1.8rem; font-weight: 700; }
.stat-label { font-size: 0.85rem; opacity: 0.92; }
.filter { margin-bottom: 16px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filter select { width: auto; min-width: 220px; }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--border); border-radius: 12px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th, .data-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table thead th { background: var(--primary); color: #fff; position: sticky; top: 0; }
.detail-list { margin: 0; }
.detail-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.detail-row dt { font-weight: 500; color: var(--muted); margin: 0; }
.detail-row dd { margin: 0; }

/* Rating con N/P: 6ª columna para el botón "N/P". Clase (no style inline: la CSP
   es style-src 'self', que bloquea inline styles). */
.rating--np, .rating-legend--np { --rating-cols: 6; }
.np-btn { font-size: 0.8rem; }

/* Resultados agregados por pregunta (task 11) */
.result-section { margin-bottom: 22px; }
.result-section h3 { margin-bottom: 2px; }
.result-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.result-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.result-label { font-weight: 500; }
.result-meta { color: var(--muted); font-size: 0.9rem; white-space: nowrap; }
.dist { display: grid; gap: 4px; }
.dist-row { display: grid; grid-template-columns: minmax(3rem, 9rem) 1fr auto; gap: 10px; align-items: center; font-size: 0.85rem; }
.dist-key { color: var(--muted); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dist-val { color: var(--muted); white-space: nowrap; }
/* Barra de distribución con <progress>: el relleno lo da value/max (no CSS inline). */
progress.bar { -webkit-appearance: none; -moz-appearance: none; appearance: none; width: 100%; height: 14px; border: none; border-radius: 7px; background: #e9eef0; overflow: hidden; }
progress.bar::-webkit-progress-bar { background: #e9eef0; border-radius: 7px; }
progress.bar::-webkit-progress-value { background: var(--primary); border-radius: 7px; }
progress.bar::-moz-progress-bar { background: var(--primary); border-radius: 7px; }
progress.bar.np-bar::-webkit-progress-value { background: var(--secondary); }
progress.bar.np-bar::-moz-progress-bar { background: var(--secondary); }

@media (max-width: 640px) {
  /* Centra el bloque de rating; números y leyenda comparten ancho, así que centrar
     ambos los mantiene alineados entre sí. */
  .rating, .rating-legend { margin-left: auto; margin-right: auto; }
  .detail-row { grid-template-columns: 1fr; gap: 2px; }
}
