/* Define Light and Dark Mode Colors */
:root {
    /* Light Mode */
     --primary: #f9fafb;
    --secondary: #f3f4f6;
    --accent: #60a5fa;
    --background: #f5f7fa;
    --text-primary: #1a2a44;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;
    --card-background: #ffffff;
    --sidebar-background: #1a2a44;
    --sidebar-bg: #1f493d;
    --sidebar-text: #ffffff;
    --sidebar-text-hover: #ffffff;
    --sidebar-active: #3b82f6;
    --border: #e6e6e6;
    --shadow: rgba(0, 0, 0, 0.05);
    --progress-fill: #3b82f6;
    --logout-text: #ff6b6b;
    --input-bg: #ffffff;
    --input-border: #e6e6e6;
    --correct-bg: #d4edda; /* Green for correct answer */
    --chosen-bg: #fff3cd; /* Yellow for chosen answer */
    --chosen-text: #856404;
}

[data-theme="dark"] {
    /* Dark Mode */
    
    --background: #1a1a1a;
    --text-primary: #e5e7eb;
    --text-secondary: #9ca3af;
    --text-tertiary: #6b7280;
    --card-background: #2d2d2d;
    --sidebar-background: #121212;
    --sidebar-text: #ffffff;
    --sidebar-text-hover: #e5e7eb;
    --sidebar-active: #2563eb;
    --border: #444444;
    --shadow: rgba(255, 255, 255, 0.05);
    --progress-fill: #60a5fa;
    --logout-text: #f87171;
    --input-bg: #3a3a3a;
    --input-border: #555555;
    --correct-bg: #2f855a; /* Darker green for correct answer in dark mode */
    --chosen-bg: #744210; /* Darker yellow for chosen answer in dark mode */
    --chosen-text: #f1e4a1;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* General Layout */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0;
    background: var(--background);
}

.container {
    display: flex;
    min-height: 100vh;
}

/* Left Sidebar */
.sidebar {
    width: 250px;
    background: var(--sidebar-background);
    color: var(--sidebar-text);
    padding: 20px;
    position: fixed;
    height: 100%;
}

.logo {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
}

.logo-image {
    width: 40px;
    height: 40px;
    margin-right: 12px;
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
}

/* Theme Toggle */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.toggle-label {
    font-size: 14px;
    color: var(--sidebar-text);
}

.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.4s;
    border-radius: 20px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #3b82f6;
}

input:checked + .slider:before {
    transform: translateX(20px);
}

/* Dashboard Styles */
.sidebar {
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    width: 220px;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    position: fixed;
    height: 100%;
    overflow-y: auto;
}

.sidebar-header {
    margin-bottom: 1.5rem;
}

.sidebar .logo {
    color: var(--sidebar-text);
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.sidebar-nav ul {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sidebar-nav a {
    color: var(--sidebar-text);
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    transition: background 0.2s ease;
}

.sidebar-nav a:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-nav a.active {
    background: var(--accent);
    color: var(--primary);
}

.sidebar-account {
    margin-top: auto;
}

.sidebar-account ul {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
}

.sidebar-account a {
    color: var(--sidebar-text);
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    transition: background 0.2s ease;
}

.sidebar-account a:hover {
    background: rgba(255, 255, 255, 0.1);
}

.user-avatar {
    padding: 0.75rem 0;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

/* Main Content Area */
.main-content {
    width: calc(100% - 250px);
    margin-left: 250px;
    padding: 30px 40px;
    background: var(--background);
}

/* Header Section */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.page-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.timer {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
}

#time-remaining {
    font-weight: 700;
}

/* Exam Section */
.exam-section {
    background: var(--card-background);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 12px var(--shadow);
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.question-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.question-tags {
    display: flex;
    gap: 10px;
}

.tag {
    padding: 5px 10px;
    color: #ffffff;
    font-size: 12px;
    font-weight: 500;
    border-radius: 4px;
}

.subject-tag {
    background: var(--progress-fill);
}

.difficulty-tag {
    background: #90ee90; /* Default to Beginner (Light Green); will be overridden by JS */
}

.problem-statement {
    margin-bottom: 20px;
}

#question {
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.structured-data {
    background: var(--input-bg);
    padding: 10px;
    border: 1px solid var(--input-border);
    border-radius: 6px;
}

.structured-data p {
    margin: 5px 0;
    font-size: 14px;
    color: var(--text-primary);
}

.structured-data p strong {
    font-weight: 600;
}

.options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.option {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--text-primary);
    padding: 10px;
    border-radius: 6px;
    transition: background 0.2s ease;
}

.option.correct {
    background: var(--correct-bg);
}

.option.chosen {
    background: var(--chosen-bg);
}

.option input {
    margin: 0;
}

.chosen-tag {
    margin-left: 10px;
    padding: 2px 8px;
    background: var(--chosen-bg);
    color: var(--chosen-text);
    font-size: 12px;
    font-weight: 500;
    border-radius: 4px;
}

.explanation-section {
    margin-top: 20px;
    padding: 15px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 6px;
}

.explanation-section h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.explanation-section p {
    margin: 5px 0;
    font-size: 14px;
    color: var(--text-primary);
}

.navigation {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

#submit-answer-button, #next-button, #submit-exam-button {
    padding: 10px 20px;
    background: var(--progress-fill);
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s ease;
}

#submit-answer-button:hover, #next-button:hover, #submit-exam-button:hover {
    background: #2563eb;
}

#next-button:disabled {
    background: #cccccc;
    cursor: not-allowed;
}

/* Results Section */
.results-section {
    background: var(--card-background);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 12px var(--shadow);
}

.results-section h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.results-section p {
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 20px;
}

#results-details .question-result {
    margin-bottom: 20px;
    padding: 15px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 6px;
}

#results-details .question-result p {
    margin: 5px 0;
    font-size: 14px;
    color: var(--text-primary);
}

.action-button {
    display: inline-block;
    padding: 10px 20px;
    background: var(--progress-fill);
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 6px;
    transition: background 0.2s ease;
}

.action-button:hover {
    background: #2563eb;
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        padding: 15px;
    }

    .main-content {
        width: 100%;
        margin-left: 0;
        padding: 15px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .exam-section, .results-section {
        padding: 20px;
    }

    .question-header h2 {
        font-size: 16px;
    }

    #question-text {
        font-size: 14px;
    }

    .option {
        font-size: 13px;
    }

    .explanation-section p {
        font-size: 13px;
    }

    .logo-image {
        width: 32px;
        height: 32px;
    }

    .logo-text {
        font-size: 18px;
    }
}

@media (min-width: 1201px) {
    .main-content {
        max-width: 1200px;
        margin-left: auto;
        margin-right: auto;
        padding: 30px 0;
    }

    .sidebar + .main-content {
        margin-left: 300px;
    }
}
