/* Generation Modal Styling - Light Footer Theme */
/* FULL SCREEN MODAL FOR EXTRAORDINARY READING EXPERIENCE */
.generation-modal-content {
    height: 95vh;
    max-height: 95vh;
    border: none !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    background: #ffffff !important;
}

/* Scoped to generationModal to avoid affecting previewModal */
#generationModal > .modal-dialog > .modal-content {
    border: none !important;
    background: #f8f9fa !important;
}

.modal-dialog {
    border: none !important;
}

#generationModal {
    background: rgba(248, 249, 250, 0.95) !important;
}

#generationModal .modal-content {
    border: none !important;
    background: #f8f9fa !important;
}

#generationModal .modal-dialog {
    border: none !important;
}

#generationModal .modal-header {
    background: #f8f9fa !important;
    border-bottom: 1px solid #dee2e6 !important;
}

#generationModal .modal-body {
    background: #f8f9fa !important;
}

#generationModal .modal-footer {
    background: #f8f9fa !important;
    border-top: 1px solid #dee2e6 !important;
}

/* FULL SCREEN CONTENT VIEWER FOR EXTRAORDINARY READING */
.content-viewer-fullscreen {
    height: 100%;
    overflow-y: auto;
    background: #ffffff !important;
    border: none !important;
}

.content-stream-fullscreen {
    height: 100%;
    width: 100%;
}

.chapter-content-fullscreen {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.chapter-text-fullscreen {
    flex: 1;
    overflow-y: auto;
    font-family: Georgia, serif;
    line-height: 1.8;
    font-size: 18px;
    color: #2c3e50;
    background: white;
    padding: 2rem 3rem;
}

.streaming-content-fullscreen {
    white-space: pre-wrap;
    word-wrap: break-word;
    min-height: 100%;
    max-width: 900px;
    margin: 0 auto;
}

.generation-start {
    background: #ffffff !important;
    color: #495057 !important;
}

.phase-step {
    background: #ffffff !important;
    border: 1px solid #dee2e6 !important;
    color: #495057 !important;
}

.chapter-list {
    background: #ffffff !important;
}

.chapter-item {
    color: #495057 !important;
    background: transparent !important;
}

.chapter-item.completed {
    color: #28a745 !important;
}

.chapter-item.pending {
    color: #6c757d !important;
}

/* Force light footer styling on all modal elements */
#generationModal * {
    background-color: inherit !important;
}

#generationModal .bg-dark,
#generationModal .text-light,
#generationModal .text-white {
    background: #f8f9fa !important;
    color: #495057 !important;
}

/* Footer bottom styling - scoped to generationModal */
#generationModal .modal-footer {
    background: #f8f9fa !important;
    color: #495057 !important;
    border-top: 1px solid #dee2e6 !important;
}

.reader-controls {
    background: #f8f9fa !important;
    color: #495057 !important;
}

.chapter-text {
    font-family: Georgia, serif;
    line-height: 1.6;
    font-size: 16px;
    color: #2c3e50;
}

.streaming-content {
    white-space: pre-wrap;
    word-wrap: break-word;
}

