/* ============================================================
   Sistema de cuestionarios — hoja de estilos unica.
   Paleta heredada del diseno original: verde profundo sobre papel.
   ============================================================ */

:root {
  /* La app tiene una paleta clara deliberada: le decimos al navegador
     que no aplique su modo oscuro automatico, que apagaba los verdes. */
  color-scheme: light;

  --paper:        #F4F6F4;
  --surface:      #FFFFFF;
  --ink:          #101B19;
  --ink-soft:     #4A5A57;
  --ink-faint:    #7A8985;
  --primary:      #145C52;
  --primary-light:#1C7A6C;
  --primary-dark: #0C3E38;
  --primary-wash: #E4EEEB;
  --accent:       #D98E04;
  --accent-wash:  #FBF0DA;
  --danger:       #B33A3A;
  --danger-wash:  #F7E6E6;
  --line:         #DBDFD8;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

html { background: var(--paper); color: var(--ink); }

body {
  margin: 0;
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.2; margin: 0; }
h1 { font-size: 1.75rem; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.02rem; }
p { margin: 0; }

a { color: var(--primary); text-underline-offset: 3px; }
a:hover { color: var(--primary-light); }

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

/* ---------- Estructura ---------- */

.shell { max-width: 720px; margin: 0 auto; padding: 2.5rem 1.25rem 5rem; }
.shell-wide { max-width: 1080px; }

.stack     { display: flex; flex-direction: column; gap: 1rem; }
.stack-sm  { display: flex; flex-direction: column; gap: 0.55rem; }
.stack-lg  { display: flex; flex-direction: column; gap: 1.75rem; }
.row       { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.row-between { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; }
.grow      { flex: 1 1 auto; }
.right     { margin-left: auto; }

/* ---------- Barra superior del admin ---------- */

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 0.7rem 1.25rem;
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
}
.brand { font-family: var(--display); font-weight: 600; font-size: 1.05rem; color: var(--ink); text-decoration: none; }
.brand span { color: var(--ink-faint); font-weight: 500; }
.topnav { display: flex; gap: 1.1rem; flex-wrap: wrap; }
.topnav a { color: var(--ink-soft); text-decoration: none; font-size: 0.9rem; font-weight: 500; }
.topnav a:hover { color: var(--primary); }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; font-size: 0.85rem; color: var(--ink-faint); }

/* ---------- Tarjetas ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}
.card-tight { padding: 1.1rem 1.25rem; }
.card + .card { margin-top: 1rem; }

.page-head { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1.5rem; }
.page-head .sub { color: var(--ink-faint); font-size: 0.92rem; }

.eyebrow {
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--primary);
}

/* ---------- Formularios ---------- */

.label {
  display: block; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-soft); margin-bottom: 0.3rem;
}
.input, .select, .textarea {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-md); padding: 0.55rem 0.7rem;
}
.textarea { min-height: 7rem; resize: vertical; line-height: 1.55; }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary);
}
.input-sm { padding: 0.35rem 0.5rem; font-size: 0.9rem; }
.hint { font-size: 0.82rem; color: var(--ink-faint); }
.field-error { font-size: 0.85rem; color: var(--danger); }

/* ---------- Botones ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  font: inherit; font-size: 0.9rem; font-weight: 500;
  padding: 0.5rem 1rem; border-radius: var(--radius-md);
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover:not(:disabled) { background: var(--paper); color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #963030; color: #fff; }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { color: var(--primary); border-color: var(--primary); }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.82rem; }
.btn-block { width: 100%; }

/* ---------- Avisos ---------- */

