/* Reading Interface - Vertical Maximized Layout */
.reading-interface {
    background: #fff;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

/* Minimalist Header */
.minimal-header {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 60;
    background: rgba(248, 249, 250, 0.95);
    backdrop-filter: blur(10px);
    padding: 0.75rem 2rem;
    border-radius: 0 0 12px 12px;
    transition: all 0.3s ease;
    opacity: 0;
    pointer-events: none;
}

.minimal-header.visible {
    opacity: 1;
    pointer-events: auto;
}

.book-title {
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.95rem;
    text-align: center;
    white-space: nowrap;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Side Panels - Navigation Only */
.side-panel {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 50;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    opacity: 0;
    pointer-events: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.side-panel.visible {
    opacity: 1;
    pointer-events: auto;
}

.left-panel {
    left: 1.5rem;
}

.right-panel {
    right: 1.5rem;
}

/* Corner Controls */
.corner-control {
    position: fixed;
    z-index: 65;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    padding: 0.75rem;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    opacity: 0;
    pointer-events: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.corner-control.visible {
    opacity: 1;
    pointer-events: auto;
}

.top-left {
    top: 4rem;
    left: 1rem;
}

.top-right {
    top: 4rem;
    right: 1rem;
}

.bottom-left {
    bottom: 1.5rem;
    left: 1.5rem;
}

.bottom-right {
    bottom: 1.5rem;
    right: 1.5rem;
}

/* Control Buttons - Shared Styles */
.corner-btn, .side-control {
    background: #3498db;
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.2);
}

.corner-btn {
    border-radius: 8px;
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
}

.side-control {
    border-radius: 12px;
    width: 56px;
    height: 56px;
    font-size: 1.5rem;
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.2);
}

.corner-btn:hover:not(:disabled), .side-control:hover:not(:disabled) {
    background: #2980b9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.side-control:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.3);
}

.side-control:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Button Variants */
.corner-btn.back-to-library, .side-control.back-to-library {
    background: #6c757d;
    font-size: 1.2rem;
}

.corner-btn.back-to-library:hover, .side-control.back-to-library:hover {
    background: #5a6268;
}

.corner-btn.toc-btn, .side-control.toc-btn {
    background: #17a2b8;
    font-size: 1.2rem;
}

.corner-btn.toc-btn:hover, .side-control.toc-btn:hover {
    background: #138496;
}

/* Font Size Controls in Top Right Corner */
.font-size-controls {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(241, 243, 244, 0.8);
    border-radius: 8px;
    padding: 0.4rem;
}

.font-btn {
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    width: 32px;
    height: 24px;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #495057;
}

.font-btn:hover {
    background: #007bff;
    color: white;
    border-color: #007bff;
    transform: scale(1.05);
}

.font-size-input {
    width: 36px;
    height: 22px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: center;
    font-size: 0.65rem;
    font-weight: 500;
    color: #495057;
    background: white;
}

.font-size-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

/* Reading Progress in Bottom Right Corner */
.reading-progress {
    text-align: right;
}

.progress-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.8rem;
    color: #6c757d;
    line-height: 1.2;
}

#current-chapter {
    font-weight: 600;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#page-info {
    color: #95a5a6;
    font-size: 0.7rem;
}

/* Reading Container - Full Height */
.reading-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Content Area - Maximized */
.content-area {
    flex: 1;
    padding: 3rem 4rem;
    background: #fff;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.chapter-content {
    max-width: 900px;
    margin: 0 auto;
    line-height: 1.8;
    font-size: 1.1rem;
    color: #2c3e50;
    font-family: Georgia, 'Times New Roman', serif;
    text-align: justify;
    hyphens: auto;
}

/* Typography for EPUB Content */
.chapter-content h1,
.chapter-content h2,
.chapter-content h3,
.chapter-content h4,
.chapter-content h5,
.chapter-content h6 {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 600;
    color: #2c3e50;
    margin: 2.5rem 0 1.5rem 0;
    line-height: 1.3;
}

.chapter-content h1 {
    font-size: 2.4rem;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 0.75rem;
}

.chapter-content h2 {
    font-size: 2rem;
}

.chapter-content h3 {
    font-size: 1.6rem;
}

.chapter-content h4 {
    font-size: 1.3rem;
}

.chapter-content p {
    margin-bottom: 1.4rem;
    text-indent: 1.8em;
}

.chapter-content p:first-child,
.chapter-content h1 + p,
.chapter-content h2 + p,
.chapter-content h3 + p,
.chapter-content h4 + p {
    text-indent: 0;
}

.chapter-content blockquote {
    border-left: 4px solid #3498db;
    padding-left: 1.8rem;
    margin: 2rem 0;
    font-style: italic;
    color: #5a6c7d;
}

.chapter-content em,
.chapter-content i {
    font-style: italic;
}

.chapter-content strong,
.chapter-content b {
    font-weight: 600;
    color: #2c3e50;
}