.content-stream {
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

.generation-start {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.phase-step {
    text-align: center;
    padding: 1rem;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.phase-step i {
    font-size: 1.2rem;
}

.generation-content-container {
    max-height: 300px;
    overflow-y: auto;
    border-radius: 0.375rem;
    padding: 0.5rem;
    font-family: 'Georgia', serif;
    margin-bottom: 0;
    transition: all 0.3s ease;
}

.generation-content {
    font-size: 0.9rem;
    line-height: 1.6;
    color: #212529;
    white-space: pre-wrap;
    padding-left: 15px;
    border-left: 3px solid #f0f0f0;
    overflow-wrap: break-word;
}

.generation-progress {
    margin-bottom: 1.5rem;
}

.generation-progress .progress {
    height: 25px;
    border-radius: 0.375rem;
    background-color: #e9ecef;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.generation-progress .progress-bar {
    background-color: #4869ee;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: width 0.5s ease;
}

/* Success state for progress bar */
.progress-bar.bg-success {
    background-color: #28a745 !important;
    transition: background-color 0.3s ease;
}

#generation-status {
    font-size: 0.9rem;
    color: #6c757d;
    margin-top: 0.5rem;
}

/* Character-by-character animation effects */
@keyframes typing {
    from { opacity: 0; transform: scale(1.2); text-shadow: 0 0 8px rgba(72, 105, 238, 0.8); }
    to { opacity: 1; transform: scale(1); text-shadow: none; }
}

.typing-animation {
    animation: typing 0.2s ease-out; /* More noticeable animation */
    display: inline-block;
    color: #4869ee;
    font-weight: bold;
}

/* Blinking cursor animation */
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.typing-cursor {
    display: inline-block;
    animation: blink 1s infinite;
    font-weight: bold;
    color: #4869ee;
    margin-left: 2px;
    font-size: 1.1em;
}

.blinking-cursor {
    display: inline-block;
    animation: blink 0.5s infinite;
    font-weight: bold;
    color: #4869ee;
    margin-left: 2px;
    font-size: 1.2em;
    vertical-align: middle;
    line-height: 1;
    text-shadow: 0 0 3px rgba(72, 105, 238, 0.7);
}

/* Spinning animation for icons */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.spinning {
    animation: spin 2s linear infinite;
}

/* Chapter progress items styling */
.chapter-progress-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border: 1px solid #e9ecef;
    border-radius: 0.375rem;
    margin-bottom: 0.5rem;
    background-color: #fff;
}

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

.chapter-progress-item .chapter-title {
    font-weight: 500;
    margin-right: 1rem;
}

.chapter-progress-item .chapter-status {
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
    border-radius: 1rem;
    font-weight: 500;
}

.chapter-status-pending {
    background-color: #f8f9fa;
    color: #6c757d;
}

.chapter-status-generating {
    background-color: #fff3cd;
    color: #856404;
}

.chapter-status-completed {
    background-color: #d4edda;
    color: #155724;
}

.chapter-status-error {
    background-color: #f8d7da;
    color: #721c24;
}

/* Modern eBook Reader Styling */
.ebook-reader-modal .modal-content {
    border-radius: 20px;
    border: none;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    background: #ffffff;
}

.ebook-reader-content {
    background: linear-gradient(135deg, #fefefe 0%, #f8f9fa 100%);
    min-height: 90vh;
    height: 90vh;
    max-height: 90vh;
}

.ebook-reader-header {
    background: linear-gradient(90deg, #ffffff 0%, #f8f9fa 100%);
    border-bottom: 1px solid #e9ecef;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.ebook-close-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #6c757d;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.3s ease;
    cursor: pointer;
}

.ebook-close-btn:hover {
    background: rgba(108, 117, 125, 0.1);
    color: #495057;
    transform: scale(1.1);
}

.ebook-reader-body {
    padding: 0;
    background: #ffffff;
}

.book-preview-container {
    border: none;
    padding: 0;
    background: #ffffff;
    font-family: 'Georgia', serif;
    min-height: 75vh;
    height: 75vh;
    max-height: 75vh;
    position: relative;
    overflow-y: auto;
}

/* Book Cover Section */
.ebook-cover-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 3rem 2rem;
    text-align: center;
    color: white;
    position: relative;
}

.ebook-cover-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="20" cy="20" r="1" fill="white" opacity="0.1"/><circle cx="80" cy="50" r="0.5" fill="white" opacity="0.1"/><circle cx="40" cy="80" r="1.5" fill="white" opacity="0.05"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
    opacity: 0.3;
}

.ebook-cover-placeholder {
    position: relative;
    z-index: 1;
    margin-bottom: 1.5rem;
}

.ebook-cover-icon {
    display: none;
}

.book-metadata {
    position: relative;
    z-index: 1;
}

.ebook-title {
    font-size: 1.4rem;
    font-weight: 300;
    margin-bottom: 0.3rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    line-height: 1.2;
}

.ebook-author {
    font-size: 0.9rem;
    opacity: 0.9;
    font-style: italic;
    margin: 0;
}

/* Navigation Tabs */
.ebook-navigation {
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    padding: 0 2rem;
    display: flex;
    gap: 0;
}

.ebook-nav-btn {
    background: none;
    border: none;
    padding: 1rem 1.5rem;
    font-size: 1rem;
    color: #6c757d;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    font-weight: 500;
}

.ebook-nav-btn:hover {
    color: #495057;
    background: rgba(255, 255, 255, 0.5);
}

.ebook-nav-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
    background: white;
}

/* Section Container */
.ebook-section {
    display: none;
    padding: 2rem;
    min-height: 400px;
    height: calc(75vh - 200px);
    overflow-y: auto;
}

.ebook-section.active {
    display: block;
}

/* Table of Contents */
.ebook-toc-container {
    max-width: 600px;
    margin: 0 auto;
}

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

.ebook-toc li {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    color: #212529 !important;
    background: #ffffff;
    border: 1px solid #e9ecef;
}

.ebook-toc li:hover {
    background: #f8f9fa !important;
    transform: translateX(5px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    color: #495057 !important;
}

.ebook-toc li:last-child {
    border-bottom: 1px solid #e9ecef;
}

/* Reading Area */
.ebook-reading-area {
    max-width: 700px;
    margin: 0 auto;
    background: #ffffff;
    padding: 3rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    position: relative;
    border: 1px solid #e9ecef;
}

.ebook-reading-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, 0.02) 2%, transparent 4%);
    pointer-events: none;
    border-radius: 12px;
}

.book-preview-content {
    font-size: 1.1rem;
    line-height: 1.8;
    color: #212529 !important;
    letter-spacing: 0.02rem;
    text-align: justify;
    hyphens: auto;
    position: relative;
    z-index: 2;
}

/* Enhanced Typography */
.book-preview-content h1,
.book-preview-content h2,
.book-preview-content h3 {
    font-family: 'Georgia', serif;
    color: #212529 !important;
    font-weight: 600;
    line-height: 1.3;
}

.book-preview-content h1 {
    font-size: 2rem;
    margin: 2rem 0 1.5rem 0;
    text-align: center;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 1rem;
    color: #212529 !important;
}

.book-preview-content h2 {
    font-size: 1.6rem;
    margin: 2rem 0 1rem 0;
    color: #495057 !important;
}

.book-preview-content h3 {
    font-size: 1.3rem;
    margin: 1.5rem 0 0.8rem 0;
    color: #495057 !important;
}

.book-preview-content p {
    margin-bottom: 1.5rem;
    text-indent: 2em;
    color: #212529 !important;
}

.book-preview-content p:first-of-type {
    text-indent: 0;
    color: #212529 !important;
}

.book-preview-content strong {
    color: #212529 !important;
    font-weight: bold;
}

.book-preview-content em {
    color: #212529 !important;
    font-style: italic;
}

