* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Georgia', 'Times New Roman', serif;
    background: #f5f5f0;
    min-height: 100vh;
    padding: 20px;
    color: #2c3e50;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Navigation Styles - Shared across pages */
.main-nav {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    padding: 1rem 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
    margin-bottom: 20px;
}

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

.nav-logo {
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    text-decoration: none;
    letter-spacing: 1px;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
    align-items: center;
}

.nav-menu a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
    padding: 0.5rem 0;
}

.nav-menu a:hover,
.nav-menu a.active {
    color: #3498db;
    border-bottom: 2px solid #3498db;
}

.mobile-menu-btn {
    display: none;
    flex-direction: column;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 5px;
    gap: 4px;
}

.mobile-menu-btn span {
    width: 25px;
    height: 3px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s ease;
}

@media (max-width: 768px) {
    .nav-menu {
        position: fixed;
        left: -100%;
        top: 60px;
        flex-direction: column;
        background: #2c3e50;
        width: 100%;
        text-align: center;
        transition: 0.3s;
        box-shadow: 0 10px 27px rgba(0, 0, 0, 0.05);
        padding: 2rem 0;
        gap: 0;
    }

    .nav-menu.active {
        left: 0;
    }

    .nav-menu li {
        width: 100%;
    }

    .nav-menu a {
        display: block;
        padding: 1rem;
        width: 100%;
    }

    .mobile-menu-btn {
        display: flex;
    }
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    border: 1px solid #e0e0e0;
}

header {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    padding: 50px 40px;
    text-align: center;
    border-bottom: 4px solid #3498db;
}

header h1 {
    font-size: 2.2rem;
    margin-bottom: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.header-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-left: auto;
}

.home-link {
    color: #ecf0f1;
    text-decoration: none;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.3s;
    font-size: 1.1rem;
}

.home-link:hover {
    color: #3498db;
}

.test-button {
    background-color: #e74c3c;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    text-decoration: none;
    font-weight: bold;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    border: 2px solid #c0392b;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.test-button:hover {
    background-color: #c0392b;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.ai-tutor-button {
    background-color: #28a745;
    color: #ffffff;
    padding: 8px 16px;
    border-radius: 20px;
    text-decoration: none;
    font-weight: bold;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    border: 2px solid #1e7e34;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.ai-tutor-button:hover {
    background-color: #218838;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
    margin-bottom: 30px;
    font-style: italic;
}

.search-container {
    max-width: 600px;
    margin: 0 auto 30px;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 15px 20px;
    border-radius: 30px;
    border: none;
    font-size: 1rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.search-input:focus {
    outline: none;
    box-shadow: 0 4px 20px rgba(52, 152, 219, 0.3);
    transform: scale(1.02);
}

.clear-search-btn {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #7f8c8d;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 5px;
}

.clear-search-btn:hover {
    color: #e74c3c;
}

.progress-bar-container {
    max-width: 600px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 10px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: #ecf0f1;
}

.progress-bar {
    height: 10px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: #2ecc71;
    width: 0%;
    transition: width 0.5s ease;
}

.reset-progress-btn {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.reset-progress-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

main {
    padding: 40px;
}

.level-section {
    margin-bottom: 50px;
}

.level-title {
    color: #2c3e50;
    border-bottom: 3px solid #3498db;
    padding-bottom: 10px;
    margin-bottom: 30px;
    font-size: 1.8rem;
    font-weight: 700;
}

.courses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
}

.toc-section {
    margin-bottom: 40px;
}

.toc-toggle {
    width: 100%;
    text-align: left;
    background: linear-gradient(135deg, #34495e 0%, #2c3e50 100%);
    color: #ecf0f1;
    border: none;
    padding: 12px 16px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.toc-toggle .chev {
    transition: transform 0.2s ease;
}

.toc-section.open .toc-toggle .chev {
    transform: rotate(180deg);
}

.toc-panel {
    margin-top: 10px;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 14px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

.toc-group {
    margin-bottom: 12px;
}

.toc-group-title {
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 8px;
    border-left: 4px solid #3498db;
    padding-left: 8px;
}

.toc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 10px;
}

.toc-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: #f8f9fa;
    border: 1px solid #e1e8ed;
    border-radius: 8px;
    transition: background-color 0.2s, transform 0.2s;
}

.toc-item:hover {
    background: #eef2f7;
    transform: translateY(-2px);
}

.toc-code {
    background-color: #3498db;
    color: white;
    padding: 4px 8px;
    border-radius: 14px;
    font-size: 0.8rem;
    font-weight: bold;
    margin-right: 10px;
}

.toc-link {
    text-decoration: none;
    color: #2c3e50;
    font-weight: 600;
}

.toc-link:hover {
    color: #3498db;
    text-decoration: underline;
}

.toc-note {
    margin-top: 10px;
    color: #7f8c8d;
    font-style: italic;
}

.course-card {
    background: white;
    border: 1px solid #e1e8ed;
    border-radius: 12px;
    padding: 25px;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.course-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.08);
    border-color: #3498db;
}

.course-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 5px;
    height: 100%;
    background-color: #3498db;
}

