/* ============================================================
   IActuo - estilos simples, sin librerias externas
   ============================================================ */
:root {
    --fondo: #f4f6fa;
    --superficie: #ffffff;
    --texto: #1f2933;
    --texto-suave: #616e7c;
    --borde: #d9dee5;
    --primario: #2457d6;
    --primario-oscuro: #1a43a8;
    --exito: #1e7e46;
    --exito-fondo: #e3f5ea;
    --error: #b42318;
    --error-fondo: #fdecea;
    --radio: 10px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --fondo: #12161c;
        --superficie: #1c222b;
        --texto: #e6e9ee;
        --texto-suave: #9aa5b1;
        --borde: #333c48;
        --primario: #5b8cff;
        --primario-oscuro: #3f73f0;
        --exito: #6fd39a;
        --exito-fondo: #173524;
        --error: #ff8a80;
        --error-fondo: #3a1d1b;
    }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    background: var(--fondo);
    color: var(--texto);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main { flex: 1; padding-top: 24px; padding-bottom: 40px; }

a { color: var(--primario); }

h1, h2, h3 { line-height: 1.25; margin: 0 0 12px; }

.contenedor { width: 100%; max-width: 960px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }

.texto-suave { color: var(--texto-suave); }

/* ---------- Barra superior y menu ---------- */
.barra { background: var(--superficie); border-bottom: 1px solid var(--borde); }
.barra-interior { display: flex; align-items: center; justify-content: space-between; min-height: 60px; flex-wrap: wrap; }
.marca { font-weight: 700; font-size: 1.2rem; text-decoration: none; color: var(--texto); }

.menu { display: flex; align-items: center; gap: 4px; }
.menu a, .enlace-salir {
    padding: 8px 12px; border-radius: 8px; text-decoration: none;
    color: var(--texto); font: inherit; background: none; border: 0; cursor: pointer;
}
.menu a:hover, .enlace-salir:hover { background: var(--fondo); }
.menu a.activo { color: var(--primario); font-weight: 600; }
.form-salir { margin: 0; }

.menu-toggle, .menu-boton { display: none; }

@media (max-width: 640px) {
    .menu-boton { display: block; font-size: 1.5rem; cursor: pointer; padding: 4px 8px; }
    .menu { display: none; width: 100%; flex-direction: column; align-items: stretch; padding-bottom: 12px; }
    .menu a, .enlace-salir { text-align: left; width: 100%; }
    .menu-toggle:checked ~ .menu { display: flex; }
}

/* ---------- Tarjetas ---------- */
.tarjeta {
    background: var(--superficie);
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    padding: 24px;
    margin-bottom: 20px;
}

.tarjeta-login { max-width: 400px; margin: 8vh auto 0; }
.tarjeta-login h1 { text-align: center; }
.tarjeta-login > .texto-suave { text-align: center; margin-top: 0; }

/* ---------- Formularios ---------- */
label { display: block; font-weight: 600; margin: 14px 0 6px; }

input[type="text"], input[type="email"], input[type="password"], textarea, select {
    width: 100%; padding: 10px 12px; font: inherit; color: var(--texto);
    background: var(--superficie); border: 1px solid var(--borde); border-radius: 8px;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--primario); outline-offset: 1px; border-color: var(--primario); }
select:disabled { opacity: .6; }
.ayuda { font-size: 0.85rem; margin: 4px 0 0; }

/* Campo de contrasena con boton "ojito" */
.campo-password { position: relative; }
.campo-password input { padding-right: 44px; }
.ver-password {
    position: absolute; top: 50%; right: 4px; transform: translateY(-50%);
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; padding: 0;
    background: none; border: 0; border-radius: 6px; color: var(--texto-suave); cursor: pointer;
}
.ver-password:hover { color: var(--texto); }
.ver-password:focus-visible { outline: 2px solid var(--primario); }
.ver-password svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ver-password .icono-ojo-tachado,
.ver-password[aria-pressed="true"] .icono-ojo { display: none; }
.ver-password[aria-pressed="true"] .icono-ojo-tachado { display: block; }
/* Oculta el ojito propio de Edge para que no salgan dos */
.campo-password input::-ms-reveal { display: none; }

