:root {
    /* =========================================
       COLOR PALETTE - PREMIUM MODERN
       ========================================= */
    /* Primary (Indigo) - Brand Identity */
    --primary-color: #4F46E5;
    /* Indigo 600 */
    --primary-light: #818CF8;
    /* Indigo 400 */
    --primary-dark: #3730A3;
    /* Indigo 800 */
    --primary-subtle: #EEF2FF;
    /* Indigo 50 */

    /* Secondary (Slate) - Backgrounds */
    --bg-main: #F8FAFC;
    /* Slate 50 */
    --bg-surface: #FFFFFF;
    /* White */
    --bg-subtle: #F1F5F9;
    /* Slate 100 */

    /* Typography Colors */
    --text-main: #1E293B;
    /* Slate 800 */
    --text-muted: #64748B;
    /* Slate 500 */
    --text-light: #94A3B8;
    /* Slate 400 */

    /* Functional Colors */
    --success: #10B981;
    /* Emerald 500 */
    --success-bg: #D1FAE5;
    /* Emerald 100 */
    --warning: #F59E0B;
    /* Amber 500 */
    --warning-bg: #FEF3C7;
    /* Amber 100 */
    --danger: #EF4444;
    /* Red 500 */
    --danger-bg: #FEE2E2;
    /* Red 100 */
    --info: #3B82F6;
    /* Blue 500 */

    /* =========================================
       GLASSMORPHISM TOKENS
       ========================================= */
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: 1px solid rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    --backdrop-blur: blur(16px);

    /* =========================================
       SPACING & RADIUS
       ========================================= */
    --radius-xl: 24px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --radius-xs: 4px;

    --header-height: 72px;
    --sidebar-width: 280px;
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =========================================
   DARK THEME OVERRIDES
   ========================================= */
[data-theme="dark"] {
    /* Backgrounds: Dark Slate Palette */
    --bg-main: #0F172A;
    /* Slate 900 */
    --bg-surface: #1E293B;
    /* Slate 800 */
    --bg-subtle: #334155;
    /* Slate 700 */

    /* Typography: Light Colors */
    --text-main: #F8FAFC;
    /* Slate 50 */
    --text-muted: #94A3B8;
    /* Slate 400 */
    --text-light: #64748B;
    /* Slate 500 */

    /* Primary Colors: Adjusted for Dark Mode Contrast */
    --primary-color: #6366F1;
    /* Indigo 500 (Brighter) */
    --primary-light: #818CF8;
    /* Indigo 400 */
    --primary-subtle: rgba(99, 102, 241, 0.1);

    /* Glassmorphism: Dark variation */
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* =========================================
   RESET & BASE STYLES
   ========================================= */
html {
    scroll-behavior: smooth;
    box-sizing: border-box;
    font-size: 16px;
}

*,
*::before,
*::after {
    box-sizing: inherit;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--text-main);
    background-color: var(--bg-main);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition-fast);
}

ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* =========================================
   TYPOGRAPHY
   ========================================= */
h1,
h2,
h3,
h4,
h5,
h6 {
    margin-top: 0;
    margin-bottom: 0.5em;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-main);
}

h1 {
    font-size: 2.25rem;
    line-height: 2.5rem;
}

h2 {
    font-size: 1.875rem;
    line-height: 2.25rem;
}

h3 {
    font-size: 1.5rem;
    line-height: 2rem;
}

p {
    margin-top: 0;
    margin-bottom: 1rem;
    line-height: 1.625;
    color: var(--text-muted);
}

.text-sm {
    font-size: 0.875rem;
}

.text-xs {
    font-size: 0.75rem;
}

.font-medium {
    font-weight: 500;
}

.font-bold {
    font-weight: 700;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

/* =========================================
   UTILITIES
   ========================================= */
.d-flex {
    display: flex;
}

.flex-column {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-1 {
    gap: 0.25rem;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-4 {
    gap: 1rem;
}

.w-full {
    width: 100%;
}

.h-full {
    height: 100%;
}

.hidden {
    display: none !important;
}

/* =========================================
   COMPONENTS: BUTTONS
   ========================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.9375rem;
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: white;
    box-shadow: 0 4px 6px rgba(79, 70, 229, 0.25);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 12px rgba(79, 70, 229, 0.35);
}

.btn-primary:disabled {
    background: var(--text-light);
    cursor: not-allowed;
    transform: none;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--text-light);
    color: var(--text-main);
}

.btn-outline:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: var(--bg-surface);
}

/* =========================================
   COMPONENTS: CARDS (Glassmorphism)
   ========================================= */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: var(--backdrop-blur);
    -webkit-backdrop-filter: var(--backdrop-blur);
    border: var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: var(--radius-xl);
    padding: 2rem;
}

/* =========================================
   COMPONENTS: FORMS
   ========================================= */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-surface);
    border: 1px solid #E2E8F0;
    border-radius: var(--radius-md);
    font-size: 1rem;
    color: var(--text-main);
    transition: var(--transition-fast);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-error {
    color: var(--danger);
    font-size: 0.8125rem;
    margin-top: 0.375rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* =========================================
   COMPONENTS: ALERTS / TOASTS
   ========================================= */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    min-width: 300px;
    padding: 1rem;
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideInRight 0.3s ease-out forwards;
    border-left: 4px solid var(--primary-color);
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: var(--danger);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 0px;
    }
}

