/* ==========================================================
   Base compartida (modo usuario y modo administrador)
   Idea visual: la hoja de respuestas óptica del examen.
   Azul de burbuja, amarillo de marcador, papel claro.
   ========================================================== */

:root {
  --ink: #17203d;
  --ink-2: #4a5472;
  --ink-3: #7b84a0;
  --paper: #f6f7fb;
  --card: #ffffff;
  --line: #e2e5ef;
  --line-2: #cfd4e4;

  --brand: #3347d6;
  --brand-d: #2536ad;
  --brand-soft: #e8ebfc;
  --mark: #ffd23f;
  --mark-soft: #fff4c7;

  --ok: #14805a;
  --ok-soft: #dff3ea;
  --warn: #8f5b00;
  --warn-soft: #fff0cf;
  --bad: #b73535;
  --bad-soft: #fbe4e4;

  --r-s: 8px;
  --r-m: 12px;
  --r-l: 18px;
  --shadow-1: 0 1px 2px rgba(23, 32, 61, .06), 0 4px 14px rgba(23, 32, 61, .05);
  --shadow-2: 0 10px 40px rgba(23, 32, 61, .16);

  --font-head: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "Figtree", "Segoe UI", system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.12; margin: 0; letter-spacing: -.015em; }
p { margin: 0; }
a { color: var(--brand); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 44px; padding: 0 1.25rem;
  border: 1.5px solid transparent; border-radius: var(--r-m);
  font-weight: 650; font-size: .97rem; text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s, transform .08s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 2px 0 var(--brand-d); }
.btn-primary:hover { background: var(--brand-d); }
.btn-ghost { background: transparent; border-color: var(--line-2); color: var(--ink); }
.btn-ghost:hover { background: #fff; border-color: var(--ink-3); }
.btn-danger { background: transparent; border-color: #e6b9b9; color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-sm { min-height: 36px; padding: 0 .9rem; font-size: .9rem; border-radius: var(--r-s); }
.btn-block { width: 100%; }
.btn .spin {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Formularios ---------- */
.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field > label, .field > .label { font-weight: 600; font-size: .93rem; }
.field .hint { font-size: .84rem; color: var(--ink-3); }
.field .err { font-size: .86rem; color: var(--bad); font-weight: 600; min-height: 0; }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: .6rem .85rem;
  background: #fff; border: 1.5px solid var(--line-2); border-radius: var(--r-m);
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { min-height: 96px; resize: vertical; }
.input:hover { border-color: var(--ink-3); }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.field.invalid .input { border-color: var(--bad); box-shadow: 0 0 0 4px var(--bad-soft); }

/* ---------- Insignias de estado ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .2rem .65rem .2rem .5rem; border-radius: 999px;
  font-size: .84rem; font-weight: 650; white-space: nowrap;
}
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge-pendiente { background: var(--warn-soft); color: var(--warn); }
.badge-confirmada { background: var(--ok-soft); color: var(--ok); }
.badge-observada { background: var(--bad-soft); color: var(--bad); }

/* ---------- Avisos (toast) ---------- */
.toasts {
  position: fixed; z-index: 100; right: 1rem; bottom: 1rem;
  display: flex; flex-direction: column; gap: .6rem; max-width: min(92vw, 380px);
}
.toast {
  display: flex; gap: .7rem; align-items: flex-start;
  background: var(--ink); color: #fff; padding: .85rem 1rem;
  border-radius: var(--r-m); box-shadow: var(--shadow-2); font-size: .95rem;
  animation: toast-in .25s ease-out;
}
.toast.ok { background: #0f5f44; }
.toast.error { background: #8d2626; }
.toast.out { opacity: 0; transform: translateY(8px); transition: .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Burbuja de hoja óptica ---------- */
.bubble {
  display: inline-block; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--line-2); background: transparent;
}
.bubble.filled { background: var(--ink); border-color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- Botón de WhatsApp ---------- */
.btn-wa { background: #137a45; color: #fff; box-shadow: 0 2px 0 #0d5a32; }
.btn-wa:hover { background: #0f6a3b; }
.btn-wa svg { flex: none; }

/* ---------- Estados de curso ---------- */
.badge-abierto { background: var(--ok-soft); color: var(--ok); }
.badge-cerrado { background: var(--warn-soft); color: var(--warn); }
.badge-finalizado { background: #e9ebf3; color: var(--ink-2); }

/* ---------- Botón de advertencia y etiquetas (chips) ---------- */
.btn-warn { background: var(--mark); color: var(--ink); box-shadow: 0 2px 0 #c9a21d; }
.btn-warn:hover { background: #f5c52a; }
.chip { display: inline-flex; align-items: center; padding: .15rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 650; white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.done { background: var(--brand-soft); color: var(--brand-d); }

/* ---------- Pantallas táctiles ---------- */
@media (pointer: coarse) {
  .btn { min-height: 46px; }
  .btn-sm { min-height: 42px; }
  .input, select.input { min-height: 48px; }
}

/* ---------- Celulares ---------- */
@media (max-width: 620px) {
  body { font-size: 16px; }
  .toasts { left: .8rem; right: .8rem; bottom: max(.8rem, env(safe-area-inset-bottom)); max-width: none; }
  .btn { padding: 0 1.1rem; }
}

.app-version { font-size: .75rem; color: var(--ink-3); font-weight: 600; }
.side .app-version { display: block; text-align: center; color: #8e98c0; }

/* ---------- Menú desplegable (tres puntos) ---------- */
.ctx-menu {
  position: fixed; z-index: 70; min-width: 180px; padding: .35rem;
  background: #fff; border: 1px solid var(--line-2); border-radius: var(--r-m); box-shadow: var(--shadow-2);
  animation: ctx-in .12s ease-out;
}
@keyframes ctx-in { from { opacity: 0; transform: translateY(-4px); } }
.ctx-item {
  display: flex; align-items: center; gap: .65rem; width: 100%; min-height: 44px; padding: 0 .8rem;
  border: 0; border-radius: var(--r-s); background: transparent; color: var(--ink);
  font-weight: 600; font-size: .95rem; text-align: left; cursor: pointer;
}
.ctx-item:hover, .ctx-item:focus-visible { background: var(--paper); outline: none; }
.ctx-item.danger { color: var(--bad); }
.ctx-item.danger:hover, .ctx-item.danger:focus-visible { background: var(--bad-soft); }
.ctx-item svg { flex: none; }

.spin.dark { display: inline-block; width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid rgba(23,32,61,.2); border-top-color: var(--ink); animation: spin .7s linear infinite; }
