/*
 * Estilos de la entrevista y del panel de administración. Solo modo claro, sin fuentes ni recursos externos.
 * Se diseña para 360 px de ancho (celular) y se amplía; los botones y opciones miden al menos 48 px de alto.
 */

/* ---------- Colores y medidas ---------- */
:root {
  --amarillo: #F8CC03;
  --gris: #3C4343;
  --gris-claro: #6b7373;
  --linea: #d9dcdc;
  --borde-campo: #858d8d;
  --fondo: #ffffff;
  --fondo-suave: #fbf8e8;
  --error: #b3261e;
  --ok: #1f7a3d;
  --radio: 12px;
  --sombra: 0 1px 3px rgba(60, 67, 67, .18), 0 6px 18px rgba(60, 67, 67, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.5;
  color: var(--gris);
  background: #f4f5f5;
}

h1 { margin: 0 0 12px; font-size: 1.75rem; line-height: 1.2; }
h2 { margin: 24px 0 8px; font-size: 1.15rem; }
h3 { margin: 0 0 8px; font-size: 1.15rem; }
p { margin: 0 0 12px; }
a { color: var(--gris); }

:focus-visible { outline: 3px solid var(--gris); outline-offset: 2px; }

.visualmente-oculto { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.saltar { position: absolute; left: -999px; top: 8px; background: var(--amarillo); padding: 8px 12px; border-radius: 8px; z-index: 50; }
.saltar:focus { left: 8px; }

/* ---------- Encabezado ---------- */
.marca { background: #fff; border-bottom: 6px solid var(--amarillo); padding: 8px 16px; }
.logo img { display: block; height: 44px; width: auto; max-width: 70vw; }

/* ---------- Estructura de la entrevista ---------- */
.contenido { max-width: 640px; margin: 0 auto; padding: 16px 16px 24px; }
.contenido:focus { outline: none; }
.tarjeta { background: #fff; border-radius: 16px; padding: 20px 16px; box-shadow: var(--sombra); }
.cargando { color: var(--gris-claro); }
.etiqueta { margin: 0 0 4px; font-size: .85rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--gris-claro); }
.ayuda, .ayuda-paso { font-size: .95rem; color: var(--gris-claro); margin: -2px 0 8px; }
.ayuda-paso { margin: 0 0 16px; }
.aviso-paso:empty { display: none; }
.aviso-paso { background: #fdecea; color: var(--error); padding: 10px 12px; border-radius: 10px; font-weight: 600; }
.nota-final { margin-top: 20px; padding: 12px; background: var(--fondo-suave); border-radius: 10px; }
.aviso-noscript { max-width: 640px; margin: 16px auto; padding: 0 16px; font-weight: 700; }

/* Progreso */
.progreso { max-width: 640px; margin: 0 auto; padding: 12px 16px 0; }
.progreso-texto { margin: 0 0 6px; font-size: .95rem; font-weight: 600; }
.progreso-barra { height: 10px; background: var(--linea); border-radius: 999px; overflow: hidden; }
.progreso-relleno { height: 100%; background: var(--amarillo); border-right: 2px solid var(--gris); transition: width .15s ease; }
.avance-1 { width: 14.29%; } .avance-2 { width: 28.57%; } .avance-3 { width: 42.86%; } .avance-4 { width: 57.14%; }
.avance-5 { width: 71.43%; } .avance-6 { width: 85.71%; } .avance-7 { width: 100%; }

/* Bienvenida */
.bienvenida .tiempo { margin: 8px 0 16px; }
.privacidad { background: var(--fondo-suave); border-left: 6px solid var(--amarillo); border-radius: 8px; padding: 12px 14px; margin: 16px 0 20px; }
.privacidad h2 { margin: 0 0 6px; font-size: 1.05rem; }
.privacidad p:last-child { margin-bottom: 0; }

/* Botones */
.boton {
  display: inline-block; min-height: 52px; padding: 12px 20px; font: inherit; font-weight: 700; text-align: center; text-decoration: none;
  color: var(--gris); background: var(--amarillo); border: 2px solid var(--gris); border-radius: 10px; cursor: pointer;
  transition: background .15s ease;
}
.boton:hover { background: #e9be00; }
.boton.secundario { background: #fff; }
.boton.secundario:hover { background: var(--fondo-suave); }
.boton.peligro { background: #fff; color: var(--error); border-color: var(--error); }
.boton[disabled] { opacity: .55; cursor: not-allowed; }
.enlace { background: none; border: 0; padding: 12px 8px; min-height: 48px; font: inherit; color: var(--gris); text-decoration: underline; cursor: pointer; }
.bienvenida .boton { width: 100%; }

/* Barra de acciones pegada abajo */
.barra-accion { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: #fff; border-top: 1px solid var(--linea); padding: 10px 16px; }
.barra-in { max-width: 640px; margin: 0 auto; display: flex; gap: 12px; }
.barra-in .boton { flex: 1; }
.barra-in .secundario { flex: 0 0 34%; }

/* Pie: enlace para continuar y estado del guardado */
.pie { max-width: 640px; margin: 0 auto; padding: 8px 16px 110px; font-size: .95rem; }
.estado-guardado { margin: 8px 0 0; color: var(--gris-claro); min-height: 1.5em; }
.estado-guardado.sin_conexion, .estado-guardado.limite, .estado-guardado.error { color: var(--error); font-weight: 600; }
.enlace-continuar summary { cursor: pointer; min-height: 48px; display: flex; align-items: center; font-weight: 600; }
.enlace-caja { margin: 4px 0 8px; }
.estado-copia { margin-left: 8px; color: var(--ok); font-weight: 600; }

/* ---------- Preguntas ---------- */
.campo { margin: 0 0 22px; padding: 0; border: 0; min-width: 0; }
.campo[hidden] { display: none; }
label, legend { display: block; padding: 0; font-weight: 600; margin-bottom: 6px; }
.num { font-weight: 700; color: var(--gris-claro); }
.opcional { font-weight: 400; color: var(--gris-claro); }

input[type="text"], input[type="search"], textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; font: inherit; color: var(--gris); background: #fff;
  border: 2px solid var(--borde-campo); border-radius: 10px;
}
textarea { min-height: 110px; line-height: 1.45; resize: vertical; }
input[type="text"]:focus, input[type="search"]:focus, textarea:focus { border-color: var(--gris); box-shadow: 0 0 0 4px rgba(248, 204, 3, .55); outline: none; }
.campo.invalido input[type="text"], .campo.invalido textarea { border-color: var(--error); }

.error { margin: 6px 0 0; font-size: .95rem; font-weight: 600; color: var(--error); }
.error:empty { display: none; }

/* Opciones como tarjetas grandes (radio y casillas) */
.opciones { display: grid; gap: 10px; }
.opcion { position: relative; display: block; margin: 0; font-weight: 400; cursor: pointer; }
.opcion input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.opcion span {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 10px 14px; background: #fff;
  border: 2px solid var(--borde-campo); border-radius: var(--radio); transition: background .15s ease, border-color .15s ease;
}
.opcion span::before { content: ""; flex: none; width: 22px; height: 22px; border: 2px solid var(--borde-campo); border-radius: 50%; background: #fff; }
.opcion input[type="checkbox"] + span::before { border-radius: 6px; }
.opcion input:checked + span { background: var(--fondo-suave); border-color: var(--gris); box-shadow: inset 0 0 0 1px var(--gris); }
.opcion input[type="radio"]:checked + span::before { border-color: var(--gris); background: var(--gris); box-shadow: inset 0 0 0 4px #fff; }
.opcion input[type="checkbox"]:checked + span::before { content: "✓"; display: grid; place-items: center; color: #fff; font-weight: 800; border-color: var(--gris); background: var(--gris); }
.opcion input:focus-visible + span { outline: 3px solid var(--gris); outline-offset: 2px; }
.campo.invalido .opcion span { border-color: var(--error); }
.otra-texto { margin-top: 10px; }
.otra-texto[hidden] { display: none; }

/* Escala 1 a 5 */
.escala { display: flex; gap: 8px; }
.opcion-escala { position: relative; flex: 1; margin: 0; font-weight: 700; cursor: pointer; }
.opcion-escala input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.opcion-escala span {
  display: grid; place-items: center; min-height: 52px; background: #fff; border: 2px solid var(--borde-campo); border-radius: var(--radio);
  transition: background .15s ease;
}
.opcion-escala input:checked + span { background: var(--amarillo); border-color: var(--gris); box-shadow: inset 0 0 0 1px var(--gris); }
.opcion-escala input:focus-visible + span { outline: 3px solid var(--gris); outline-offset: 2px; }
.campo.invalido .opcion-escala span { border-color: var(--error); }
.escala-etiquetas { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; font-size: .9rem; color: var(--gris-claro); }

/* ---------- Buscador de actividades ---------- */
.selector { margin-top: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.chip {
  min-height: 48px; padding: 8px 16px; font: inherit; color: var(--gris); background: #fff; border: 2px solid var(--borde-campo);
  border-radius: 999px; cursor: pointer; transition: background .15s ease;
}
.chip.activo { background: var(--amarillo); border-color: var(--gris); font-weight: 700; }
.selector-estado { color: var(--gris-claro); }
.selector-estado:empty { display: none; }
details.familia { background: #fff; border: 1px solid var(--linea); border-radius: var(--radio); margin: 8px 0; }
details.familia summary { min-height: 48px; padding: 12px 14px; font-weight: 700; cursor: pointer; display: flex; align-items: center; }
details.familia .cuenta { font-weight: 400; color: var(--gris-claro); margin-left: 6px; }
details.familia ul { list-style: none; margin: 0; padding: 0 10px 10px; }
details.familia li { margin: 6px 0; }
.actividad-op {
  display: block; width: 100%; min-height: 48px; padding: 10px 12px; text-align: left; font: inherit; color: var(--gris);
  background: #fff; border: 1px solid var(--borde-campo); border-radius: 10px; cursor: pointer; transition: background .15s ease;
}
.actividad-op:hover { background: var(--fondo-suave); }
.actividad-op.elegida { background: var(--fondo-suave); border: 2px solid var(--gris); font-weight: 700; }
.actividad-op.bloqueada { opacity: .6; cursor: not-allowed; background: #f4f5f5; }
.actividad-op.otra { margin-top: 12px; border-style: dashed; font-weight: 700; }
.nota-op { font-size: .9rem; color: var(--gris-claro); font-weight: 400; }

/* ---------- Tarjetas de actividad ---------- */
.tarjeta-actividad { background: #fff; border: 2px solid var(--linea); border-radius: 14px; padding: 16px; margin: 0 0 16px; transition: border-color .15s ease; }
.tarjeta-actividad.abierta { border-color: var(--gris); }
.tarjeta-actividad.resumida { background: var(--fondo-suave); border-left: 8px solid var(--amarillo); }
.tarjeta-actividad h3:focus { outline: none; }
.meta { color: var(--gris-claro); font-size: .95rem; }
.acciones { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.confirmar { margin-top: 8px; }
.confirmar .boton { margin: 0 8px 8px 0; }
.actividad-elegida { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 0 0 16px; padding: 8px 12px; background: var(--fondo-suave); border-radius: 10px; }
.estimado { margin: -10px 0 22px; padding: 10px 12px; background: var(--fondo-suave); border-radius: 10px; font-weight: 700; }
.estimado:empty { display: none; }
.copiar { margin-bottom: 16px; }
.aviso-copia { padding: 10px 12px; background: var(--fondo-suave); border-left: 6px solid var(--amarillo); border-radius: 8px; }
.copiar-lista { list-style: none; margin: 0; padding: 0; }
.copiar-lista li { margin: 6px 0; }
.etiqueta-campo { margin: 0 0 6px; font-weight: 600; }
.pie-actividades .boton { width: 100%; }

/* ---------- Porcentajes y 5.1 ---------- */
.rejilla-porcentajes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 12px; }
.campo-pct { margin-bottom: 12px; }
.campo-pct label { font-size: .95rem; }
.pct-entrada { display: flex; align-items: center; gap: 6px; }
.pct-entrada input { max-width: 96px; text-align: right; }
.pct-signo { font-weight: 700; }
.suma { margin: 8px 0 12px; padding: 10px 12px; border-radius: 10px; font-weight: 700; background: var(--fondo-suave); }
.suma.ok { background: #e4f4e9; color: var(--ok); }
.suma.sobra { background: #fdecea; color: var(--error); }
.contador { font-weight: 600; }
.contador.aviso-tope { color: var(--error); }
.elegidas { list-style: none; margin: 0 0 12px; padding: 0; }
.elegidas li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 4px 4px 12px; margin: 6px 0; background: var(--fondo-suave); border-radius: 10px; }
.sugeridas { margin-bottom: 12px; }
.sugeridas .chip { margin: 0 8px 8px 0; text-align: left; }

/* ---------- Resumen y pantalla final ---------- */
.resumen-seccion { border-top: 2px solid var(--linea); padding: 8px 0 12px; }
.resumen-cabecera { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.resumen-cabecera h2 { margin: 8px 0; }
.resumen-seccion dl { margin: 0; }
.resumen-seccion dt { margin-top: 10px; font-weight: 600; font-size: .95rem; }
.resumen-seccion dd { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.aviso-correccion, .tiempo-llenado { padding: 10px 12px; background: var(--fondo-suave); border-radius: 10px; }
.gracias { border-left: 8px solid var(--amarillo); }
.gracias-texto { font-size: 1.15rem; }
.enlace-largo { overflow-wrap: anywhere; }
.folio { color: var(--gris-claro); font-size: .95rem; }
.cerrado { border-left: 8px solid var(--gris); }

/* ---------- Panel de administración ---------- */
.admin main.ancho { max-width: 1100px; margin: 0 auto; padding: 24px 16px 40px; }
.tarjetas { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 16px 0; }
.tarjetas div { background: var(--fondo-suave); border-left: 6px solid var(--amarillo); padding: 14px 16px; border-radius: 8px; }
.tarjetas strong { display: block; font-size: 2rem; line-height: 1.1; }
.nota { font-size: .95rem; color: var(--gris-claro); }
.tabla { overflow-x: auto; }
.admin table { border-collapse: collapse; width: 100%; font-size: .9rem; background: #fff; }
.admin th, .admin td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--linea); vertical-align: top; }
.admin th { background: var(--gris); color: #fff; white-space: nowrap; }
tr.prueba td { opacity: .55; }
.repetido { display: inline-block; margin-left: 6px; padding: 1px 8px; font-size: .8rem; font-weight: 700; background: #fff3cd; border-radius: 999px; }
.aviso { background: var(--fondo-suave); border-left: 6px solid var(--amarillo); padding: 12px 14px; border-radius: 8px; margin: 16px 0; }
.aviso.urgente { background: #fdecea; border-left-color: var(--error); }
.boton.urgente { background: var(--error); color: #fff; border-color: var(--error); }
.guia { background: #fff; border: 2px solid var(--linea); border-radius: 12px; padding: 4px 16px 12px; margin: 16px 0; }
.guia.destacada { border-color: var(--gris); background: var(--fondo-suave); box-shadow: var(--sombra); }
.admin .boton { margin: 0 8px 8px 0; }

/* ---------- Pantallas más anchas ---------- */
@media (min-width: 700px) {
  .tarjeta { padding: 28px 32px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
