/* --- Default Light Theme Variables (or inside body.light-theme) --- */

:root { /* Or body.light-theme */
    --color-main-bg: #F4F7F9;        /* Light background for the main content */
    --color-sidebar-bg: #FFFFFF;     /* White background for sidebar/cards */
    --color-text-primary: #1F2937;   /* Dark text for light backgrounds */
    --color-text-secondary: #000000; /* Medium gray text for light backgrounds */
    --color-border: #E5E7EB;
    --color-card-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);

    --primary-color: #10B981;        /* Match main.css green */
    --primary-light: #A7F3D0;        /* Match main.css light green */
    --primary-dark: #047857;      /* Light version of accent for backgrounds */
}

/* --- Dark Theme Overrides (You already had this) --- */
/* --- Global Sidebar Link Styles --- */
.sidebar .main-nav ul a {
    display: flex;
    align-items: center;
    padding: 12px 15px; /* Adjust padding as needed */
    text-decoration: none;
    border-radius: var(--radius);
    
    transition: background-color 0.2s, color 0.2s;
}

.sidebar .main-nav ul a i {
    margin-right: 10px;
    font-size: 18px;
}

/* --- LIGHT THEME Link Colors (Default) --- */
.sidebar .main-nav ul a {
    color: var(--color-text-secondary); /* Default link color (gray) */
}

/* Hover state for light theme */
.sidebar .main-nav ul a:hover {
    background-color: var(--color-border); /* Subtle hover background */
    color: var(--color-text-primary); /* Darker text on hover */
}

/* --- DARK THEME Link Colors --- */
[data-theme="dark"] .sidebar .main-nav ul a {
    color: var(--color-text-secondary); /* Default link color (light gray) */
}

/* Hover state for dark theme */
[data-theme="dark"] .sidebar .main-nav ul a:hover {
    background-color: var(--color-border); /* Subtle hover background */
    color: var(--color-text-primary); /* Fully white text on hover */
}

/* --- Active Link/List Item Styling --- */

/* LIGHT THEME Active State */
.sidebar .main-nav li.active a {
    background-color: var(--primary-color); /* Bright green background */
    color: #FFFFFF; /* White text for contrast on the primary background */
}

/* DARK THEME Active State */
[data-theme="dark"] .sidebar .main-nav li.active a {
    /* Use the primary color for the background */
    background-color: var(--primary-color);
    /* Ensure the text is fully white for contrast */
    color: #FFFFFF; 
    /* You can also use a distinct color like a light primary if pure white is too much */
    /* color: var(--color-text-primary); */
}

/* --- Dark Mode Content & Card Fixes --- */

[data-theme="dark"] {
    /* Define a dark background color for general elements like sections and cards if not using --color-sidebar-bg */
    --dark-card-bg: #1F2937; /* Same as main background, or slightly lighter like #2d3748 */
    
    /* Ensure the body background is set (main-bg) */
    background-color: var(--color-main-bg);
}

/* Fix dashboard sections (e.g., Recommended for You) */
[data-theme="dark"] .dashboard-section {
    background-color: var(--dark-card-bg);
    box-shadow: var(--color-card-shadow);
}

/* Fix the stat cards (e.g., Total Points) */
[data-theme="dark"] .stat-card {
    background-color: var(--dark-card-bg);
    box-shadow: var(--color-card-shadow);
}

/* Fix the chart container background */
[data-theme="dark"] .chart-container {
    background-color: var(--dark-card-bg);
    /* Charts might need additional JS to re-render with a dark canvas background, but this fixes the container */
}

[data-theme="dark"] {
    --color-main-bg: #1F2937;
    --color-sidebar-bg: #111827;
    --color-text-primary: #F9FAFB;   /* Fully White */
    --color-text-secondary: #D1D5DB;
    --color-border: #374151;
    --color-card-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    
    --primary-color: #17db9a;
    --primary-light: #2c5a4d;        /* Adjusted light primary for dark mode */
}

/* Dashboard Layout */
.dashboard-content {
    animation: fadeIn 0.3s ease;
}

.dashboard-section {
    background-color: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    margin-bottom: var(--space-6);
    box-shadow: var(--shadow-sm);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
}

/* Performance Summary Cards */
.performance-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.stat-card {
    background-color: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-4);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xl);
    color: var(--primary-color);
    background-color: var(--primary-light);
}

