/* Root Variables */
:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #10b981;
    --accent-color: #f59e0b;
    --background-color: #0f172a;
    --surface-color: #1e293b;
    --surface-light: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --error-color: #ef4444;
    --success-color: #22c55e;
    --gradient-1: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --gradient-2: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
    padding-top: 40px; /* Space for subject nav */
}

/* Subject Navigation Bar */
.subject-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(90deg, #1e1e2e 0%, #2d2d44 100%);
    padding: 0.5rem 2rem;
    z-index: 1100;
    border-bottom: 1px solid rgba(99, 102, 241, 0.3);
}

.subject-nav-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.subject-nav-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.subject-links {
    display: flex;
    gap: 0.5rem;
}

.subject-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 1rem;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 20px;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.subject-link:hover {
    color: var(--text-primary);
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.3);
}

.subject-link.active {
    color: var(--text-primary);
    background: var(--gradient-1);
    border-color: transparent;
}

.subject-link i {
    font-size: 0.9rem;
}

/* Navbar */
.navbar {
    position: fixed;
    top: 40px;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    border-bottom: 1px solid var(--surface-light);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.nav-brand i {
    font-size: 1.8rem;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    transition: color 0.3s ease;
    position: relative;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--primary-color);
}

.nav-links a.active::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--gradient-1);
    border-radius: 2px;
}

.nav-toggle {
    display: none;
    cursor: pointer;
    font-size: 1.5rem;
}

