:root {
    /* SUNSET THEME - LIGHT MODE */
    --primary-gradient: linear-gradient(135deg, #e77c58 0%, #ff480f 100%);
    --secondary-gradient: linear-gradient(135deg, #d60326 0%, #7d289d 100%);
    --success-gradient: linear-gradient(135deg, #28a745 0%, #218838 100%);
    --warning-gradient: linear-gradient(135deg, #ffc107 0%, #e0a800 100%);
    --danger-gradient: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    --text-color-light: #212529;
    --text-muted-light: #6c757d;
    --card-bg-light: rgba(255, 255, 255, 0.85);
    --body-bg-light: linear-gradient(108deg,#e77c58 3.84%,#ff480f 22.43%,#d60326 60.36%,#7d289d 96.59%);

    /* NIGHT SKY THEME - DARK MODE */
    --bg-dark: #100a1f;
    --bg-secondary-dark: #1c162c;
    --card-bg-dark: rgba(28, 22, 44, 0.85);
    --text-color-dark: #e8e4f2;
    --text-muted-dark: #9f91bf;
    --border-dark: rgba(255, 255, 255, 0.1);
    --primary-gradient-dark: linear-gradient(135deg, #ff8c42 0%, #ff3d6b 100%);

    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 25px rgba(0,0,0,0.15);
    --shadow-xl: 0 12px 35px rgba(0,0,0,0.2);
    
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    --border-radius-lg: 16px;
    --border-radius-xl: 20px;
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Base Styles --- */
* {
    transition: var(--transition);
}

body {
    background: var(--body-bg-light);
    background-attachment: fixed;
    min-height: 100vh;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--text-color-light);
    transition: background 0.5s ease, color 0.5s ease;
}

body::before {
    content: '';
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-image: 
        radial-gradient(circle at 25% 25%, rgba(255, 255, 255, 0.07) 0%, transparent 50%),
        radial-gradient(circle at 75% 75%, rgba(255, 255, 255, 0.07) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
    transition: opacity 0.5s ease;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-color-light);
    font-weight: 700;
}
.text-muted { color: var(--text-muted-light) !important; }

/* --- Components: Light Mode --- */
.card, .stats-card {
    border: none;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(10px);
    background: var(--card-bg-light);
    overflow: hidden;
}
.card-header {
    background: rgba(255, 255, 255, 0.7);
    border-bottom: 1px solid rgba(0,0,0,0.05);
}
.navbar {
    background: rgba(255, 255, 255, 0.8) !important;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg);
}
.navbar-brand {
    font-weight: 800;
    font-size: 1.25rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.form-control:focus, .form-select:focus {
    border-color: #e77c58;
    box-shadow: 0 0 0 0.2rem rgba(231, 124, 88, 0.25);
}
.input-group-text {
    background-color: #f8f9fa;
    border: 2px solid rgba(0,0,0,0.08);
    border-right: 0;
}

/* --- Dark Mode Overrides --- */
html[data-theme='dark'] body {
    background: var(--bg-dark);
    background-image: linear-gradient(180deg, var(--bg-dark) 0%, var(--bg-secondary-dark) 100%);
    color: var(--text-color-dark);
}
html[data-theme='dark'] body::before {
    background-image: 
        radial-gradient(circle at 15% 85%, rgba(214, 3, 38, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 85% 25%, rgba(231, 124, 88, 0.1) 0%, transparent 40%);
}
html[data-theme='dark'] h1, html[data-theme='dark'] h2, html[data-theme='dark'] h3, html[data-theme='dark'] h4, html[data-theme='dark'] h5, html[data-theme='dark'] h6 {
    color: var(--text-color-dark);
}
html[data-theme='dark'] .text-muted {
    color: var(--text-muted-dark) !important;
}
html[data-theme='dark'] .card,
html[data-theme='dark'] .card p,
html[data-theme='dark'] .card h5 {
    background: var(--card-bg-dark);
    color: var(--text-color-dark) !important;
}
html[data-theme='dark'] .card-header {
    background: rgba(255, 255, 255, 0.03);
    border-bottom-color: var(--border-dark);
}
html[data-theme='dark'] .navbar {
    background: rgba(28, 22, 44, 0.8) !important;
    border-bottom: 1px solid var(--border-dark);
}
html[data-theme='dark'] .navbar-brand {
    background: var(--primary-gradient-dark);
    -webkit-background-clip: text;
    background-clip: text;
}
html[data-theme='dark'] .form-control,
html[data-theme='dark'] .form-select {
    background: var(--bg-secondary-dark);
    border-color: var(--border-dark);
    color: var(--text-color-dark);
}
html[data-theme='dark'] .form-control:focus,
html[data-theme='dark'] .form-select:focus {
    background: var(--bg-secondary-dark);
    border-color: #ff480f;
    box-shadow: 0 0 0 0.2rem rgba(255, 72, 15, 0.2);
    color: var(--text-color-dark);
}
html[data-theme='dark'] .table thead th {
    background: rgba(255, 72, 15, 0.1);
    color: var(--text-color-dark);
}
html[data-theme='dark'] .table tbody tr:hover {
    background: rgba(255, 72, 15, 0.05);
}
html[data-theme='dark'] .table tbody td {
    border-bottom-color: var(--border-dark);
}
html[data-theme='dark'] .table-striped>tbody>tr:nth-of-type(odd)>* {
    --bs-table-accent-bg: rgba(255, 255, 255, 0.02);
    color: var(--text-color-dark);
}
html[data-theme='dark'] .glass-effect {
    background: rgba(22, 26, 35, 0.5);
    border-color: var(--border-dark);
}
html[data-theme='dark'] .form-label {
    color: var(--text-muted-dark);
}
html[data-theme='dark'] .form-control::placeholder {
    color: var(--text-muted-dark);
    opacity: 0.6;
}
html[data-theme='dark'] .input-group-text {
    background-color: var(--bg-secondary-dark);
    border-color: var(--border-dark);
}
html[data-theme='dark'] .form-control {
    color: var(--text-color-dark);
}

/* --- Theme Switcher --- */
.theme-switch-wrapper {
    display: flex;
    align-items: center;
}
.theme-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}
.theme-switch input { display: none; }

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #4A5568;
    border-radius: 24px;
    transition: .4s;
}
.slider:before {
    position: absolute;
    content: "";
    height: 16px; width: 16px;
    left: 4px; bottom: 4px;
    background-color: white;
    border-radius: 50%;
    transition: .4s;
}
input:checked + .slider {
    background: var(--primary-gradient);
}
html[data-theme='dark'] input:checked + .slider {
    background: var(--primary-gradient-dark);
}
input:checked + .slider:before {
    transform: translateX(24px);
}
.theme-icon { font-size: 1.1rem; }
.theme-icon.fa-sun { color: #e77c58; }
.theme-icon.fa-moon { color: #9f91bf; }
html[data-theme='dark'] .theme-icon.fa-sun { color: #9f91bf; }
html[data-theme='dark'] .theme-icon.fa-moon { color: #e8e4f2; }

/* --- Aurora Background --- */
@keyframes aurora-move {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
body::after {
    content: '';
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: radial-gradient(circle at 15% 85%, rgba(214, 3, 38, 0.15), transparent 40%),
                radial-gradient(circle at 85% 25%, rgba(231, 124, 88, 0.1), transparent 40%);
    z-index: -2;
    animation: aurora-move 20s ease-in-out infinite;
    opacity: 0;
    transition: opacity 0.5s ease;
}
html[data-theme='dark'] body::after {
    opacity: 1;
}

/* --- Wrapper & Sidebar Layout --- */
.wrapper {
    display: flex;
    min-height: 100vh;
}
.sidebar {
    width: 260px;
    flex-shrink: 0; /* Prevents sidebar from shrinking */
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(25px);
    border-right: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
}
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    width: calc(100% - 260px); /* Adjust width */
    margin-left: 260px; /* Push content to the right */
    transition: all 0.3s ease;
}

/* Ensure non-sidebar pages take full width */
body:not(.has-sidebar) .main-content {
    width: 100%;
    margin-left: 0;
}
.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}
.sidebar-nav {
    flex-grow: 1;
    padding: 1rem;
}
.sidebar-link {
    display: flex;
    align-items: center;
    padding: 0.85rem 1.25rem;
    color: var(--text-color-light);
    font-weight: 500;
    border-radius: var(--border-radius-md);
    margin-bottom: 0.5rem;
    text-decoration: none;
    transition: all 0.2s ease;
}
.sidebar-link:hover {
    background: rgba(255,255,255,0.2);
    color: #fff;
    transform: translateX(5px);
}
.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
}
.logout-link { width: 100%; text-align: center; }

html[data-theme='dark'] .sidebar {
    background: rgba(28, 22, 44, 0.5);
    border-right-color: var(--border-dark);
}
html[data-theme='dark'] .sidebar-header,
html[data-theme='dark'] .sidebar-footer {
    border-color: var(--border-dark);
}
html[data-theme='dark'] .sidebar-link {
    color: var(--text-muted-dark);
}
html[data-theme='dark'] .sidebar-link:hover {
    color: var(--text-color-dark);
    background: rgba(255,255,255,0.05);
}

/* --- Component & FX Upgrades --- */
.btn {
    box-shadow: 0 0 1px 1px rgba(255,255,255,0.3) inset, 0 5px 10px rgba(0,0,0,0.2);
}
.btn:hover {
    box-shadow: 0 0 20px 0 var(--hover-glow-color, #ff480f),
                0 0 1px 1px rgba(255,255,255,0.3) inset;
}
.btn-primary:hover { --hover-glow-color: #ff480f; }
.btn-success:hover { --hover-glow-color: #28a745; }
.btn-danger:hover { --hover-glow-color: #dc3545; }
html[data-theme='dark'] .btn:hover {
    box-shadow: 0 0 20px 0 var(--hover-glow-color, #ff8c42),
                0 0 1px 1px rgba(255,255,255,0.1) inset;
}

.card {
    border-top: 1px solid;
    border-image-slice: 1;
    border-image-source: linear-gradient(to left, #e77c58, #d60326);
}
html[data-theme='dark'] .card {
    border-image-source: linear-gradient(to left, #ff8c42, #ff3d6b);
}

.animated-card {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}
.animated-card.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.sidebar-link.active, .sidebar-link.active:hover {
    background: var(--primary-gradient);
    color: #fff;
    box-shadow: var(--shadow-md);
    transform: translateX(5px) scale(1.02);
}
html[data-theme='dark'] .sidebar-link {
    color: var(--text-muted-dark);
}
html[data-theme='dark'] .sidebar-link:hover,
html[data-theme='dark'] .sidebar-link.active {
    color: var(--text-color-dark);
    background: rgba(255,255,255,0.05);
}
html[data-theme='dark'] .sidebar-link.active {
    background: var(--primary-gradient-dark);
}

/* Fix Navbar link colors */
.navbar .nav-link {
    color: #4a5568;
}
html[data-theme='dark'] .navbar .nav-link {
    color: var(--text-muted-dark);
}
html[data-theme='dark'] .navbar .nav-link:hover {
    color: var(--text-color-dark);
}

/* Stats Cards */
.stats-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stats-card-content {
    flex-grow: 1;
}

.stats-card-icon {
    font-size: 3rem;
    opacity: 0.15;
    transition: all 0.4s ease;
    position: absolute;
    right: 1.5rem;
    bottom: 1rem;
    transform: rotate(-10deg);
}

.stats-card:hover .stats-card-icon {
    opacity: 0.3;
    transform: rotate(5deg) scale(1.1);
}

.stats-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--primary-gradient);
}

html[data-theme='dark'] .stats-card {
    background: var(--card-bg-dark);
    border: 1px solid var(--border-dark);
}

html[data-theme='dark'] .stats-card-icon {
    opacity: 0.1;
}
html[data-theme='dark'] .stats-card:hover .stats-card-icon {
    opacity: 0.2;
}

/* === Responsive Sidebar & Mobile Tweaks === */
@media (max-width: 991.98px) {
    /* Hide sidebar by default on mobile */
    .sidebar {
        transform: translateX(-100%);
        position: fixed;
        top: 0;
        left: 0;
        width: 240px;
        height: 100vh;
        z-index: 1001; /* above overlay */
        transition: transform 0.3s ease;
    }
    .sidebar.show {
        transform: translateX(0);
    }
    /* Overlay behind sidebar when open */
    .sidebar-overlay {
        display: none;
    }
    .sidebar-overlay.show {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.55);
        backdrop-filter: blur(2px);
        z-index: 1000;
    }
    /* Main content full-width when sidebar hidden */
    .main-content {
        width: 100% !important;
        margin-left: 0 !important;
    }
    /* Mobile hamburger button */
    #sidebarToggle {
        border: none;
        background: transparent;
        color: var(--text-color-light);
        font-size: 1.5rem;
    }
    html[data-theme='dark'] #sidebarToggle {
        color: var(--text-color-dark);
    }
}

/* === Dark-mode tweaks === */
html[data-theme='dark'] .btn-outline-secondary,
html[data-theme='dark'] .btn-outline-primary,
html[data-theme='dark'] .btn-outline-success,
html[data-theme='dark'] .btn-outline-danger,
html[data-theme='dark'] .btn-outline-warning,
html[data-theme='dark'] .btn-outline-info {
    color: var(--text-color-dark);
    border-color: var(--border-dark);
}
html[data-theme='dark'] .btn-outline-secondary:hover,
html[data-theme='dark'] .btn-outline-primary:hover,
html[data-theme='dark'] .btn-outline-success:hover,
html[data-theme='dark'] .btn-outline-danger:hover,
html[data-theme='dark'] .btn-outline-warning:hover,
html[data-theme='dark'] .btn-outline-info:hover {
    color: #fff;
    background: var(--primary-gradient-dark);
    border-color: transparent;
}
html[data-theme='dark'] .table thead th {
    background: rgba(255, 255, 255, 0.03);
}

/* === Table text fix for dark mode === */
html[data-theme='dark'] .table,
html[data-theme='dark'] .table td,
html[data-theme='dark'] .table th {
    color: var(--text-color-dark) !important;
}

/* === Bootstrap table palette override (dark) === */
html[data-theme='dark'] .table {
    --bs-table-bg: rgba(255, 255, 255, 0.02); /* even rows */
    --bs-table-striped-bg: rgba(255, 255, 255, 0.04); /* odd rows when .table-striped */
    --bs-table-hover-bg: rgba(255, 255, 255, 0.06);
    --bs-table-border-color: var(--border-dark);
}

/* === Fix white blocks & labels in dark mode === */
html[data-theme='dark'] .bg-white {
    background-color: var(--card-bg-dark) !important;
    color: var(--text-color-dark) !important;
}
html[data-theme='dark'] label,
html[data-theme='dark'] .form-check-label {
    color: var(--text-color-dark);
}

/* Explicit row backgrounds when variables not applied */
html[data-theme='dark'] .table tbody tr:nth-of-type(odd) {
    background-color: rgba(255,255,255,0.04);
}
html[data-theme='dark'] .table tbody tr:nth-of-type(even) {
    background-color: rgba(255,255,255,0.02);
}
html[data-theme='dark'] .table-hover tbody tr:hover {
    background-color: rgba(255,255,255,0.06);
}

/* === Sidebar brand contrast === */
.sidebar .navbar-brand {
    /* Apply plain text color in light mode for readability */
    background: none !important;
    -webkit-text-fill-color: var(--text-color-light) !important;
    color: var(--text-color-light) !important;
}
html[data-theme='dark'] .sidebar .navbar-brand {
    /* Restore gradient text in dark mode */
    background: var(--primary-gradient-dark) !important;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: transparent;
}
html[data-theme='dark'] .sidebar .navbar-brand {
    background: none !important;
    -webkit-text-fill-color: var(--text-color-dark) !important;
    color: var(--text-color-dark) !important;
}

/* === Timeline Component === */
.timeline {
    position: relative;
    padding: 0;
    margin: 0;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 20px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, #e77c58, #d60326);
    border-radius: 1px;
}

.timeline-item {
    position: relative;
    padding-left: 60px;
    margin-bottom: 1.5rem;
}

.timeline-item:last-child {
    margin-bottom: 0;
}

.timeline-marker {
    position: absolute;
    left: 10px;
    top: 5px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    border: 3px solid rgba(255,255,255,0.9);
    z-index: 1;
}

.timeline-content {
    background: rgba(255, 255, 255, 0.7);
    border-radius: var(--border-radius-md);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
    border-left: 3px solid #e77c58;
    transition: var(--transition);
}

.timeline-content:hover {
    box-shadow: var(--shadow-md);
    transform: translateX(5px);
}

/* Dark mode timeline */
html[data-theme='dark'] .timeline::before {
    background: linear-gradient(to bottom, #ff8c42, #ff3d6b);
}

html[data-theme='dark'] .timeline-marker {
    background: var(--primary-gradient-dark);
    border-color: var(--bg-secondary-dark);
}

html[data-theme='dark'] .timeline-content {
    background: var(--card-bg-dark);
    border-left-color: #ff8c42;
    color: var(--text-color-dark);
}

/* Badge overrides for sessions */
.badge.bg-success {
    background: linear-gradient(135deg, #28a745, #20c997) !important;
}

.badge.bg-primary {
    background: var(--primary-gradient) !important;
}

html[data-theme='dark'] .badge.bg-primary {
    background: var(--primary-gradient-dark) !important;
}