/* Footer */
.ebook-reader-footer {
    background: linear-gradient(90deg, #f8f9fa 0%, #ffffff 100%);
    border-top: 1px solid #e9ecef;
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ebook-action-btn {
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    font-weight: 500;
    transition: all 0.3s ease;
    border: 2px solid #6c757d !important;
    color: #6c757d !important;
    background: #ffffff !important;
}

.ebook-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    background: #6c757d !important;
    color: #ffffff !important;
}

.ebook-action-btn i {
    margin-right: 0.5rem;
}

.ebook-footer-meta {
    display: flex;
    align-items: center;
    color: #6c757d;
    font-size: 0.9rem;
}

.ebook-generated-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Loading State */
.ebook-loading {
    text-align: center;
    padding: 4rem 2rem;
    color: #495057 !important;
    background: #ffffff;
}

.ebook-loading p {
    color: #495057 !important;
    font-size: 1.1rem;
}

.ebook-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Chapter Reader Specific Styles */
.chapter-reader {
    max-width: 900px;
}

.chapter-header-info {
    flex: 1;
}

.chapter-title-text {
    font-size: 1.2rem;
    font-weight: 500;
    color: #495057;
}

.chapter-container {
    background: #ffffff;
}

.chapter-reading {
    max-width: 650px;
    margin: 0 auto;
}

.chapter-content {
    padding: 2rem;
}

.chapter-footer {
    justify-content: flex-start;
    gap: 1rem;
}

.chapter-actions {
    display: flex;
    gap: 1rem;
}

/* Mobile Draggable Reader */
.mobile-reader-container {
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.mobile-resize-handle {
    width: 100%;
    height: 30px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.05), rgba(0,0,0,0.1), rgba(0,0,0,0.05));
    cursor: ns-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
    user-select: none;
    position: relative;
    border-top: 1px solid #e9ecef;
    border-bottom: 1px solid #e9ecef;
    margin: 5px 0;
}

.mobile-resize-handle::before {
    content: '⋯';
    color: #4869ee;
    font-size: 2rem;
    font-weight: bold;
    opacity: 0.8;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

.mobile-resize-handle:active::before {
    opacity: 1;
    color: #3355dd;
    transform: scale(1.1);
}

/* Responsive Design */
@media (max-width: 768px) {
    .ebook-reader-content {
        height: 100vh;
        max-height: 100vh;
        display: flex;
        flex-direction: column;
    }
    
    .ebook-reader-body {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        padding: 0;
    }
    
    .book-preview-container {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        padding: 0;
        height: 100%;
    }
    
    .ebook-cover-section {
        padding: 0.5rem 1rem 0.3rem 1rem;
        flex-shrink: 0;
    }
    
    .ebook-navigation {
        padding: 0;
        flex-shrink: 0;
        background: #f8f9fa;
        border-bottom: 1px solid #e9ecef;
    }
    
    .ebook-section {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        padding: 0;
        height: auto;
        min-height: 0;
    }
    
    .ebook-section.active {
        display: flex;
    }
    
    .ebook-title {
        font-size: 1.2rem;
        margin-bottom: 0.2rem;
        line-height: 1.2;
    }
    
    .ebook-author {
        font-size: 0.8rem;
        margin: 0;
    }
    
    .ebook-reading-area {
        flex: 1;
        padding: 1rem;
        margin: 0;
        overflow-y: auto;
        border-radius: 0;
        background: #ffffff;
        min-height: 200px;
        max-height: none;
    }
    
    .book-preview-content {
        font-size: 1rem;
        line-height: 1.6;
        max-width: none;
    }
    
    .ebook-nav-btn {
        padding: 0.7rem 1rem;
        font-size: 0.9rem;
        flex: 1;
        border-radius: 0;
    }
    
    .ebook-reader-footer {
        flex-shrink: 0;
        flex-direction: row;
        gap: 0.5rem;
        padding: 0.7rem;
        background: rgba(248, 249, 250, 0.98);
        border-top: 1px solid #e9ecef;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .ebook-action-btn {
        font-size: 0.85rem;
        padding: 0.5rem 1rem;
        flex: 0 0 auto;
        min-width: 100px;
    }
    
    .chapter-actions {
        display: flex;
        gap: 0.5rem;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .chapter-footer {
        justify-content: center;
    }
    
    /* Adjust modal dialog for mobile */
    .ebook-reader-modal .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100vh;
        display: flex;
    }
    
    .ebook-reader-modal .modal-content {
        border-radius: 0;
        border: none;
        height: 100vh;
        display: flex;
        flex-direction: column;
    }
    
    /* Table of Contents mobile optimization */
    .ebook-toc-container {
        flex: 1;
        overflow-y: auto;
        padding: 1rem;
    }
    
    .ebook-toc {
        margin: 0;
        padding: 0;
    }
    
    .ebook-toc li {
        padding: 1rem;
        margin-bottom: 0.5rem;
        font-size: 0.95rem;
        background: #ffffff;
        border: 1px solid #e9ecef;
        border-radius: 8px;
    }
    
    .ebook-toc li:hover,
    .ebook-toc li:active {
        background: #f8f9fa;
        transform: none;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }
}

/* Modal-specific styling for the book preview modal */
#bookPreviewModal .modal-footer {
    /* The general modal-footer styles will handle alignment */
}

.book-preview-content {
    font-size: 1.05rem;
    line-height: 1.8;
    color: #212529;
    letter-spacing: 0.01rem;
    max-width: 42em;
    margin: 0 auto;
}

