
:root {
    --background-light: #f8fafc;
    --foreground-light: #1e293b;
    --card-light: #ffffff;
    --card-foreground-light: #1e293b;
    --primary-light: #3b82f6;
    --primary-foreground-light: #ffffff;
    --secondary-light: #e2e8f0;
    --secondary-foreground-light: #475569;
    --muted-light: #f1f5f9;
    --muted-foreground-light: #64748b;
    --accent-light: #dbeafe;
    --accent-foreground-light: #1e40af;
    --border-light: #e2e8f0;
    --input-light: #ffffff;
    --ring-light: #3b82f6;
    --header-light: #ffffff;
    --shadow-light: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg-light: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    --background-dark: #0f172a;
    --foreground-dark: #f1f5f9;
    --card-dark: #1e293b;
    --card-foreground-dark: #f1f5f9;
    --primary-dark: #3b82f6;
    --primary-foreground-dark: #ffffff;
    --secondary-dark: #334155;
    --secondary-foreground-dark: #cbd5e1;
    --muted-dark: #1e293b;
    --muted-foreground-dark: #94a3b8;
    --accent-dark: #1e40af;
    --accent-foreground-dark: #dbeafe;
    --border-dark: #334155;
    --input-dark: #1e293b;
    --ring-dark: #3b82f6;
    --header-dark: #1e293b;
    --shadow-dark: 0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 1px 2px 0 rgba(0, 0, 0, 0.2);
    --shadow-lg-dark: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--background);
    color: var(--foreground);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

/* Header Styles */
.header {
    background: var(--header);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    backdrop-filter: blur(8px);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo i {
    color: var(--primary);
    font-size: 1.5rem;
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--foreground);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.search-container {
    position: relative;
    display: flex;
    align-items: center;
}

.search-container i {
    position: absolute;
    left: 0.75rem;
    color: var(--muted-foreground);
    z-index: 1;
}

.search-container input {
    padding: 0.5rem 0.75rem 0.5rem 2.5rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--input);
    color: var(--foreground);
    width: 300px;
    transition: all 0.2s ease;
}

.search-container input:focus {
    outline: none;
    border-color: var(--ring);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.view-toggle,
.theme-toggle,
.github-link {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--input);
    color: var(--foreground);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.view-toggle:hover,
.theme-toggle:hover,
.github-link:hover {
    background: var(--accent);
    color: var(--accent-foreground);
}

/* Breadcrumb */
.breadcrumb {
    position: fixed;
    top: 67px; /* dont even */
    left: 0;
    right: 0;
    background: var(--muted);
    border-bottom: 1px solid var(--border);
    z-index: 999;
}

.breadcrumb-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

.breadcrumb i {
    color: var(--primary);
}

/* Main Container */
.main-container {
    display: flex;
    margin-top: 116px;
    min-height: calc(100vh - 125px);
}

/* Center content when sidebar is hidden (desktop) */
@media (min-width: 769px) {
  .main-container.sidebar-hidden {
    justify-content: center;
  }
  .main-container.sidebar-hidden .content-wrapper {
    flex: 0 1 auto;
  }
  .main-container.sidebar-hidden .sidebar {
    position: absolute;
    left: 0;
    transform: translateX(-100%);
    z-index: 100;
  }
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: var(--card);
    border-right: 1px solid var(--border);
    transition: transform 0.3s ease;
    position: relative;
    box-shadow: var(--shadow);
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

.sidebar-toggle {
    position: absolute;
    top: 1rem;
    right: -30px;
    background: var(--primary);
    color: var(--primary-foreground);
    border: none;
    border-radius: 0 0.5rem 0.5rem 0;
    padding: 0.5rem;
    cursor: pointer;
    z-index: 100;
}

.navigation {
    padding: 1.5rem;
    height: 100%;
    overflow-y: auto;
}

.navigation ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.navigation li {
    margin-bottom: 0.25rem;
}

.navigation li > div {
    font-weight: 600;
    color: var(--foreground);
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    background: var(--muted);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navigation .folder-header {
    cursor: pointer;
    transition: background-color 0.2s ease;
    user-select: none;
}

.navigation .folder-header:hover {
    background: var(--accent);
    color: var(--accent-foreground);
}

.navigation .folder-toggle {
    transition: transform 0.2s ease;
    font-size: 0.75rem;
    width: 12px;
    text-align: center;
}

.navigation .folder-content {
    margin-left: 1rem;
    margin-top: 0.5rem;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.2s ease;
}

.navigation .folder-content.collapsed {
    max-height: 0;
    opacity: 0;
}

.navigation .folder-content.expanded {
    max-height: none;
    opacity: 1;
}

.navigation a {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--muted-foreground);
    text-decoration: none;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.navigation a:hover {
    background: var(--accent);
    color: var(--accent-foreground);
    transform: translateX(4px);
}

/* Highlight selected file in sidebar */
.navigation a.active {
    background: var(--primary);
    color: var(--primary-foreground);
}

/* Content Wrapper */
.content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.content-view {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Course screen (detail view) */
.course-screen {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.course-view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.course-view-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 600;
}

.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

.file-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1rem;
    box-shadow: var(--shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.file-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.file-card .meta {
    color: var(--muted-foreground);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0.5rem;
    color: var(--muted-foreground);
    background: var(--muted);
    border: 1px dashed var(--border);
    border-radius: 0.75rem;
    padding: 2rem;
}

/* Dashboard */
.dashboard {
    display: block;
}

.dashboard-header {
    text-align: center;
    margin-bottom: 3rem;
}

.dashboard-header h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.dashboard-header i {
    color: var(--primary);
}

.dashboard-header p {
    color: var(--muted-foreground);
    font-size: 1.125rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-card i {
    font-size: 2rem;
    color: var(--primary);
}

.stat-info h3 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.stat-info p {
    color: var(--muted-foreground);
    font-size: 0.875rem;
}

/* Courses Grid */
.courses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
    align-items: stretch;
}

.course-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.25rem 1.25rem 1rem 1.25rem;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.course-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--accent-foreground));
}

.course-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.course-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.course-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--foreground);
}

