/* =========================================================================
   Sala de Economía — sistema de estilos
   Paleta institucional: azul tinta + acento teal. Bootstrap 5.3 se carga aparte.
   ========================================================================= */

/* Fuente única del sitio: Inter (misma que usan los aplicativos). Subconjuntos
   .woff2 servidos localmente; se aplica a toda la plataforma y los aplicativos. */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/inter-400.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/inter-500.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap; src: url('../fonts/inter-600.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap; src: url('../fonts/inter-700.woff2') format('woff2'); }

:root {
    /* Marca / login */
    --se-brand: #14213d;
    --se-brand-2: #1b6ca8;
    --se-accent: #d98a2b;

    /* Tokens del backoffice */
    --ink: #14213d;
    --ink-2: #1e2f4d;
    --ink-3: #2a3d60;
    --surface: #f3f6fa;
    --card: #ffffff;
    --accent: #0f766e;
    --accent-600: #0b5d57;
    --accent-soft: #e6f2f0;
    --border: #e4e9f0;
    --text: #1e2a3d;
    --muted: #6b7688;
    --radius: 12px;
    --sidebar-w: 266px;
    --font-sans: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    /* Bootstrap usa esta variable para el body y sus componentes. */
    --bs-body-font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* =========================================================================
   Overrides de Bootstrap (color de marca)
   ========================================================================= */

.btn-primary {
    --bs-btn-bg: var(--accent);
    --bs-btn-border-color: var(--accent);
    --bs-btn-hover-bg: var(--accent-600);
    --bs-btn-hover-border-color: var(--accent-600);
    --bs-btn-active-bg: var(--accent-600);
    --bs-btn-active-border-color: var(--accent-600);
    --bs-btn-disabled-bg: var(--accent);
    --bs-btn-disabled-border-color: var(--accent);
}

.btn-outline-primary {
    --bs-btn-color: var(--accent);
    --bs-btn-border-color: var(--accent);
    --bs-btn-hover-bg: var(--accent);
    --bs-btn-hover-border-color: var(--accent);
    --bs-btn-active-bg: var(--accent);
    --bs-btn-active-border-color: var(--accent);
}

.btn { --bs-btn-font-weight: 500; border-radius: 9px; }

.form-control:focus,
.form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 0.2rem var(--accent-soft);
}

.form-check-input:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}

.form-check-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 0.2rem var(--accent-soft);
}

a { color: var(--accent-600); }

.badge.text-bg-info { --bs-info-rgb: 15, 118, 110; color: #fff; }

.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.card-header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    color: var(--text);
    padding: 0.85rem 1.1rem;
}

.table {
    --bs-table-bg: transparent;
    margin-bottom: 0;
}

.table > thead.table-light th {
    background: #f7f9fc;
    text-transform: uppercase;
    letter-spacing: 0.045em;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--muted);
    border-bottom-color: var(--border);
}