.boton {
    display: inline-block; margin-top: 20px; padding: 10px 20px;
    background: var(--primario); color: #fff; font: inherit; font-weight: 600;
    border: 0; border-radius: 8px; cursor: pointer; text-decoration: none;
}
.boton:hover { background: var(--primario-oscuro); }
.boton-bloque { width: 100%; }

/* ---------- Alertas ---------- */
.alerta { padding: 12px 14px; border-radius: 8px; margin: 12px 0; }
.alerta-error { background: var(--error-fondo); color: var(--error); }
.alerta-exito { background: var(--exito-fondo); color: var(--exito); }

/* ---------- Inicio: tarjeta del curso ---------- */
.saludo { margin-bottom: 20px; }
.curso-tarjeta h2 { margin-bottom: 4px; }
.progreso { margin: 16px 0 4px; height: 12px; background: var(--fondo); border: 1px solid var(--borde); border-radius: 999px; overflow: hidden; }
.progreso-barra { height: 100%; background: var(--exito); }
.progreso-texto { font-size: 0.9rem; color: var(--texto-suave); }

/* ---------- Perfil ---------- */
.datos { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; }
.datos dt { font-weight: 600; }
.datos dd { margin: 0; overflow-wrap: anywhere; }
.form-angosto { max-width: 420px; }

