/* ===== CSS Variables & Theme ===== */
:root {
    --primary: #4A90D9;
    --primary-dark: #357ABD;
    --primary-light: #6BA3E0;
    --primary-bg: #EBF2FC;
    --secondary: #6C757D;
    --success: #28A745;
    --success-bg: #D4EDDA;
    --danger: #DC3545;
    --danger-bg: #F8D7DA;
    --warning: #FFC107;
    --warning-bg: #FFF3CD;
    --info: #17A2B8;
    --info-bg: #D1ECF1;

    --bg: #F5F7FA;
    --bg-card: #FFFFFF;
    --bg-sidebar: #FFFFFF;
    --bg-nav: #FFFFFF;
    --bg-input: #FFFFFF;
    --bg-hover: #F0F2F5;
    --bg-active: #EBF2FC;

    --text: #1A1A2E;
    --text-secondary: #6C757D;
    --text-muted: #9CA3AF;
    --text-inverse: #FFFFFF;

    --border: #E2E8F0;
    --border-focus: #4A90D9;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --shadow-xl: 0 16px 48px rgba(0,0,0,0.16);

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 50%;

    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono: 'Cascadia Code', 'Fira Code', monospace;

    --nav-height: 64px;
    --sidebar-width: 260px;
    --transition: 0.2s ease;
}

[data-theme="dark"] {
    --bg: #0F172A;
    --bg-card: #1E293B;
    --bg-sidebar: #1E293B;
    --bg-nav: #1E293B;
    --bg-input: #334155;
    --bg-hover: #334155;
    --bg-active: #1E3A5F;
    --primary-bg: #1E3A5F;

    --text: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;

    --border: #334155;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

img {
    max-width: 100%;
    display: block;
}

/* ===== Layout ===== */
#app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== Navigation ===== */
#main-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--bg-nav);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    z-index: 100;
    box-shadow: var(--shadow-sm);
    gap: 24px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 200px;
}

.nav-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.5px;
}

.nav-search {
    flex: 1;
    max-width: 480px;
}

.nav-search input {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text);
    font-size: 0.9rem;
    transition: all var(--transition);
}

.nav-search input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.15);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.nav-icon-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.nav-icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
}

/* User Menu */
.user-menu {
    position: relative;
}

.user-avatar-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border: none;
    background: transparent;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text);
    transition: background var(--transition);
}

.user-avatar-btn:hover {
    background: var(--bg-hover);
}

.avatar {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-full);
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
}

.avatar.avatar-sm {
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
}

.avatar.avatar-lg {
    width: 48px;
    height: 48px;
    font-size: 1.1rem;
}

.dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 200;
}

.dropdown-item {
    display: block;
    padding: 10px 16px;
    color: var(--text);
    font-size: 0.9rem;
    transition: background var(--transition);
}

.dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.dropdown hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 4px 0;
}

/* ===== Sidebar ===== */
#app-body {
    display: flex;
    margin-top: var(--nav-height);
    min-height: calc(100vh - var(--nav-height));
}

#sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    position: fixed;
    top: var(--nav-height);
    left: 0;
    bottom: 0;
    overflow-y: auto;
    padding: 16px 0;
    z-index: 50;
    transition: transform var(--transition);
}

#sidebar::-webkit-scrollbar {
    width: 4px;
}

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

.sidebar-section {
    padding: 0 12px;
    margin-bottom: 8px;
}

.sidebar-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    padding: 8px 12px 4px;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    transition: all var(--transition);
    cursor: pointer;
}

.sidebar-item:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.sidebar-item.active {
    background: var(--bg-active);
    color: var(--primary);
    font-weight: 600;
}

.sidebar-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar-item .sidebar-badge {
    margin-left: auto;
    background: var(--primary);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
}

.sidebar-course-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ===== Main Content ===== */
#main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 24px 32px;
    max-width: calc(100% - var(--sidebar-width));
}

#page-content {
    max-width: 1200px;
    margin: 0 auto;
}

/* ===== Page Headers ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.page-header h2 {
    font-size: 1.35rem;
    font-weight: 600;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.breadcrumb a {
    color: var(--text-secondary);
}

.breadcrumb span {
    color: var(--text);
    font-weight: 500;
}

/* ===== Utility Classes ===== */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-primary { color: var(--primary) !important; }
.font-mono { font-family: var(--font-mono); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.grid { display: grid; }
.w-full { width: 100%; }

/* Slide Panel */
.slide-panel {
    position: fixed;
    top: var(--nav-height);
    right: 0;
    width: 380px;
    height: calc(100vh - var(--nav-height));
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-xl);
    z-index: 150;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.slide-panel:not(.hidden) {
    transform: translateX(0);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 1;
}

.panel-body {
    padding: 16px 20px;
}

/* Loading States */
.loading-spinner {
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    flex-direction: column;
    gap: 16px;
    color: var(--text-muted);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

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

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