:root {
    --bg-dark: #0f1115;
    --bg-sidebar: #16181d;
    --bg-card: #1e2128;
    --bg-hover: #262a33;
    --accent: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.3);
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --border: rgba(255, 255, 255, 0.08);
    --sidebar-width: 280px;
    --topbar-height: 70px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
    /* App-like feel */
    height: 100vh;
}

/* Layout Grid */
/* Layout Grid */
.app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    height: 100vh;
    transition: grid-template-columns 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-layout.collapsed {
    grid-template-columns: 0px 1fr;
}

/* Sidebar */
.sidebar {
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px;
    height: 100%;
    z-index: 10;
    overflow: hidden;
    /* Ocultar contenido al colapsar */
    white-space: nowrap;
    /* Evitar saltos de línea feos */
}

.sidebar-header {
    margin-bottom: 30px;
}

.logo {
    font-size: 1.4rem;
    font-weight: 700;
    color: white;
}

.highlight {
    color: var(--accent);
}

.subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 5px;
}

.sidebar-nav {
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 5px;
}

/* Scrollbar fina */
.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 4px;
}

/* Nav Items */
.nav-group {
    margin-bottom: 15px;
}

.nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-primary);
    font-weight: 600;
    transition: all 0.2s;
    user-select: none;
}

.nav-header:hover {
    background: var(--bg-hover);
}

.nav-header.active {
    background: var(--accent);
    color: white;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.nav-subitems {
    padding-left: 15px;
    margin-top: 5px;
    display: none;
    /* Collapsed by default */
    animation: slideDown 0.2s ease-out;
}

.nav-subitems.open {
    display: block;
}

.nav-item {
    padding: 10px 15px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: 0.2s;
}

.nav-item:hover {
    color: white;
    background: rgba(255, 255, 255, 0.03);
}

.nav-item.active-topic {
    color: var(--accent);
    background: rgba(99, 102, 241, 0.1);
    font-weight: 500;
}

/* Main Content */
.main-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    position: relative;
}

/* Topbar */
.topbar {
    height: var(--topbar-height);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    background: rgba(15, 17, 21, 0.8);
    backdrop-filter: blur(10px);
    z-index: 5;
}

.breadcrumbs {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.breadcrumbs span {
    color: white;
}

.search-container {
    position: relative;
    width: 300px;
}

.search-container i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.search-container input {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 10px 10px 10px 40px;
    border-radius: 20px;
    color: white;
    outline: none;
    font-family: inherit;
    transition: border 0.3s;
}

.search-container input:focus {
    border-color: var(--accent);
}

/* Content Area */
.content-scroll {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0 30px;
    /* Padding vertical 0 para sticky flush */
    padding-bottom: 50px;
}

/* Empty State */
.empty-state {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: var(--text-secondary);
}

/* Video Grid */
.section-info {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
}

.section-info h2 {
    font-size: 1.8rem;
}

.badge {
    background: var(--bg-card);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    border: 1px solid var(--border);
}

.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
}

.video-card {
    background: var(--bg-card);
    overflow: hidden;
    border: 1px solid var(--border);
    transition: transform 0.2s;
}

.video-card:hover {
    transform: translateY(-5px);
    border-color: rgba(255, 255, 255, 0.2);
}

.video-preview {
    position: relative;
    width: 100%;
    /* Aspect Ratio 16:9 Moderno */
    aspect-ratio: 16 / 9;
    background: #000;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Capa de imagen de fondo ajustada */
.thumb-layer,
.placeholder-bg {
    background-size: contain !important;
    /* Asegura que se vea completa sin recorte */
    background-repeat: no-repeat !important;
    background-position: center !important;
    background-color: #000;
    /* Fondo negro para rellenar huecos si el ratio no es exacto */
}

border: none;
z-index: 1;
}

/* ESCUDO: Bloqueador de Esquina (Pop-out button) */
.popout-blocker {
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 80px;
    z-index: 20;
    cursor: default;
}

/* ESCUDO: Bloqueador de Título */
.title-blocker {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    z-index: 19;
}

.overlay-shield {
    position: absolute;
    inset: 0;
    pointer-events: none;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.6);
    z-index: 2;
}

.video-details {
    padding: 15px;
}

.video-name {
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 5px;
    color: #ececec;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Loaders */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile */
.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .app-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        left: -100%;
        width: 280px;
        height: 100%;
        transition: 0.3s;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    }

    .sidebar.active {
        left: 0;
    }

    .mobile-only {
        display: block;
        background: none;
        border: none;
        color: white;
        font-size: 1.5rem;
        cursor: pointer;
    }
}

/* Actualizaciones para Vista One-Page */

.course-page-title {
    font-size: 2.5rem;
    margin-top: 40px;
    /* Nuevo margen superior */
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
    animation: fadeIn 0.5s ease;
}

/* Ajuste de Secciones Compactas */
/* Ajuste de Secciones Compactas */
.course-section {
    position: relative;
    padding-top: 10px;
    padding-bottom: 20px;
    /* Reducido */
    scroll-margin-top: 80px;
}

/* Sticky Headers V2: Diseño Tipo "Bloque" Sólido */
.section-header-sticky {
    position: sticky;
    top: 0;
    z-index: 50;

    background-color: var(--bg-dark);
    border-bottom: 1px solid var(--border);
    /* Borde más sutil */
    margin: 0 -30px 15px -30px;
    /* Margen inferior reducido */
    padding: 12px 30px;
    /* Padding vertical reducido */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);

    display: flex;
    align-items: center;
}

.section-header-sticky h2 {
    font-size: 1.4rem;
    color: var(--accent);
    /* Color acento para destacar más */
    margin: 0;
    font-weight: 700;
}


.section-header-sticky::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 24px;
    background: var(--accent);
    margin-right: 12px;
    border-radius: 4px;
}

/* Ajuste de navegación activa */
/* Ajuste de navegación activa (Diseño sutil) */
.nav-item.active-topic {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent);
    font-weight: 600;
    border-left: 3px solid var(--accent);
    padding-left: 12px;
}

/* Estilos para el Facade Player (Carga Rápida) */
.video-preview.placeholder {
    cursor: pointer;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.placeholder-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, #1a1c23 0%, #2d2f3a 100%);
    opacity: 0.8;
}

.play-button {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    z-index: 2;
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
}

.video-preview.placeholder:hover .play-button {
    background: var(--accent);
    border-color: var(--accent);
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
}

.placeholder-title {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 15px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    color: white;
    font-size: 0.9rem;
    z-index: 2;
    opacity: 0;
    transform: translateY(10px);
    transition: 0.3s;
}

.video-preview.placeholder:hover .placeholder-title {
    opacity: 1;
    transform: translateY(0);
}