/* ---------- Botones extra ---------- */
.boton-secundario { background: transparent; color: var(--primario); border: 1px solid var(--primario); }
.boton-secundario:hover { background: var(--fondo); }
.boton-sin-margen { margin-top: 0; }
.insignia { display: inline-block; font-size: 0.8rem; vertical-align: middle; padding: 2px 10px; border-radius: 999px; background: var(--exito-fondo); color: var(--exito); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Curso y acordeon ---------- */
.curso-cabecera { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.curso-cabecera h2 { margin-bottom: 0; }
.acordeon { margin-top: 20px; display: grid; gap: 10px; }
.modulo { border: 1px solid var(--borde); border-radius: var(--radio); background: var(--superficie); }
.modulo summary {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 14px 16px; cursor: pointer; font-weight: 600; list-style: none;
}
.modulo summary::-webkit-details-marker { display: none; }
.modulo summary::before { content: "▸"; color: var(--texto-suave); transition: transform .15s; }
.modulo[open] summary::before { transform: rotate(90deg); }
.modulo-titulo { flex: 1; }
.modulo-estado { font-size: 0.85rem; font-weight: 400; color: var(--texto-suave); white-space: nowrap; }
.modulo-estado.completo { color: var(--exito); font-weight: 600; }
.lista-lecciones { list-style: none; margin: 0; padding: 0 16px 8px; }
.lista-lecciones li { display: flex; gap: 10px; align-items: baseline; padding: 8px 0; border-top: 1px solid var(--borde); }
.lista-lecciones li.actual a { font-weight: 700; }
.marca-leccion { width: 1.2em; color: var(--texto-suave); flex-shrink: 0; }
.lista-lecciones li.hecha .marca-leccion { color: var(--exito); }
.materiales { padding: 4px 16px 14px; }
.materiales ul { margin: 6px 0 0; padding-left: 20px; }
.materiales li { margin: 4px 0; }
section.materiales { padding: 24px; }

/* ---------- Leccion ---------- */
.migas { margin-bottom: 8px; }
.modulo-etiqueta { margin: 0 0 4px; font-size: 0.9rem; }
.navegacion-leccion { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.navegacion-leccion .boton { margin-top: 0; }
.form-completar { margin: 0; margin-left: auto; }
.form-completar.resaltar .boton { box-shadow: 0 0 0 4px var(--exito-fondo), 0 0 0 6px var(--exito); }

/* ---------- Reproductor ---------- */
.reproductor { position: relative; background: #000; border-radius: 8px; overflow: hidden; line-height: 0; }
.reproductor video { width: 100%; max-height: 70vh; display: block; background: #000; }
.reproductor:fullscreen { display: flex; align-items: center; border-radius: 0; }
.reproductor:fullscreen video { max-height: 100vh; height: 100%; }
.marca-agua {
    position: absolute; top: 10%; left: 10%; line-height: 1.2;
    color: #fff; opacity: .35; font-size: 14px; pointer-events: none; user-select: none;
    text-shadow: 0 0 3px #000; transition: top 1s, left 1s; white-space: nowrap;
}
/* Ocultar el boton nativo de pantalla completa (usamos el nuestro) */
.reproductor video::-webkit-media-controls-fullscreen-button { display: none; }
.boton-pantalla {
    position: absolute; top: 8px; right: 8px; line-height: 1;
    background: rgba(0,0,0,.55); color: #fff; border: 0; border-radius: 6px;
    font-size: 18px; padding: 6px 9px; cursor: pointer;
}
.boton-pantalla:hover { background: rgba(0,0,0,.8); }
.reproductor-error { position: absolute; inset: auto 0 0 0; line-height: 1.5; padding: 10px 14px; background: var(--error-fondo); color: var(--error); }
.reproductor-error[hidden] { display: none; }

/* ---------- Comentarios ---------- */
.comentario { border-top: 1px solid var(--borde); padding: 12px 0; }
.comentario header { display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.comentario time { font-size: 0.85rem; }
.comentario p { margin: 6px 0 0; overflow-wrap: anywhere; }
.form-comentario { border-top: 1px solid var(--borde); padding-top: 4px; }
textarea { resize: vertical; min-height: 80px; }

/* ---------- Pantalla final ---------- */
.final { text-align: center; padding: 48px 24px; }
.final-icono { font-size: 4rem; line-height: 1; margin-bottom: 12px; }
.final-botones { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }

/* ---------- Pie ---------- */
.pie { border-top: 1px solid var(--borde); padding: 16px 0; color: var(--texto-suave); font-size: 0.9rem; text-align: center; }

/* ---------- Administracion de usuarios ---------- */
.cabecera-pagina { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.cabecera-pagina h1 { margin: 0; }
.tarjeta-tabla { padding: 0; overflow-x: auto; }
.tabla { width: 100%; border-collapse: collapse; }
.tabla th, .tabla td { padding: 12px 16px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--borde); }
.tabla th { font-size: 0.85rem; font-weight: 600; color: var(--texto-suave); white-space: nowrap; }
.tabla tbody tr:last-child td { border-bottom: 0; }
.celda-correo { overflow-wrap: anywhere; }
.celda-acciones { text-align: right; white-space: nowrap; }
.insignia-inactiva { background: var(--fondo); color: var(--texto-suave); border: 1px solid var(--borde); }
.insignia-admin { margin-left: 6px; background: transparent; color: var(--primario); border: 1px solid var(--primario); }
.acciones-form { display: flex; gap: 12px; flex-wrap: wrap; }
.solo-movil { display: none; }

/* En movil cada usuario se muestra como una ficha */
@media (max-width: 640px) {
    .tabla thead { display: none; }
    .tabla tr {
        display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 14px 16px;
        grid-template-areas: "nombre estado" "correo acciones" "acceso acciones";
        border-bottom: 1px solid var(--borde);
    }
    .tabla tbody tr:last-child { border-bottom: 0; }
    .tabla td { padding: 0; border: 0; }
    .celda-nombre { grid-area: nombre; font-weight: 600; }
    .celda-correo { grid-area: correo; }
    .celda-estado { grid-area: estado; text-align: right; }
    .celda-acceso { grid-area: acceso; font-size: 0.85rem; }
    .celda-acciones { grid-area: acciones; align-self: end; }
    .solo-movil { display: inline; }
}
