/* ==============================
   DARK PREMIUM SIDEBAR - EXACT DESIGN
   ============================== */

/* Force drawer to be visible */
.drawer.drawer-left.not-initialized,
.theme_remui-drawers-courseindex.not-initialized {
    display: block !important;
}

/* CRITICAL: Hide the primary navigation drawer on module/course pages */
/* We only want the course index drawer, not the main site navigation */
html body #theme_remui-drawers-primary,
html body div#theme_remui-drawers-primary,
html body .drawer-primary {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    left: -9999px !important;
}

/* Sidebar base - Course Index Drawer (follows RemUI pattern) */
/* CRITICAL: Target ONLY the course index drawer, not other drawers */
html body #theme_remui-drawers-courseindex,
html body #theme_remui-drawers-courseindex.drawer,
html body #theme_remui-drawers-courseindex.drawer-left,
html body div#theme_remui-drawers-courseindex {
    --eginary-primary: #4f46e5;
    --eginary-secondary: #0ea5e9;
    --eginary-accent: #f97316;
    --eginary-surface: #ffffff;
    --eginary-background: #f6f9ff;
    --eginary-heading: #0f172a;
    --eginary-text: #1f2937;
    --eginary-muted: #94a3b8;
    background: linear-gradient(180deg, rgba(79, 70, 229, 0.04) 0%, rgba(14, 165, 233, 0.03) 45%, var(--eginary-surface) 100%) !important;
    padding: 18px 10px !important;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
    color: var(--eginary-text) !important;
    border-right: 1px solid rgba(148, 163, 184, 0.25) !important;
    position: fixed !important;
    top: 50px !important;
    bottom: 0 !important;
    height: auto !important;
    max-height: calc(100vh - 50px) !important;
    width: 350px !important;
    max-width: 350px !important;
    z-index: 1040 !important;
    transition: left 0.3s ease, visibility 0.3s ease, opacity 0.3s ease, transform 0.3s ease !important;
    box-shadow: 4px 0 18px rgba(79, 70, 229, 0.08), 0 8px 24px rgba(14, 165, 233, 0.06) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
}

/* CRITICAL: RemUI uses BOTH .show class AND aria-hidden attribute! */
/* We need to check BOTH to handle all scenarios */

/* Drawer is VISIBLE when:
   1. Has .show class, OR
   2. aria-hidden is false or missing */
html body #theme_remui-drawers-courseindex.show,
html body div#theme_remui-drawers-courseindex.show,
html body #theme_remui-drawers-courseindex.drawer.show,
html body #theme_remui-drawers-courseindex.drawer-left.show,
html body #theme_remui-drawers-courseindex:not([aria-hidden]),
html body #theme_remui-drawers-courseindex[aria-hidden="false"],
html body div#theme_remui-drawers-courseindex:not([aria-hidden]),
html body div#theme_remui-drawers-courseindex[aria-hidden="false"] {
    left: 0 !important;
    visibility: visible !important;
    opacity: 1 !important;
    transform: translateX(0) !important;
    pointer-events: auto !important;
    display: flex !important;
}

/* Drawer is HIDDEN when:
   1. Does NOT have .show class AND aria-hidden is true */
html body #theme_remui-drawers-courseindex:not(.show)[aria-hidden="true"],
html body div#theme_remui-drawers-courseindex:not(.show)[aria-hidden="true"] {
    left: -360px !important;
    visibility: hidden !important;
    opacity: 0 !important;
    transform: translateX(-100%) !important;
    pointer-events: none !important;
    display: flex !important;
}

/* Ensure drawer uses flexbox for proper content sizing and no cut-off */
html body #theme_remui-drawers-courseindex,
html body #theme_remui-drawers-courseindex.drawer,
html body #theme_remui-drawers-courseindex.drawer-left,
html body div#theme_remui-drawers-courseindex {
    display: flex !important;
    flex-direction: column !important;
}

/* Drawer content area must flex and scroll properly */
html body #theme_remui-drawers-courseindex .drawercontent,
html body #theme_remui-drawers-courseindex .drawer-content {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 0.5rem 0 !important;
}

/* Header should not shrink */
html body #theme_remui-drawers-courseindex .drawerheader,
html body #theme_remui-drawers-courseindex .drawer-header {
    flex: 0 0 auto !important;
    flex-shrink: 0 !important;
    margin: -18px -10px 1rem -10px !important;
}