/* Book content formatting */
.book-preview-content h1,
.book-preview-content h2,
.book-preview-content h3 {
    font-family: 'Georgia', serif;
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.book-preview-content h1 {
    font-size: 1.75rem;
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 0.5rem;
}

.book-preview-content h2 {
    font-size: 1.5rem;
}

.book-preview-content h3 {
    font-size: 1.25rem;
}

.book-preview-content p {
    margin-bottom: 1rem;
    text-align: justify;
}

.book-preview-content ul, 
.book-preview-content ol {
    margin-bottom: 1.5rem;
    padding-left: 2rem;
}

.book-preview-content li {
    margin-bottom: 0.5rem;
}

.book-preview-content blockquote {
    border-left: 3px solid #ccc;
    margin-left: 1.5rem;
    padding-left: 1rem;
    font-style: italic;
    color: #555;
    margin-bottom: 1.5rem;
}

.book-preview-content em {
    font-style: italic;
}

.book-preview-content strong {
    font-weight: bold;
}

/* First paragraph and dropcap styling */
.book-preview-content .first-paragraph {
    margin-top: 1.5rem;
}

.book-preview-content .dropcap {
    float: left;
    font-size: 3.5rem;
    line-height: 0.8;
    margin-right: 0.2em;
    margin-top: 0.15em;
    font-weight: bold;
    color: #4869ee;
}

/* Chapter Preview Modal Style */
#chapterPreviewModal .modal-content {
    background-color: #fff;
    color: #212529;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

#chapterPreviewModal .modal-header {
    border-bottom: 1px solid #e9ecef;
    background: linear-gradient(to right, #f8f9fa, #ffffff);
    border-radius: 8px 8px 0 0;
    padding: 1.25rem 1.5rem;
}

#chapterPreviewModal .modal-body {
    padding: 0;
    max-height: 70vh;
    overflow-y: auto;
}

#chapterPreviewModal .modal-footer {
    border-top: 1px solid #e9ecef;
    background: linear-gradient(to right, #ffffff, #f8f9fa);
    border-radius: 0 0 8px 8px;
    padding: 1rem 1.5rem;
}

/* Inline generation container styles for real-time streaming */
#inline-generation-container {
    margin-top: 2rem;
    margin-bottom: 2rem;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    background-color: #f8f9fa;
    transition: all 0.3s ease;
    position: relative;
}

/* Animation for Claude-like pulsing effect */
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(72, 105, 238, 0.4); }
    70% { box-shadow: 0 0 0 5px rgba(72, 105, 238, 0); }
    100% { box-shadow: 0 0 0 0 rgba(72, 105, 238, 0); }
}

/* Apply animation to container when generating */
#inline-generation-container.generating {
    animation: pulse 2s infinite;
    border-left: 3px solid #4869ee;
}

#inline-content-display {
    max-height: 600px;
    overflow-y: auto;
    padding: 40px 50px;
    font-family: 'Times New Roman', Times, serif;
    font-size: 18px;
    line-height: 1.8;
    margin-top: 1rem;
    background-color: #fefefe;
    background-image: linear-gradient(135deg, #fefefe 0%, #fcfcfc 100%);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.08), inset 0 2px 8px rgba(0,0,0,0.03);
    position: relative;
    color: #1a1a1a;
    text-align: justify;
    text-justify: inter-word;
    hyphens: auto;
    text-indent: 2em;
}

/* Active typing with cursor styling */
#inline-content-display.typing::after {
    content: "|";
    display: inline-block;
    color: #4869ee;
    font-weight: bold;
    animation: blink 0.7s infinite;
    position: relative;
    margin-left: 2px;
    font-size: 1.1em;
    line-height: 1;
    vertical-align: middle;
}

/* Typing cursor styling */
.typing-cursor {
    display: inline-block;
    vertical-align: middle;
    color: #4869ee;
    font-weight: bold;
    animation: blink 0.5s infinite;
    font-size: 1.2em;
    text-shadow: 0 0 3px rgba(72, 105, 238, 0.7);
}

/* Enhanced streamed content styling */
.streamed-content {
    opacity: 1;
    transition: opacity 0.5s ease;
}

/* Simplified generation modal styles */
#generationModal .modal-content {
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

#generationModal .modal-body {
    padding: 2rem;
    background-color: #ffffff;
}

#generationModal .progress {
    overflow: hidden;
    height: 25px;
}

#generationModal .progress-bar {
    transition: width 0.8s ease, background-color 0.3s ease;
}

/* General modal footer styles for consistent button alignment - SCOPED to generationModal */
#generationModal .modal-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    align-items: center;
}

#generationModal .modal-footer .btn,
#generationModal .modal-footer form {
    min-width: 100px;
    margin: 0; /* Remove default button margins */
    flex: 0 1 auto;
}

#generationModal .modal-footer form {
    display: inline-flex;
}

#generationModal .modal-footer form button {
    width: 100%;
}

/* Responsive adjustments for smaller screens - SCOPED to generationModal */
@media (max-width: 576px) {
    #generationModal .modal-footer {
        flex-direction: column;
        align-items: stretch;
    }
    
    #generationModal .modal-footer .btn,
    #generationModal .modal-footer form {
        width: 100%;
        margin-bottom: 5px;
    }
    
    /* Change the button order on mobile */
    #generationModal .modal-footer .btn-secondary {
        order: 10; /* Move close button to the bottom */
    }
    
    #generationModal .modal-footer .btn-danger {
        order: 5; /* Keep delete button in the middle */
    }
    
    #generationModal .modal-footer .btn-primary,
    #generationModal .modal-footer .btn-success {
        order: 1; /* Primary actions at the top */
    }
}

/* Very small screen adjustments - hide text, keep icons - SCOPED to generationModal */
@media (max-width: 350px) {
    #generationModal .modal-footer .btn .button-text {
        display: none;
    }
    
    #generationModal .modal-footer .btn {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
        min-width: 44px;
        text-align: center;
    }
    
    #generationModal .modal-footer .btn i {
        margin-right: 0 !important;
        font-size: 1.1rem;
    }
    
    /* For side-by-side layout on very small screens */
    #generationModal .modal-footer {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
    }
    
    #generationModal .modal-footer .btn,
    #generationModal .modal-footer form {
        flex: 0 0 auto;
        margin-bottom: 5px;
        width: auto;
    }
}

