/* ═══════════════════════════════════════════════════
   ReazonBi Academy — Global Sidebar Navigation
   Collapsible, all levels, all features
   ═══════════════════════════════════════════════════ */

/* ── App Layout: sidebar + main ── */
.app-with-sidebar {
    display: flex;
    min-height: 100vh;
    padding-top: 72px; /* header height */
}

/* ── Sidebar Base ── */
#academySidebar {
    width: 280px;
    min-width: 280px;
    height: calc(100vh - 72px);
    position: sticky;
    top: 72px;
    background: var(--navy-dark);
    border-left: 1px solid var(--border-subtle);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 100;
    transition: width 0.3s ease, min-width 0.3s ease;
    scrollbar-width: thin;
    scrollbar-color: rgba(197, 165, 90, 0.2) transparent;
}

[dir="ltr"] #academySidebar {
    border-left: none;
    border-right: 1px solid var(--border-subtle);
}

#academySidebar::-webkit-scrollbar {
    width: 4px;
}
#academySidebar::-webkit-scrollbar-track {
    background: transparent;
}
#academySidebar::-webkit-scrollbar-thumb {
    background: rgba(197, 165, 90, 0.2);
    border-radius: 4px;
}

/* ── Sidebar Header ── */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border-subtle);
}

.sidebar-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 0.5px;
}

.sidebar-collapse-all {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 0.9rem;
    transition: color 0.2s;
}
.sidebar-collapse-all:hover {
    color: var(--gold);
}

/* ── Section ── */
.sidebar-section {
    border-bottom: 1px solid rgba(27, 58, 92, 0.15);
}

.sidebar-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
}

.sidebar-section-header:hover {
    background: rgba(197, 165, 90, 0.04);
}

.sidebar-section-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.sidebar-section-header-left i {
    color: var(--gold);
    font-size: 0.75rem;
    width: 16px;
    text-align: center;
}

.sidebar-chevron {
    font-size: 0.6rem;
    color: var(--text-muted);
    transition: transform 0.25s ease;
}

/* Collapsed state */
.sidebar-section.collapsed .sidebar-section-content {
    display: none;
}
.sidebar-section.collapsed .sidebar-chevron {
    transform: rotate(-90deg);
}
[dir="ltr"] .sidebar-section.collapsed .sidebar-chevron {
    transform: rotate(-90deg);
}

/* ── Section Content ── */
.sidebar-section-content {
    padding: 0 0 8px 0;
}

/* ── Navigation Links ── */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 18px 8px 28px;
    color: var(--text-secondary);
    font-size: 0.78rem;
    text-decoration: none;
    transition: all 0.15s;
    border-right: 2px solid transparent;
}

[dir="ltr"] .sidebar-link {
    padding: 8px 28px 8px 18px;
    border-right: none;
    border-left: 2px solid transparent;
}

.sidebar-link i {
    width: 16px;
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.sidebar-link:hover {
    color: var(--text-primary);
    background: rgba(197, 165, 90, 0.04);
}

.sidebar-link.active {
    color: var(--gold);
    border-right-color: var(--gold);
    background: rgba(197, 165, 90, 0.06);
}

[dir="ltr"] .sidebar-link.active {
    border-right-color: transparent;
    border-left-color: var(--gold);
}

/* ── Level Dot ── */
.sidebar-level-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── Module Title ── */
.sidebar-module {
    margin-bottom: 4px;
}

.sidebar-module-title {
    padding: 6px 18px 6px 28px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-right: 2px solid rgba(197, 165, 90, 0.15);
    transition: all 0.15s;
}

[dir="ltr"] .sidebar-module-title {
    padding: 6px 28px 6px 18px;
    border-right: none;
    border-left: 2px solid rgba(197, 165, 90, 0.15);
}

.sidebar-module-title:hover {
    color: var(--text-primary);
    background: rgba(197, 165, 90, 0.03);
}

.sidebar-module.collapsed .sidebar-units {
    display: none;
}

/* ── Unit Links ── */
.sidebar-units {
    padding: 2px 0;
}

.sidebar-unit-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 18px 5px 40px;
    color: var(--text-muted);
    font-size: 0.72rem;
    text-decoration: none;
    transition: all 0.15s;
}

[dir="ltr"] .sidebar-unit-link {
    padding: 5px 40px 5px 18px;
}

.sidebar-unit-link:hover {
    color: var(--text-primary);
    background: rgba(27, 58, 92, 0.1);
}

.sidebar-unit-link.active {
    color: var(--gold);
    background: rgba(197, 165, 90, 0.06);
}

.sidebar-unit-num {
    font-weight: 700;
    font-size: 0.7rem;
    min-width: 24px;
}

.sidebar-unit-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Main Content Area ── */
.sidebar-main-content {
    flex: 1;
    min-width: 0;
    overflow-x: hidden;
}

/* ── Minimized sidebar ── */
#academySidebar.sidebar-minimized {
    width: 56px;
    min-width: 56px;
}

#academySidebar.sidebar-minimized .sidebar-title,
#academySidebar.sidebar-minimized .sidebar-section-header-left span,
#academySidebar.sidebar-minimized .sidebar-section-content,
#academySidebar.sidebar-minimized .sidebar-chevron {
    display: none;
}

#academySidebar.sidebar-minimized .sidebar-section-header {
    justify-content: center;
    padding: 12px 8px;
}

#academySidebar.sidebar-minimized .sidebar-section-header-left {
    gap: 0;
}

/* ── Mobile sidebar toggle button ── */
.sidebar-mobile-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 200;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--gold);
    color: var(--navy-darkest);
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(197, 165, 90, 0.3);
    animation: breathe-subtle 4s ease-in-out infinite;
}

[dir="ltr"] .sidebar-mobile-toggle {
    left: auto;
    right: 20px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    #academySidebar {
        position: fixed;
        top: 72px;
        right: 0;
        left: auto;
        width: 280px;
        min-width: 280px;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        box-shadow: -8px 0 32px rgba(0, 0, 0, 0.4);
    }

    [dir="ltr"] #academySidebar {
        right: auto;
        left: 0;
        transform: translateX(-100%);
        box-shadow: 8px 0 32px rgba(0, 0, 0, 0.4);
    }

    #academySidebar.sidebar-mobile-open {
        transform: translateX(0);
    }

    .sidebar-mobile-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar-main-content {
        width: 100%;
    }
}

@media (max-width: 480px) {
    #academySidebar {
        width: 260px;
        min-width: 260px;
    }
}
