@import url('https://fonts.googleapis.com/css2?family=Crimson+Text:wght@400;700&display=swap');
/* Book Reader Styles */

.book-reader {
    display: flex;
    min-height: calc(100vh - 80px);
    background: #f8f9fa;
}

/* Sidebar Styles */
.book-sidebar {
    width: 320px;
    background: white;
    border-right: 1px solid #e9ecef;
    position: fixed;
    top: 80px; /* Position below the main navbar */
    left: 0;
    height: calc(100vh - 80px); /* Full viewport height minus navbar */
    overflow-y: auto;
    z-index: 999; /* Below main navbar (1000) but above content */
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}

.book-sidebar.active {
    transform: translateX(0);
}

/* Ensure the main content accounts for sidebar when active */
.book-content {
    flex: 1;
    margin-left: 0;
    transition: margin-left 0.3s ease;
}

/* When sidebar is active, push content over on desktop */
@media (min-width: 768px) {
    .book-sidebar.active ~ .book-content {
        margin-left: 320px;
    }
}

.sidebar-header {
    padding: 2rem 1.5rem 1rem;
    border-bottom: 1px solid #e9ecef;
    position: relative;
}

.sidebar-header h3 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.book-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0;
}

.sidebar-toggle {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    display: none;
}

/* Progress Section */
.progress-section {
    padding: 1.5rem;
    border-bottom: 1px solid #e9ecef;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.progress-percent {
    font-weight: 600;
    color: var(--primary-color);
}

.progress-bar {
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--accent-color) 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Table of Contents */
.toc {
    padding: 1.5rem;
}

.toc h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 1rem;
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-item {
    margin-bottom: 0.5rem;
}

.toc-link {
    display: flex;
    align-items: flex-start;
    padding: 0.75rem;
    text-decoration: none;
    color: var(--text-dark);
    border-radius: 8px;
    transition: all 0.2s ease;
    gap: 0.75rem;
}

.toc-link:hover {
    background: #f8f9fa;
    color: var(--primary-color);
}

.toc-item.active .toc-link {
    background: var(--primary-color);
    color: white;
}

.chapter-number {
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--accent-color);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    min-width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.toc-item.active .chapter-number {
    background: rgba(255,255,255,0.2);
}

.chapter-title {
    font-size: 0.9rem;
    line-height: 1.4;
    flex: 1;
}

/* Main Content */
.book-content {
    flex: 1;
    margin-left: 0;
    transition: margin-left 0.3s ease;
}

/* Mobile Header */
.mobile-header {
    display: none;
    position: sticky;
    top: 80px;
    background: white;
    border-bottom: 1px solid #e9ecef;
    padding: 1rem;
    z-index: 999;
    transition: transform 0.3s ease;
}

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

.mobile-sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-dark);
    cursor: pointer;
    padding: 0.5rem;
}

.mobile-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0;
}

.mobile-progress {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-color);
}

/* Chapter Content */
.chapter-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
    background: white;
    min-height: calc(100vh - 200px);
}

.chapter-header {
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 2px solid #e9ecef;
}

.chapter-meta {
    text-align: center;
}

.chapter-label {
    display: inline-block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-color);
    background: rgba(var(--primary-color-rgb), 0.1);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    margin-bottom: 1rem;
}

.chapter-header .chapter-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
    line-height: 1.2;
}

/* Chapter Body Styles */
.chapter-body {
    font-family: 'Crimson Text', 'Georgia', 'Times New Roman', serif; /* More readable book font */
    font-size: 1.1rem;
    line-height: 1.8; /* Increased line height for better readability */
    color: var(--text-dark);
    max-width: 65ch; /* Optimal reading line length */
    margin: 0 auto;
    text-rendering: optimizeLegibility;
}

.chapter-body h2 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 3rem 0 1.5rem; /* Increased top margin */
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 0.5rem;
}

.chapter-body h3 {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-dark);
    margin: 2.5rem 0 1rem; /* Increased top margin */
}

.chapter-body h4 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary-color);
    margin: 2rem 0 1rem; /* Added specific h4 styling with good spacing */
    padding-top: 1rem; /* Extra padding above h4 headers */
}

.chapter-body p {
    margin-bottom: 1.5rem;
    text-align: left;
}