/* Dark theme overrides if needed */
[data-bs-theme="dark"] .modal-content {
    background-color: #212529;
    color: #f8f9fa;
}

[data-bs-theme="dark"] .modal-header {
    border-bottom: 1px solid #343a40;
    background: linear-gradient(to right, #2c3034, #212529);
}

[data-bs-theme="dark"] .modal-footer {
    border-top: 1px solid #343a40;
    background: linear-gradient(to right, #212529, #2c3034);
}

[data-bs-theme="dark"] .generation-content-container {
    background-color: #2c3034;
    border-color: #343a40;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

[data-bs-theme="dark"] .generation-content {
    color: #f8f9fa;
}

[data-bs-theme="dark"] .chapter-progress-item {
    background-color: #343a40;
    border-color: #495057;
}

[data-bs-theme="dark"] .book-preview-container {
    background-color: #2c3034;
    border-color: #343a40;
}

[data-bs-theme="dark"] .book-preview-content {
    color: #f8f9fa;
}

[data-bs-theme="dark"] .book-preview-content h1 {
    border-bottom-color: #343a40;
}

[data-bs-theme="dark"] .book-preview-content blockquote {
    border-left-color: #495057;
    color: #adb5bd;
}

[data-bs-theme="dark"] .book-preview-content .dropcap {
    color: #6c91fa;
}

[data-bs-theme="dark"] #chapterPreviewModal .modal-content {
    background-color: #212529;
    color: #f8f9fa;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

[data-bs-theme="dark"] #chapterPreviewModal .modal-header {
    background: linear-gradient(to right, #2c3034, #212529);
    border-bottom-color: #343a40;
}

[data-bs-theme="dark"] #chapterPreviewModal .modal-footer {
    background: linear-gradient(to right, #212529, #2c3034);
    border-top-color: #343a40;
}

/* RTL (Right-to-Left) Language Support */
.rtl-content,
[dir="rtl"] .streaming-content-fullscreen,
[dir="rtl"] .book-preview-content,
[dir="rtl"] .chapter-text-fullscreen {
    direction: rtl;
    text-align: right;
}

.rtl-content blockquote,
[dir="rtl"] blockquote {
    border-left: none;
    border-right: 3px solid #ccc;
    padding-left: 0;
    padding-right: 1em;
    margin-left: 0;
    margin-right: 1em;
}

[data-bs-theme="dark"] .rtl-content blockquote,
[data-bs-theme="dark"] [dir="rtl"] blockquote {
    border-right-color: #495057;
}

/* ========================================
   PROFESSIONAL PAGE-BASED BOOK PREVIEW
   ======================================== */

/* Modal Container */
.ebook-page-modal .modal-content {
    border: none;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.3);
}

.ebook-page-content {
    background: #e8e4df;
    border: none;
}

.ebook-page-body {
    padding: 2rem;
    background: linear-gradient(135deg, #d4cfc9 0%, #e8e4df 50%, #d4cfc9 100%);
    min-height: 70vh;
}

/* Book Pages Wrapper */
.book-pages-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    min-height: 60vh;
}

/* Page Navigation Buttons */
.page-nav-btn {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid #ccc;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #555;
    flex-shrink: 0;
}

.page-nav-btn:hover:not(:disabled) {
    background: #fff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    transform: scale(1.1);
}

.page-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Book Page Display */
.book-page-display {
    flex: 1;
    max-width: 650px;
    perspective: 1500px;
}

.book-page {
    background: #fffef9;
    border-radius: 4px;
    box-shadow: 
        0 0 5px rgba(0, 0, 0, 0.1),
        0 5px 20px rgba(0, 0, 0, 0.15),
        inset 0 0 50px rgba(0, 0, 0, 0.02);
    min-height: 500px;
    max-height: 65vh;
    overflow-y: auto;
    padding: 3rem 2.5rem;
    position: relative;
    font-family: 'Georgia', 'Times New Roman', serif;
    line-height: 1.7;
    color: #2c2c2c;
}

/* Page edge effect */
.book-page::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(90deg, rgba(0,0,0,0.03) 0%, transparent 100%);
    pointer-events: none;
}

.book-page::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(-90deg, rgba(0,0,0,0.02) 0%, transparent 100%);
    pointer-events: none;
}

/* Page Loading */
.page-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

/* Page Info Bar */
.page-info-bar {
    text-align: center;
    padding: 1rem;
    color: #666;
    font-size: 0.9rem;
}

.page-counter {
    background: rgba(255, 255, 255, 0.7);
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-family: 'Georgia', serif;
}

/* Footer */
.ebook-page-footer {
    background: #f5f3f0;
    border-top: 1px solid #ddd;
    padding: 1rem 2rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
}

/* ========================================
   PAGE CONTENT TYPES
   ======================================== */

/* Cover Page */
.page-cover {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 450px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin: -3rem -2.5rem;
    padding: 3rem 2.5rem;
    border-radius: 4px;
}

.page-cover .cover-placeholder {
    font-size: 4rem;
    opacity: 0.3;
    margin-bottom: 2rem;
}

.page-cover .book-title {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 1rem;
    line-height: 1.3;
}

.page-cover .book-author {
    font-size: 1.2rem;
    opacity: 0.9;
    font-style: italic;
}

/* Blank Page */
.page-blank {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 450px;
    color: #ccc;
    font-style: italic;
}

/* Title Page */
.page-title {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 450px;
}