/* Remove all default borders from all items */
#course-index .courseindex-section,
#course-index .courseindex-item,
.drawer .courseindex-section,
.drawer .courseindex-item,
.courseindex .courseindex-section,
.courseindex .courseindex-item,
html body .drawer .courseindex-section,
html body .drawer .courseindex-item {
    border: none !important;
    border-color: transparent !important;
}

/* Top title / Drawer Header - Neutral */
.drawer .drawerheader,
.drawer .drawer-header,
.theme_remui-drawers-courseindex .drawerheader,
.theme_remui-drawers-courseindex .drawer-header,
#course-index h4,
#course-index .courseindex-heading {
    background: transparent !important;
    font-size: 18px !important;
    font-weight: 700 !important;
    color: var(--eginary-heading) !important;
    padding: 1.5rem 1.25rem !important;
    border-bottom: 1px solid rgba(79, 70, 229, 0.1) !important;

    height: auto !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 10 !important;
}

/* Drawer title text */
.drawer .drawer-header .drawer-title,
.theme_remui-drawers-courseindex .drawer-header .drawer-title {
    color: var(--eginary-primary) !important;
    font-size: 0.875rem !important;
    font-weight: 700 !important;
    letter-spacing: 1.5px !important;
    text-transform: uppercase !important;
}

/* Hide large "Course Menu" text */
.drawer .drawerheader > h2,
.drawer .drawer-header > h2 {
    display: none !important;
}

/* Close button styling */
.drawer .drawerheader button.drawertoggle,
.drawer .drawer-header button.close {
    color: var(--eginary-primary) !important;
    background: rgba(255, 255, 255, 0.6) !important;
    border: none !important;
    border-radius: 6px !important;
    width: 32px !important;
    height: 32px !important;
}

.drawer .drawerheader button.drawertoggle:hover,
.drawer .drawer-header button.close:hover {
    background: rgba(255, 255, 255, 0.9) !important;
}

/* Drawer body */
.drawer .drawercontent,
.drawer .drawer-body,
.theme_remui-drawers-courseindex .drawercontent {
    padding: 0 !important;
    background: transparent !important;
    overflow-y: auto !important;
}

/* ========== SCROLLBARS ========== */
#course-index::-webkit-scrollbar,
.drawer .drawercontent::-webkit-scrollbar,
.drawer-left::-webkit-scrollbar,
.theme_remui-drawers-courseindex::-webkit-scrollbar {
    width: 6px !important;
}

#course-index::-webkit-scrollbar-track,
.drawer .drawercontent::-webkit-scrollbar-track,
.drawer-left::-webkit-scrollbar-track,
.theme_remui-drawers-courseindex::-webkit-scrollbar-track {
    background: transparent !important;
}

#course-index::-webkit-scrollbar-thumb,
.drawer .drawercontent::-webkit-scrollbar-thumb,
.drawer-left::-webkit-scrollbar-thumb,
.theme_remui-drawers-courseindex::-webkit-scrollbar-thumb {
    background: rgba(79, 70, 229, 0.35) !important;
    border-radius: 6px !important;
}

#course-index::-webkit-scrollbar-thumb:hover,
.drawer .drawercontent::-webkit-scrollbar-thumb:hover,
.drawer-left::-webkit-scrollbar-thumb:hover,
.theme_remui-drawers-courseindex::-webkit-scrollbar-thumb:hover {
    background: rgba(14, 165, 233, 0.45) !important;
}

/* ========== LESSON (Parent Level) ========== */
#course-index .courseindex-section,
.drawer .courseindex-section,
.theme_remui-drawers-courseindex .courseindex-section,
.courseindex .courseindex-section,
.courseindex-section.w-100,
.drawer .courseindex-section.w-100,
html body .drawer .courseindex-section,
html body .courseindex .courseindex-section {
    padding: 10px 6px !important;
    margin: 4px 0 !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    color: var(--eginary-heading) !important;
    border-radius: 6px !important;
    display: block !important;
    background: transparent !important;
    background-color: transparent !important;
    transition: background 0.2s ease !important;
    position: relative !important;
    box-shadow: none !important;
    border: none !important;
    width: auto !important;
    max-width: 100% !important;
}

/* Lesson hover - neutral (no highlight) */
#course-index .courseindex-section:hover,
.drawer .courseindex-section:hover,
.theme_remui-drawers-courseindex .courseindex-section:hover {
    background: transparent !important;
    color: var(--eginary-heading) !important;
}