.alert {
  border-radius: var(--radius-md); padding: 0.7rem 0.95rem;
  font-size: 0.92rem; margin-bottom: 1.25rem; border: 1px solid;
}
.alert-ok    { background: var(--primary-wash); border-color: #BBD6D0; color: var(--primary-dark); }
.alert-error { background: var(--danger-wash);  border-color: #E4BDBD; color: #8E2C2C; }
.alert-warn  { background: var(--accent-wash);  border-color: #EBD4A0; color: #8A5C05; }

/* ---------- Chips ---------- */

.chip {
  display: inline-block; font-size: 0.74rem; font-weight: 600;
  padding: 0.15rem 0.55rem; border-radius: 999px; border: 1px solid; white-space: nowrap;
}
.chip-ok      { background: var(--primary-wash); border-color: #BBD6D0; color: var(--primary-dark); }
.chip-warn    { background: var(--accent-wash);  border-color: #EBD4A0; color: #8A5C05; }
.chip-neutral { background: var(--paper);        border-color: var(--line); color: var(--ink-soft); }
.chip-danger  { background: var(--danger-wash);  border-color: #E4BDBD; color: #8E2C2C; }

/* ---------- Tablas ---------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
table { border-collapse: collapse; width: 100%; min-width: 640px; }
th, td { text-align: left; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th {
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--ink-faint); background: var(--paper);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #FAFBFA; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-empty { padding: 2.5rem 1rem; text-align: center; color: var(--ink-faint); }

/* ---------- Barra de umbral (firma del diseno) ---------- */

.threshold {
  position: relative; height: 10px; width: 100%;
  background: rgba(219, 223, 216, 0.7); border-radius: 999px; overflow: hidden;
}
.threshold-fill { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: var(--primary); }
.threshold-fill.is-fail { background: var(--danger); }
.threshold-mark { position: absolute; top: 50%; width: 2px; height: 16px; transform: translateY(-50%); background: rgba(16, 27, 25, 0.7); }

/* ---------- Progreso del cuestionario ---------- */

.progress-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: 0.45rem; }
.progress-head .step { font-family: var(--display); font-weight: 600; font-size: 0.95rem; }
.progress-head .meta { font-size: 0.8rem; color: var(--ink-faint); }
.progress { height: 6px; background: rgba(219, 223, 216, 0.7); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 999px; transition: width 0.3s; }

/* ---------- Pregunta ---------- */

.question-body { font-family: var(--display); font-size: 1.3rem; font-weight: 600; line-height: 1.35; text-wrap: balance; }

.option {
  display: flex; align-items: flex-start; gap: 0.7rem;
  border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 0.75rem 0.9rem; cursor: pointer; background: var(--surface);
  transition: border-color 0.15s, background-color 0.15s;
}
.option:hover { border-color: var(--primary-light); }
.option input { margin: 0.28rem 0 0; accent-color: var(--primary); flex: 0 0 auto; }
.option.is-selected { border-color: var(--primary); background: var(--primary-wash); }
.option-correct { margin-left: auto; font-size: 0.72rem; font-weight: 600; color: var(--primary); white-space: nowrap; }

.question-chip {
  display: inline-flex; align-items: center; justify-content: center;
  height: 34px; width: 34px; flex: 0 0 auto; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  font-family: var(--display); font-weight: 600; font-size: 0.85rem;
}
.question-chip.is-done { background: var(--primary); border-color: var(--primary); color: #fff; }
.question-chip.is-marked { border-color: var(--accent); color: #8A5C05; background: var(--accent-wash); }

.nav-buttons { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }

/* ---------- Panel: metricas ---------- */

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1.1rem 1.25rem; }
.metric .value { font-family: var(--display); font-size: 1.9rem; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.metric .label-plain { font-size: 0.8rem; color: var(--ink-faint); margin-top: 0.35rem; }

/* ---------- Bloque de respuesta en la calificacion ---------- */

.answer-block { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); padding: 1.15rem 1.25rem; }
.answer-block + .answer-block { margin-top: 0.85rem; }
.answer-text {
  white-space: pre-wrap; background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius-md); padding: 0.75rem 0.9rem; font-size: 0.94rem; color: var(--ink-soft);
}
.score-input { display: flex; align-items: center; gap: 0.5rem; }
.score-input .input { width: 5.5rem; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Modal de bloqueo ---------- */

.overlay {
  position: fixed; inset: 0; background: rgba(16, 27, 25, 0.55);
  display: flex; align-items: center; justify-content: center; padding: 1.25rem; z-index: 50;
}
.modal { background: var(--surface); border-radius: var(--radius-lg); padding: 1.75rem; max-width: 26rem; width: 100%; }

/* ---------- Opciones editables (admin) ---------- */

.option-row { display: flex; gap: 0.6rem; align-items: center; }
.option-row .input { flex: 1 1 auto; }
.option-row label { display: flex; align-items: center; gap: 0.35rem; font-size: 0.85rem; color: var(--ink-soft); white-space: nowrap; }
.option-row input[type="radio"] { accent-color: var(--primary); }

.divider { height: 1px; background: var(--line); border: 0; margin: 0; }

.text-danger { color: var(--danger); }
.text-muted  { color: var(--ink-faint); }
.text-sm     { font-size: 0.87rem; }
.mono        { font-variant-numeric: tabular-nums; }

@media (max-width: 560px) {
  .shell { padding: 1.5rem 1rem 4rem; }
  .card { padding: 1.15rem; }
  h1 { font-size: 1.45rem; }
  .question-body { font-size: 1.15rem; }
}