.course-icon {
    color: var(--primary);
    font-size: 1.25rem;
}

.course-meta {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

.course-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.course-progress {
    background: var(--muted);
    border-radius: 0.5rem;
    height: 6px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.course-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent-foreground));
    transition: width 0.3s ease;
}

/* Content Display */
.content {
    display: none;
    background: var(--card);
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    padding: 2rem;
    box-shadow: var(--shadow);
    line-height: 1.8;
}

.content.active {
    display: block;
}

/* Content toolbar above file content */
.content-toolbar {
    display: flex;
    align-items: stretch;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-bottom: 0.75rem;
}

/* Generic button style used in toolbars, sidebar controls, and headers */
.btn {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--muted);
    color: var(--foreground);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-family: inherit;
    font-size: 0.875rem;
}

.btn:hover {
    background: var(--accent);
    color: var(--accent-foreground);
}

/* Image-based note rendering */
.content figure.image-note {
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.content figure.image-note img {
    width: 100%;
    max-width: 900px;
    height: auto;
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
}

.content figure.image-note figcaption {
    font-size: 0.85rem;
    color: var(--muted-foreground);
    text-align: center;
}

.content .unsupported-note {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 2rem 1rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
}

.content .unsupported-note i {
    font-size: 2rem;
    color: #ef4444;
}

/* Small pill badge (e.g., Quiz / No quiz) */
.badge {
    display: inline-block;
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--card);
}

/* Search results panel */
.search-panel {
    position: fixed;
    top: 120px;
    left: 50%;
    transform: translateX(-50%);
    width: min(900px, 92vw);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    box-shadow: var(--shadow-lg);
    z-index: 1001;
    overflow: hidden;
}

.search-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    color: var(--muted-foreground);
    font-size: 0.85rem;
}

.search-list {
    max-height: 60vh;
    overflow: auto;
}

.search-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

.search-item:hover,
.search-item.active {
    background: var(--accent);
    color: var(--accent-foreground);
}

.search-item-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-weight: 600;
}

.search-item-meta {
    color: var(--muted-foreground);
    font-size: 0.85rem;
}

.search-snippet {
    margin-top: 0.25rem;
    color: var(--foreground);
    font-size: 0.9rem;
}

.search-snippet mark {
    background: var(--accent);
    color: var(--accent-foreground);
    padding: 0 2px;
    border-radius: 3px;
}

.content {
    word-break: break-word;
    overflow-wrap: anywhere;
}

