* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --text-primary: #c9d1d9;
    --text-secondary: #8b949e;
    --accent: #58a6ff;
    --accent-hover: #79c0ff;
    --border: #30363d;
    --success: #3fb950;
    --warning: #d29922;
    --danger: #f85149;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.2);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* ==================== HOME PAGE ==================== */
.home-container {
    min-height: 100vh;
    padding: 60px 20px;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

.home-header {
    max-width: 1200px;
    margin: 0 auto 60px;
    text-align: center;
    animation: slideDown 0.6s ease;
}

.home-header h1 {
    font-size: 3.5rem;
    margin-bottom: 20px;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.home-header p {
    font-size: 1.2rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

.subjects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.subject-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 30px;
    transition: all 0.3s ease;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.subject-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

.subject-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow);
    transform: translateY(-5px);
}

.subject-card:hover::before {
    transform: translateX(0);
}

.subject-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.subject-card h2 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.subject-meta {
    color: var(--text-secondary);
    margin: 15px 0;
    font-size: 0.95rem;
}

.subject-count {
    font-weight: 600;
    color: var(--accent);
}

.card-footer {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.open-btn {
    background: var(--accent);
    color: var(--bg-primary);
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.open-btn:hover {
    background: var(--accent-hover);
}

/* ==================== SUBJECT PAGES ==================== */
.page-container {
    display: flex;
    min-height: 100vh;
    background-color: var(--bg-primary);
}

/* Sidebar Navigation */
.sidebar {
    width: 280px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 20px;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    transition: all 0.3s ease;
    z-index: 1000;
}

.sidebar-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
    font-size: 1.25rem;
    margin-bottom: 10px;
}

.sidebar-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.search-box {
    width: 100%;
    padding: 10px 15px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.search-box::placeholder {
    color: var(--text-secondary);
}

.search-box:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.1);
}

.nav-list {
    list-style: none;
}

.nav-item {
    margin-bottom: 8px;
}

.nav-link {
    display: block;
    padding: 12px 15px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    cursor: pointer;
}

.nav-link:hover,
.nav-link.active {
    background-color: var(--bg-tertiary);
    color: var(--accent);
}

.home-link {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    background-color: var(--accent);
    color: var(--bg-primary);
    text-decoration: none;
    border-radius: 6px;
    margin-bottom: 20px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.home-link:hover {
    background-color: var(--accent-hover);
}

/* Main Content */
.main-content {
    margin-left: 280px;
    flex: 1;
    padding: 40px;
}

.page-header {
    margin-bottom: 40px;
    padding-bottom: 30px;
    border-bottom: 2px solid var(--border);
    animation: slideDown 0.6s ease;
}

.page-header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.page-meta {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.content-wrapper {
    max-width: 900px;
}

/* Question Container */
.question-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 30px;
    overflow: hidden;
    transition: all 0.3s ease;
    animation: fadeIn 0.5s ease;
}

.question-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-sm);
}

.question-header {
    padding: 25px;
    background: linear-gradient(135deg, rgba(88, 166, 255, 0.05), rgba(88, 166, 255, 0.02));
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.question-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--accent);
    margin: 0;
}

.collapse-icon {
    font-size: 1.2rem;
    color: var(--accent);
    transition: transform 0.3s ease;
}

.question-card.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.question-body {
    padding: 25px;
    max-height: 2000px;
    overflow: hidden;
    transition: max-height 0.4s ease, padding 0.4s ease;
}

.question-card.collapsed .question-body {
    max-height: 0;
    padding: 0 25px;
}

.section {
    margin-bottom: 25px;
}

.section:last-child {
    margin-bottom: 0;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
}

.section-title::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 4px;
    background: var(--accent);
    border-radius: 50%;
    margin-right: 10px;
}

.problem-explanation,
.step-instruction,
.key-concept {
    color: var(--text-primary);
    line-height: 1.8;
}

.steps-list {
    list-style: none;
    counter-reset: step-counter;
}

.steps-list li {
    counter-increment: step-counter;
    margin-bottom: 12px;
    padding-left: 30px;
    position: relative;
}

.steps-list li::before {
    content: counter(step-counter);
    position: absolute;
    left: 0;
    top: 0;
    background: var(--accent);
    color: var(--bg-primary);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Code Section */
.code-section {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0;
    overflow: hidden;
    margin: 15px 0;
}

.code-header {
    background: linear-gradient(135deg, rgba(88, 166, 255, 0.1), rgba(88, 166, 255, 0.05));
    padding: 12px 15px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.code-language {
    color: var(--accent);
}

.copy-btn {
    background: var(--accent);
    color: var(--bg-primary);
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.copy-btn:hover {
    background: var(--accent-hover);
}

.copy-btn.copied {
    background: var(--success);
}

pre {
    margin: 0;
    padding: 15px;
    overflow-x: auto;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
}

code {
    color: var(--text-primary);
}

/* Syntax Highlighting Classes */
.keyword {
    color: #ff7b72;
}

.string {
    color: #a5d6ff;
}

.comment {
    color: #8b949e;
}

.function {
    color: #d2a8ff;
}

.class-name {
    color: #79c0ff;
}

/* Output Section */
.output-section {
    background: var(--bg-tertiary);
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
}

.output-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.output-content {
    background: var(--bg-primary);
    padding: 12px;
    border-radius: 4px;
    color: var(--success);
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.85rem;
    white-space: pre-wrap;
    word-break: break-all;
}

.output-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin-top: 10px;
    border: 1px solid var(--border);
}

/* Theme Toggle */
.theme-toggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: var(--accent);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
    z-index: 999;
}

.theme-toggle:hover {
    background: var(--accent-hover);
    transform: scale(1.1);
}

/* Light Theme */
body.light-theme {
    --bg-primary: #ffffff;
    --bg-secondary: #f6f8fa;
    --bg-tertiary: #eaeef2;
    --text-primary: #24292f;
    --text-secondary: #57606a;
    --border: #d0d7de;
}

/* Animations */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .home-header h1 {
        font-size: 2.5rem;
    }

    .subjects-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .page-container {
        flex-direction: column;
    }

    .sidebar {
        position: relative;
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
        max-height: 300px;
        overflow-y: auto;
    }

    .main-content {
        margin-left: 0;
        padding: 20px;
    }

    .page-header h1 {
        font-size: 1.8rem;
    }

    .question-header {
        padding: 15px;
    }

    .question-title {
        font-size: 1.1rem;
    }

    .theme-toggle {
        bottom: 20px;
        right: 20px;
        width: 45px;
        height: 45px;
        font-size: 1.2rem;
    }

    .search-box {
        margin-bottom: 15px;
    }

    .nav-list {
        max-height: 200px;
        overflow-y: auto;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}