.table td, .table th { border-color: var(--border); }
.table tbody tr:hover > * { background: #f7fafc; }
td, th { font-variant-numeric: tabular-nums; }

.form-label { font-weight: 500; font-size: 0.9rem; color: #334155; margin-bottom: 0.3rem; }

/* Utilidades (evitan estilos inline bloqueados por la CSP §9.7) */
.text-accent { color: var(--accent-600) !important; }
.text-ink { color: var(--ink) !important; }
.col-w-xs { width: 3rem; }
.col-w-sm { width: 6rem; }

/* =========================================================================
   Backoffice — panel lateral + contenido
   ========================================================================= */

.admin-body {
    margin: 0;
    min-height: 100vh;
    background: var(--surface);
    color: var(--text);
    font-family: var(--font-sans);
}

.admin-shell { display: flex; min-height: 100vh; }

/* --- Sidebar --- */
.admin-sidebar {
    --bs-offcanvas-width: var(--sidebar-w);
    --bs-offcanvas-bg: var(--ink); /* fondo del offcanvas en móvil */
    background: var(--ink);
    color: #c3cde0;
    display: flex;
    flex-direction: column;
}

@media (min-width: 992px) {
    .admin-sidebar {
        width: var(--sidebar-w);
        flex: 0 0 var(--sidebar-w);
        position: sticky;
        top: 0;
        height: 100vh;
        /* Vence el `background-color: transparent !important` que Bootstrap
           aplica a .offcanvas-lg en pantallas grandes. */
        background: var(--ink) !important;
    }
}

.admin-sidebar svg,
.topbar-burger svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: 0 0 auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 1.25rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.3rem;
    height: 2.3rem;
    border-radius: 0.6rem;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.5px;
    font-size: 0.95rem;
}

.brand-text {
    display: flex;
    flex-direction: column;
    font-weight: 600;
    color: #fff;
    line-height: 1.2;
}

.brand-text small {
    font-weight: 400;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #8595b4;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0.75rem 1.25rem;
}

.nav-section {
    margin: 1.1rem 0.6rem 0.4rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.11em;
    text-transform: uppercase;
    color: #6b7ba0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 0.7rem;
    margin-bottom: 0.15rem;
    border-radius: 0.6rem;
    color: #c3cde0;
    text-decoration: none;
    font-size: 0.925rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: background 0.14s ease, color 0.14s ease;
}

.nav-item:hover { background: var(--ink-2); color: #fff; }

.nav-item.is-active {
    background: var(--ink-2);
    color: #fff;
    border-left-color: var(--accent);
}

.nav-item.is-active svg { color: #4fd1c5; }

.sidebar-foot {
    padding: 0.9rem 1rem 1.1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.7rem;
    min-width: 0;
}

.user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--ink-3);
    color: #fff;
    font-weight: 600;
    font-size: 0.85rem;
}

.user-meta {
    font-size: 0.8rem;
    color: #9aa7c2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-logout {
    display: block;
    text-align: center;
    padding: 0.5rem;
    border-radius: 0.55rem;
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: #c3cde0;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
}

.btn-logout:hover { background: var(--ink-2); color: #fff; }

/* --- Main / topbar --- */
.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.admin-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    height: 62px;
    padding: 0 1.5rem;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--border);
}

.topbar-title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--ink);
}

.topbar-burger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.2rem;
    height: 2.2rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: #fff;
    color: var(--ink);
}

.admin-content { padding: 1.5rem; }

@media (max-width: 575.98px) {
    .admin-topbar { padding: 0 1rem; }
    .admin-content { padding: 1rem; }
}

/* =========================================================================
   Frontend del participante
   ========================================================================= */

.front-body {
    margin: 0;
    min-height: 100vh;
    background: var(--surface);
    color: var(--text);
    font-family: var(--font-sans);
}

.front-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0 1.25rem;
    height: 60px;
    background: var(--ink);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 20;
}

.front-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: #fff;
    text-decoration: none;
    font-weight: 600;
}

.front-user {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    font-size: 0.875rem;
    color: #c3cde0;
}

.front-content { padding: 1.75rem 0 3rem; }

.course-block { margin-bottom: 1.75rem; }
.course-block__title {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.6rem;
}

.exam-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1.1rem;
    border-bottom: 1px solid var(--border);
}
.exam-row:last-child { border-bottom: 0; }
.exam-row__name { font-weight: 600; }
.exam-row__meta { font-size: 0.82rem; color: var(--muted); }

