/* =====================================================================
   Academia Protecom — estilos base (mobile-first)
   Marca: azul #022C82 · cian #069DBF · naranja #C55A11
          fondo suave #E6F4F8 · gris texto #4D4D4D
   ===================================================================== */
:root {
  --azul:      #022C82;
  --cian:      #069DBF;
  --naranja:   #C55A11;
  --fondo:     #E6F4F8;
  --texto:     #4D4D4D;
  --blanco:    #ffffff;
  --rojo:      #c0392b;
  --verde:     #2e7d32;
  --amarillo:  #c9a227;
  --gris:      #9aa0a6;
  --borde:     #d5e6ec;
  --sombra:    0 2px 10px rgba(2, 44, 130, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Roboto', Arial, sans-serif;
  color: var(--texto);
  background: var(--fondo);
  line-height: 1.5;
}
h1, h2, h3 { color: var(--azul); font-weight: 700; margin: 0 0 .5rem; }
a { color: var(--cian); }

/* ── Botones ──────────────────────────────────────────────────────── */
.btn {
  display: inline-block; border: 0; border-radius: 8px;
  padding: .7rem 1.2rem; font-size: 1rem; font-weight: 500;
  cursor: pointer; text-decoration: none; text-align: center;
}
.btn-primario { background: var(--azul); color: var(--blanco); }
.btn-primario:hover { background: #03399f; }
.btn-accion   { background: var(--naranja); color: var(--blanco); }
.btn-plano    { background: transparent; color: var(--azul); }
.btn-salir {
  background: rgba(255,255,255,.15); color: var(--blanco);
  padding: .4rem .9rem; border-radius: 6px; text-decoration: none; font-size: .9rem;
}
.btn-salir:hover { background: rgba(255,255,255,.28); }

/* ── Pantallas de autenticación ───────────────────────────────────── */
body.auth {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 1.5rem;
  background: linear-gradient(135deg, var(--azul), var(--cian));
}
.auth-card {
  background: var(--blanco); border-radius: 14px; box-shadow: var(--sombra);
  width: 100%; max-width: 400px; padding: 2rem;
}
.auth-logo { text-align: center; margin-bottom: 1.2rem; }
.auth-logo img { max-height: 64px; margin-bottom: .5rem; }
.auth-logo h1 { font-size: 1.25rem; margin: 0; }
.auth-titulo { text-align: center; font-size: 1.1rem; margin-bottom: 1rem; }
.auth-pie { text-align: center; color: var(--gris); font-size: .8rem; margin-top: 1.2rem; }

form label { display: block; margin-bottom: 1rem; font-size: .9rem; font-weight: 500; }
form input {
  display: block; width: 100%; margin-top: .35rem;
  padding: .65rem .8rem; font-size: 1rem;
  border: 1px solid var(--borde); border-radius: 8px; background: #fbfdfe;
}
form input:focus { outline: 2px solid var(--cian); border-color: var(--cian); }
form .btn { width: 100%; margin-top: .3rem; }
form .btn-plano { width: auto; display: block; margin: .6rem auto 0; }

/* ── Alertas y flashes ────────────────────────────────────────────── */
.alerta { padding: .7rem .9rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; }
.alerta-error { background: #fde8e6; color: var(--rojo); border: 1px solid #f5c6c0; }
.alerta-aviso { background: #fff4e6; color: var(--naranja); border: 1px solid #ffd8a8; }
.flash { padding: .7rem 1rem; margin: 0 auto; max-width: 960px; border-radius: 8px; margin-top: 1rem; }
.flash-exito { background: #e6f4ea; color: var(--verde); border: 1px solid #b7dfc2; }
.flash-error { background: #fde8e6; color: var(--rojo);  border: 1px solid #f5c6c0; }

/* ── Layout con sesión ────────────────────────────────────────────── */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--azul); color: var(--blanco); padding: .7rem 1.2rem;
}
.topbar-marca { display: flex; align-items: center; gap: .6rem; font-weight: 700; }
.topbar-marca img { max-height: 34px; }
.topbar-usuario { display: flex; align-items: center; gap: .8rem; }
.usuario-nombre { font-weight: 500; }
.usuario-rol { font-size: .8rem; opacity: .8; }
.contenido { max-width: 960px; margin: 1.5rem auto; padding: 0 1.2rem; }

.tarjeta { background: var(--blanco); border-radius: 12px; box-shadow: var(--sombra); padding: 1.5rem; }
.nota { color: var(--gris); font-size: .85rem; margin-top: 1rem; }

/* ── Semáforo del Índice de Seguridad (para fases posteriores) ────── */
.sem { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 500; color: #fff; }
.sem-rojo     { background: var(--rojo); }
.sem-naranja  { background: var(--naranja); }
.sem-amarillo { background: var(--amarillo); }
.sem-verde    { background: var(--verde); }
.sem-gris     { background: var(--gris); }

/* ── Layout con nav lateral (sección admin) ───────────────────────── */
.layout { display: flex; gap: 0; align-items: flex-start; }
.lateral {
  width: 210px; flex: 0 0 210px; background: var(--blanco);
  min-height: calc(100vh - 56px); padding: 1rem .6rem; box-shadow: var(--sombra);
}
.lateral a {
  display: block; padding: .6rem .8rem; margin-bottom: .2rem; border-radius: 8px;
  color: var(--texto); text-decoration: none; font-size: .92rem;
}
.lateral a:hover { background: var(--fondo); }
.lateral a.activo { background: var(--azul); color: #fff; font-weight: 500; }
.panel.con-nav .contenido { max-width: none; flex: 1; margin: 1.2rem; }

/* ── Cabeceras de sección y barras ────────────────────────────────── */
.cabecera-seccion { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .6rem; margin-bottom: 1rem; }
.cabecera-seccion h1 { margin: 0; }
.barra-busqueda { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.barra-busqueda input, .barra-busqueda select { padding: .5rem .7rem; border: 1px solid var(--borde); border-radius: 8px; background: #fbfdfe; }

/* ── KPIs ─────────────────────────────────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; }
.kpi { background: var(--blanco); border-radius: 12px; box-shadow: var(--sombra); padding: 1.2rem; text-align: center; text-decoration: none; color: var(--texto); }
.kpi:hover { outline: 2px solid var(--cian); }
.kpi-num { display: block; font-size: 2rem; font-weight: 700; color: var(--azul); }
.kpi-lbl { display: block; font-size: .85rem; color: var(--texto); margin-top: .2rem; }

/* ── Tablas ───────────────────────────────────────────────────────── */
.tabla-wrap { overflow-x: auto; }
.tabla { width: 100%; border-collapse: collapse; background: var(--blanco); border-radius: 12px; overflow: hidden; box-shadow: var(--sombra); }
.tabla th, .tabla td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid var(--borde); vertical-align: middle; }
.tabla thead th { background: #f2f9fc; color: var(--azul); font-size: .85rem; }
.tabla tbody tr:hover { background: #f8fcfe; }
.acciones { white-space: nowrap; display: flex; gap: .3rem; align-items: center; }
.btn-sm { padding: .35rem .7rem; font-size: .82rem; }

/* ── Chips / estados ──────────────────────────────────────────────── */
.chip { display: inline-block; padding: .12rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 500; color: #fff; }
.chip-verde { background: var(--verde); }
.chip-rojo  { background: var(--rojo); }
.chip-gris  { background: var(--gris); }

/* ── Formularios en grilla ────────────────────────────────────────── */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 1rem; }
form textarea { width: 100%; margin-top: .35rem; padding: .6rem .8rem; border: 1px solid var(--borde); border-radius: 8px; background: #fbfdfe; font-family: inherit; font-size: .95rem; }
form select { width: 100%; margin-top: .35rem; padding: .6rem .8rem; border: 1px solid var(--borde); border-radius: 8px; background: #fbfdfe; }
.panel .btn { width: auto; }

/* ── Curso detalle ────────────────────────────────────────────────── */
.datos-curso { display: flex; gap: 1.2rem; flex-wrap: wrap; margin-bottom: .8rem; font-size: .9rem; }
.acciones-estado { display: flex; gap: .5rem; flex-wrap: wrap; }
.modulo-cab { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; flex-wrap: wrap; }
.modulo .lecciones { list-style: none; padding: 0; margin: .5rem 0 0; }
.modulo .lecciones li { display: flex; align-items: center; gap: .5rem; padding: .4rem 0; border-top: 1px solid var(--borde); }
.modulo .lecciones li .acciones { margin-left: auto; }
.tipo-lec { font-size: .78rem; padding: .1rem .5rem; border-radius: 6px; background: var(--fondo); color: var(--azul); }
details.editar-modulo summary, details summary { cursor: pointer; display: inline-block; }
details[open] > form { margin-top: .8rem; }

/* ── Banco de preguntas ───────────────────────────────────────────── */
.pregunta.retirada { opacity: .6; }
.pregunta-cab { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .5rem; }
.pregunta-cab .acciones { margin-left: auto; }
.enunciado { font-weight: 500; }
.opciones { list-style: none; padding: 0; margin: .5rem 0 0; }
.opciones li { padding: .35rem .6rem; border-radius: 6px; margin-bottom: .25rem; background: #f7fafb; }
.opciones li.correcta { background: #e6f4ea; border: 1px solid #b7dfc2; }
.marca-ok { color: var(--verde); font-size: .8rem; margin-left: .4rem; }
.opcion-form { display: block; margin-bottom: .8rem; }
.opcion-letra { display: block; font-size: .85rem; margin-bottom: .2rem; }

/* ── Matriz ───────────────────────────────────────────────────────── */
.matriz th.curso-cel { background: #f2f9fc; }
.celda-matriz { text-align: center; min-width: 150px; }
.celda-matriz.on  { background: #eefaf0; }
.celda-matriz.off { background: #fbf1f0; }
.switch { border: 0; border-radius: 999px; padding: .35rem .8rem; font-size: .8rem; font-weight: 500; cursor: pointer; color: #fff; }
.switch-on  { background: var(--verde); }
.switch-off { background: var(--gris); }
.cupos-form { margin-top: .5rem; display: flex; gap: .4rem; align-items: center; justify-content: center; }
.cupos-form .mini { font-size: .72rem; }
.cupos-form input { width: 64px; padding: .25rem .4rem; }
.ocupacion { font-size: .75rem; color: var(--texto); }

/* ── Inscripciones / empleados (empresa) ──────────────────────────── */
.cursos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.curso-card h3 { margin-bottom: .4rem; }
.ocupacion-card { font-size: .9rem; margin: .6rem 0; }
.lista-check { max-height: 320px; overflow-y: auto; border: 1px solid var(--borde); border-radius: 8px; padding: .6rem .8rem; margin-bottom: .8rem; }
.check-item, .check-todos { display: block; padding: .3rem 0; }
.check-todos { border-bottom: 1px solid var(--borde); margin-bottom: .3rem; font-weight: 500; }
.ejemplo-csv { background: #f2f9fc; padding: .8rem; border-radius: 8px; overflow-x: auto; font-size: .85rem; }
.panel form input[type="file"] { display: block; margin-top: .35rem; }

/* ── Auditoría (badges por categoría) ─────────────────────────────── */
.badge { display:inline-block; padding:.12rem .55rem; border-radius:6px; font-size:.76rem; font-weight:500; color:#fff; white-space:nowrap; }
.badge-cian   { background: var(--cian); }
.badge-azul   { background: var(--azul); }
.badge-naranja{ background: var(--naranja); }
.badge-rojo   { background: var(--rojo); }
.badge-gris   { background: var(--gris); }
.barra-busqueda .mini { font-size:.78rem; display:flex; align-items:center; gap:.3rem; }

/* ── Índice de Seguridad ──────────────────────────────────────────── */
.indice-curso { display:flex; gap:1rem; flex-wrap:wrap; margin:.6rem 0 1rem; }
.ival { flex:1 1 140px; text-align:center; background:#f7fbfd; border:1px solid var(--borde); border-radius:10px; padding:.7rem; }
.ival-lbl { display:block; font-size:.8rem; color:var(--texto); margin-bottom:.35rem; }
.ival .sem { font-size:1.1rem; padding:.25rem .8rem; }
.ival-total { background:#eef6ff; }

/* ── Verificación pública ─────────────────────────────────────────── */
.verif-estado { text-align: center; padding: .8rem; border-radius: 10px; font-weight: 700; font-size: 1.05rem; }
.verif-ok { background: #e6f4ea; color: #2e7d32; border: 1px solid #b7dfc2; }
.verif-vencido { background: #fff4e6; color: #C55A11; border: 1px solid #ffd8a8; }

/* ── Examen ───────────────────────────────────────────────────────── */
.examen-cab { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .3rem; flex-wrap: wrap; }
.timer { font-size: 1.4rem; font-weight: 700; color: var(--azul); background: #fff; padding: .2rem .8rem; border-radius: 8px; box-shadow: var(--sombra); font-variant-numeric: tabular-nums; }
.timer-rojo { color: #fff; background: var(--rojo); animation: pulso 1s infinite; }
@keyframes pulso { 50% { opacity: .6; } }
.examen-pregunta .enunciado { font-size: 1.1rem; margin-bottom: 1rem; }
.opciones-examen { display: grid; gap: .6rem; margin-bottom: 1.2rem; }
.opcion-examen { display: flex; align-items: center; gap: .7rem; padding: .8rem 1rem; border: 2px solid var(--borde); border-radius: 10px; cursor: pointer; }
.opcion-examen:hover { border-color: var(--cian); background: #f7fcfd; }
.opcion-examen input { width: 20px; height: 20px; }
.opcion-examen input:checked ~ .op-letra { background: var(--azul); color: #fff; }
.op-letra { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--fondo); color: var(--azul); font-weight: 700; flex: 0 0 auto; }
.op-texto { flex: 1; }

/* ── Aula del empleado ────────────────────────────────────────────── */
.contenido-aula { max-width: 820px; }
.contenido-aula:has(.aula-layout) { max-width: 1060px; }

/* Dos columnas: cursos + panel de progreso */
.aula-layout { display: flex; gap: 1.2rem; align-items: flex-start; }
.aula-main { flex: 1; min-width: 0; }
.aula-side { width: 290px; flex: 0 0 290px; position: sticky; top: 1rem; }
.progreso-panel h3 { margin-bottom: .5rem; }
.progreso-lista { list-style: none; padding: 0; margin: 0; }
.progreso-lista li {
  display: grid; grid-template-columns: 1fr auto; grid-template-areas: "nombre iconos" "barra pct";
  gap: .2rem .5rem; align-items: center; padding: .55rem 0; border-top: 1px solid var(--borde);
}
.progreso-lista li:first-child { border-top: 0; }
.prog-nombre { grid-area: nombre; font-weight: 600; color: var(--azul); text-decoration: none; }
.prog-iconos { grid-area: iconos; font-size: 1.1rem; white-space: nowrap; letter-spacing: .1rem; }
.barra-mini { grid-area: barra; height: 6px; margin: 0; align-self: center; }
.prog-pct { grid-area: pct; font-size: .8rem; color: var(--texto); text-align: right; font-variant-numeric: tabular-nums; }
.logro { margin-left: .25rem; }

@media (max-width: 760px) {
  .aula-layout { flex-direction: column; }
  .aula-side { width: 100%; flex-basis: auto; position: static; }
}
.barra { height: 10px; background: #dcecf2; border-radius: 999px; overflow: hidden; margin: .3rem 0 .6rem; }
.barra-in { height: 100%; background: var(--cian); border-radius: 999px; transition: width .3s; }
.curso-link { display: block; text-decoration: none; color: var(--texto); }
.curso-link:hover { outline: 2px solid var(--cian); }
.temario { border: 0; }
.temario li { display: flex; align-items: center; gap: .6rem; padding: .55rem 0; border-top: 1px solid var(--borde); }
.temario li:first-child { border-top: 0; }
.lec-icono { width: 1.4rem; text-align: center; }
.lec-titulo { text-decoration: none; color: var(--azul); font-weight: 500; }
.lec-titulo.bloq { color: var(--gris); font-weight: 400; }
.lec-hecha .lec-icono { color: var(--verde); }
.lec-actual { background: #f2fbfd; border-radius: 8px; }
.lec-bloqueada { opacity: .65; }

.video-wrap { position: relative; width: 100%; padding-top: 56.25%; border-radius: 10px; overflow: hidden; background: #000; }
.video-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.leccion-cont { margin-bottom: 1rem; }
.lectura { line-height: 1.7; }
.lectura h2, .lectura h3 { margin-top: 1.2rem; }
.lectura img { max-width: 100%; height: auto; border-radius: 8px; }
.lectura table { border-collapse: collapse; width: 100%; }
.lectura th, .lectura td { border: 1px solid var(--borde); padding: .5rem; }
.acciones-leccion { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.acciones-leccion form { display: flex; align-items: center; gap: .6rem; }

@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .lateral { width: 100%; flex-basis: auto; min-height: 0; display: flex; flex-wrap: wrap; gap: .3rem; }
  .lateral a { flex: 1 1 auto; text-align: center; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .topbar { flex-direction: column; gap: .5rem; align-items: flex-start; }
  .usuario-rol { display: none; }
}

/* ── Lecturas: destacados, citas de fuente y tablas ──────────────────
   El sanitizador de lecciones elimina el atributo class, así que estos
   estilos se aplican por ETIQUETA (blockquote, em, thead) y no por clase. */
.lectura h3 { color: var(--azul); }
.lectura h4 { color: var(--cian); margin-top: 1.1rem; margin-bottom: .3rem; }
.lectura blockquote {
  margin: 1rem 0; padding: .75rem 1rem;
  border-left: 4px solid var(--cian); background: var(--fondo);
  border-radius: 0 8px 8px 0;
}
.lectura blockquote p { margin: 0; }
/* Un párrafo compuesto SOLO por <em> es una cita de fuente: pequeña y discreta. */
.lectura p > em:only-child { display: block; font-size: .85rem; color: var(--gris); line-height: 1.5; }
.lectura thead th { background: var(--fondo); color: var(--azul); text-align: left; }
.lectura table { margin: .8rem 0; }
.lectura hr { border: 0; border-top: 1px solid var(--borde); margin: 1.5rem 0; }