.stat-info h3 {
    font-size: var(--text-sm);
    color: var(--text-medium);
    margin-bottom: var(--space-1);
}

.stat-info p {
    font-size: var(--text-xl);
    font-weight: 600;
    color: var(--text-dark);
}

/* Chart Containers */
.chart-container {
    height: 300px;
    position: relative;
}

/* Recent Activity */
.activity-list {
    margin-top: var(--space-4);
}

.activity-item {
    display: flex;
    align-items: center;
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--border-light);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: var(--space-3);
}

.activity-icon.completed {
    background-color: var(--success-light);
    color: var(--success);
}

.activity-icon.in-progress {
    background-color: var(--warning-light);
    color: var(--warning);
}

.activity-info {
    flex: 1;
}

.activity-info h4 {
    font-size: var(--text-base);
    margin-bottom: var(--space-1);
}

.activity-info p {
    font-size: var(--text-sm);
    color: var(--text-medium);
}

.activity-date {
    font-size: var(--text-sm);
    color: var(--text-light);
}

/* Recommendations */
.recommendations {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-4);
    margin-top: var(--space-4);
}

.recommendation-card {
    background-color: var(--bg-light);
    border-radius: var(--radius);
    padding: var(--space-4);
    border: 1px solid var(--border-light);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.recommendation-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.recommendation-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--space-2);
}

.subject-badge, .difficulty-badge {
    font-size: var(--text-xs);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius);
}

.subject-badge {
    background-color: var(--primary-light);
    color: var(--primary-dark);
}

.difficulty-badge.easy {
    background-color: var(--success-light);
    color: var(--success);
}

.difficulty-badge.medium {
    background-color: var(--warning-light);
    color: var(--warning);
}

.difficulty-badge.hard {
    background-color: var(--error-light);
    color: var(--error);
}

.recommendation-card h3 {
    margin-bottom: var(--space-2);
    font-size: var(--text-lg);
}

.recommendation-card p {
    margin-bottom: var(--space-3);
    color: var(--text-medium);
    font-size: var(--text-sm);
}

.recommendation-card .quiz-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--space-3);
    font-size: var(--text-xs);
    color: var(--text-medium);
}

/* Achievement Badges */
.badges-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-4);
    margin-top: var(--space-4);
}

.achievement-badge {
    display: flex;
    align-items: center;
    background-color: var(--bg-light);
    border-radius: var(--radius);
    padding: var(--space-3);
    border: 1px solid var(--border-light);
}

.badge-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xl);
    background: linear-gradient(45deg, #FFD700, #FFA500);
    color: white;
    margin-right: var(--space-3);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.badge-info {
    flex: 1;
}

.badge-info h4 {
    font-size: var(--text-base);
    margin-bottom: var(--space-1);
}

.badge-info p {
    font-size: var(--text-xs);
    color: var(--text-medium);
}

.badge-date {
    font-size: var(--text-xs);
    color: var(--text-light);
}

/* Loading indicator */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
}

.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top: 4px solid var(--primary-color);
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: var(--space-4);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* No access message */
.no-access-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 400px;
    text-align: center;
}

/* Find this block in dashboard.css */
.no-access-message i {
    font-size: 48px;
    /* CHANGE THIS LINE: */
    color: var(--text-medium); /* Use a darker color for light mode visibility */
    margin-bottom: var(--space-4);
}

.no-access-message h2 {
    margin-bottom: var(--space-2);
}

.no-access-message p {
    margin-bottom: var(--space-6);
    color: var(--text-medium);
}

.no-access-message .auth-buttons {
    display: flex;
    gap: var(--space-3);
}

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-6);
    text-align: center;
}

/* Find this block in dashboard.css */
.empty-state i {
    font-size: 36px;
    /* CHANGE THIS LINE: */
    color: var(--text-medium); /* Use a darker color for light mode visibility */
    margin-bottom: var(--space-3);
}

.empty-state p {
    margin-bottom: var(--space-4);
    color: var(--text-medium);
}