/* Etiqueta de estado (fondo claro, letra oscura) — no se confunde con los botones. */
.state-tag {
    display: inline-block;
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: 999px;
    padding: 0.18rem 0.65rem;
    line-height: 1.3;
    white-space: nowrap;
}
.state-tag--success   { background: #e3f3ea; color: #1c7a49; }
.state-tag--warning   { background: #fbf0da; color: #8a5a00; }
.state-tag--secondary { background: #eef1f6; color: #5a6675; }
.state-tag--dark      { background: #e5e8ef; color: #2a3d60; }

/* --- Encabezado de curso como enlace claro --- */
.course-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}
.course-link {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ink);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.course-link::after {
    content: "\2192"; /* → */
    color: var(--accent-600);
    transition: transform 0.15s ease;
}
.course-link:hover { color: var(--accent-600); text-decoration: underline; }
.course-link:hover::after { transform: translateX(3px); }

/* --- Logo de marca (imagen) --- */
.brand-logo {
    height: 40px;
    width: auto;
    display: block;
    border-radius: 6px;
}
.sidebar-brand .brand-logo { height: 44px; }
.login-logo-img {
    width: 108px;
    height: auto;
    display: block;
    margin-bottom: 0.5rem;
    border-radius: 10px;
}

/* --- Tarjeta de curso (listado del front) --- */
.course-list { display: flex; flex-direction: column; }
.course-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin-bottom: 0.85rem;
    box-shadow: 0 1px 2px rgba(20, 33, 61, 0.04);
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.course-card:hover { box-shadow: 0 0.4rem 1rem rgba(20, 33, 61, 0.08); transform: translateY(-1px); }
.course-card__info { flex: 1 1 auto; min-width: 0; }
.course-card__info .course-link { margin-bottom: 0.35rem; }
.course-card__btn { flex: 0 0 auto; }
@media (max-width: 575.98px) {
    .course-card { flex-direction: column; align-items: stretch; }
    .course-card__btn { width: 100%; }
}

/* --- Metadatos de curso (conteos) --- */
.course-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.course-meta__item {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent-600);
    background: var(--accent-soft);
    border-radius: 999px;
    padding: 0.12rem 0.6rem;
}

/* --- Tarjeta de aplicativo --- */
.app-card {
    height: 100%;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.app-card:hover {
    box-shadow: 0 0.5rem 1.25rem rgba(20, 33, 61, 0.12);
    transform: translateY(-2px);
}
.app-card__icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent-600);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    margin-bottom: 0.6rem;
}

/* Ancho de página en dispositivos grandes: 1320px desde xl (≥1200), igual en
   todas las páginas del sitio (dashboard, cursos y aplicativos). */
@media (min-width: 1200px) {
    .container {
        max-width: 1320px;
    }
}

/* --- Aplicativo fusionado en el chrome de la plataforma --- */
.app-crumbs {
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}
/* Raíz del aplicativo: hereda ancho del .container y la fuente del sitio. Las
   reglas `body { … }` de cada plantilla se reescriben a este selector. */
.app-fused {
    width: 100%;
}
/* El título/subtítulo del aplicativo se muestran arriba (los del layout): se
   ocultan los propios de la plantilla para no duplicarlos. El intro se conserva. */
.app-fused #app-title,
.app-fused #app-subtitle {
    display: none;
}

/* --- Editor WYSIWYG (admin) --- */
.wysiwyg__toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}
.wysiwyg__editor {
    min-height: 300px;
    max-height: 60vh;
    overflow-y: auto;
    height: auto;
}
.wysiwyg__editor:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 0.2rem var(--accent-soft);
    outline: none;
}
.wysiwyg__editor h2 { font-size: 1.4rem; margin: 1rem 0 0.5rem; }
.wysiwyg__editor h3 { font-size: 1.15rem; margin: 0.9rem 0 0.4rem; }
.wysiwyg__editor blockquote { border-left: 3px solid var(--border); padding-left: 0.9rem; color: var(--muted); }

