/* ==============================================================
   Visor de cursos — Sistema de diseño «Subrayador»
   --------------------------------------------------------------
   Restilado con los tokens --cg-* de assets/css/theme.css.
   IMPORTANTE: se conservan TODOS los nombres de clase existentes
   porque assets/js/curso-viewer.js los usa como selectores
   (.sidebar, .open/.closed, .main-content, .expanded, .progress-*,
   .apartado-item, .visto, .nav-prev/.nav-next, .btn-certificate...).
   ============================================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Alias locales sobre los tokens globales del sistema */
    --primary-color: var(--cg-primary, #0C7C6C);
    --primary-dark: var(--cg-primary-dark, #095E52);
    --success-color: #16A34A;          /* verde semántico (completado) */
    --warning-color: var(--cg-marcador-dark, #F2CC0F);
    --danger-color: #B91C1C;           /* rojo semántico (error) */
    --text-dark: var(--cg-ink, #1E2A32);
    --text-muted: var(--cg-ink-soft, #52616B);
    --bg-gray: var(--cg-paper, #F8F7F4);
    --border-color: var(--cg-line, #E7E4DB);
    --sidebar-width: 320px;
}

body {
    font-family: 'Instrument Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    background: #fff;
}

/* --------------------------------------------------------------
   Iconos: esta página no carga FontAwesome, así que damos glifo
   visible a las clases fa-* usadas como hooks por el JS
   (markApartadoAsVisto alterna far/fa-circle ↔ fas/fa-check-circle).
   NO renombrar estas clases.
   -------------------------------------------------------------- */
.fas, .far {
    font-style: normal;
    display: inline-block;
    line-height: 1;
}
.fa-bars::before { content: "☰"; }
.fa-times::before { content: "✕"; }
.fa-chevron-left::before { content: "‹"; font-weight: 700; }
.fa-chevron-right::before { content: "›"; font-weight: 700; }
.fa-circle::before { content: "○"; }
.fa-check-circle::before { content: "✔"; }
.fa-tasks::before { content: "✎"; }
.fa-book::before { content: "📖"; }
.fa-trophy::before { content: "🏆"; }
.fa-certificate::before { content: "🎓"; }
.fa-file-alt::before { content: "📄"; }
.fa-rocket::before { content: "🚀"; }
.fa-user-plus::before { content: "👤"; }

/* Layout principal */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: #fff;
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar.closed {
    transform: translateX(-100%);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-gray);
    position: sticky;
    top: 0;
    z-index: 10;
}

.sidebar-header h2 {
    font-family: 'Bricolage Grotesque', sans-serif;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 5px;
    color: var(--text-dark);
}

.close-sidebar {
    display: none;
    position: absolute;
    right: 15px;
    top: 15px;
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px;
}

.close-sidebar:hover {
    color: var(--text-dark);
}

.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    background: #fff;
    transition: margin-left 0.3s ease;
}

.main-content.expanded {
    margin-left: 0;
}

/* Barra de progreso en sidebar: fondo line, relleno primary */
.progress-container {
    padding: 20px;
    background: white;
    border-bottom: 1px solid var(--border-color);
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 14px;
    color: var(--text-muted);
}

.progress-percentage {
    font-family: 'Bricolage Grotesque', sans-serif;
    font-weight: 700;
    color: var(--primary-color);
    font-size: 16px;
}

.progress-bar {
    height: 8px;
    background: var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.5s ease;
    border-radius: 10px;
}

.progress-stats {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

/* Índice del curso */
.course-index {
    padding: 15px 0;
}

.module-item {
    margin-bottom: 10px;
}

.module-header {
    padding: 12px 20px;
    background: var(--bg-gray);
    border-left: 4px solid var(--primary-color);
}

.module-number {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--primary-color);
    font-weight: 700;
    letter-spacing: 0.08em;
}

.module-title {
    font-family: 'Bricolage Grotesque', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    margin-top: 3px;
}

.apartados-list {
    list-style: none;
}

.apartado-item {
    border-left: 3px solid transparent;
    transition: all 0.2s;
}

.apartado-item a {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    text-decoration: none;
    color: var(--text-dark);
    gap: 10px;
    transition: background 0.2s;
}

.apartado-item:hover {
    background: var(--bg-gray);
}

/* Sección actual: fondo primary suave + subrayado de marca */
.apartado-item.active {
    background: rgba(12, 124, 108, 0.10);
    border-left-color: var(--primary-color);
}

.apartado-item.active .apartado-title {
    font-weight: 600;
    background-image: linear-gradient(to top,
        var(--cg-marcador, #FFE14D) 0%,
        var(--cg-marcador, #FFE14D) 3px,
        transparent 3px);
    padding-bottom: 2px;
}

.apartado-item.visto .apartado-check i {
    color: var(--success-color);
}

.apartado-check {
    font-size: 14px;
    color: var(--border-color);
}

.apartado-number {
    font-family: 'Spline Sans Mono', ui-monospace, monospace;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    min-width: 35px;
}

.apartado-title {
    flex: 1;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Tipos especiales de apartados */
.apartado-item.tipo-actividades {
    background: rgba(255, 225, 77, 0.18); /* tinte marcador */
}

.apartado-item.tipo-actividades .apartado-title i {
    color: var(--cg-marcador-dark, #F2CC0F);
}

.apartado-item.tipo-bibliografia {
    background: var(--bg-gray);
}

.apartado-item.tipo-bibliografia .apartado-title i {
    color: var(--text-muted);
}

/* Sección de certificado: tinta + marcador (señal de conversión) */
.certificate-section {
    padding: 20px;
    background: var(--cg-ink, #1E2A32);
    margin: 20px;
    border-radius: var(--cg-radius-card, 16px);
    text-align: center;
    color: white;
}

.certificate-badge {
    margin-bottom: 15px;
}

.certificate-badge i {
    font-size: 40px;
    margin-bottom: 10px;
    color: var(--cg-marcador, #FFE14D);
}

.certificate-badge span {
    display: block;
    font-family: 'Bricolage Grotesque', sans-serif;
    font-weight: 700;
    font-size: 16px;
}

.btn-certificate {
    display: inline-block;
    padding: 12px 24px;
    background: var(--cg-marcador, #FFE14D);
    color: var(--cg-ink, #1E2A32);
    text-decoration: none;
    border-radius: var(--cg-radius, 10px);
    font-weight: 700;
    transition: transform 0.2s, background-color 0.15s;
    box-shadow: 0 8px 20px -10px rgba(242, 204, 15, .8);
}

.btn-certificate:hover {
    background: var(--cg-marcador-dark, #F2CC0F);
    transform: translateY(-2px);
}

.btn-certificate i {
    margin-right: 8px;
}

/* Header del contenido */
.content-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--border-color);
    padding: 15px 30px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.btn-toggle-sidebar {
    background: var(--bg-gray);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    min-height: 44px; /* área táctil mínima */
    border-radius: var(--cg-radius, 10px);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: border-color 0.15s, color 0.15s;
}

.btn-toggle-sidebar:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.breadcrumb {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    min-width: 0;
}

.breadcrumb a {
    color: var(--primary-color);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.breadcrumb a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.breadcrumb i {
    font-size: 12px;
    color: var(--text-muted);
}

.breadcrumb span {
    color: var(--text-muted);
    white-space: nowrap;
}

/* Mini progreso: highlight de marcador (la firma de la marca) */
.progress-mini {
    background: var(--cg-marcador, #FFE14D);
    color: var(--cg-ink, #1E2A32);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
}

/* Contenido del apartado */
.apartado-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 30px;
}

.apartado-header {
    margin-bottom: 30px;
}

/* Etiqueta «Tema X.Y»: highlight completo de marcador */
.apartado-label {
    display: inline-block;
    background: var(--cg-marcador, #FFE14D);
    color: var(--cg-ink, #1E2A32);
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 12px;
}

.apartado-header h1 {
    font-family: 'Bricolage Grotesque', sans-serif;
    font-size: 32px;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1.15;
}

.content-body {
    font-size: 16px;
    line-height: 1.8;
    color: var(--text-dark);
}

.content-body h2 {
    font-family: 'Bricolage Grotesque', sans-serif;
    font-size: 24px;
    font-weight: 700;
    margin: 30px 0 15px;
    color: var(--text-dark);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 8px;
}

.content-body h3 {
    font-family: 'Bricolage Grotesque', sans-serif;
    font-size: 20px;
    font-weight: 600;
    margin: 25px 0 12px;
    color: var(--text-dark);
}

.content-body p {
    margin-bottom: 16px;
}

.content-body ul, .content-body ol {
    margin: 16px 0;
    padding-left: 30px;
}

.content-body li {
    margin-bottom: 8px;
}

.content-body strong {
    font-weight: 600;
    color: var(--text-dark);
}

.content-body code {
    font-family: 'Spline Sans Mono', ui-monospace, monospace;
    background: var(--bg-gray);
    border: 1px solid var(--border-color);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 14px;
}

.content-body blockquote {
    border-left: 4px solid var(--cg-marcador, #FFE14D);
    padding: 15px 20px;
    background: var(--bg-gray);
    border-radius: 0 var(--cg-radius, 10px) var(--cg-radius, 10px) 0;
    margin: 20px 0;
    font-style: italic;
}

.content-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}

.content-body table th {
    background: var(--bg-gray);
    padding: 12px;
    text-align: left;
    font-weight: 600;
    border: 1px solid var(--border-color);
}

.content-body table td {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
}

/* Navegación inferior */
.content-navigation {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-top: 50px;
    padding-top: 30px;
    border-top: 2px solid var(--border-color);
}

.nav-btn {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--cg-radius-card, 16px);
    text-decoration: none;
    color: var(--text-dark);
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.nav-btn:hover {
    border-color: rgba(12, 124, 108, 0.45);
    transform: translateY(-2px);
    box-shadow: 0 14px 34px -16px rgba(30, 42, 50, .22);
}

.nav-btn i {
    font-size: 22px;
    color: var(--primary-color);
}

.nav-btn div {
    flex: 1;
}

.nav-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.nav-title {
    display: block;
    font-family: 'Bricolage Grotesque', sans-serif;
    font-weight: 600;
    font-size: 14px;
}

.nav-prev {
    text-align: left;
}

.nav-next {
    text-align: right;
    justify-content: flex-end;
}

/* Botón final «Obtener certificado»: marcador = señal de conversión */
.nav-certificate {
    background: var(--cg-marcador, #FFE14D);
    color: var(--cg-ink, #1E2A32);
    border-color: var(--cg-marcador-dark, #F2CC0F);
    box-shadow: 0 8px 20px -10px rgba(242, 204, 15, .8);
}

.nav-certificate .nav-label,
.nav-certificate .nav-title {
    color: var(--cg-ink, #1E2A32);
}

.nav-certificate i {
    color: var(--cg-ink, #1E2A32);
}

.nav-certificate:hover {
    background: var(--cg-marcador-dark, #F2CC0F);
    border-color: var(--cg-marcador-dark, #F2CC0F);
    transform: scale(1.02);
}

/* Estado vacío */
.empty-state {
    text-align: center;
    padding: 80px 20px;
}

.empty-state i {
    font-size: 64px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.empty-state h2 {
    font-family: 'Bricolage Grotesque', sans-serif;
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 10px;
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 20px;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 12px 24px;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: var(--cg-radius, 10px);
    font-weight: 600;
    transition: background-color 0.15s;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 0 0 40px rgba(30, 42, 50, .35);
    }

    .close-sidebar {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

    .apartado-content {
        padding: 20px 15px;
    }

    .apartado-header h1 {
        font-size: 24px;
    }

    .content-navigation {
        flex-direction: column;
    }

    .nav-btn {
        flex-direction: column;
        text-align: center;
    }

    .breadcrumb {
        display: none;
    }
}
