/* library/style.css – Wider Cards & Improved Visuals */

/* ----- MAIN LAYOUT ----- */
.library-page #main {
    padding-top: 96px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: #fdfdfd;
}

.library-container {
    display: flex;
    flex: 1;
    max-width: 1600px;
    width: calc(100% - 64px);
    margin: 32px auto;
    min-height: 600px;
    border: 1px solid var(--border, #eaeaea);
    border-radius: 12px;
    background: #fff;
    box-shadow: var(--shadow-sm, 0 2px 8px rgba(0,0,0,0.05));
    overflow: hidden;
}

/* ----- SIDEBAR ----- */
.library-sidebar {
    width: 320px;
    min-width: 70px;
    background: #fafafa;
    border-right: 1px solid var(--border, #eaeaea);
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Scoped Desktop Collapse Logic */
@media (min-width: 781px) {
    .library-sidebar.collapsed {
        width: 70px;
    }
    .library-sidebar.collapsed .sidebar-content,
    .library-sidebar.collapsed .sidebar-header h2 {
        display: none;
    }
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid var(--border, #eaeaea);
    height: 80px;
    flex-shrink: 0;
    background: #fff;
}

.library-sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 0;
}

.sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: var(--muted, #666);
    transition: color 0.2s;
}

.sidebar-toggle:hover {
    color: var(--accent, #EFBF04);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px 12px;
    -webkit-overflow-scrolling: touch;
}

/* ----- NESTED SECTIONS ----- */
.board-section, .level-section, .subject-section, .topic-section {
    margin-bottom: 6px;
}

.level-section { margin-left: 16px; border-left: 1px solid #eee; }
.subject-section { margin-left: 16px; border-left: 1px solid #eee; }
.topic-section { margin-left: 16px; }

.section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    user-select: none;
    font-weight: 500;
    color: var(--text, #333);
    transition: background 0.2s;
    border-radius: 6px;
    font-size: 14px;
}

.section-header:hover {
    background: #f3f4f6;
    color: var(--accent-hover, #d9ad00);
}

.collapse-btn {
    background: transparent;
    border: none;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #bbb;
    transition: transform 0.3s;
    cursor: pointer;
}

.section-title.active {
    color: var(--accent, #EFBF04);
    font-weight: 600;
    background: none;
    padding-left: 0;
    border-left: none;
}
.topic-section .section-title.active {
    color: var(--accent, #EFBF04);
    background: none;
    padding-left: 0;
    border-left: none;
}

/* Children containers – unified class .section-children */
.section-children {
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    max-height: 0;
}
.section-children:not(.collapsed) {
    max-height: 2000px;
}

/* ----- RIGHT CONTENT ----- */
.library-content {
    flex: 1;
    min-height: 0;
    background: #fff;
    padding: 40px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.library-content::-webkit-scrollbar { width: 8px; }
.library-content::-webkit-scrollbar-thumb {
    background: #e5e7eb;
    border-radius: 8px;
}
.library-content::-webkit-scrollbar-thumb:hover {
    background: var(--accent, #EFBF04);
}

.content-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 40px;
    gap: 20px;
}

.mobile-filter-btn {
    display: none; /* hidden on desktop */
}

.breadcrumb .crumb {
    font-size: 14px;
    color: var(--muted, #666);
    font-weight: 600;
    cursor: pointer;
}

.view-options { display: flex; gap: 10px; }

.view-btn {
    width: 42px;
    height: 42px;
    border: 1px solid var(--border, #eaeaea);
    background: #fff;
    border-radius: 8px;
    color: var(--muted, #666);
    cursor: pointer;
    transition: background 0.2s;
}

.view-btn.active {
    background: var(--accent, #EFBF04);
    border-color: var(--accent, #EFBF04);
    color: #000;
    box-shadow: 0 4px 12px rgba(239, 191, 4, 0.2);
}

/* ----- FILE GRID – WIDER CARDS & IMPROVED VISUALS ----- */
.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 28px;
    padding-top: 20px;
}

.file-card {
    display: flex;
    flex-direction: column;
    padding: 20px;
    background: #fff;
    border: 1px solid var(--border, #eaeaea);
    border-radius: 16px;
    transition: all 0.25s ease;
    text-decoration: none;
    color: inherit;
    gap: 16px;
}

.file-card:hover {
    border-color: #000;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.file-icon {
    font-size: 32px;
    color: #000;
    margin-bottom: 0;
}
.file-info h4 {
    margin: 0 0 6px;
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-info p {
    margin: 0;
    font-size: 13px;
    color: var(--muted, #666);
}

.file-actions {
    margin-top: auto;
    display: flex;
    gap: 12px;
    border-top: 1px solid var(--border, #eaeaea);
    padding-top: 14px;
}

.file-view, .file-download {
    flex: 1;
    background: #f9f9f9;
    border: 1px solid #eee;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    color: #444;
    transition: background 0.2s;
    text-decoration: none;
    text-align: center;
    font-size: 14px;
}

.file-view:hover, .file-download:hover {
    border-color: #EFBF04;
    color: var(--accent, #EFBF04);
}

/* ----- LIST VIEW ADJUSTMENTS ----- */
.file-grid.list-view {
    grid-template-columns: 1fr;
    gap: 12px;
}
.file-grid.list-view .file-card {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    gap: 20px;
}
.file-grid.list-view .file-icon {
    margin-bottom: 0;
    margin-right: 0;
    font-size: 28px;
}
.file-grid.list-view .file-info {
    flex: 1;
}
.file-grid.list-view .file-info h4 {
    font-size: 15px;
}
.file-grid.list-view .file-info p {
    font-size: 12px;
}
.file-grid.list-view .file-actions {
    margin-top: 0;
    border-top: none;
    padding-top: 0;
    gap: 12px;
    width: auto;
}
.file-grid.list-view .file-view,
.file-grid.list-view .file-download {
    width: 40px;
    padding: 8px;
}

/* ----- EMPTY STATE & LOADING ----- */
.loading-state, .empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 100px 20px;
    color: var(--muted, #666);
}
.empty-state a {
    color: var(--accent, #EFBF04);
    text-decoration: underline;
    font-size: 14px;
}

/* ----- RESPONSIVE: FULL SCREEN OVERLAY MOBILE MENU ----- */
@media (max-width: 780px) {
    .library-container {
        flex-direction: column;
        width: 100%;
        margin: 0;
        border-radius: 0;
        border: none;
        min-height: calc(100vh - 96px);
    }

    .mobile-filter-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        background: var(--accent, #EFBF04);
        color: #000;
        border: none;
        padding: 12px 20px;
        border-radius: 8px;
        font-weight: 600;
        cursor: pointer;
        font-size: 15px;
        box-shadow: 0 4px 12px rgba(239, 191, 4, 0.2);
        transition: transform 0.2s, box-shadow 0.2s;
    }

    .mobile-filter-btn:active {
        transform: scale(0.98);
    }

    .content-bar {
        flex-wrap: wrap;
    }

    .breadcrumb {
        width: 100%;
        order: 3;
        margin-top: 8px;
    }

    .view-options {
        margin-left: auto;
    }

    /* Fixed 100vw Overlay for the sidebar */
    .library-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        z-index: 9999;
        background: #fff;
        transform: translateX(0);
        border: none;
    }

    .library-sidebar.collapsed {
        transform: translateX(-100%);
    }

    .sidebar-header {
        height: 80px;
        padding: 0 24px;
        background: #fafafa;
        justify-content: space-between; /* ensures title and X are apart */
    }

    /* Override Desktop Chevron logic to output FontAwesome X */
    #sidebarToggle i::before {
        content: "\f00d" !important;
        font-size: 24px;
    }

    #sidebarToggle {
        color: var(--text, #333);
    }

    .library-content {
        padding: 24px 20px;
    }

    .file-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 20px;
    }
}