/* --- Contenido HTML de una lección --- */
.lesson-content {
    line-height: 1.7;
    color: var(--text);
}
.lesson-content img { max-width: 100%; height: auto; border-radius: 8px; }
.lesson-content h2,
.lesson-content h3 { margin-top: 1.6rem; margin-bottom: 0.6rem; color: var(--ink); }
.lesson-content p { margin-bottom: 1rem; }
.lesson-content table { width: 100%; margin-bottom: 1rem; border-collapse: collapse; }
.lesson-content table th,
.lesson-content table td { border: 1px solid var(--border); padding: 0.5rem 0.7rem; }
.lesson-content figure { margin: 0 0 1rem; }
.lesson-content pre { background: #f6f8fa; padding: 1rem; border-radius: 8px; overflow-x: auto; }

/* --- Runner --- */
.runner-bar {
    position: sticky;
    top: 60px;
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.7rem 1rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
}

.runner-timer {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    font-size: 1.1rem;
    padding: 0.2rem 0.7rem;
    border-radius: 0.5rem;
    background: var(--accent-soft);
    color: var(--accent-600);
}
.runner-timer.is-danger { background: #fdecec; color: #b42318; }
.runner-progress { font-size: 0.9rem; color: var(--muted); }

.question-card { margin-bottom: 1rem; }
.question-card .card-body { padding: 1.1rem 1.25rem; }
.question-number {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent-600);
}
.question-text { font-size: 1.05rem; font-weight: 500; margin: 0.35rem 0 0.9rem; }

.option {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
}
.option:hover { border-color: #c3c9d0; background: #f8fafc; }
.option input { margin-top: 0.15rem; }
.option__letter { font-weight: 600; color: var(--muted); min-width: 1.2rem; }
.option.is-correct { border-color: #12805c; background: #eafaf3; }
.option.is-wrong { border-color: #e0b4b4; background: #fdf0f0; }

.answered-dot { color: #12805c; }
.unanswered-dot { color: #cbd5e1; }

/* Panel numerado (modo pregunta a pregunta) */
.q-nav {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(2.4rem, 1fr));
    gap: 0.4rem;
}
.q-nav-btn {
    aspect-ratio: 1;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: #fff;
    color: var(--muted);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
}
.q-nav-btn:hover { border-color: var(--accent); }
.q-nav-btn.is-answered { background: #eafaf3; border-color: #12805c; color: #0c7a4f; }
.q-nav-btn.is-current { outline: 2px solid var(--accent); outline-offset: 1px; }

/* =========================================================================
   Login
   ========================================================================= */

.login-body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-sans);
    color: #1f2933;
    background: #eef2f6;
}

.login-shell { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }

.login-brand {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    overflow: hidden;
    color: #fff;
    background:
        radial-gradient(1200px 600px at 80% -10%, rgba(15, 118, 110, 0.45), transparent 60%),
        linear-gradient(135deg, var(--ink) 0%, #223c66 100%);
}

.login-brand::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(255, 255, 255, 0.10) 1px, transparent 1px);
    background-size: 22px 22px;
    opacity: 0.5;
    pointer-events: none;
}

.login-brand__content { position: relative; max-width: 26rem; }

.login-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 1rem;
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: 0.5px;
    color: var(--ink);
    background: #fff;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.login-brand__title { margin: 1.5rem 0 0.5rem; font-size: 2rem; font-weight: 700; line-height: 1.15; }
.login-brand__tag { margin: 0; font-size: 1.05rem; line-height: 1.6; color: rgba(255, 255, 255, 0.85); }

.login-panel { display: flex; align-items: center; justify-content: center; padding: 2rem 1.5rem; }
.login-card { width: 100%; max-width: 24rem; }
.login-card__title { margin: 0 0 0.35rem; font-size: 1.5rem; font-weight: 700; }
.login-card__subtitle { margin: 0 0 1.75rem; color: #6b7280; }
.login-actions { display: flex; flex-direction: column; gap: 0.85rem; }

.login-btn {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    width: 100%;
    padding: 0.85rem 1.1rem;
    border: 1px solid #d7dbe0;
    border-radius: 0.8rem;
    background: #fff;
    color: #202124;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

.login-btn:hover { border-color: #c3c9d0; box-shadow: 0 6px 18px rgba(16, 42, 67, 0.12); transform: translateY(-1px); }
.login-btn:focus-visible { outline: 3px solid rgba(15, 118, 110, 0.45); outline-offset: 2px; }
.login-btn__icon { display: inline-flex; width: 1.35rem; height: 1.35rem; flex: 0 0 auto; }
.login-btn__icon svg { width: 100%; height: 100%; display: block; }

.login-alert {
    margin-bottom: 1.25rem;
    padding: 0.8rem 1rem;
    border-radius: 0.7rem;
    background: #fdecec;
    border: 1px solid #f5c2c2;
    color: #9b1c1c;
    font-size: 0.92rem;
}

.login-foot { margin: 1.75rem 0 0; font-size: 0.8rem; color: #9aa3ad; text-align: center; }

@media (max-width: 860px) {
    .login-shell { grid-template-columns: 1fr; }
    .login-brand { padding: 2.5rem 1.5rem; min-height: 34vh; }
    .login-brand__title { font-size: 1.6rem; }
}