.chapter-content img {
    max-width: 100%;
    height: auto;
    margin: 2rem auto;
    display: block;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.chapter-content ul,
.chapter-content ol {
    margin: 1.2rem 0 1.8rem 2.5rem;
}

.chapter-content li {
    margin-bottom: 0.7rem;
}

.chapter-content pre,
.chapter-content code {
    font-family: 'Monaco', 'Consolas', monospace;
    background: #f8f9fa;
    padding: 0.3rem 0.5rem;
    border-radius: 4px;
    font-size: 0.95em;
}

.chapter-content pre {
    padding: 1.5rem;
    margin: 2rem 0;
    overflow-x: auto;
    border: 1px solid #e9ecef;
    border-radius: 8px;
}

/* Auto-hide Behavior */
.reading-interface.reading-mode .side-panel {
    opacity: 0.3;
    transform: translateY(-50%) scale(0.9);
}

.reading-interface.reading-mode .side-panel:hover,
.reading-interface.reading-mode .side-panel.visible {
    opacity: 1;
    transform: translateY(-50%) scale(1);
}

.reading-interface.reading-mode .minimal-header {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
}

/* Show panels on hover zones */
.reading-interface::before,
.reading-interface::after {
    content: '';
    position: fixed;
    top: 0;
    bottom: 0;
    width: 120px;
    z-index: 45;
    pointer-events: none;
}

.reading-interface::before {
    left: 0;
}

.reading-interface::after {
    right: 0;
}

/* Dark Mode Support */
body.dark-mode .reading-interface {
    background: #1a1a1a;
}

body.dark-mode .minimal-header {
    background: rgba(45, 45, 45, 0.95);
}

body.dark-mode .book-title {
    color: #e0e0e0;
}

body.dark-mode .side-panel {
    background: rgba(45, 45, 45, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-mode .corner-control {
    background: rgba(45, 45, 45, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-mode .corner-btn.back-to-library,
body.dark-mode .side-control.back-to-library {
    background: #4d4d4d;
    color: #e0e0e0;
}

body.dark-mode .corner-btn.back-to-library:hover,
body.dark-mode .side-control.back-to-library:hover {
    background: #5d5d5d;
}

body.dark-mode .content-area {
    background: #1a1a1a;
}

body.dark-mode .chapter-content {
    color: #e0e0e0;
    background: #1a1a1a;
}

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

body.dark-mode .chapter-content h1 {
    border-bottom-color: #3d3d3d;
}

body.dark-mode .chapter-content blockquote {
    color: #b0b0b0;
    border-left-color: #3498db;
}

body.dark-mode .chapter-content strong,
body.dark-mode .chapter-content b {
    color: #f0f0f0;
}

body.dark-mode .chapter-content pre,
body.dark-mode .chapter-content code {
    background: #2d2d2d;
    color: #e0e0e0;
    border-color: #3d3d3d;
}

body.dark-mode .font-size-controls {
    background: rgba(61, 61, 61, 0.8);
}

body.dark-mode .font-btn {
    background: #4d4d4d;
    border-color: #5d5d5d;
    color: #e0e0e0;
}

body.dark-mode .font-btn:hover {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

body.dark-mode .font-size-input {
    background: #4d4d4d;
    border-color: #5d5d5d;
    color: #e0e0e0;
}

body.dark-mode .font-size-input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

body.dark-mode .progress-info {
    color: #b0b0b0;
}

body.dark-mode #page-info {
    color: #888;
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
    .side-panel {
        padding: 0.5rem;
        gap: 0.5rem;
        /* Move panels to bottom corners on mobile to avoid overlapping text */
        top: auto;
        bottom: 6rem;
        transform: none;
    }
    
    .left-panel {
        left: 1rem;
    }
    
    .right-panel {
        right: 1rem;
    }
    
    .side-control {
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
    }
    
    /* Adjust corner controls spacing on mobile */
    .top-left, .top-right {
        top: 3.5rem;
    }
    
    .bottom-left, .bottom-right {
        bottom: 1rem;
    }
    
    .content-area {
        padding: 2rem 1.5rem;
    }
    
    .chapter-content {
        max-width: 100%;
        font-size: 1rem;
        line-height: 1.7;
        text-align: left;
    }
    
    .chapter-content h1 {
        font-size: 2rem;
    }
    
    .chapter-content h2 {
        font-size: 1.7rem;
    }
    
    .font-size-controls {
        padding: 0.5rem;
        gap: 0.4rem;
    }
    
    .font-btn {
        width: 36px;
        height: 28px;
        font-size: 0.7rem;
    }
    
    .font-size-input {
        width: 40px;
        height: 24px;
        font-size: 0.7rem;
    }
    
    .minimal-header {
        padding: 0.5rem 1.5rem;
        border-radius: 0 0 8px 8px;
    }
    
    .book-title {
        font-size: 0.85rem;
        max-width: 250px;
    }
}

@media (max-width: 480px) {
    .side-panel {
        gap: 0.5rem;
        padding: 0.5rem 0.4rem;
    }
    
    .left-panel {
        left: 0.5rem;
    }
    
    .right-panel {
        right: 0.5rem;
    }
    
    .side-control {
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
    }
    
    .content-area {
        padding: 1.5rem 1rem;
    }
    
    .chapter-content {
        font-size: 0.95rem;
        line-height: 1.6;
    }
    
    .chapter-content p {
        text-indent: 1.2em;
        margin-bottom: 1.2rem;
    }
    
    .chapter-content h1 {
        font-size: 1.7rem;
    }
    
    .chapter-content h2 {
        font-size: 1.4rem;
    }
    
    .progress-info {
        font-size: 0.65rem;
    }
}

/* Touch-friendly interactions */
@media (hover: none) and (pointer: coarse) {
    .side-panel {
        opacity: 0.7;
    }
    
    .side-panel.active {
        opacity: 1;
    }
    
    .side-control {
        min-height: 48px;
        min-width: 48px;
    }
}

/* Print Styles */
@media print {
    .minimal-header,
    .side-panel {
        display: none;
    }
    
    .content-area {
        padding: 0;
        height: auto;
    }
    
    .chapter-content {
        font-size: 12pt;
        line-height: 1.5;
        color: #000;
        max-width: none;
    }
}
