/* Cross-browser compatibility fixes */
:root {
    --remax-red: #e61a1a;
    --remax-blue: #0054a4;
    --remax-cream: #f7f3e9;
    --remax-dark: #1a1a1a;
    --remax-light-gray: #f5f5f5;
    --remax-gray: #888888;
    --shadow-light: 0 2px 10px rgba(0, 0, 0, 0.05);
    --shadow-medium: 0 4px 20px rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
    --transition-speed: 0.3s;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background-color: var(--remax-light-gray);
    color: var(--remax-dark);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header Styles */
header {
    background-color: white;
    box-shadow: var(--shadow-light);
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.logo-img {
    height: 40px;
    width: auto;
}

.balloon-img {
    height: 50px;
    width: auto;
}

header h1 {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--remax-blue);
}

/* Main Container Styles */
.main-container {
    display: flex;
    max-width: 1400px;
    margin: 2rem auto;
    gap: 2rem;
    padding: 0 1rem;
    flex: 1;
}

/* Sidebar Styles */
.sidebar {
    width: 300px;
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    position: sticky;
    top: 100px;
    height: calc(100vh - 120px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--remax-light-gray);
}

.sidebar-header h2 {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--remax-dark);
}

.module-nav ul {
    list-style: none;
}

.module-nav li {
    padding: 0.8rem 1.5rem;
    border-bottom: 1px solid var(--remax-light-gray);
    transition: background-color var(--transition-speed);
}

.module-nav li:hover {
    background-color: var(--remax-light-gray);
}

.module-nav a {
    text-decoration: none;
    color: var(--remax-dark);
    font-weight: 500;
    display: block;
}

/* Content Styles */
.content {
    flex: 1;
    min-width: 0; /* Fix for flexbox overflow */
}

.page-title {
    background-color: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    margin-bottom: 2rem;
    text-align: center;
}

.page-title h2 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--remax-red);
    margin-bottom: 0.5rem;
}

.page-title h3 {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--remax-blue);
}

/* Module Styles */
.module-card {
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    margin-bottom: 2rem;
    overflow: hidden;
    transition: box-shadow var(--transition-speed);
}

.module-card:hover {
    box-shadow: var(--shadow-medium);
}

.module-header {
    background-color: var(--remax-blue);
    color: white;
    padding: 1.5rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
}

.module-header h3 {
    font-size: 1.3rem;
    font-weight: 600;
}

.module-toggle {
    font-size: 1.2rem;
    transition: transform var(--transition-speed);
}

.module-content {
    display: none;
    padding: 0 1rem;
}

.module-content.active {
    display: block;
}

/* Part Styles */
.part-card {
    margin: 1.5rem 0;
    border-left: 4px solid var(--remax-red);
    background-color: var(--remax-light-gray);
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

.part-header {
    padding: 1rem 1.5rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
}

.part-toggle {
    font-size: 1rem;
    transition: transform var(--transition-speed);
}

.part-content {
    display: none;
    padding: 0 1rem 1rem 1.5rem;
}

.part-content.active {
    display: block;
}

/* Lecture Styles */
.lecture-list {
    list-style: none;
}

.lecture-item {
    padding: 0.8rem 1rem;
    margin: 0.5rem 0;
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    display: flex;
    align-items: center;
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
}

.lecture-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.lecture-number {
    min-width: 30px;
    height: 30px;
    background-color: var(--remax-red);
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 600;
    font-size: 0.9rem;
    margin-right: 1rem;
}

.lecture-code {
    color: var(--remax-gray);
    font-size: 0.9rem;
    margin-right: 1rem;
    min-width: 80px;
}

.lecture-title {
    font-weight: 500;
}

/* Footer Styles */
footer {
    background-color: var(--remax-dark);
    color: white;
    padding: 2rem 0;
    width: 100%;
}

.footer-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
}

.footer-logo-img {
    height: 40px;
    width: auto;
}

/* Back to Top Button */
#back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background-color: var(--remax-red);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    box-shadow: var(--shadow-medium);
    transition: background-color var(--transition-speed);
    z-index: 99;
}

#back-to-top:hover {
    background-color: #c91515;
}

#back-to-top.visible {
    display: flex;
}

/* Responsive Styles */
@media (max-width: 1024px) {
    .main-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        position: relative;
        top: 0;
        height: auto;
        margin-bottom: 2rem;
    }
    
    .header-container {
        padding: 1rem;
    }
    
    .logo-img, .balloon-img {
        height: 30px;
    }
    
    header h1 {
        font-size: 1.4rem;
    }
}

@media (max-width: 768px) {
    .lecture-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .lecture-number {
        margin-bottom: 0.5rem;
    }
    
    .lecture-code {
        margin-bottom: 0.5rem;
    }
    
    .footer-container {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    .page-title h2 {
        font-size: 1.4rem;
    }
    
    .page-title h3 {
        font-size: 1.1rem;
    }
    
    .module-header h3 {
        font-size: 1.1rem;
    }
    
    .header-container {
        flex-direction: column;
        gap: 0.5rem;
    }
}