.content h1,
.content h2,
.content h3,
.content h4,
.content h5,
.content h6 {
    color: var(--foreground);
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.content h1 {
    font-size: 2rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0.5rem;
}

.content h2 {
    font-size: 1.5rem;
}

.content h3 {
    font-size: 1.25rem;
}

.content p {
    margin-bottom: 1rem;
    color: var(--foreground);
}

.content code {
    background: var(--muted);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
}

.content pre {
    background: var(--muted);
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 1rem 0;
}

.content ul,
.content ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.content li {
    margin-bottom: 0.5rem;
}

.content blockquote {
    border-left: 4px solid var(--primary);
    padding-left: 1rem;
    margin: 1rem 0;
    font-style: italic;
    color: var(--muted-foreground);
}

/* Mathematical Content Styling */
.content .MathJax {
    font-size: 1.1em !important;
}

.content .MathJax_Display {
    margin: 1.5rem 0 !important;
    text-align: center !important;
}

.content mjx-container[jax="CHTML"][display="true"] {
    margin: 1.5rem 0 !important;
    text-align: center !important;
}

/* Table Styling for Mathematical References */
.content table {
    border-collapse: collapse;
    width: 100%;
    margin: 1.5rem 0;
    background: var(--card);
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: var(--shadow);
    table-layout: fixed;
}

.content th,
.content td {
    border: 1px solid var(--border);
    padding: 0.75rem;
    text-align: left;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.content th {
    background: var(--muted);
    font-weight: 600;
    color: var(--foreground);
}

.content td {
    color: var(--foreground);
}

.content tr:nth-child(even) {
    background: var(--muted);
}

.content tr:hover {
    background: var(--accent);
}

/* Code Block Styling for Decision Trees */
.content pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    color: var(--foreground);
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    line-height: 1.4;
}

/* Highlight Important Mathematical Concepts */
.content strong {
    color: inherit;
    font-weight: 600;
}

.content em {
    color: inherit;
    font-style: italic;
}

/* Warning/Note Styling */
.content p:has(⚠️) {
    background: rgba(245, 158, 11, 0.1);
    border-left: 4px solid #f59e0b;
    padding: 1rem;
    border-radius: 0.5rem;
    margin: 1rem 0;
}

/* Mathematical Formula Containers */
.content p:has(.MathJax) {
    text-align: center;
}

/* Inline Math Styling */
.content mjx-container[jax="CHTML"] {
    display: inline-block;
    margin: 0 0.1em;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        padding: 1rem;
    }
    
    .search-container input {
        width: 200px;
    }
    
    .logo h1 {
        font-size: 1rem;
    }
    
    .sidebar {
        width: 280px;
        position: fixed;
        left: 0;
        top: 125px;
        height: calc(100vh - 125px);
        z-index: 998;
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-container {
        margin-left: 0;
    }
    
    .content-view {
        padding: 1rem;
    }
    
    .courses-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .logo h1 {
        display: none;
    }
    
    .logo::after {
        content: "Leiden DSAI";
        font-size: 1rem;
        font-weight: 600;
        color: var(--foreground);
    }
}

/* Light Theme */
body:not(.dark-mode) {
    --background: var(--background-light);
    --foreground: var(--foreground-light);
    --card: var(--card-light);
    --card-foreground: var(--card-foreground-light);
    --primary: var(--primary-light);
    --primary-foreground: var(--primary-foreground-light);
    --secondary: var(--secondary-light);
    --secondary-foreground: var(--secondary-foreground-light);
    --muted: var(--muted-light);
    --muted-foreground: var(--muted-foreground-light);
    --accent: var(--accent-light);
    --accent-foreground: var(--accent-foreground-light);
    --border: var(--border-light);
    --input: var(--input-light);
    --ring: var(--ring-light);
    --header: var(--header-light);
    --shadow: var(--shadow-light);
    --shadow-lg: var(--shadow-lg-light);
}

/* Dark Theme */
body.dark-mode {
    --background: var(--background-dark);
    --foreground: var(--foreground-dark);
    --card: var(--card-dark);
    --card-foreground: var(--card-foreground-dark);
    --primary: var(--primary-dark);
    --primary-foreground: var(--primary-foreground-dark);
    --secondary: var(--secondary-dark);
    --secondary-foreground: var(--secondary-foreground-dark);
    --muted: var(--muted-dark);
    --muted-foreground: var(--muted-foreground-dark);
    --accent: var(--accent-dark);
    --accent-foreground: var(--accent-foreground-dark);
    --border: var(--border-dark);
    --input: var(--input-dark);
    --ring: var(--ring-dark);
    --header: var(--header-dark);
    --shadow: var(--shadow-dark);
    --shadow-lg: var(--shadow-lg-dark);
}

body.dark-mode .theme-toggle i::before {
    content: "\f185"; /* sun icon */
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--muted);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--muted-foreground);
}

/* Quiz CTA (loaded before quiz.css to style the banner) */
.quiz-cta {
    margin: 1rem 0 1.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--muted);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.quiz-cta button {
    margin-left: auto;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--primary);
    background: var(--primary);
    color: var(--primary-foreground);
    cursor: pointer;
}