.page-title .author-name {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 2rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.page-title .main-title {
    font-size: 2.2rem;
    font-weight: 600;
    color: #2c2c2c;
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

.page-title .subtitle {
    font-size: 1.1rem;
    color: #666;
    font-style: italic;
    margin-top: 1rem;
}

.page-title .edition-info {
    margin-top: 3rem;
    font-size: 0.9rem;
    color: #888;
}

/* Description/Blurb Page */
.page-description {
    min-height: 450px;
}

.page-description .section-title {
    text-align: center;
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 2rem;
    color: #444;
    border-bottom: 1px solid #ddd;
    padding-bottom: 1rem;
}

.page-description .blurb-text {
    font-size: 1.1rem;
    line-height: 1.9;
    text-align: justify;
    color: #333;
}

/* Table of Contents Page */
.page-toc {
    min-height: 450px;
}

.page-toc .toc-title {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 2rem;
    color: #2c2c2c;
}

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

.page-toc .toc-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.6rem 0;
    border-bottom: 1px dotted #ccc;
}

.page-toc .toc-item:last-child {
    border-bottom: none;
}

.page-toc .toc-chapter-num {
    color: #888;
    margin-right: 0.5rem;
}

.page-toc .toc-chapter-title {
    flex: 1;
    color: #333;
}

.page-toc .toc-page-num {
    color: #888;
    font-size: 0.9rem;
}

/* Chapter Page */
.page-chapter {
    min-height: 450px;
}

.page-chapter .chapter-heading {
    text-align: center;
    margin-bottom: 2rem;
}

.page-chapter .chapter-number {
    font-size: 0.9rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    margin-bottom: 0.5rem;
}

.page-chapter .chapter-title {
    font-size: 1.6rem;
    font-weight: 600;
    color: #2c2c2c;
    line-height: 1.3;
}

.page-chapter .chapter-content {
    font-size: 1.05rem;
    line-height: 1.8;
    text-align: justify;
}

.page-chapter .chapter-content p {
    margin-bottom: 1.2rem;
    text-indent: 1.5em;
}

.page-chapter .chapter-content p:first-child {
    text-indent: 0;
}

/* Author Biography Page */
.page-biography {
    min-height: 450px;
}

.page-biography .bio-title {
    text-align: center;
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 2rem;
    color: #444;
}

.page-biography .bio-content {
    font-size: 1.05rem;
    line-height: 1.9;
    text-align: justify;
    color: #333;
}

/* RTL Support for Book Pages */
[dir="rtl"] .book-page,
.book-page.rtl-page {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] .book-page::before,
.book-page.rtl-page::before {
    left: auto;
    right: 0;
    background: linear-gradient(-90deg, rgba(0,0,0,0.03) 0%, transparent 100%);
}

[dir="rtl"] .book-page::after,
.book-page.rtl-page::after {
    right: auto;
    left: 0;
    background: linear-gradient(90deg, rgba(0,0,0,0.02) 0%, transparent 100%);
}

[dir="rtl"] .page-chapter .chapter-content p,
.book-page.rtl-page .page-chapter .chapter-content p {
    text-indent: 0;
}

[dir="rtl"] .page-toc .toc-item,
.book-page.rtl-page .page-toc .toc-item {
    flex-direction: row-reverse;
}

/* Responsive Adjustments for old modals */
@media (max-width: 768px) {
    .ebook-page-body {
        padding: 1rem;
    }
    
    .book-page-display {
        max-width: 100%;
    }
    
    .book-page {
        padding: 2rem 1.5rem;
        min-height: 400px;
        max-height: 55vh;
    }
    
    .page-nav-btn {
        width: 36px;
        height: 36px;
    }
    
    .page-cover .book-title {
        font-size: 1.5rem;
    }
    
    .page-title .main-title {
        font-size: 1.6rem;
    }
    
    .ebook-page-footer {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* ========================================
   PROFESSIONAL EPUB READER - WYSIWYG PREVIEW
   True eBook Reader Experience
   ======================================== */

/* Full Screen Reader Modal */
.epub-reader-modal {
    margin: 0;
    max-width: 100%;
    width: 100%;
    height: 100%;
}

.epub-reader-content {
    background: #f8f9fa !important;
    border: none !important;
    border-radius: 0 !important;
    height: 100vh !important;
    display: flex !important;
    flex-direction: column !important;
}

/* Reader Header Chrome - Light Theme */
.epub-reader-header {
    background: #ffffff !important;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #e9ecef !important;
    flex-shrink: 0;
}

.reader-header-left {
    display: flex;
    align-items: center;
    color: #212529 !important;
    font-weight: 500;
    min-width: 0;
    flex: 1;
}

.reader-book-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 400px;
    color: #212529 !important;
}

.reader-header-center {
    flex: 2;
    text-align: center;
}

.reader-progress {
    color: #6c757d !important;
    font-size: 0.9rem;
}

.reader-header-right {
    flex: 1;
    display: flex;
    justify-content: flex-end;
}

.reader-close-btn {
    border-radius: 50%;
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent !important;
    border: 1px solid #dee2e6 !important;
    color: #495057 !important;
}

.reader-close-btn:hover {
    background: #e9ecef !important;
    color: #212529 !important;
}

/* Main Reader Body - Light Theme */
.epub-reader-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa !important;
    position: relative;
    padding: 2rem;
    overflow: hidden;
}

/* Navigation Arrows - Light Theme */
.epub-nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: #ffffff !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #495057 !important;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.epub-nav-prev {
    left: 1.5rem;
}

.epub-nav-next {
    right: 1.5rem;
}

.epub-nav-arrow:hover:not(:disabled) {
    background: #e9ecef !important;
    border-color: #adb5bd !important;
    transform: translateY(-50%) scale(1.05);
    color: #212529 !important;
}

