/* ==========================================================================
   NidoDigital — Sistema de estilos (tokens, utilidades y componentes SaaS)
   ========================================================================== */

/* ---------- Tokens ----------
   Paleta institucional alineada con la Universidad de La Serena (userena.cl):
   azul ULS #003082 y rojo ULS #CF142B (colores del logotipo oficial). */
:root {
  --c-brand: #003082;          /* azul ULS (fijo en ambos temas) */
  --c-brand-700: #002566;
  --c-brand-900: #001a47;
  --c-brand-ink: #e9eef8;      /* texto sobre fondos azules */
  --c-red: #cf142b;            /* rojo ULS */
  --c-red-600: #ad1024;

  --c-primary: #003082;
  --c-primary-600: #002566;
  --c-primary-50: #eaf0fa;
  --c-primary-100: #cbd8f0;
  --c-accent: #cf142b;
  --c-accent-50: #fcebed;
  --c-danger: #b42318;
  --c-danger-50: #fdecea;
  --c-success: #15803d;
  --c-success-50: #e8f6ec;
  --c-info: #1d5fbf;
  --c-info-50: #e8f0fc;

  --c-bg: #f4f6fa;
  --c-surface: #ffffff;
  --c-surface-2: #eef2f8;
  --c-border: #dde3ee;
  --c-border-strong: #c3ccdc;
  --c-text: #14213d;
  --c-text-2: #44506a;
  --c-muted: #69748c;

  --font-sans: "Open Sans", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0, 26, 71, .06);
  --shadow: 0 1px 3px rgba(0, 26, 71, .08), 0 4px 12px rgba(0, 26, 71, .06);
  --shadow-lg: 0 12px 32px rgba(0, 26, 71, .14);
  --container: 1180px;
  --header-h: 68px;
  --sidebar-w: 248px;
  --sidebar-w-collapsed: 68px;
  --t: .18s ease;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --c-brand-ink: #e9eef8;
    --c-primary: #7fa6ff;
    --c-primary-600: #a9c3ff;
    --c-primary-50: #0f1d3d;
    --c-primary-100: #1a2c56;
    --c-accent: #ff4d61;
    --c-accent-50: #3a1218;
    --c-danger: #ff7a6b;
    --c-danger-50: #3b1512;
    --c-success: #4ade80;
    --c-success-50: #12301c;
    --c-info: #93b4ff;
    --c-info-50: #172443;
    --c-bg: #0b1222;
    --c-surface: #111a2e;
    --c-surface-2: #17223a;
    --c-border: #233150;
    --c-border-strong: #33456b;
    --c-text: #e6ebf5;
    --c-text-2: #b3bdd3;
    --c-muted: #8592ad;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
  }
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font-sans); font-size: 16px; line-height: 1.6;
  color: var(--c-text); background: var(--c-bg); -webkit-font-smoothing: antialiased;
}
img, video, iframe { max-width: 100%; display: block; }
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.75rem, 3vw, 2.4rem); }
h2 { font-size: clamp(1.35rem, 2.2vw, 1.7rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Utilidades ---------- */
.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: 16px; }
.container-narrow { max-width: 780px; }
.stack > * + * { margin-top: var(--stack, 1rem); }
.flex { display: flex; } .inline-flex { display: inline-flex; }
.items-center { align-items: center; } .items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; } .justify-end { justify-content: flex-end; }
.wrap { flex-wrap: wrap; } .grow { flex: 1 1 auto; } .shrink-0 { flex-shrink: 0; }
.gap-1 { gap: .25rem; } .gap-2 { gap: .5rem; } .gap-3 { gap: .75rem; } .gap-4 { gap: 1rem; } .gap-6 { gap: 1.5rem; }
.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: .25rem; } .mt-2 { margin-top: .5rem; } .mt-4 { margin-top: 1rem; } .mt-6 { margin-top: 1.5rem; } .mt-8 { margin-top: 2rem; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: .5rem; } .mb-4 { margin-bottom: 1rem; } .mb-6 { margin-bottom: 1.5rem; }
.p-4 { padding: 1rem; } .p-6 { padding: 1.5rem; }
.text-muted { color: var(--c-muted); } .text-2 { color: var(--c-text-2); }
.text-sm { font-size: .875rem; } .text-xs { font-size: .78rem; } .text-lg { font-size: 1.125rem; }
.text-center { text-align: center; } .text-right { text-align: right; }
.fw-600 { font-weight: 600; } .fw-700 { font-weight: 700; }
.mono { font-family: var(--font-mono); }
.nowrap { white-space: nowrap; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.divider { border: 0; border-top: 1px solid var(--c-border); margin: 1.5rem 0; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .55rem 1rem; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: .9rem; font-weight: 600; line-height: 1.2; cursor: pointer; text-decoration: none !important;
  transition: background var(--t), border-color var(--t), color var(--t), box-shadow var(--t); white-space: nowrap;
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-600); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary { background: #2f5fc4; color: #fff; } :root:not([data-theme="light"]) .btn-primary:hover { background: #3a6fd8; } }
.btn-secondary { background: var(--c-surface); color: var(--c-text); border-color: var(--c-border-strong); }
.btn-secondary:hover { background: var(--c-surface-2); }
.btn-ghost { background: transparent; color: var(--c-text-2); }
.btn-ghost:hover { background: var(--c-surface-2); color: var(--c-text); }
.btn-danger { background: var(--c-danger-50); color: var(--c-danger); border-color: transparent; }
.btn-danger:hover { background: var(--c-danger); color: #fff; }
.btn-accent { background: var(--c-red); color: #fff; }
.btn-accent:hover { background: var(--c-red-600); }
.btn-sm { padding: .35rem .65rem; font-size: .8rem; }
.btn-lg { padding: .8rem 1.4rem; font-size: 1rem; }
.btn-icon { padding: .4rem; width: 34px; height: 34px; }
.btn-block { width: 100%; }

/* ---------- Iconos (SVG inline) ---------- */
.icon { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 24px; height: 24px; }

/* ---------- Formularios ---------- */
.form-grid { display: grid; gap: 1.1rem; }
.form-grid-2 { display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.field { display: flex; flex-direction: column; gap: .35rem; }
.label { font-size: .85rem; font-weight: 600; color: var(--c-text); }
.label .req { color: var(--c-danger); }
.hint { font-size: .78rem; color: var(--c-muted); }
.input, .select, .textarea {
  width: 100%; padding: .6rem .75rem; background: var(--c-surface); border: 1px solid var(--c-border-strong);
  border-radius: var(--radius-sm); font-size: .92rem; transition: border-color var(--t), box-shadow var(--t);
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--c-primary-100); }
.textarea { min-height: 110px; resize: vertical; }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea, .field.has-error .rich-editor { border-color: var(--c-danger); }
.field-error { font-size: .8rem; color: var(--c-danger); }
.checkbox { display: inline-flex; align-items: center; gap: .5rem; font-size: .9rem; cursor: pointer; }
.checkbox input { width: 17px; height: 17px; accent-color: var(--c-primary); }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.search-input { position: relative; }
.search-input .icon { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--c-muted); pointer-events: none; }
.search-input .input { padding-left: 2.3rem; }
.form-actions { display: flex; gap: .75rem; justify-content: flex-end; flex-wrap: wrap; padding-top: .5rem; }

/* ---------- Tarjetas ---------- */
.card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-body { padding: 1.25rem; }
.card-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--c-border); display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.card-header h2, .card-header h3 { margin: 0; font-size: 1rem; }
.card-footer { padding: .9rem 1.25rem; border-top: 1px solid var(--c-border); }

.content-card { display: flex; flex-direction: column; overflow: hidden; transition: transform var(--t), box-shadow var(--t); color: inherit; }
.content-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); text-decoration: none; }
.content-card .cover { aspect-ratio: 16 / 9; background: var(--c-surface-2); overflow: hidden; }
.content-card .cover img { width: 100%; height: 100%; object-fit: cover; }
.content-card .card-body { display: flex; flex-direction: column; gap: .5rem; flex: 1; }
.content-card h3 { margin: 0; font-size: 1.05rem; color: var(--c-text); }
.content-card p { margin: 0; color: var(--c-text-2); font-size: .9rem; }
.content-card .meta { margin-top: auto; padding-top: .5rem; font-size: .8rem; color: var(--c-muted); display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }

/* Portada generada (sin imagen) */
.cover-generated {
  width: 100%; height: 100%; min-height: 160px; display: flex; flex-direction: column; justify-content: space-between;
  padding: 1rem 1.1rem; color: #fff; background:
    radial-gradient(circle at 85% 15%, rgba(255,255,255,.18) 0 18%, transparent 19%),
    radial-gradient(circle at 10% 110%, rgba(207,20,43,.75) 0 30%, transparent 31%),
    linear-gradient(135deg, #003082, #001a47);
}
.cover-generated .cg-kicker { font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; opacity: .85; font-weight: 700; }
.cover-generated .cg-title { font-size: 1.05rem; font-weight: 700; line-height: 1.25; }
.cover-generated.cg-course { background: radial-gradient(circle at 90% 10%, rgba(255,255,255,.14) 0 20%, transparent 21%), linear-gradient(135deg, #001a47, #003082 60%, #1d4fa8); }
.cover-generated.cg-tutorial { background: radial-gradient(circle at 15% 15%, rgba(255,255,255,.14) 0 16%, transparent 17%), linear-gradient(135deg, #8f0e1f, #cf142b); }
.cover-generated.cg-article { background: radial-gradient(circle at 80% 85%, rgba(255,255,255,.12) 0 22%, transparent 23%), linear-gradient(135deg, #002566, #2d5bb3); }

/* ---------- Badges / chips ---------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 600; line-height: 1.6; background: var(--c-surface-2); color: var(--c-text-2); border: 1px solid var(--c-border); white-space: nowrap; }
.badge-primary { background: var(--c-primary-50); color: var(--c-primary); border-color: var(--c-primary-100); }
.badge-success { background: var(--c-success-50); color: var(--c-success); border-color: transparent; }
.badge-warning { background: var(--c-accent-50); color: #9a5b00; border-color: transparent; }
.badge-danger { background: var(--c-danger-50); color: var(--c-danger); border-color: transparent; }
.badge-info { background: var(--c-info-50); color: var(--c-info); border-color: transparent; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .badge-warning { color: #fbbf24; } }
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { display: inline-flex; align-items: center; padding: .35rem .8rem; border-radius: 999px; border: 1px solid var(--c-border-strong); background: var(--c-surface); color: var(--c-text-2); font-size: .82rem; font-weight: 500; cursor: pointer; text-decoration: none !important; transition: all var(--t); }
.chip:hover { border-color: var(--c-primary); color: var(--c-primary); }
.chip.is-active, .chip:has(input:checked) { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.chip:has(input:focus-visible) { outline: 2px solid var(--c-primary); outline-offset: 2px; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.filter-group { display: flex; flex-direction: column; gap: .4rem; }
.filter-group > .label { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--c-muted); }
.tag { font-size: .78rem; color: var(--c-text-2); background: var(--c-surface-2); padding: .1rem .5rem; border-radius: var(--radius-sm); }

/* ---------- Alertas y toasts ---------- */
.alert { display: flex; gap: .6rem; align-items: flex-start; padding: .8rem 1rem; border-radius: var(--radius-sm); font-size: .9rem; border: 1px solid transparent; }
.alert-success { background: var(--c-success-50); color: var(--c-success); }
.alert-error { background: var(--c-danger-50); color: var(--c-danger); }
.alert-info { background: var(--c-info-50); color: var(--c-info); }
.alert-warning { background: var(--c-accent-50); color: #8a5300; }

.toast-stack { position: fixed; right: 16px; bottom: 16px; z-index: 1000; display: flex; flex-direction: column; gap: .5rem; max-width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; gap: .6rem; align-items: flex-start; padding: .8rem 1rem; border-radius: var(--radius); background: var(--c-surface); border: 1px solid var(--c-border); box-shadow: var(--shadow-lg); font-size: .9rem; animation: toast-in .25s ease; }
.toast.is-leaving { animation: toast-out .2s ease forwards; }
.toast-success { border-left: 4px solid var(--c-success); }
.toast-error { border-left: 4px solid var(--c-danger); }
.toast-info { border-left: 4px solid var(--c-info); }
.toast button { margin-left: auto; background: none; border: 0; cursor: pointer; color: var(--c-muted); font-size: 1.1rem; line-height: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--c-muted); font-weight: 600; padding: .7rem 1rem; border-bottom: 1px solid var(--c-border); background: var(--c-surface-2); white-space: nowrap; }
.table td { padding: .75rem 1rem; border-bottom: 1px solid var(--c-border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--t), opacity .3s; }
.table tbody tr:hover { background: var(--c-surface-2); }
.table tr.htmx-swapping { opacity: 0; }
.table .actions { display: flex; gap: .35rem; justify-content: flex-end; }
.table .title-cell { font-weight: 600; color: var(--c-text); }
.thumb { width: 44px; height: 44px; border-radius: var(--radius-sm); object-fit: cover; background: var(--c-surface-2); }

/* ---------- Paginación ---------- */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .9rem 1.25rem; flex-wrap: wrap; font-size: .85rem; color: var(--c-muted); }
.pagination .pages { display: flex; gap: .25rem; flex-wrap: wrap; }
.pagination a, .pagination span.current { min-width: 34px; height: 34px; padding: 0 .6rem; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); border: 1px solid var(--c-border); color: var(--c-text-2); background: var(--c-surface); text-decoration: none; }
.pagination a:hover { border-color: var(--c-primary); color: var(--c-primary); }
.pagination span.current { background: var(--c-primary); border-color: var(--c-primary); color: #fff; font-weight: 600; }

/* ---------- Estados vacíos e indicadores ---------- */
.empty { text-align: center; padding: 3rem 1rem; color: var(--c-muted); }
.empty .icon { width: 40px; height: 40px; margin: 0 auto .75rem; opacity: .6; }
.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--c-border-strong); border-top-color: var(--c-primary); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
[hx-target].htmx-request, .is-loading { opacity: .65; transition: opacity .2s; }

/* ---------- Progreso ---------- */
.progress { height: 8px; background: var(--c-surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--c-border); }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--c-brand), #2d6be0); border-radius: 999px; transition: width .5s ease; }
.progress-label { display: flex; justify-content: space-between; font-size: .8rem; color: var(--c-muted); margin-bottom: .35rem; }

/* ==========================================================================
   Sitio público
   ========================================================================== */
.site-header { position: sticky; top: 0; z-index: 50; background: var(--c-brand); border-top: 4px solid var(--c-red); box-shadow: 0 2px 10px rgba(0, 26, 71, .25); color: #fff; }
.site-header .container { height: var(--header-h); display: flex; align-items: center; gap: 1.5rem; }
.brand { display: inline-flex; align-items: center; gap: .55rem; text-decoration: none !important; flex-shrink: 0; }
.brand-logo { height: 40px; width: auto; display: block; }
.main-nav { display: flex; gap: .25rem; margin-left: auto; }
.main-nav a { position: relative; padding: .45rem .75rem; border-radius: var(--radius-sm); color: rgba(255,255,255,.86); font-size: .92rem; font-weight: 600; text-decoration: none; }
.main-nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.main-nav a.is-active { color: #fff; }
.main-nav a.is-active::after { content: ""; position: absolute; left: .75rem; right: .75rem; bottom: -2px; height: 3px; border-radius: 2px; background: var(--c-red); }
.header-actions { display: flex; gap: .5rem; align-items: center; }
.nav-toggle { display: none; }

.user-menu { position: relative; }
.user-menu summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: .5rem; padding: .25rem .6rem .25rem .25rem; border-radius: 999px; border: 1px solid rgba(255,255,255,.3); color: #fff; }
.user-menu summary::-webkit-details-marker { display: none; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--c-primary-50); color: var(--c-primary); display: grid; place-items: center; font-weight: 700; font-size: .85rem; flex-shrink: 0; }
.dropdown { position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: .4rem; z-index: 60; }
.dropdown a, .dropdown button { display: flex; width: 100%; align-items: center; gap: .55rem; padding: .55rem .7rem; border-radius: var(--radius-sm); color: var(--c-text); font-size: .88rem; background: none; border: 0; cursor: pointer; text-align: left; text-decoration: none; }
.dropdown a:hover, .dropdown button:hover { background: var(--c-surface-2); }
.dropdown hr { border: 0; border-top: 1px solid var(--c-border); margin: .3rem 0; }

@media (max-width: 960px) {
  .nav-toggle { display: inline-flex; margin-left: auto; }
  .main-nav { display: none; position: absolute; left: 0; right: 0; top: var(--header-h); flex-direction: column; background: var(--c-brand-700); padding: .75rem 16px; box-shadow: var(--shadow); }
  .main-nav.is-open { display: flex; }
  .header-actions .btn-label { display: none; }
}

.site-main { min-height: calc(100vh - var(--header-h) - 200px); }
.section { padding-block: 3.5rem; }
.section-sm { padding-block: 2rem; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.section-head h2 { margin: 0; }
.kicker { display: inline-block; font-size: .75rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--c-primary); margin-bottom: .4rem; }

.hero { padding: 4.5rem 0 3.5rem; background:
  radial-gradient(800px 380px at 85% -10%, var(--c-primary-50), transparent 70%),
  radial-gradient(600px 300px at -5% 110%, var(--c-accent-50), transparent 70%); border-bottom: 1px solid var(--c-border); }
.hero h1 { font-size: clamp(2rem, 4.5vw, 3.2rem); max-width: 17ch; }
.hero p.lead { font-size: 1.15rem; color: var(--c-text-2); max-width: 58ch; }
.hero-stats { display: flex; gap: 2rem; flex-wrap: wrap; margin-top: 2rem; }
.hero-stats strong { display: block; font-size: 1.6rem; color: var(--c-text); }
.hero-stats span { font-size: .85rem; color: var(--c-muted); }

.page-head { padding: 2.5rem 0 1.5rem; border-bottom: 1px solid var(--c-border); background: var(--c-surface); }
.page-head p { color: var(--c-text-2); max-width: 65ch; margin: 0; }
.breadcrumbs { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; font-size: .82rem; color: var(--c-muted); margin-bottom: .75rem; }
.breadcrumbs a { color: var(--c-muted); }
.breadcrumbs a:hover { color: var(--c-primary); }
.breadcrumbs .sep { opacity: .5; }

.filters-bar { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; margin: 1.5rem 0; }
.filters-bar .search-input { flex: 1 1 260px; max-width: 420px; }

.module-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); }
.module-tile { padding: 1.25rem; display: flex; flex-direction: column; gap: .5rem; color: inherit; }
.module-tile:hover { text-decoration: none; border-color: var(--c-primary-100); box-shadow: var(--shadow); }
.module-tile .tile-icon { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; background: var(--c-primary-50); color: var(--c-primary); }
.module-tile h3 { margin: 0; font-size: 1rem; color: var(--c-text); }
.module-tile p { margin: 0; font-size: .87rem; color: var(--c-text-2); }

/* Detalle con barra lateral */
.layout-aside { display: grid; gap: 2rem; grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
.layout-aside aside { position: sticky; top: calc(var(--header-h) + 1rem); display: flex; flex-direction: column; gap: 1rem; }
@media (max-width: 960px) { .layout-aside { grid-template-columns: 1fr; } .layout-aside aside { position: static; } }

.meta-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; font-size: .88rem; }
.meta-list li { display: flex; justify-content: space-between; gap: 1rem; }
.meta-list li span:first-child { color: var(--c-muted); }
.meta-list li span:last-child { font-weight: 600; text-align: right; }

/* Contenido enriquecido */
.prose { font-size: 1.04rem; line-height: 1.75; color: var(--c-text); }
.prose > * + * { margin-top: 1em; }
.prose h2 { margin-top: 1.8em; font-size: 1.45rem; } .prose h3 { margin-top: 1.5em; font-size: 1.2rem; }
.prose p { margin: 0; }
.prose ul, .prose ol { padding-left: 1.4em; margin: 0; } .prose li + li { margin-top: .3em; }
.prose blockquote { margin: 0; padding: .5em 1.1em; border-left: 3px solid var(--c-primary); background: var(--c-primary-50); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--c-text-2); }
.prose pre { background: #0b1630; color: #dbe5ff; padding: 1em 1.2em; border-radius: var(--radius); overflow-x: auto; font-size: .88rem; }
.prose code { font-family: var(--font-mono); font-size: .9em; background: var(--c-surface-2); padding: .1em .35em; border-radius: 4px; }
.prose pre code { background: none; padding: 0; }
.prose img { border-radius: var(--radius); margin-inline: auto; }
.prose table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.prose th, .prose td { border: 1px solid var(--c-border); padding: .5em .75em; text-align: left; }
.prose a { text-decoration: underline; text-underline-offset: 2px; }
.prose hr { border: 0; border-top: 1px solid var(--c-border); margin: 2em 0; }

.article-cover { border-radius: var(--radius-lg); overflow: hidden; aspect-ratio: 21 / 9; margin: 1.5rem 0; background: var(--c-surface-2); }
.article-cover img { width: 100%; height: 100%; object-fit: cover; }

/* Wiki */
.alpha-index { display: flex; flex-wrap: wrap; gap: .25rem; }
.alpha-index a, .alpha-index span { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); font-weight: 600; font-size: .85rem; text-decoration: none; }
.alpha-index a { color: var(--c-text-2); border: 1px solid var(--c-border); background: var(--c-surface); }
.alpha-index a:hover { border-color: var(--c-primary); color: var(--c-primary); }
.alpha-index a.is-active { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.alpha-index span { color: var(--c-border-strong); }
.term-list { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.term-item { padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .35rem; color: inherit; }
.term-item:hover { text-decoration: none; border-color: var(--c-primary-100); box-shadow: var(--shadow); }
.term-item h3 { margin: 0; font-size: 1rem; color: var(--c-text); }
.term-item p { margin: 0; font-size: .87rem; color: var(--c-text-2); }
.citations { list-style: none; padding: 0; margin: 0; display: grid; gap: .75rem; counter-reset: cite; }
.citations li { counter-increment: cite; padding: .85rem 1rem .85rem 3rem; position: relative; background: var(--c-surface-2); border-radius: var(--radius-sm); font-size: .9rem; word-break: break-word; }
.citations li::before { content: "[" counter(cite) "]"; position: absolute; left: 1rem; top: .85rem; font-weight: 700; color: var(--c-primary); font-family: var(--font-mono); font-size: .85rem; }

/* Tutoriales */
.steps { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 1.5rem; counter-reset: step; }
.step { display: grid; grid-template-columns: 44px 1fr; gap: 1rem; }
.step-number { width: 44px; height: 44px; border-radius: 50%; background: var(--c-primary); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 1.05rem; }
.step-body { padding: 1.25rem; }
.gallery { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); margin-top: 1rem; }
.gallery figure { margin: 0; }
.gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--c-border); cursor: zoom-in; }
.gallery figcaption { font-size: .78rem; color: var(--c-muted); margin-top: .25rem; }
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: .45rem; font-size: .9rem; }
.checklist li { display: flex; gap: .5rem; align-items: flex-start; }
.checklist .icon { color: var(--c-primary); margin-top: 3px; }