/* Definition lists styling for better readability */
.chapter-body .book-term {
    display: block;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    color: var(--primary-color);
    font-size: 1.3rem;
    line-height: 1.4;
    font-weight: 700;
}

/* Improve spacing for better readability */
.chapter-body > p:not(:last-child) {
    margin-bottom: 1.5rem;
}

/* Better styling for emphasis text */
.chapter-body em, .chapter-body i {
    font-style: italic;
    color: var(--text-dark);
}

/* Improve links within content */
.chapter-body a {
    color: var(--primary-color);
    text-decoration: underline;
    border-bottom: 1px dotted var(--primary-color);
    transition: all 0.2s ease;
}

.chapter-body a:hover {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
}

/* Better blockquote styling */
.chapter-body blockquote {
    background: #f8f9fa;
    border-left: 4px solid var(--primary-color);
    padding: 1.5rem;
    margin: 2rem 0;
    font-style: italic;
    color: var(--text-muted);
    border-radius: 0 4px 4px 0;
}

/* Improve border styling for section dividers */
.chapter-body .border-bottom {
    border-bottom: 2px solid var(--accent-color) !important;
    margin: 2rem 0;
    padding-bottom: 0.5rem;
}

.chapter-body ul, .chapter-body ol {
    margin-bottom: 1.5rem;
    padding-left: 2rem;
}

.chapter-body li {
    margin-bottom: 0.5rem;
}

.chapter-body blockquote {
    background: #f8f9fa;
    border-left: 4px solid var(--primary-color);
    padding: 1.5rem;
    margin: 2rem 0;
    font-style: italic;
    color: var(--text-muted);
}

.chapter-body a {
    color: var(--primary-color);
    text-decoration: none;
    border-bottom: 1px dotted var(--primary-color);
}

.chapter-body a:hover {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
}

.chapter-body .border-bottom {
    border-bottom: 1px solid #e9ecef !important;
    padding-bottom: 1.5rem;
    margin-bottom: 2rem;
}

/* Chapter Navigation */
.chapter-nav {
    background: white;
    border-top: 1px solid #e9ecef;
    padding: 2rem;
    margin-top: 3rem;
}

.nav-buttons {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 2rem;
}

.nav-button {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s ease;
    max-width: 300px;
    gap: 1rem;
}

.nav-button:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.nav-button.prev-button {
    margin-right: auto;
}

.nav-button.next-button {
    margin-left: auto;
}

.nav-arrow {
    font-size: 1.2rem;
    font-weight: bold;
}

.nav-info {
    display: flex;
    flex-direction: column;
}

.nav-label {
    font-size: 0.8rem;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-top: 0.25rem;
}

.nav-center {
    text-align: center;
}

.back-to-top {
    background: none;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.back-to-top:hover {
    background: var(--primary-color);
    color: white;
}

/* Sidebar Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Desktop Styles */
@media (min-width: 769px) {
    .book-sidebar {
        /* Keep fixed positioning for desktop */
        transform: translateX(0); /* Always show on desktop */
    }
    
    .book-content {
        margin-left: 320px; /* Always account for sidebar width on desktop */
    }
    
    .mobile-header {
        display: none;
    }
    
    .sidebar-toggle {
        display: none;
    }
    
    .chapter-content {
        padding: 3rem 2rem;
    }
}

/* Mobile Styles */
@media (max-width: 768px) {
    .book-reader {
        flex-direction: column;
    }
    
    .book-sidebar {
        width: 280px;
    }
    
    .sidebar-toggle {
        display: block;
    }
    
    .mobile-header {
        display: flex;
    }
    
    .chapter-content {
        padding: 2rem 1rem;
    }
    
    .chapter-header .chapter-title {
        font-size: 2rem;
    }
    
    .nav-buttons {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-button {
        max-width: none;
        justify-content: center;
        text-align: center;
    }
    
    .nav-button.prev-button,
    .nav-button.next-button {
        margin: 0;
    }
    
    body.sidebar-open {
        overflow: hidden;
    }
}

@media (max-width: 480px) {
    .chapter-body {
        font-size: 1rem;
    }
    
    .chapter-header .chapter-title {
        font-size: 1.8rem;
    }
    
    .chapter-content {
        padding: 1.5rem 1rem;
    }
}