.course-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.course-code {
    background-color: #3498db;
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: bold;
}

.toggle-icon {
    font-size: 1.2rem;
    color: #7f8c8d;
    transition: transform 0.3s;
}

.course-card.expanded .toggle-icon {
    transform: rotate(180deg);
}

.course-title {
    font-size: 1.3rem;
    color: #2c3e50;
    margin-bottom: 15px;
    font-weight: 600;
    line-height: 1.4;
}

.topics-list {
    display: none;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    animation: fadeIn 0.5s ease;
}

.course-card.expanded .topics-list {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.topic-item {
    margin-bottom: 15px;
    padding: 12px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border-left: 3px solid #bdc3c7;
    transition: background-color 0.2s;
    cursor: pointer;
}

.topic-item.expanded .topic-explanation {
    display: block;
    animation: fadeIn 0.3s ease;
}

.topic-item:hover {
    background-color: #eef2f7;
    border-left-color: #3498db;
}

.topic-item:last-child {
    margin-bottom: 0;
}

.topic-checkbox {
    margin-right: 10px;
    cursor: pointer;
    width: 18px;
    height: 18px;
    accent-color: #2ecc71;
}

.topic-content {
    display: inline-block;
    vertical-align: top;
    width: calc(100% - 35px);
}

.topic-explanation {
    display: none;
    margin-top: 8px;
    font-size: 0.95rem;
    color: #555;
    line-height: 1.6;
    padding: 10px;
    background: white;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.show-explanation {
    color: #3498db;
    font-size: 0.8rem;
    cursor: pointer;
    margin-left: 5px;
    text-decoration: underline;
}

.search-highlight {
    background-color: #fffacd !important;
    border-left-color: #f1c40f !important;
}

footer {
    text-align: center;
    padding: 30px;
    background-color: #2c3e50;
    color: #ecf0f1;
    border-top: 4px solid #3498db;
}

.about-link {
    color: #3498db;
    text-decoration: none;
    margin-left: 10px;
    font-weight: bold;
}

.about-link:hover {
    text-decoration: underline;
    color: #5dade2;
}

/* Dark Mode Styles */
body.dark-mode {
    background-color: #1a1a1a;
    color: #ecf0f1;
}

body.dark-mode .container {
    background-color: #2c3e50;
    border-color: #34495e;
}

body.dark-mode .course-card {
    background-color: #34495e;
    border-color: #465c71;
}

body.dark-mode .course-card:hover {
    border-color: #3498db;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

body.dark-mode .course-title,
body.dark-mode .level-title {
    color: #ecf0f1;
}

body.dark-mode .topic-item {
    background-color: #2c3e50;
    border-left-color: #7f8c8d;
}

body.dark-mode .topic-item:hover {
    background-color: #3e5063;
}

body.dark-mode .topic-explanation {
    background-color: #2c3e50;
    color: #bdc3c7;
    border-color: #465c71;
}

body.dark-mode .search-highlight {
    background-color: #5d4037 !important;
    color: #fff !important;
    border-left-color: #f39c12 !important;
}

body.dark-mode .search-input {
    background-color: #34495e;
    color: white;
}

body.dark-mode footer {
    background-color: #1a1a1a;
}

.dark-mode-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    padding: 5px;
    border-radius: 50%;
    transition: background-color 0.3s;
}

.dark-mode-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

@media (max-width: 768px) {
    header {
        padding: 30px 20px;
    }

    header h1 {
        font-size: 1.8rem;
    }

    .header-nav {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .header-controls {
        margin-left: 0;
        margin-top: 10px;
        width: 100%;
        justify-content: space-between;
    }

    main {
        padding: 20px;
    }

    .courses-grid {
        grid-template-columns: 1fr;
    }
}

/* Scrolling Marquee */
.marquee-container {
    background-color: #3498db;
    color: white;
    overflow: hidden;
    white-space: nowrap;
    position: relative;
    padding: 10px 0;
    margin-bottom: 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.marquee-content {
    display: inline-block;
    padding-left: 100%;
    animation: marquee 20s linear infinite;
    font-weight: 600;
    font-size: 1.1rem;
}

.marquee-content:hover {
    animation-play-state: paused;
}

@keyframes marquee {
    0% {
        transform: translate(0, 0);
    }
    100% {
        transform: translate(-100%, 0);
    }
}
