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

body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 18px;
    line-height: 1.7;
    color: #000000;
    background-color: #ffffff;
    margin: 0;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Page Wrapper with Sidebar */
.page-wrapper {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    gap: 40px;
    padding: 0 20px;
}

/* Main Content Area */
.content {
    flex: 1;
    max-width: 900px;
    min-width: 0;
}

/* Header */
.header {
    background-color: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    padding: 20px 0;
    margin-bottom: 0;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.header h1 {
    font-family: 'Roboto Slab', serif;
    font-size: 28px;
    font-weight: 700;
    color: #000000;
    margin: 0;
    flex: 1;
    text-align: center;
}

.course-info {
    flex: 1;
    text-align: center;
}

.course-author {
    font-family: 'Nunito', sans-serif;
    font-size: 14px;
    font-weight: 400;
    color: #666666;
    margin: 4px auto 0;
    text-align: center;
    display: block;
}

/* Logo */
.logo {
    flex-shrink: 0;
}

.logo-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.logo-link:hover {
    opacity: 0.8;
}

.logo-img {
    height: auto;
    width: auto;
    max-width: 100%;
    display: block;
}

.header-controls {
    flex-shrink: 0;
}

/* Language Switcher */
.lang-switcher {
    display: flex;
    align-items: center;
    gap: 8px;
}

.lang-link {
    font-family: 'Roboto Slab', serif;
    font-size: 16px;
    font-weight: 600;
    color: #333333;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 4px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.lang-link:hover {
    background-color: #f2f2f2;
    color: #ff9838;
}

.lang-link.active {
    background-color: #ff8562;
    color: #ffffff;
    font-weight: 700;
}

.lang-separator {
    color: #c2c2c2;
    font-weight: 300;
}

/* Courses Navigation */
.courses-nav {
    background-color: transparent;
    border-bottom: 1px solid #e0e0e0;
    padding: 0;
    margin-bottom: 60px;
}

.courses-nav .container {
    display: flex;
    gap: 30px;
    padding: 0 20px;
    overflow-x: auto;
}

.course-tab {
    display: inline-block;
    padding: 12px 0;
    font-family: 'Roboto Slab', serif;
    font-size: 15px;
    font-weight: 600;
    color: #333333;
    text-decoration: none;
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.course-tab:hover {
    color: #ff9838;
}

.course-tab.active {
    color: #e26552;
    border-bottom-color: #e26552;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Roboto Slab', serif;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 20px;
    color: #000000;
}

h1 {
    font-size: 42px;
    margin-bottom: 30px;
    margin-top: 40px;
}

h2 {
    font-size: 36px;
    margin-top: 50px;
    margin-bottom: 25px;
    color: #000000;
}

h3 {
    font-size: 28px;
    margin-top: 35px;
    margin-bottom: 20px;
    color: #333333;
}

article h1:first-child {
    margin-top: 0;
}

/* Paragraphs */
p {
    margin-bottom: 20px;
    color: #000000;
}

.intro-text {
    font-size: 20px;
    line-height: 1.8;
    color: #333333;
    margin-bottom: 30px;
}

/* Links */
a {
    color: #6767e2;
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: #ff9838;
}

/* External Links */
article a[href^="http"]::after,
article a[href^="https://"]::after {
    content: " ↗";
    font-size: 0.85em;
    vertical-align: super;
    line-height: 0;
}

article a[href^="http"],
article a[href^="https://"] {
    text-decoration: underline;
    text-decoration-style: dotted;
    text-decoration-color: #6767e2;
}

/* Inline Code */
code {
    background-color: #f2f2f2;
    color: #e26552;
    padding: 3px 8px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 0.9em;
    font-weight: 500;
}

/* Bold Text */
strong, b {
    font-weight: 700;
    color: #000000;
}

/* Italic Text */
em, i {
    font-style: italic;
    color: #333333;
}

/* Lists */
ul, ol {
    margin-bottom: 25px;
    padding-left: 30px;
}

ul li, ol li {
    margin-bottom: 12px;
    line-height: 1.7;
    color: #000000;
}

ul li {
    list-style-type: disc;
}

ol li {
    list-style-type: decimal;
}

/* Blockquotes */
blockquote {
    background-color: #f2f2f2;
    border-left: 4px solid #ff8562;
    padding: 25px 30px;
    margin: 35px 0;
    font-size: 19px;
    line-height: 1.7;
    font-style: italic;
    color: #333333;
}

blockquote::before {
    content: '"';
    font-size: 48px;
    color: #ff8562;
    line-height: 0;
    margin-right: 5px;
    vertical-align: -10px;
}

/* Conclusion Box */
.conclusion {
    background-color: #f2f2f2;
    border: 2px solid #e26552;
    border-radius: 8px;
    padding: 30px;
    margin: 40px 0;
}

.conclusion h3 {
    color: #e26552;
    font-size: 26px;
    margin-top: 0;
    margin-bottom: 20px;
    font-weight: 700;
}

.conclusion p {
    color: #000000;
    margin-bottom: 15px;
    line-height: 1.7;
}

.conclusion p:last-child {
    margin-bottom: 0;
}

/* Images */
article img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 30px auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Footer */
.footer {
    background-color: #f2f2f2;
    border-top: 1px solid #c2c2c2;
    padding: 40px 0;
    margin-top: 80px;
    text-align: center;
}

.footer p {
    color: #333333;
    font-size: 16px;
    margin: 0;
}

/* Article Spacing */
article {
    margin-bottom: 60px;
}

/* Sidebar Navigation */
.sidebar {
    width: 280px;
    flex-shrink: 0;
    position: sticky;
    top: 20px;
    align-self: flex-start;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    padding: 20px;
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
}

.sidebar-title {
    font-family: 'Roboto Slab', serif;
    font-size: 20px;
    font-weight: 700;
    color: #000000;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
}

/* Module Styles */
.module {
    margin-bottom: 15px;
}

.module-title {
    font-family: 'Roboto Slab', serif;
    font-size: 16px;
    font-weight: 600;
    color: #333333;
    padding: 10px 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s ease, color 0.2s ease;
    user-select: none;
}

.module-title:hover {
    background-color: #f2f2f2;
}

.module-title.collapsed::before {
    content: '▶ ';
    font-size: 12px;
    margin-right: 5px;
}

.module-title.active::before {
    content: '▼ ';
    font-size: 12px;
    margin-right: 5px;
}

/* Submodules List */
.submodules {
    list-style: none;
    padding-left: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.submodules.expanded {
    max-height: 2000px;
    margin-top: 8px;
}

.submodules li {
    margin-bottom: 0;
}

.submodules a {
    display: block;
    padding: 8px 12px 8px 28px;
    color: #333333;
    text-decoration: none;
    font-size: 15px;
    border-radius: 4px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.submodules a:hover {
    background-color: #f2f2f2;
    color: #ff9838;
}

.submodules a.active {
    background-color: #fff3ed;
    color: #e26552;
    font-weight: 600;
    border-left: 3px solid #e26552;
    padding-left: 25px;
}

/* Scrollbar Styling for Sidebar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: #f2f2f2;
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #c2c2c2;
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #999999;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .page-wrapper {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        position: static;
        max-height: none;
        margin-bottom: 30px;
    }
    
    .content {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    body {
        font-size: 16px;
    }
    
    .header h1 {
        display: block;
        font-size: 20px;
        margin-bottom: 5px;
    }
    
    .course-author {
        font-size: 12px;
    }
    
    h1 {
        font-size: 32px;
    }
    
    h2 {
        font-size: 28px;
        margin-top: 40px;
    }
    
    h3 {
        font-size: 22px;
        margin-top: 30px;
    }
    
    .intro-text {
        font-size: 18px;
    }
    
    blockquote {
        font-size: 17px;
        padding: 20px 20px;
    }
    
    .conclusion {
        padding: 20px;
    }
    
    .conclusion h3 {
        font-size: 22px;
    }
    
    .sidebar {
        padding: 15px;
    }
    
    .sidebar-title {
        font-size: 18px;
    }
    
    .module-title {
        font-size: 15px;
    }
    
    .submodules a {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .container,
    .page-wrapper {
        padding: 0 15px;
    }
    
    .header {
        padding: 20px 0;
        margin-bottom: 40px;
    }
    
    h1 {
        font-size: 28px;
    }
    
    h2 {
        font-size: 24px;
    }
    
    h3 {
        font-size: 20px;
    }
    
    blockquote {
        padding: 15px;
        font-size: 16px;
    }
    
    .sidebar {
        padding: 12px;
    }
    
    .module-title {
        font-size: 14px;
        padding: 8px 10px;
    }
    
    .submodules a {
        font-size: 13px;
        padding: 6px 10px 6px 24px;
    }
    
    .submodules a.active {
        padding-left: 21px;
    }
}

/* Page Navigation */
.page-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 60px;
    padding-top: 30px;
    border-top: 2px solid #e0e0e0;
}

.nav-button {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    background-color: #f2f2f2;
    color: #000000;
    text-decoration: none;
    border-radius: 6px;
    font-family: 'Roboto Slab', serif;
    font-weight: 600;
    transition: all 0.2s ease;
}

.nav-button:hover {
    background-color: #ff8562;
    color: #ffffff;
}

.nav-button.nav-disabled {
    visibility: hidden;
}

.nav-arrow {
    font-size: 20px;
}

/* Render Stats Pane */
.render-stats {
    position: fixed;
    top: 120px;
    right: 20px;
    background-color: #f2f2f2;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 12px 16px;
    font-size: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 100;
}

.stats-title {
    font-family: 'Roboto Slab', serif;
    font-weight: 600;
    color: #333333;
    margin-bottom: 4px;
}

.stats-value {
    font-family: 'Monaco', 'Menlo', monospace;
    color: #e26552;
    font-weight: 500;
}

/* Reading Progress Bar */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 4px;
    background: linear-gradient(90deg, #e26552, #ff9838);
    width: 0%;
    z-index: 1000;
    transition: width 0.1s ease;
}

/* Dark Mode Toggle */
.dark-mode-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 24px;
    padding: 6px 12px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.dark-mode-toggle:hover {
    background-color: #f2f2f2;
}

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

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

body.dark-mode .header {
    background-color: #2a2a2a;
    border-bottom-color: #404040;
}

body.dark-mode .courses-nav {
    border-bottom-color: #404040;
}

body.dark-mode .course-tab {
    color: #d0d0d0;
}

body.dark-mode .course-tab:hover {
    color: #ffb366;
}

body.dark-mode .course-tab.active {
    color: #ff9b7a;
    border-bottom-color: #ff7a5c;
}

body.dark-mode .course-author {
    color: #999999;
}

body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3,
body.dark-mode h4,
body.dark-mode h5,
body.dark-mode h6 {
    color: #ffffff;
}

body.dark-mode p,
body.dark-mode li {
    color: #d0d0d0;
}

body.dark-mode a {
    color: #8b8bff;
}

body.dark-mode a:hover {
    color: #ffb366;
}

body.dark-mode code {
    background-color: #333333;
    color: #ff9b7a;
}

body.dark-mode blockquote {
    background-color: #2a2a2a;
    border-left-color: #ff9b7a;
    color: #d0d0d0;
}

body.dark-mode .conclusion {
    background-color: #2a2a2a;
    border-color: #ff7a5c;
}

body.dark-mode .sidebar {
    background-color: #2a2a2a;
    border-color: #404040;
}

body.dark-mode .module-title {
    color: #d0d0d0;
}

body.dark-mode .module-title:hover {
    background-color: #333333;
}

body.dark-mode .module-title.has-active-page {
    background-color: #ff7a5c;
    color: #ffffff;
}

body.dark-mode .submodules a {
    color: #d0d0d0;
}

body.dark-mode .submodules a:hover {
    background-color: #333333;
    color: #ffb366;
}

body.dark-mode .submodules a.active {
    background-color: #3a2a25;
    color: #ff9b7a;
    border-left-color: #ff7a5c;
}

body.dark-mode article img {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    opacity: 0.95;
}

body.dark-mode .footer {
    background-color: #2a2a2a;
    border-top-color: #404040;
}

body.dark-mode .footer p {
    color: #909090;
}

body.dark-mode .lang-link {
    color: #d0d0d0;
}

body.dark-mode .lang-link:hover {
    background-color: #333333;
}

body.dark-mode .lang-link.active {
    background-color: #ff7a5c;
    color: #ffffff;
}

body.dark-mode .dark-mode-toggle:hover {
    background-color: #333333;
}

body.dark-mode .render-stats {
    background-color: #2a2a2a;
    border-color: #404040;
}

body.dark-mode .stats-title {
    color: #d0d0d0;
}

body.dark-mode .stats-value {
    color: #ff9b7a;
}

body.dark-mode .nav-button {
    background-color: #2a2a2a;
    color: #d0d0d0;
}

body.dark-mode .nav-button:hover {
    background-color: #ff7a5c;
    color: #ffffff;
}

body.dark-mode .page-navigation {
    border-top-color: #404040;
}

body.dark-mode .logo-img {
    filter: invert(1) brightness(1.2);
}

/* Fix bold text in dark mode */
body.dark-mode strong,
body.dark-mode b {
    color: #ffffff;
}

/* Fix italic text in dark mode */
body.dark-mode em,
body.dark-mode i {
    color: #c0c0c0;
}

/* User Controls */
.user-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-right: 20px;
}

.user-name {
    font-family: 'Nunito', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: #2d3748;
}

.auth-link {
    font-family: 'Nunito', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: #667eea;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.auth-link:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #764ba2;
}

body.dark-mode .user-name {
    color: #e2e8f0;
}

body.dark-mode .auth-link {
    color: #90cdf4;
}

body.dark-mode .auth-link:hover {
    background: rgba(144, 205, 244, 0.1);
}

/* Login Page Styles */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-box {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 50px 40px;
    max-width: 420px;
    width: 100%;
    animation: fadeInUp 0.6s ease;
}

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

.login-header {
    text-align: center;
    margin-bottom: 40px;
}

.login-logo {
    width: 180px;
    height: auto;
    margin-bottom: 20px;
}

.login-title {
    font-family: 'Roboto Slab', serif;
    font-size: 28px;
    font-weight: 700;
    color: #2d3748;
    margin: 0 0 10px 0;
}

.login-subtitle {
    font-family: 'Nunito', sans-serif;
    font-size: 16px;
    color: #718096;
    margin: 0;
}

.form-group {
    margin-bottom: 25px;
}

.form-label {
    display: block;
    font-family: 'Nunito', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    font-family: 'Nunito', sans-serif;
    font-size: 15px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.form-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-input::placeholder {
    color: #cbd5e0;
}

.login-button {
    width: 100%;
    padding: 16px;
    font-family: 'Nunito', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: white;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.login-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
}

.login-button:active {
    transform: translateY(0);
}

.error-message {
    background: #fed7d7;
    color: #c53030;
    padding: 12px 16px;
    border-radius: 10px;
    font-family: 'Nunito', sans-serif;
    font-size: 14px;
    margin-bottom: 20px;
    border-left: 4px solid #c53030;
}

.back-link {
    display: block;
    text-align: center;
    margin-top: 25px;
    font-family: 'Nunito', sans-serif;
    font-size: 14px;
    color: #667eea;
    text-decoration: none;
    transition: color 0.3s ease;
}

.back-link:hover {
    color: #764ba2;
    text-decoration: underline;
}

body.dark-mode .login-box {
    background: #2d3748;
}

body.dark-mode .login-title {
    color: #e2e8f0;
}

body.dark-mode .login-subtitle {
    color: #a0aec0;
}

body.dark-mode .form-label {
    color: #cbd5e0;
}

body.dark-mode .form-input {
    background: #1a202c;
    border-color: #4a5568;
    color: #e2e8f0;
}

body.dark-mode .form-input:focus {
    border-color: #667eea;
    background: #2d3748;
}

body.dark-mode .form-input::placeholder {
    color: #4a5568;
}