/* Error message styling */
.error-message {
    background-color: var(--error-light);
    color: var(--error);
    padding: var(--space-6);
    border-radius: var(--radius-lg);
    text-align: center;
    margin: var(--space-8) 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.error-message i {
    font-size: 48px;
    margin-bottom: var(--space-4);
}

.error-message h3 {
    margin-bottom: var(--space-3);
    font-size: var(--text-xl);
}

.error-message p {
    margin-bottom: var(--space-5);
    color: var(--text-dark);
}

.error-message button {
    margin: var(--space-2);
}

.error-message .btn.secondary-btn {
    background-color: var(--bg-light);
    color: var(--text-dark);
    border: 1px solid var(--border-medium);
}

/* Demo notice styling */
.demo-notice {
    background-color: #e3f2fd;
    color: #0d47a1;
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-6);
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    border-left: 4px solid #1976d2;
}

.demo-notice i {
    font-size: var(--text-xl);
    color: #1976d2;
}

.demo-notice p {
    margin: 0;
    font-size: var(--text-sm);
}

/* Small button variant */
.btn-sm {
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-sm);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .performance-summary {
        grid-template-columns: 1fr 1fr;
    }
    
    .recommendations, .badges-container {
        grid-template-columns: 1fr;
    }
    
    .chart-container {
        height: 250px;
    }
}

@media (max-width: 576px) {
    .performance-summary {
        grid-template-columns: 1fr;
    }
    
    .activity-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .activity-icon {
        margin-bottom: var(--space-2);
    }
    
    .activity-date {
        margin-top: var(--space-2);
    }
}

/* Improve Chart Container Visuals */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
    padding: 10px;
    background: var(--bg-white); /* Ensure chart has background */
    border-radius: var(--radius-lg);
}

/* Ensure canvas fits nicely */
#subject-performance-chart, 
#weekly-progress-chart {
    max-height: 100%;
}

/* Dark Mode fix for Charts */
[data-theme="dark"] .chart-container {
    background: var(--color-sidebar-bg);
}

/* Better Grid for Summary Cards */
.performance-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); /* Better responsiveness */
    gap: 20px;
    margin-bottom: 30px;
}

/* --- History Smart Tabs --- */
.history-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 10px;
}

.history-tab {
    background: transparent;
    border: none;
    padding: 8px 16px;
    font-size: 1rem;
    color: var(--text-medium);
    cursor: pointer;
    border-radius: 20px;
    transition: all 0.2s;
    font-weight: 500;
}

.history-tab.active {
    background-color: var(--primary-color);
    color: #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* --- Responsive Grid --- */
.history-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); /* Smart sizing */
    gap: 15px;
    margin-bottom: 15px;
}

/* --- Card Styles --- */
.quiz-history-card {
    background: var(--color-sidebar-bg);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: transform 0.2s;
}

.quiz-history-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.card-top {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.85rem;
    color: var(--text-medium);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.card-stats {
    display: flex;
    justify-content: space-between;
    background: var(--color-main-bg);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.stat-item {
    text-align: center;
}
.stat-item span { display: block; font-size: 0.75rem; color: var(--text-medium); }
.stat-item strong { font-size: 1rem; color: var(--text-primary); }

/* --- Mobile Button Fix --- */
.card-actions {
    margin-top: auto;
}
.card-actions .btn {
    width: 100%;
    justify-content: center;
}

.load-more-btn {
    width: 100%;
    margin-top: 10px;
    padding: 12px;
}

/* --- Modal Styles --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8); z-index: 2000;
    display: flex; justify-content: center; align-items: center;
}
.modal-content-box {
    background: var(--color-sidebar-bg); width: 90%; max-width: 600px; height: 80%;
    border-radius: 12px; display: flex; flex-direction: column; padding: 20px;
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding-bottom: 15px; border-bottom: 1px solid var(--color-border);
}
.modal-body-scroll { flex: 1; overflow-y: auto; padding-top: 15px; }

/* Review Item Styles */
.review-item { padding: 10px; border-bottom: 1px solid var(--color-border); }
.review-item.correct { border-left: 4px solid #10B981; }
.review-item.wrong { border-left: 4px solid #EF4444; }
.r-opt { padding: 5px; margin: 2px 0; font-size: 0.9rem; border-radius: 4px; }
.r-opt.is-valid { background: rgba(16, 185, 129, 0.1); color: #059669; font-weight: bold; }
.r-opt.is-invalid { background: rgba(239, 68, 68, 0.1); color: #DC2626; text-decoration: line-through; }
.close-modal-btn {
    background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-medium);
}