/*
 * nav-sidebar-patch.css
 * Append to style.css  OR  enqueue separately after main-style.
 * Covers: header courses dropdown + sidebar accordion + dark mode.
 */

/* ═══════════════════════════════════════════════════
   1. HEADER — General fixes
═══════════════════════════════════════════════════ */

.header-container {
    align-items: center;   /* vertically center logo + nav */
    gap: 20px;
}

.site-branding {
    flex-shrink: 0;
}

/* Nav sits right, fully centred vertically */
.main-navigation {
    display: flex;
    align-items: center;
}

#primary-menu {
    display: flex;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 4px;
}

#primary-menu > li > a {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    border-radius: 6px;
    color: #fff;
    font-weight: 500;
    font-size: 0.95rem;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.2s ease, color 0.2s ease;
}

#primary-menu > li > a:hover {
    background: rgba(255,255,255,0.15);
}

.nav-arrow {
    font-size: 0.72em;
    opacity: 0.8;
    transition: transform 0.2s ease;
}

/* ═══════════════════════════════════════════════════
   2. HEADER — Courses dropdown
═══════════════════════════════════════════════════ */

.has-courses-dropdown {
    position: relative;
}

.courses-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 220px;
    background: #fff;
    border: 1px solid #e0e4e8;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    list-style: none;
    padding: 8px 0;
    margin: 0;
    z-index: 2000;
    animation: dropdownFade 0.15s ease;
}

@keyframes dropdownFade {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.has-courses-dropdown:hover .courses-dropdown,
.has-courses-dropdown.dropdown-open .courses-dropdown {
    display: block;
}

.has-courses-dropdown:hover .nav-arrow {
    transform: rotate(180deg);
}

.courses-dropdown li a {
    display: block;
    padding: 9px 18px;
    color: #333;
    font-size: 0.92rem;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}

.courses-dropdown li a:hover {
    background: #f0faf3;
    color: #2f8d46;
}

/* Active category highlight in dropdown */
.courses-dropdown li.current-cat a {
    color: #2f8d46;
    font-weight: 600;
    background: #e8f5ec;
}

/* ═══════════════════════════════════════════════════
   3. SIDEBAR — Accordion (GFG-style)
═══════════════════════════════════════════════════ */

.sliding-sidebar {
    padding-top: 0;
}

.sidebar-close {
    display: block;
    width: 100%;
    text-align: right;
    padding: 12px 16px;
    background: #e8e8e8;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    font-weight: 600;
    color: #444;
    transition: background 0.2s ease;
}

.sidebar-close:hover {
    background: #d4d4d4;
}

.sidebar-nav {
    padding: 8px 0 40px;
}

/* Subject row */
.sidebar-subject {
    border-bottom: 1px solid #e8e8e8;
}

.sidebar-subject-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0;
}

.sidebar-subject-link {
    flex: 1;
    display: block;
    padding: 12px 16px;
    color: #1e1e1e;
    font-weight: 600;
    font-size: 0.93rem;
    text-decoration: none;
    transition: color 0.2s ease;
}

.sidebar-subject-link:hover {
    color: #2f8d46;
}

/* Active subject link */
.sidebar-subject.open > .sidebar-subject-header > .sidebar-subject-link {
    color: #2f8d46;
}

/* Toggle arrow button */
.sidebar-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 12px 14px;
    color: #888;
    font-size: 0.85rem;
    transition: color 0.2s ease;
    line-height: 1;
}

.sidebar-toggle-btn:hover {
    color: #2f8d46;
}

.toggle-arrow {
    display: inline-block;
    transition: transform 0.22s ease;
}

.sidebar-subject.open .toggle-arrow {
    transform: rotate(90deg);
}

/* Topics list */
.sidebar-topic-list {
    list-style: none;
    padding: 0;
    margin: 0;
    background: #fafafa;
    border-top: 1px solid #eee;
}

.sidebar-topic-item a {
    display: block;
    padding: 9px 16px 9px 26px;
    color: #444;
    font-size: 0.88rem;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all 0.15s ease;
}

.sidebar-topic-item a:hover {
    color: #2f8d46;
    background: #f0faf3;
    border-left-color: #2f8d46;
}

.sidebar-topic-item.current-topic a {
    color: #2f8d46;
    font-weight: 600;
    background: #e8f5ec;
    border-left-color: #2f8d46;
}

.sidebar-empty {
    padding: 20px 16px;
    color: #888;
    font-size: 0.9rem;
}

/* ═══════════════════════════════════════════════════
   4. MOBILE nav overrides
═══════════════════════════════════════════════════ */

@media (max-width: 768px) {
    #primary-menu {
        flex-direction: column;
        align-items: flex-start;
        gap: 0;
        padding-top: 60px;
    }

    #primary-menu > li {
        width: 100%;
    }

    #primary-menu > li > a {
        border-radius: 0;
        padding: 14px 20px;
        font-size: 1rem;
        width: 100%;
    }

    .courses-dropdown {
        position: static;
        box-shadow: none;
        border: none;
        border-top: 1px solid rgba(255,255,255,0.15);
        border-radius: 0;
        background: #1e4b28;
        animation: none;
        padding: 0;
    }

    .courses-dropdown li a {
        color: #c8e6d0;
        padding: 11px 20px 11px 34px;
        font-size: 0.92rem;
    }

    .courses-dropdown li a:hover {
        background: rgba(255,255,255,0.08);
        color: #fff;
    }

    /* On mobile dropdown shows when parent has class */
    .has-courses-dropdown .courses-dropdown {
        display: none;
    }

    .has-courses-dropdown.dropdown-open .courses-dropdown {
        display: block;
    }
}

/* ═══════════════════════════════════════════════════
   5. DARK MODE
═══════════════════════════════════════════════════ */

[data-theme="dark"] .courses-dropdown {
    background: #1a1d27;
    border-color: #2e3348;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

[data-theme="dark"] .courses-dropdown li a {
    color: #c8d0e8;
}

[data-theme="dark"] .courses-dropdown li a:hover {
    background: #162a1f;
    color: #5bc87a;
}

[data-theme="dark"] .courses-dropdown li.current-cat a {
    background: #0d2018;
    color: #5bc87a;
}

[data-theme="dark"] .sidebar-close {
    background: #2a2e42;
    color: #b0b8cc;
}

[data-theme="dark"] .sidebar-close:hover {
    background: #353a55;
}

[data-theme="dark"] .sidebar-subject {
    border-bottom-color: #2e3348;
}

[data-theme="dark"] .sidebar-subject-link {
    color: #c8d0e8;
}

[data-theme="dark"] .sidebar-subject-link:hover,
[data-theme="dark"] .sidebar-subject.open > .sidebar-subject-header > .sidebar-subject-link {
    color: #5bc87a;
}

[data-theme="dark"] .sidebar-toggle-btn {
    color: #6a7490;
}

[data-theme="dark"] .sidebar-toggle-btn:hover {
    color: #5bc87a;
}

[data-theme="dark"] .sidebar-topic-list {
    background: #13161f;
    border-top-color: #2e3348;
}

[data-theme="dark"] .sidebar-topic-item a {
    color: #8a93b0;
}

[data-theme="dark"] .sidebar-topic-item a:hover {
    color: #5bc87a;
    background: #0d1f14;
    border-left-color: #5bc87a;
}

[data-theme="dark"] .sidebar-topic-item.current-topic a {
    color: #5bc87a;
    background: #0a1a10;
    border-left-color: #5bc87a;
}

@media (max-width: 768px) {
    [data-theme="dark"] .courses-dropdown {
        background: #111822;
        border-top-color: rgba(255,255,255,0.08);
    }
}