.epub-nav-arrow:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Book Container - Expanded to fill space */
.epub-book-container {
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 100%;
    width: 100%;
    height: calc(100vh - 120px);
    perspective: 2000px;
    position: relative;
    padding: 0.5rem;
}

/* epub.js Viewer Area - WYSIWYG rendering */
.epub-viewer-area {
    width: 100%;
    height: 100%;
    background: #fdfcf7;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    position: relative;
    overflow: hidden;
}

/* epub.js iframe styling */
.epub-viewer-area iframe {
    border: none !important;
    background: #fdfcf7 !important;
}

/* Light theme for epub.js content */
.epub-viewer-area .epub-container {
    background: #fdfcf7 !important;
}

/* Two-Page Book Wrapper - Larger, fills more space */
.epub-book-wrapper {
    display: flex;
    align-items: stretch;
    transform: rotateY(0deg);
    transform-style: preserve-3d;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border-radius: 2px;
    height: 95%;
    max-height: 95%;
}

/* Book Pages - Wider to fill space, hidden scrollbar for clean look */
.epub-page {
    background: #fdfcf7;
    width: 45vw;
    max-width: 500px;
    min-width: 300px;
    min-height: 400px;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    font-family: 'Georgia', 'Palatino Linotype', 'Book Antiqua', serif;
    font-size: 0.85rem;
    line-height: 1.75;
    color: #2c2c2c;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,0.15) transparent;
}

/* Hide scrollbar but keep functionality */
.epub-page::-webkit-scrollbar {
    width: 4px;
}

.epub-page::-webkit-scrollbar-track {
    background: transparent;
}

.epub-page::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.1);
    border-radius: 2px;
}

.epub-page::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.2);
}

/* Left Page */
.epub-page-left {
    border-radius: 4px 0 0 4px;
    box-shadow: inset -5px 0 15px rgba(0, 0, 0, 0.05);
}

.epub-page-left::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 40px;
    background: linear-gradient(90deg, rgba(0,0,0,0.04) 0%, transparent 100%);
    pointer-events: none;
}

/* Book Spine - Subtle professional divider */
.epub-book-spine {
    width: 3px;
    background: linear-gradient(90deg, 
        rgba(0, 0, 0, 0.08) 0%, 
        rgba(0, 0, 0, 0.12) 50%,
        rgba(0, 0, 0, 0.08) 100%
    );
    position: relative;
}

.epub-book-spine::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -3px;
    width: 6px;
    background: linear-gradient(90deg, 
        transparent 0%,
        rgba(0, 0, 0, 0.03) 50%,
        transparent 100%
    );
}

.epub-book-spine::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    right: -3px;
    width: 6px;
    background: linear-gradient(90deg, 
        transparent 0%,
        rgba(0, 0, 0, 0.03) 50%,
        transparent 100%
    );
}

/* Right Page */
.epub-page-right {
    border-radius: 0 4px 4px 0;
    box-shadow: inset 5px 0 15px rgba(0, 0, 0, 0.05);
}

.epub-page-right::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 40px;
    background: linear-gradient(-90deg, rgba(0,0,0,0.04) 0%, transparent 100%);
    pointer-events: none;
}

/* Page Inner Content - Proportional padding */
.epub-page-inner {
    padding: 1rem 1.25rem;
    min-height: 100%;
}

/* Paper Texture Overlay */
.epub-page::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    opacity: 0.015;
    pointer-events: none;
}

