/* Dark Mode Variables */
:root {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-active: rgba(255, 255, 255, 0.1);
    --card-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    --card-shadow-hover: 0 8px 16px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --sidebar-bg: #020617;
    --sidebar-text: #64748b;
    --sidebar-active: rgba(255, 255, 255, 0.15);
    --card-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    --card-shadow-hover: 0 8px 16px rgba(0, 0, 0, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow-x: hidden;
}

.dashboard-layout {
    display: flex;
    min-height: 100vh;
    background: var(--bg-primary);
    margin: 0 auto;
    
}

/* MOBILE TOGGLE BUTTON */
.mobile-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1002;
    /* HIGHER THAN OVERLAY AND SIDEBAR */
    background: var(--sidebar-bg);
    color: white;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    align-items: center;
    justify-content: center;
}

.mobile-toggle:hover {
    transform: scale(1.05);
}

.mobile-toggle span {
    font-size: 1.5rem;
    display: block;
}

/* SIDEBAR - DESKTOP */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: white;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 1001;
    /* HIGHER THAN OVERLAY (999) */
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateX(0);
    will-change: transform;
}

.sidebar-header {
    padding: 2rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar .logo {
    color: white;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 1.5rem;
}

.sidebar-nav {
    padding: 1.5rem 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.5rem;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.2s ease;
}

.nav-item:hover,
.nav-item.active {
    background: var(--sidebar-active);
    color: white;
}

.nav-item span {
    font-size: 1.25rem;
}

/* MAIN CONTENT - DESKTOP */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 2rem;
    transition: margin-left 0.3s ease;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.dashboard-header h1 {
    font-size: 2rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.dashboard-header p {
    color: var(--text-secondary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* OVERLAY FOR MOBILE - MUST BE BELOW SIDEBAR */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 999;
    /* BELOW SIDEBAR (1001) AND TOGGLE (1002) */
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.show {
    display: block !important;
    opacity: 1 !important;
}

/* ============================================
   TABLET STYLES (768px - 1024px)
   ============================================ */
@media (max-width: 1024px) and (min-width: 769px) {
    .sidebar {
        width: 220px;
    }

    .main-content {
        margin-left: 220px;
    }

    .sidebar-nav {
        padding: 1rem 0;
    }

    .nav-item {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
}

/* ============================================
   MOBILE STYLES (< 768px)
   ============================================ */
@media (max-width: 768px) {

    /* Show mobile toggle button */
    .mobile-toggle {
        display: flex !important;
    }

    /* Sidebar hidden by default - SLIDE LEFT */
    .sidebar {
        width: 280px;
        transform: translateX(-100%) !important;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
        z-index: 1001 !important;
        /* CRITICAL: MUST BE ABOVE OVERLAY */
    }

    /* Sidebar visible when open - SLIDE RIGHT */
    .sidebar.open {
        transform: translateX(0) !important;
    }

    /* Remove margin on mobile */
    .main-content {
        margin-left: 0 !important;
        padding: 5rem 1rem 1rem 1rem;
    }

    /* Adjust dashboard header for mobile */
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .dashboard-header h1 {
        font-size: 1.5rem;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
    }

    /* Larger touch targets on mobile */
    .nav-item {
        padding: 1rem 1.5rem;
        font-size: 1rem;
    }

    .nav-item span {
        font-size: 1.5rem;
    }
}

/* ============================================
   SMALL MOBILE (< 480px)
   ============================================ */
@media (max-width: 480px) {
    .sidebar {
        width: 75vw;
        max-width: 280px;
    }

    .main-content {
        padding: 4.5rem 0.75rem 0.75rem 0.75rem;
    }

    .dashboard-header h1 {
        font-size: 1.25rem;
    }

    .dashboard-header p {
        font-size: 0.875rem;
    }

    .mobile-toggle {
        top: 0.75rem;
        left: 0.75rem;
        padding: 0.625rem;
    }
}

/* Prevent body scroll when sidebar is open on mobile */
@media (max-width: 768px) {
    body.sidebar-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
.mobile-toggle:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

.nav-item:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: -2px;
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {

    .sidebar,
    .mobile-toggle,
    .sidebar-overlay {
        display: none;
    }

    .main-content {
        margin-left: 0;
    }
}

.user-name {
    background: var(--bg-secondary);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    box-shadow: var(--card-shadow);
    color: var(--text-primary);
}

.score-card {
    background: var(--bg-secondary);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    margin-bottom: 2rem;
}

.score-card h2 {
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.score-display {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2rem;
    margin-bottom: 1.5rem;
}

.score-item {
    text-align: center;
}

.score-item small {
    display: block;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.score-value {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--secondary-color);
}

.score-value.current {
    color: var(--primary-color);
}

.score-value.green {
    color: var(--success-green);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-box {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    display: flex;
    gap: 1rem;
    transition: all 0.3s ease;
}

.stat-box:hover {
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-2px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-content {
    flex: 1;
}

.stat-content h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.stat-row strong {
    color: var(--text-primary);
    font-weight: 600;
}

.activity-card {
    background: var(--bg-secondary);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
}

.activity-card h2 {
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.activity-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.activity-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.activity-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-weight: bold;
}

.activity-icon.success {
    background: #d1fae5;
    color: var(--success-green);
}

.activity-icon.info {
    background: #dbeafe;
    color: var(--secondary-color);
}

.activity-icon.warning {
    background: #fef3c7;
    color: var(--warning-yellow);
}

.activity-content {
    flex: 1;
}

.activity-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.activity-desc {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.activity-time {
    font-size: 0.75rem;
    color: #94a3b8;
}

.progress-bar {
    background: var(--bg-tertiary);
}

.score-range {
    color: var(--text-secondary);
}

/* Responsive Design */
@media (max-width: 968px) and (min-width: 769px) {
    .score-display {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .score-display {
        grid-template-columns: 1fr;
    }

    .header-actions {
        flex-direction: column;
        align-items: flex-start;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

           .sidebar {
               display: block !important;
               /* FORCE VISIBLE */
               z-index: 1001 !important;
           }
}