/* Sections */
.section {
    min-height: 100vh;
    padding: 8rem 2rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.section-title {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 3rem;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Hero Section */
.hero-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4rem;
}

.hero-content {
    flex: 1;
}

.hero-content h1 {
    font-size: 3rem;
    line-height: 1.2;
    margin-bottom: 1.5rem;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-content p {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.hero-stats {
    display: flex;
    gap: 3rem;
    margin-bottom: 2rem;
}

.stat-item {
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-label {
    color: var(--text-secondary);
}

.hero-image {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.math-animation {
    position: relative;
    width: 300px;
    height: 300px;
}

.formula-float {
    position: absolute;
    padding: 1rem 1.5rem;
    background: var(--surface-color);
    border-radius: 12px;
    border: 1px solid var(--surface-light);
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    animation: float 3s ease-in-out infinite;
}

.formula-float:nth-child(1) {
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    animation-delay: 0s;
}

.formula-float:nth-child(2) {
    bottom: 30%;
    left: 0;
    animation-delay: 1s;
}

.formula-float:nth-child(3) {
    bottom: 10%;
    right: 0;
    animation-delay: 2s;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

/* Buttons */
.btn {
    padding: 0.8rem 2rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: var(--gradient-1);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--surface-light);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--surface-color);
}

.btn-success {
    background: var(--secondary-color);
    color: white;
}

/* Chapters Grid */
.chapters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.chapter-card {
    background: var(--surface-color);
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid var(--surface-light);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

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

.chapter-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.chapter-number {
    display: inline-block;
    background: var(--gradient-1);
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    text-align: center;
    line-height: 35px;
    font-weight: 600;
    margin-bottom: 1rem;
}

.chapter-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.chapter-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.chapter-topics {
    margin-top: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.topic-tag {
    background: var(--surface-light);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    overflow-y: auto;
}

.modal-content {
    background: var(--surface-color);
    margin: 5% auto;
    padding: 2rem;
    border-radius: 16px;
    max-width: 900px;
    width: 90%;
    position: relative;
    max-height: 85vh;
    overflow-y: auto;
}

.close-btn {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.3s;
}

.close-btn:hover {
    color: var(--error-color);
}

/* Chapter Detail Styles */
.chapter-detail-header {
    margin-bottom: 2rem;
}

.chapter-detail-header h2 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.chapter-overview {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.concept-section {
    background: var(--background-color);
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
}

.concept-section h3 {
    color: var(--secondary-color);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.concept-section ul {
    list-style: none;
    padding-left: 1rem;
}

.concept-section li {
    padding: 0.5rem 0;
    position: relative;
    padding-left: 1.5rem;
}

.concept-section li::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: var(--primary-color);
}

.formula-box {
    background: var(--surface-light);
    padding: 1rem;
    border-radius: 8px;
    margin: 0.5rem 0;
    font-family: 'Courier New', monospace;
    border-left: 3px solid var(--accent-color);
}

/* Practice Section */
.practice-container {
    max-width: 800px;
    margin: 0 auto;
}

.practice-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.practice-filters select {
    flex: 1;
    min-width: 150px;
    padding: 0.8rem 1rem;
    background: var(--surface-color);
    border: 1px solid var(--surface-light);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
}

.problem-area {
    text-align: center;
}

.problem-card {
    background: var(--surface-color);
    padding: 2rem;
    border-radius: 16px;
    margin-bottom: 1.5rem;
    border: 1px solid var(--surface-light);
}

.problem-card h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.problem-card .problem-text {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.problem-card .problem-difficulty {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    margin-bottom: 1rem;
}

.problem-difficulty.easy {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success-color);
}

.problem-difficulty.medium {
    background: rgba(245, 158, 11, 0.2);
    color: var(--accent-color);
}

.problem-difficulty.hard {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error-color);
}

.placeholder-text {
    color: var(--text-secondary);
    font-style: italic;
}

.answer-section {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.answer-section input {
    padding: 0.8rem 1rem;
    background: var(--surface-color);
    border: 1px solid var(--surface-light);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    min-width: 200px;
}

.solution-card {
    background: var(--surface-color);
    padding: 1.5rem;
    border-radius: 12px;
    text-align: left;
    border: 1px solid var(--secondary-color);
}

.solution-card h4 {
    color: var(--secondary-color);
    margin-bottom: 1rem;
}

.solution-card .step {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--surface-light);
}

.solution-card .step:last-child {
    border-bottom: none;
}

.feedback {
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
    font-weight: 600;
}

.feedback.correct {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success-color);
    border: 1px solid var(--success-color);
}

.feedback.incorrect {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error-color);
    border: 1px solid var(--error-color);
}

.hidden {
    display: none !important;
}

/* Formulas Section */
.formulas-tabs {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 0.8rem 1.5rem;
    background: var(--surface-color);
    border: 1px solid var(--surface-light);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn:hover,
.tab-btn.active {
    background: var(--gradient-1);
    color: white;
    border-color: transparent;
}

.formulas-content {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.formula-card {
    background: var(--surface-color);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--surface-light);
}

.formula-card h4 {
    color: var(--primary-color);
    margin-bottom: 0.75rem;
}

.formula-card .formula {
    background: var(--background-color);
    padding: 1rem;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    text-align: center;
}

.formula-card .description {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Calculator Section */
.calculator-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.calc-card {
    background: var(--surface-color);
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid var(--surface-light);
}

.calc-card h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.calc-form p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    text-align: center;
    font-family: 'Courier New', monospace;
}

.input-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.input-group input,
.calc-form select {
    flex: 1;
    min-width: 80px;
    padding: 0.8rem;
    background: var(--background-color);
    border: 1px solid var(--surface-light);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
}

.calc-form select {
    width: 100%;
    margin-bottom: 1rem;
}

.calc-result {
    background: var(--background-color);
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
    min-height: 50px;
    font-family: 'Courier New', monospace;
}

.calc-result .result-item {
    padding: 0.25rem 0;
}

.calc-result .result-label {
    color: var(--text-secondary);
}

.calc-result .result-value {
    color: var(--secondary-color);
    font-weight: 600;
}

/* Footer */
.footer {
    background: var(--surface-color);
    padding: 2rem;
    text-align: center;
    border-top: 1px solid var(--surface-light);
}

.footer p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .subject-nav {
        padding: 0.4rem 1rem;
    }

    .subject-nav-container {
        flex-direction: column;
        gap: 0.3rem;
    }

    .subject-nav-label {
        font-size: 0.7rem;
    }

    .subject-link {
        padding: 0.3rem 0.8rem;
        font-size: 0.75rem;
    }

    .subject-link span {
        display: none;
    }

    .navbar {
        top: 55px;
    }

    body {
        padding-top: 55px;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--background-color);
        flex-direction: column;
        padding: 1rem;
        gap: 1rem;
        border-bottom: 1px solid var(--surface-light);
    }

    .nav-links.active {
        display: flex;
    }

    .nav-toggle {
        display: block;
    }

    .hero-section {
        flex-direction: column;
        text-align: center;
    }

    .hero-content h1 {
        font-size: 2rem;
    }

    .hero-stats {
        justify-content: center;
    }

    .math-animation {
        display: none;
    }

    .section {
        padding: 7rem 1rem 2rem;
    }

    .section-title {
        font-size: 1.8rem;
    }

    .practice-filters {
        flex-direction: column;
    }

    .answer-section {
        flex-direction: column;
        align-items: center;
    }

    .answer-section input {
        width: 100%;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background-color);
}

::-webkit-scrollbar-thumb {
    background: var(--surface-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Animation for page elements */
.chapter-card,
.formula-card,
.calc-card {
    animation: fadeInUp 0.5s ease forwards;
    opacity: 0;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chapter-card:nth-child(1) { animation-delay: 0.1s; }
.chapter-card:nth-child(2) { animation-delay: 0.15s; }
.chapter-card:nth-child(3) { animation-delay: 0.2s; }
.chapter-card:nth-child(4) { animation-delay: 0.25s; }
.chapter-card:nth-child(5) { animation-delay: 0.3s; }
.chapter-card:nth-child(6) { animation-delay: 0.35s; }
.chapter-card:nth-child(7) { animation-delay: 0.4s; }
.chapter-card:nth-child(8) { animation-delay: 0.45s; }
.chapter-card:nth-child(9) { animation-delay: 0.5s; }
.chapter-card:nth-child(10) { animation-delay: 0.55s; }
.chapter-card:nth-child(11) { animation-delay: 0.6s; }
.chapter-card:nth-child(12) { animation-delay: 0.65s; }
.chapter-card:nth-child(13) { animation-delay: 0.7s; }
.chapter-card:nth-child(14) { animation-delay: 0.75s; }
.chapter-card:nth-child(15) { animation-delay: 0.8s; }