.lightbox { position: fixed; inset: 0; background: rgba(5, 10, 9, .88); display: grid; place-items: center; z-index: 1100; padding: 2rem; cursor: zoom-out; }
.lightbox img { max-height: 90vh; border-radius: var(--radius); }

/* Boletines */
.pdf-viewer { width: 100%; height: 78vh; min-height: 520px; border: 1px solid var(--c-border); border-radius: var(--radius); background: var(--c-surface-2); }

/* Cursos y lecciones */
.curriculum { display: flex; flex-direction: column; gap: .75rem; }
.curriculum-module { overflow: hidden; }
.curriculum-module > summary { list-style: none; cursor: pointer; padding: .9rem 1.1rem; display: flex; justify-content: space-between; gap: 1rem; align-items: center; font-weight: 600; }
.curriculum-module > summary::-webkit-details-marker { display: none; }
.curriculum-module[open] > summary { border-bottom: 1px solid var(--c-border); }
.lesson-list { list-style: none; margin: 0; padding: .35rem; }
.lesson-link { display: flex; gap: .65rem; align-items: center; padding: .55rem .75rem; border-radius: var(--radius-sm); color: var(--c-text-2); font-size: .9rem; text-decoration: none !important; }
a.lesson-link:hover { background: var(--c-surface-2); color: var(--c-text); }
.lesson-link.is-current { background: var(--c-primary-50); color: var(--c-primary); font-weight: 600; }
.lesson-link .status-dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--c-border-strong); flex-shrink: 0; display: grid; place-items: center; }
.lesson-link.is-done .status-dot { background: var(--c-success); border-color: var(--c-success); color: #fff; }
.lesson-link.is-done .status-dot .icon { width: 12px; height: 12px; stroke-width: 3; }
.lesson-link .duration { margin-left: auto; font-size: .78rem; color: var(--c-muted); }

.lesson-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.5rem; align-items: start; padding: 1.5rem 0 3rem; }
.lesson-layout aside { position: sticky; top: calc(var(--header-h) + 1rem); max-height: calc(100vh - var(--header-h) - 2rem); overflow: auto; }
@media (max-width: 1000px) { .lesson-layout { grid-template-columns: 1fr; } .lesson-layout aside { position: static; max-height: none; } }
.video-frame { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.video-frame iframe, .video-frame > div { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.lesson-status { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 1rem 1.25rem; }
.certificate-banner { display: flex; gap: 1rem; align-items: center; padding: 1.1rem 1.25rem; border-radius: var(--radius); background: linear-gradient(135deg, var(--c-primary-50), var(--c-accent-50)); border: 1px solid var(--c-primary-100); flex-wrap: wrap; }
.certificate-banner .icon-lg { color: var(--c-primary); }

/* Verificación de constancias */
.verify-card { max-width: 640px; margin: 0 auto; }
.verify-result { border-radius: var(--radius); padding: 1.25rem; border: 1px solid; }
.verify-result.is-valid { background: var(--c-success-50); border-color: color-mix(in srgb, var(--c-success) 35%, transparent); }
.verify-result.is-revoked { background: var(--c-danger-50); border-color: color-mix(in srgb, var(--c-danger) 35%, transparent); }

/* Autenticación */
.auth-wrap { min-height: calc(100vh - var(--header-h)); display: grid; place-items: center; padding: 2.5rem 16px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .card-body { padding: 2rem; }

/* Footer */
.site-footer { background: var(--c-brand-900); border-top: 4px solid var(--c-red); padding: 2.75rem 0 1.5rem; margin-top: 3rem; font-size: .88rem; color: rgba(233,238,248,.82); }
.footer-grid { display: grid; gap: 2rem; grid-template-columns: 2fr repeat(3, 1fr); }
.footer-grid h4 { font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: #fff; margin-bottom: .75rem; }
.footer-grid ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .4rem; }
.footer-grid a { color: rgba(233,238,248,.82); }
.footer-grid a:hover { color: #fff; }
.footer-bottom { margin-top: 2rem; padding-top: 1.25rem; border-top: 1px solid rgba(255,255,255,.15); font-size: .8rem; color: rgba(233,238,248,.65); display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.footer-bottom a { color: #fff; }
@media (max-width: 760px) { .footer-grid { grid-template-columns: 1fr 1fr; } }

/* ==========================================================================
   Backoffice
   ========================================================================== */
.admin-body { background: var(--c-bg); }
.admin-shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns var(--t); }
.admin-shell.is-collapsed { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--c-brand); border-top: 4px solid var(--c-red); display: flex; flex-direction: column; overflow: hidden auto; color: #fff; }
.sidebar-head { height: var(--header-h); display: flex; align-items: center; padding: 0 1rem; border-bottom: 1px solid rgba(255,255,255,.12); gap: .5rem; }
.sidebar-nav { padding: .75rem .6rem; display: flex; flex-direction: column; gap: .15rem; flex: 1; }
.sidebar-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: rgba(233,238,248,.55); font-weight: 700; padding: .9rem .7rem .35rem; white-space: nowrap; }
.sidebar-link { position: relative; display: flex; align-items: center; gap: .7rem; padding: .55rem .7rem; border-radius: var(--radius-sm); color: rgba(233,238,248,.82); font-size: .88rem; font-weight: 500; white-space: nowrap; text-decoration: none !important; }
.sidebar-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-link.is-active { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; }
.sidebar-link.is-active::before { content: ""; position: absolute; left: -.6rem; top: 6px; bottom: 6px; width: 4px; border-radius: 0 3px 3px 0; background: var(--c-red); }
.sidebar-foot { padding: .75rem .6rem; border-top: 1px solid rgba(255,255,255,.12); }
.admin-shell.is-collapsed .sidebar .link-label, .admin-shell.is-collapsed .sidebar-section { display: none; }
.admin-shell.is-collapsed .brand-logo { height: 30px; width: 30px; object-fit: cover; object-position: left center; }
.admin-shell.is-collapsed .sidebar-link { justify-content: center; }
.admin-shell.is-collapsed .sidebar-head { justify-content: center; padding: 0; }

.admin-topbar { height: var(--header-h); display: flex; align-items: center; gap: 1rem; padding: 0 1.5rem; background: var(--c-surface); border-bottom: 1px solid var(--c-border); position: sticky; top: 0; z-index: 40; }
.admin-topbar .breadcrumbs { margin: 0; }
.admin-content { padding: 1.5rem; max-width: 1320px; width: 100%; }
.admin-page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.admin-page-head h1 { font-size: 1.5rem; margin: 0; }
.admin-page-head p { margin: .25rem 0 0; color: var(--c-muted); font-size: .9rem; }
.toolbar { display: flex; gap: .75rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--c-border); flex-wrap: wrap; align-items: center; }
.toolbar .search-input { flex: 1 1 240px; max-width: 360px; }
.toolbar .select { width: auto; min-width: 160px; }

.stat-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); margin-bottom: 1.5rem; }
.stat { padding: 1.1rem 1.25rem; }
.stat .stat-label { font-size: .8rem; color: var(--c-muted); font-weight: 500; display: flex; align-items: center; gap: .4rem; }
.stat .stat-value { font-size: 1.75rem; font-weight: 700; margin-top: .25rem; letter-spacing: -.02em; }
.stat .stat-sub { font-size: .78rem; color: var(--c-muted); }

.form-layout { display: grid; gap: 1.5rem; grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
.form-layout > aside { display: flex; flex-direction: column; gap: 1.25rem; position: sticky; top: calc(var(--header-h) + 1rem); }
@media (max-width: 1100px) { .form-layout { grid-template-columns: 1fr; } .form-layout > aside { position: static; } }

@media (max-width: 860px) {
  .admin-shell, .admin-shell.is-collapsed { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: var(--sidebar-w); z-index: 80; transform: translateX(-100%); transition: transform var(--t); box-shadow: var(--shadow-lg); }
  .admin-shell.is-mobile-open .sidebar { transform: none; }
  .admin-shell.is-collapsed .sidebar .link-label, .admin-shell.is-collapsed .sidebar-section { display: initial; }
  .admin-shell.is-collapsed .brand-logo { height: 40px; width: auto; }
  .admin-content { padding: 1rem; }
}

/* Editor de texto enriquecido */
.rich-editor { border: 1px solid var(--c-border-strong); border-radius: var(--radius-sm); background: var(--c-surface); overflow: hidden; }
.rich-editor:focus-within { border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--c-primary-100); }
.rich-toolbar { display: flex; flex-wrap: wrap; gap: .15rem; padding: .35rem; border-bottom: 1px solid var(--c-border); background: var(--c-surface-2); }
.rich-toolbar button { min-width: 32px; height: 32px; padding: 0 .45rem; border: 0; border-radius: var(--radius-sm); background: transparent; cursor: pointer; font-size: .85rem; font-weight: 600; color: var(--c-text-2); }
.rich-toolbar button:hover, .rich-toolbar button.is-active { background: var(--c-surface); color: var(--c-primary); }
.rich-toolbar .sep { width: 1px; background: var(--c-border-strong); margin: .3rem .2rem; }
.rich-content { min-height: 280px; max-height: 70vh; overflow-y: auto; padding: 1rem 1.1rem; outline: none; }
.rich-content:empty::before { content: attr(data-placeholder); color: var(--c-muted); }
.rich-editor.is-source .rich-content { display: none; }
.rich-source { display: none; width: 100%; min-height: 280px; border: 0; padding: 1rem; font-family: var(--font-mono); font-size: .85rem; background: var(--c-surface); resize: vertical; }
.rich-editor.is-source .rich-source { display: block; }

/* Dropzone */
.dropzone { border: 2px dashed var(--c-border-strong); border-radius: var(--radius); padding: 1.25rem; text-align: center; cursor: pointer; transition: border-color var(--t), background var(--t); background: var(--c-surface); position: relative; }
.dropzone:hover, .dropzone.is-dragover { border-color: var(--c-primary); background: var(--c-primary-50); }
.dropzone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone .dz-label { font-size: .88rem; color: var(--c-text-2); }
.dropzone .dz-files { font-size: .8rem; color: var(--c-primary); font-weight: 600; margin-top: .35rem; word-break: break-all; }
.dropzone .dz-preview { max-height: 140px; margin: .75rem auto 0; border-radius: var(--radius-sm); }
.current-file { display: flex; align-items: center; gap: .75rem; padding: .6rem .75rem; background: var(--c-surface-2); border-radius: var(--radius-sm); font-size: .85rem; margin-bottom: .6rem; }
.current-file img { width: 56px; height: 40px; object-fit: cover; border-radius: 4px; }

/* Listas ordenables */
.sortable-item { display: flex; gap: .75rem; align-items: flex-start; }
.drag-handle { cursor: grab; color: var(--c-muted); padding: .2rem; border-radius: 4px; display: inline-flex; }
.drag-handle:hover { background: var(--c-surface-2); color: var(--c-text); }
.sortable-item.is-dragging { opacity: .45; }
.sortable-item.is-drop-target { box-shadow: 0 -2px 0 var(--c-primary); }

.builder-module { margin-bottom: 1rem; }
.builder-module > .card-header { background: var(--c-surface-2); }
.builder-lessons { list-style: none; margin: 0; padding: .5rem; display: flex; flex-direction: column; gap: .35rem; min-height: 12px; }
.builder-lesson { padding: .6rem .75rem; border: 1px solid var(--c-border); border-radius: var(--radius-sm); background: var(--c-surface); align-items: center; }
.builder-lesson .yt-thumb { width: 72px; height: 40px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.inline-form { padding: 1rem; background: var(--c-surface-2); border-radius: var(--radius-sm); border: 1px dashed var(--c-border-strong); }

/* Repetidor de fuentes */
.repeater-item { position: relative; padding: 1rem; border: 1px solid var(--c-border); border-radius: var(--radius-sm); background: var(--c-surface-2); }
.repeater-item + .repeater-item { margin-top: .75rem; }
.repeater-item .repeater-remove { position: absolute; top: .5rem; right: .5rem; }
.repeater-item .repeater-index { font-size: .75rem; font-weight: 700; color: var(--c-primary); margin-bottom: .5rem; font-family: var(--font-mono); }

/* Interruptor */
.switch { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; background: none; border: 0; padding: 0; font-size: .82rem; color: var(--c-text-2); }
.switch .track { width: 36px; height: 20px; border-radius: 999px; background: var(--c-border-strong); position: relative; transition: background var(--t); flex-shrink: 0; }
.switch .track::after { content: ""; position: absolute; width: 16px; height: 16px; top: 2px; left: 2px; border-radius: 50%; background: #fff; transition: transform var(--t); box-shadow: var(--shadow-sm); }
.switch.is-on .track { background: var(--c-success); }
.switch.is-on .track::after { transform: translateX(16px); }

/* Constancia (vista HTML) */
.cert-code { font-family: var(--font-mono); font-weight: 700; letter-spacing: .08em; }

/* ==========================================================================
   Tema institucional ULS — encabezado, hero y elementos sobre fondo azul
   ========================================================================== */
.site-header .btn-ghost, .site-header .nav-toggle { color: #fff; }
.site-header .btn-ghost:hover { background: rgba(255,255,255,.12); color: #fff; }
.site-header .avatar { background: rgba(255,255,255,.16); color: #fff; }
.site-header .dropdown { color: var(--c-text); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .site-header { background: var(--c-brand-900); } }

.hero { position: relative; overflow: hidden; color: #fff; border-bottom: 0;
  background:
    radial-gradient(700px 360px at 92% -10%, rgba(255,255,255,.10), transparent 70%),
    radial-gradient(520px 280px at -8% 115%, rgba(207,20,43,.45), transparent 70%),
    linear-gradient(120deg, #001a47 0%, #003082 55%, #0b46a8 100%); }
.hero h1 { color: #fff; }
.hero .kicker { color: #ffd2d8; }
.hero p.lead { color: rgba(233,238,248,.88); }
.hero-stats strong { color: #fff; }
.hero-stats span { color: rgba(233,238,248,.72); }
.hero-stats > div { padding-left: .9rem; border-left: 3px solid var(--c-red); }
.btn-outline-light { background: transparent; color: #fff; border-color: rgba(255,255,255,.55); }
.btn-outline-light:hover { background: rgba(255,255,255,.12); }

.page-head { border-top: 0; box-shadow: inset 0 3px 0 var(--c-primary-50); }
.kicker { color: var(--c-red); }
.section-head h2::after { content: ""; display: block; width: 44px; height: 3px; margin-top: .45rem; border-radius: 2px; background: var(--c-red); }
.module-tile .tile-icon { background: var(--c-primary-50); color: var(--c-brand); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .module-tile .tile-icon { color: var(--c-primary); } }
.institutional-strip { display: flex; align-items: center; gap: .75rem; font-size: .8rem; color: rgba(233,238,248,.7); }
.institutional-strip img { height: 34px; width: auto; }
.content-card .cover img { object-position: top center; }