/* ========== MODULE (Child Level 1) ========== */
#course-index .courseindex-item,
.drawer .courseindex-item,
.theme_remui-drawers-courseindex .courseindex-item,
.courseindex .courseindex-item,
html body .drawer .courseindex-item,
html body .courseindex .courseindex-item {
    padding: 8px 12px 8px 30px !important;
    margin: 3px 0 3px 10px !important;
    border-radius: 6px !important;
    font-size: 14px !important;
    color: var(--eginary-text) !important;
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    transition: all 0.2s ease !important;
    position: relative !important;
    cursor: pointer !important;
    box-shadow: none !important;
    outline: none !important;
}

/* Module hover - neutral (no highlight) */
#course-index .courseindex-item:hover,
.drawer .courseindex-item:hover,
.theme_remui-drawers-courseindex .courseindex-item:hover,
html body .drawer .courseindex-item:hover {
    background: transparent !important;
    color: var(--eginary-text) !important;
    border-color: transparent !important;
    box-shadow: none !important;
}

/* ========== ACTIVE MODULE - Light Blue Highlight with Bar ========== */
#course-index .courseindex-item.is-current,
#course-index .courseindex-item.active,
.courseindex .courseindex-item.active,
.drawer .courseindex-item.active,
.theme_remui-drawers-courseindex .courseindex-item.active,
.courseindex .courseindex-item.pageitem,
.drawer .courseindex-item.pageitem,
.theme_remui-drawers-courseindex .courseindex-item.pageitem,
.courseindex .courseindex-section.current > .courseindex-item,
.drawer .courseindex-section.current > .courseindex-item,
.courseindex .courseindex-item[aria-current="true"],
.drawer .courseindex-item[aria-current="true"],
html body .drawer .courseindex-item.active,
html body .drawer .courseindex-item.pageitem {
    background: transparent !important;
    background-color: transparent !important;
    color: var(--eginary-primary) !important;
    font-weight: 600 !important;
    border-radius: 6px !important;
    border-left: 5px solid var(--eginary-primary) !important;
    border-top: none !important;
    border-right: none !important;
    border-bottom: none !important;
    box-shadow: 0 6px 18px rgba(79, 70, 229, 0.22) !important;
    margin: 3px 0 3px 10px !important;
    padding: 8px 12px 8px 28px !important;
    position: relative !important;
}

/* Active item halo + card highlight */
html body #course-index .courseindex-item.active,
html body #course-index .courseindex-item.pageitem,
html body .drawer .courseindex-item.active,
html body .drawer .courseindex-item.pageitem,
html body .theme_remui-drawers-courseindex .courseindex-item.active,
html body .theme_remui-drawers-courseindex .courseindex-item.pageitem {
    position: relative !important;
    z-index: 1 !important;
}

html body #course-index .courseindex-item.active::before,
html body #course-index .courseindex-item.pageitem::before,
html body .drawer .courseindex-item.active::before,
html body .drawer .courseindex-item.pageitem::before,
html body .theme_remui-drawers-courseindex .courseindex-item.active::before,
html body .theme_remui-drawers-courseindex .courseindex-item.pageitem::before {
    content: "" !important;
    position: absolute !important;
    inset: -8px !important;
    border-radius: 14px !important;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.32) 0%, rgba(14, 165, 233, 0.18) 100%) !important;
    z-index: -2 !important;
    pointer-events: none !important;
    transition: opacity 0.2s ease, transform 0.2s ease !important;
    opacity: 1 !important;
    transform: scale(1) !important;
    box-shadow: 0 14px 32px rgba(79, 70, 229, 0.2) !important;
}

html body #course-index .courseindex-item.active::after,
html body #course-index .courseindex-item.pageitem::after,
html body .drawer .courseindex-item.active::after,
html body .drawer .courseindex-item.pageitem::after,
html body .theme_remui-drawers-courseindex .courseindex-item.active::after,
html body .theme_remui-drawers-courseindex .courseindex-item.pageitem::after {
    content: "" !important;
    position: absolute !important;
    inset: -2px !important;
    border-radius: 10px !important;
    background: linear-gradient(135deg, rgba(238, 242, 255, 0.95) 0%, rgba(224, 242, 254, 0.95) 100%) !important;
    z-index: -1 !important;
    pointer-events: none !important;
    transition: opacity 0.2s ease !important;
    box-shadow: 0 10px 26px rgba(14, 165, 233, 0.18) !important;
}