/* =========================================
   LAYOUT: DASHBOARD
   ========================================= */
/* =========================================
   LAYOUT: DASHBOARD (Fixed Sidebar + Margin)
   ========================================= */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
    background: #F1F5F9;
}

/* Sidebar - Fixed Position */
.sidebar {
    background: var(--bg-surface);
    border-right: 1px solid #E2E8F0;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 280px;
    z-index: 100;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

/* Main Content - Pushed by Sidebar */
.main-content {
    flex: 1;
    padding: 2rem;
    margin-left: 280px;
    /* Width of sidebar */
    width: calc(100% - 280px);
    min-height: 100vh;
    transition: all 0.3s ease;
}

.brand {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 2.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-weight: 500;
    transition: all 0.2s;
}

.nav-link:hover,
.nav-link.active {
    background: var(--primary-subtle);
    color: var(--primary-color);
}

.sidebar-footer {
    padding-top: 1.5rem;
    border-top: 1px solid #E2E8F0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Mobile & Tablet Responsive */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        /* Hidden by default */
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 1.5rem;
    }

    /* =========================================
   COMMAND PALETTE (Spotlight Search)
   ========================================= */
    .palette-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(4px);
        z-index: 9999;
        display: flex;
        justify-content: center;
        align-items: flex-start;
        padding-top: 15vh;
        animation: fadeIn 0.15s ease-out;
    }

    .palette-modal {
        width: 100%;
        max-width: 600px;
        background: var(--bg-surface);
        border-radius: var(--radius-xl);
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
        overflow: hidden;
        display: flex;
        flex-direction: column;
        animation: slideDown 0.2s ease-out;
        border: 1px solid rgba(255, 255, 255, 0.1);
    }

    .palette-header {
        display: flex;
        align-items: center;
        padding: 1.5rem;
        border-bottom: 1px solid #E2E8F0;
        position: relative;
    }

    .palette-header input {
        width: 100%;
        font-size: 1.25rem;
        border: none;
        outline: none;
        background: transparent;
        color: var(--text-main);
        margin-left: 1rem;
    }

    .palette-header .search-icon {
        font-size: 1.25rem;
        color: var(--text-light);
    }

    .esc-hint {
        background: #E2E8F0;
        color: var(--text-muted);
        padding: 0.2rem 0.5rem;
        border-radius: 4px;
        font-size: 0.75rem;
        font-weight: 600;
    }

    .palette-content {
        max-height: 400px;
        overflow-y: auto;
        padding: 0.5rem;
    }

    .palette-section {
        padding: 0.5rem 1rem;
        font-size: 0.75rem;
        font-weight: 600;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.05em;
        margin-top: 0.5rem;
    }

    .palette-item {
        display: flex;
        align-items: center;
        padding: 0.75rem 1rem;
        color: var(--text-main);
        border-radius: var(--radius-md);
        cursor: pointer;
        text-decoration: none;
        transition: all 0.1s;
    }

    .palette-item .icon {
        margin-right: 1rem;
        font-size: 1.25rem;
        width: 24px;
        text-align: center;
    }

    .palette-item:hover,
    .palette-item.active {
        background: var(--primary-color);
        color: white;
    }

    .palette-footer {
        padding: 0.75rem 1.5rem;
        background: var(--bg-subtle);
        border-top: 1px solid #E2E8F0;
        display: flex;
        justify-content: space-between;
        font-size: 0.75rem;
        color: var(--text-muted);
    }

    @keyframes fadeIn {
        from {
            opacity: 0;
        }

        to {
            opacity: 1;
        }
    }

    @keyframes slideDown {
        from {
            transform: translateY(-20px);
            opacity: 0;
        }

        to {
            transform: translateY(0);
            opacity: 1;
        }
    }
}

/* =========================================
   AI SMART MENTOR WIDGET
   ========================================= */
#ai-widget-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9990;
    font-family: 'Inter', sans-serif;
}

#ai-fab {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), #6366f1);
    color: white;
    border: none;
    box-shadow: 0 10px 25px rgba(79, 70, 229, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    position: relative;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#ai-fab:hover {
    transform: scale(1.1) rotate(10deg);
}

.fab-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger);
    color: white;
    font-size: 0.75rem;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

#ai-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    animation: popIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

#ai-chat-window.hidden {
    display: none;
}

.ai-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    padding: 1rem;
    color: white;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ai-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.ai-info h4 {
    margin: 0;
    font-size: 1rem;
}

.status-dot {
    font-size: 0.75rem;
    color: #a7f3d0;
    display: flex;
    align-items: center;
    gap: 4px;
}

.status-dot::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    display: block;
}

.ai-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.5rem;
    cursor: pointer;
    margin-left: auto;
}

.ai-messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    background: var(--bg-main);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.4;
}

.message.bot {
    background: white;
    border-bottom-left-radius: 2px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    align-self: flex-start;
}

.message.user {
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 2px;
    align-self: flex-end;
}

.ai-input-area {
    padding: 1rem;
    background: white;
    border-top: 1px solid #eee;
    display: flex;
    gap: 0.5rem;
}

#ai-input {
    flex: 1;
    padding: 0.5rem 1rem;
    border: 1px solid #eee;
    border-radius: 20px;
    outline: none;
}

.ai-send {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}