/* Loading State - Light Theme */
.epub-loading-state {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.epub-loading-state.hidden {
    display: none;
}

.epub-loading-book {
    text-align: center;
    color: #212529 !important;
}

.epub-loading-book p {
    color: #495057 !important;
}

.epub-loading-book .text-muted {
    color: #6c757d !important;
}

.epub-loading-book .spinner-border {
    width: 3rem;
    height: 3rem;
    color: #0d6efd !important;
}

/* Reader Footer - Light Theme - Minimal like real readers */
.epub-reader-footer {
    background: #fafafa !important;
    padding: 0.35rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid #e9ecef !important;
    flex-shrink: 0;
    min-height: auto;
}

.footer-left {
    flex: 1;
}

.page-indicator {
    color: #888 !important;
    font-size: 0.75rem;
    font-family: 'Georgia', serif;
}

.location-divider {
    margin: 0 0.5rem;
    color: #adb5bd !important;
}

.footer-center {
    flex: 3;
    padding: 0 2rem;
}

.reading-progress-container {
    background: #e9ecef !important;
    height: 4px;
    border-radius: 2px;
    overflow: hidden;
    cursor: pointer;
}

.reading-progress-bar {
    height: 100%;
    background: #0d6efd;
    border-radius: 2px;
    transition: width 0.3s ease;
}

.footer-right {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.footer-action-btn {
    border-radius: 4px;
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

/* Chapter Content Styling in Reader */
/* Typography proportional to page size like real ebook readers */
.epub-page-inner h1,
.epub-page-inner h2,
.epub-page-inner h3 {
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: #1a1a1a;
}

.epub-page-inner h1 {
    font-size: 1rem;
    text-align: center;
    margin-top: 1rem;
}

.epub-page-inner h2 {
    font-size: 0.9rem;
}

.epub-page-inner p {
    font-size: 0.8rem;
    line-height: 1.7;
    margin-bottom: 0.75rem;
    text-align: justify;
    text-indent: 1.25em;
}

.epub-page-inner p:first-child {
    text-indent: 0;
}

/* Cover Page Styling - Proportional */
.epub-cover-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
    min-height: 100%;
}

.epub-cover-page .cover-icon {
    font-size: 2.5rem;
    opacity: 0.3;
    margin-bottom: 1rem;
}

.epub-cover-page .cover-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.epub-cover-page .cover-author {
    font-size: 0.85rem;
    opacity: 0.9;
    font-style: italic;
}

/* Blank Page */
.epub-blank-page {
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(0, 0, 0, 0.2);
    font-style: italic;
    min-height: 100%;
}

/* Title Page - Proportional */
.epub-title-page {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: 1.5rem 1rem;
}

.epub-title-page .title-author {
    font-size: 0.7rem;
    color: #666;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.epub-title-page .title-main {
    font-size: 1.3rem;
    font-weight: 600;
    color: #1a1a1a;
    line-height: 1.2;
    margin-bottom: 0.5rem;
}

.epub-title-page .title-edition {
    margin-top: 1.5rem;
    font-size: 0.65rem;
    color: #888;
}

/* TOC Page - Proportional */
.epub-toc-page {
    padding: 1.25rem 1.5rem;
}

.epub-toc-page .toc-heading {
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #333;
}

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

.epub-toc-page .toc-item {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px dotted #ccc;
    cursor: pointer;
    transition: background 0.2s ease;
    font-size: 0.75rem;
}

.epub-toc-page .toc-item:hover {
    background: rgba(102, 126, 234, 0.1);
}

.epub-toc-page .toc-chapter-title {
    color: #333;
}

.epub-toc-page .toc-page-num {
    color: #888;
    font-style: italic;
}

/* Chapter Page - Proportional typography like real ebook readers */
.epub-chapter-page {
    padding: 1.25rem 1.5rem;
}

.epub-chapter-page .chapter-header {
    text-align: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #eee;
}

.epub-chapter-page .chapter-number {
    font-size: 0.65rem;
    color: #888;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.epub-chapter-page .chapter-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0;
}

.epub-chapter-page .chapter-body {
    font-size: 0.8rem;
    line-height: 1.7;
    color: #2c2c2c;
}

.epub-chapter-page .chapter-body p {
    margin-bottom: 0.75rem;
    text-align: justify;
    text-indent: 1.25em;
}

.epub-chapter-page .chapter-body p:first-child {
    text-indent: 0;
}

/* Biography Page - Proportional */
.epub-bio-page {
    padding: 1.25rem 1.5rem;
}

.epub-bio-page .bio-heading {
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #444;
}

.epub-bio-page .bio-text {
    font-size: 0.8rem;
    line-height: 1.7;
    text-align: justify;
    color: #333;
}

/* RTL Support for EPUB Reader */
[dir="rtl"] .epub-page-inner,
.epub-page.rtl-page .epub-page-inner {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] .epub-page-inner p,
.epub-page.rtl-page .epub-page-inner p {
    text-indent: 0;
}

[dir="rtl"] .epub-toc-page .toc-item,
.epub-page.rtl-page .epub-toc-page .toc-item {
    flex-direction: row-reverse;
}

/* RTL Navigation Swap */
[dir="rtl"] .epub-nav-prev,
.epub-reader-rtl .epub-nav-prev {
    left: auto;
    right: 2rem;
}

[dir="rtl"] .epub-nav-next,
.epub-reader-rtl .epub-nav-next {
    right: auto;
    left: 2rem;
}

/* Responsive Design for EPUB Reader */
@media (max-width: 1200px) {
    .epub-page {
        width: 350px;
    }
}

@media (max-width: 992px) {
    .epub-book-wrapper {
        flex-direction: column;
    }
    
    .epub-book-spine {
        width: 100%;
        height: 10px;
    }
    
    .epub-book-spine::before {
        top: 50%;
        left: 0;
        right: 0;
        width: auto;
        height: 2px;
        transform: translateY(-50%);
    }
    
    .epub-page {
        width: 100%;
        max-width: 500px;
        border-radius: 4px;
    }
    
    .epub-page-left {
        border-radius: 4px 4px 0 0;
    }
    
    .epub-page-right {
        border-radius: 0 0 4px 4px;
    }
    
    .epub-nav-arrow {
        width: 44px;
        height: 44px;
    }
    
    .epub-nav-prev {
        left: 1rem;
    }
    
    .epub-nav-next {
        right: 1rem;
    }
}

@media (max-width: 768px) {
    .epub-reader-header {
        padding: 0.5rem 1rem;
    }
    
    .reader-book-title {
        max-width: 200px;
        font-size: 0.9rem;
    }
    
    .reader-header-center {
        display: none;
    }
    
    .epub-reader-body {
        padding: 1rem;
    }
    
    .epub-book-container {
        height: calc(100vh - 150px);
    }
    
    .epub-page {
        min-height: 400px;
    }
    
    .epub-page-inner {
        padding: 1.5rem 1rem;
    }
    
    .epub-nav-arrow {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .epub-nav-prev {
        left: 0.5rem;
    }
    
    .epub-nav-next {
        right: 0.5rem;
    }
    
    .epub-reader-footer {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .footer-left, .footer-right {
        flex: 1 1 100%;
        text-align: center;
    }
    
    .footer-center {
        flex: 1 1 100%;
        padding: 0.5rem 0;
        order: -1;
    }
    
    .footer-right {
        justify-content: center;
    }
    
    .footer-action-btn {
        padding: 0.4rem 1rem;
        font-size: 0.9rem;
    }
}

/* Single Page Mode for Small Screens */
@media (max-width: 600px) {
    .epub-page-left {
        display: none;
    }
    
    .epub-book-spine {
        display: none;
    }
    
    .epub-page-right {
        border-radius: 4px;
        width: calc(100vw - 100px);
    }
}