/* ========== SUB-SUB-ITEM (Nested) ========== */
#course-index .courseindex-item .courseindex-item,
.drawer .courseindex-section .courseindex-section .courseindex-item,
.drawer .courseindex-item .courseindex-section .courseindex-item,
html body .drawer .courseindex-section .courseindex-section .courseindex-item {
    margin-left: 20px !important;
    margin: 3px 0 3px 20px !important;
    font-size: 13px !important;
    opacity: 0.85 !important;
    padding: 8px 12px 8px 30px !important;
    background: transparent !important;
    background-color: transparent !important;
    color: var(--eginary-text) !important;
    position: relative !important;
}

/* ========== TEXT AND LINKS ========== */
.courseindex .courseindex-item .courseindex-link,
.drawer .courseindex-item .courseindex-link,
.courseindex .courseindex-item a,
.drawer .courseindex-item a,
.courseindex .courseindex-link,
.drawer .courseindex-link,
html body .drawer .courseindex-item .courseindex-link,
html body .drawer .courseindex-item a {
    color: var(--eginary-text) !important;
    text-decoration: none !important;
    font-weight: inherit !important;
}

/* Active item text - Dark blue on light blue background */
.courseindex .courseindex-item.active .courseindex-link,
.drawer .courseindex-item.active .courseindex-link,
.courseindex .courseindex-item.pageitem .courseindex-link,
.drawer .courseindex-item.pageitem .courseindex-link {
    color: var(--eginary-primary) !important;
    font-weight: 600 !important;
}

/* Section title text */
.courseindex .courseindex-section-title,
.drawer .courseindex-section-title,
html body .drawer .courseindex-section-title {
    color: var(--eginary-heading) !important;
    background: transparent !important;
    background-color: transparent !important;
    padding: 12px 6px !important;
    margin: 6px 0 !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    border: none !important;
}

/* ========== ICONS ========== */
/* Green checkmark icons - enhance visibility */
#course-index .treeitem img,
#course-index .treeitem .icon,
.drawer .courseindex-item .icon,
.drawer .courseindex-item img,
.courseindex .courseindex-item .icon,
.courseindex .courseindex-item img,
.drawer .activityicon,
.courseindex .activityicon {
    filter: brightness(1.2) saturate(1.2) !important;
}

/* Completion icons */
.courseindex .courseindex-item .completion-icon,
.drawer .courseindex-item .completion-icon {
    width: 20px !important;
    height: 20px !important;
    border-radius: 50% !important;
}

.courseindex .courseindex-item .completion-icon.completed,
.drawer .courseindex-item .completion-icon.completed {
    background: #10b981 !important;
    color: white !important;
}

/* Timeline connector - vertical line for nested items - BLUE */
#course-index .courseindex-item:not(.active):not(.pageitem)::before,
.drawer .courseindex-item:not(.active):not(.pageitem)::before,
.theme_remui-drawers-courseindex .courseindex-item:not(.active):not(.pageitem)::before,
html body .drawer .courseindex-item:not(.active):not(.pageitem)::before {
    content: "" !important;
    position: absolute !important;
    left: 10px !important;
    top: 0 !important;
    bottom: 0 !important;
    width: 2px !important;
    background: linear-gradient(180deg, rgba(79, 70, 229, 0.25) 0%, rgba(14, 165, 233, 0.18) 100%) !important;
    border: none !important;
    margin: 0 !important;
    display: block !important;
}

/* Timeline connector - horizontal line - BLUE */
#course-index .courseindex-item:not(.active):not(.pageitem)::after,
.drawer .courseindex-item:not(.active):not(.pageitem)::after,
.theme_remui-drawers-courseindex .courseindex-item:not(.active):not(.pageitem)::after,
html body .drawer .courseindex-item:not(.active):not(.pageitem)::after {
    content: "" !important;
    position: absolute !important;
    left: 10px !important;
    top: 50% !important;
    width: 12px !important;
    height: 2px !important;
    background: rgba(79, 70, 229, 0.35) !important;
    border: none !important;
    margin: 0 !important;
    display: block !important;
}

/* Remove timeline from last item in section */
.courseindex .courseindex-section > ul > li:last-child .courseindex-item::before,
.drawer .courseindex-section > ul > li:last-child .courseindex-item::before {
    bottom: 50% !important;
}

/* Chevron/Caret icons */
.courseindex .courseindex-item .courseindex-chevron,
.drawer .courseindex-item .courseindex-chevron,
.courseindex .courseindex-chevron,
.drawer .courseindex-chevron {
    margin-left: auto !important;
    color: var(--eginary-muted) !important;
    transition: transform 0.2s ease !important;
}

.courseindex .courseindex-item.collapsed .courseindex-chevron,
.drawer .courseindex-item.collapsed .courseindex-chevron {
    transform: rotate(-90deg) !important;
}

/* ========== NUCLEAR OVERRIDES - Remove all unwanted backgrounds ========== */

/* Force ALL courseindex elements transparent with black text */
.drawer [class*="courseindex"],
.drawer .courseindex *,
html body .drawer .courseindex *,
html body .drawer [class*="courseindex"],
.drawer-left [class*="courseindex"],
.drawer .courseindex-section *,
.drawer .courseindex-section > *,
.drawer ul.courseindex *,
.drawer ul.courseindex li * {
    background: transparent !important;
    background-color: transparent !important;
    color: var(--eginary-text) !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

/* Override section title backgrounds */
.courseindex .courseindex-section-title,
.drawer .courseindex-section-title,
html body .drawer .courseindex-section-title,
div[class*="courseindex-section-title"],
[class*="courseindex-section-title"] {
    background: transparent !important;
    background-color: transparent !important;
    color: var(--eginary-heading) !important;
    padding: 12px 6px !important;
    margin: 6px 0 !important;
    border: none !important;
}



#theme_remui-drawers-courseindex .drawercontent #courseindex #courseindex-content .courseindex .courseindex-section.delegated-section .courseindex-section-title,
#theme_remui-drawers-courseindex .drawercontent #course-index #courseindex-content .courseindex .courseindex-section.delegated-section .courseindex-section-title {
    padding-left: 30px !important;
}

/* Remove active/current backgrounds from parent theme */
html body .drawer .courseindex .courseindex-item.active,
html body .drawer .courseindex .courseindex-section.current,
html body .drawer .courseindex-item.indented {
    border-color: transparent !important;
}

/* Override RemUI parent theme backgrounds */
html body .drawer .courseindex .courseindex-item.active:not(.pageitem):not([aria-current="true"]) {
    background-color: transparent !important;
}

/* Additional support for .drawers container class toggle */
.drawers.show-drawer-left .theme_remui-drawers-courseindex,
.drawers.show-drawer-left #theme_remui-drawers-courseindex {
    left: 0 !important;
    visibility: visible !important;
}

/* Support for body class toggle (standard Moodle/RemUI) */
body.drawer-open-left #page.drawers {
    margin-left: 350px !important;
    transition: margin-left 0.3s ease !important;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1200px) {
    .drawer.drawer-left,
    .theme_remui-drawers-courseindex {
        width: 320px !important;
        max-width: 320px !important;
    }
}

@media (max-width: 767px) {
    .drawer.drawer-left,
    .theme_remui-drawers-courseindex {
        width: 320px !important;
        max-width: 320px !important;
        left: -320px !important;
    }
    
    html body.drawer-open-left .drawer.drawer-left.show,
    html body.show-drawer-left .drawer.drawer-left.show,
    html body.drawer-open-left .theme_remui-drawers-courseindex.show,
    html body.show-drawer-left .theme_remui-drawers-courseindex.show {
        left: 0 !important;
    }
}

/* ========== DRAWER TOGGLE BUTTON ========== */
.drawer-toggle,
button[data-action="toggle-drawer"] {
    background: linear-gradient(135deg, var(--eginary-primary) 0%, var(--eginary-secondary) 100%) !important;
    border: none !important;
    border-radius: 16px !important;
    width: 60px !important;
    height: 60px !important;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4), 0 0 20px rgba(102, 126, 234, 0.3) !important;
    position: relative !important;
    overflow: hidden !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.drawer-toggle::after,
button[data-action="toggle-drawer"]::after {
    content: '' !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 100%) !important;
    pointer-events: none !important;
}

.drawer-toggle:hover,
button[data-action="toggle-drawer"]:hover {
    transform: scale(1.05) translateY(-2px) !important;
    box-shadow: 0 12px 32px rgba(102, 126, 234, 0.5), 0 0 25px rgba(102, 126, 234, 0.4) !important;
}
