/**
 * Ebook Reader CSS
 * 
 * Styles for the EPUB reader interface
 */

/* Container */
.ebook-reader-container {
    position: relative;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Controls */
.ebook-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    min-height: 60px;
}

.ebook-controls-left,
.ebook-controls-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ebook-controls-center {
    flex: 1;
    text-align: center;
    margin: 0 20px;
}

.ebook-title {
    margin: 0;
    font-size: 30px;
    font-weight: 700;
    color: #000;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ebook-controls .ebook-title {
    font-size: 16px;
}

/* Buttons */
.ebook-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    color: #333;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    min-width: 36px;
    height: 36px;
}

.ebook-btn:hover {
    background: #f8f9fa;
    border-color: #adb5bd;
    color: #333;
}

.ebook-btn:active {
    background: #e9ecef;
    transform: translateY(1px);
}

.ebook-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ebook-icon {
    font-size: 16px;
    line-height: 1;
}

/* Location display */
.ebook-location {
    display: none;
    font-size: 14px;
    color: #666;
    margin-left: 15px;
}

/* Content wrapper */
.ebook-content-wrapper {
    display: flex;
    position: relative;
    height: 100%;
}

/* Sidebar (TOC) */
.ebook-sidebar {
    width: 280px;
    background: #f8f9fa;
    border-right: 1px solid #dee2e6;
    display: none;
    flex-shrink: 0;
}

.ebook-reader-container.toc-visible .ebook-sidebar {
    display: block;
}

.ebook-toc-container {
    padding: 20px;
    height: 100%;
    overflow-y: auto;
}

.ebook-toc-container h4 {
    margin: 0 0 15px 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.ebook-toc-item {
    margin-bottom: 5px;
}

.ebook-toc-link {
    display: block;
    padding: 8px 12px;
    color: #555;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.4;
    transition: all 0.2s ease;
}

.ebook-toc-link:hover {
    background: #e9ecef;
    color: #333;
}

.ebook-toc-link.active {
    background: #0073aa;
    color: #fff;
}

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

.ebook-toc-subitem .ebook-toc-link {
    padding-left: 24px;
    font-size: 13px;
    color: #666;
}

/* Main content */
.ebook-main-content {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.ebook-viewer {
    width: 100%;
    height: 100%;
    position: relative;
    background: #fff;
}

/* Loading state */
.ebook-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    color: #666;
}

.ebook-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0073aa;
    border-radius: 50%;
    animation: ebook-spin 1s linear infinite;
    margin-bottom: 15px;
}
.ebook-viewer iframe {
    width: 100%;
    height: 100%;
    border: none;
    overflow: auto !important;     /* Enable scroll */
    -webkit-overflow-scrolling: touch; /* for smooth scrolling on iOS */
}
.ebook-viewer {
    height: 100%; /* or specific height */
    overflow: hidden; /* you may want to set this to visible or auto */
}
@keyframes ebook-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error state */
.ebook-error {
    background: #f8d7da;
    color: #721c24;
    padding: 20px;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    margin: 20px;
    text-align: center;
}

/* Settings panel */
.ebook-settings-panel {
    position: absolute;
    top: 60px;
    right: 0;
    width: 280px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 0 0 0 8px;
    box-shadow: -2px 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.ebook-settings-content {
    padding: 20px;
}

.ebook-settings-content h4 {
    margin: 0 0 20px 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.ebook-setting-group {
    margin-bottom: 20px;
}

.ebook-setting-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.ebook-setting-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
}

.ebook-close-settings {
    width: 100%;
    background: #0073aa;
    color: #fff;
    border: none;
}

.ebook-close-settings:hover {
    background: #005a87;
    color: #fff;
}

/* Theme variations */
.ebook-reader-container.theme-light .ebook-viewer {
    background: #fff;
    color: #333;
}

.ebook-reader-container.theme-dark {
    background: #1a1a1a;
    border-color: #333;
}

.ebook-reader-container.theme-dark .ebook-controls {
    background: #2d2d2d;
    border-color: #444;
}

.ebook-reader-container.theme-dark .ebook-title {
    color: #fff;
}

.ebook-reader-container.theme-dark .ebook-btn {
    background: #333;
    border-color: #555;
    color: #fff;
}

.ebook-reader-container.theme-dark .ebook-btn:hover {
    background: #444;
    border-color: #666;
}

.ebook-reader-container.theme-dark .ebook-sidebar {
    background: #2d2d2d;
    border-color: #444;
}

.ebook-reader-container.theme-dark .ebook-toc-container h4 {
    color: #fff;
}

.ebook-reader-container.theme-dark .ebook-toc-link {
    color: #ccc;
}

.ebook-reader-container.theme-dark .ebook-toc-link:hover {
    background: #444;
    color: #fff;
}

.ebook-reader-container.theme-dark .ebook-viewer {
    background: #1a1a1a;
    color: #fff;
}

.ebook-reader-container.theme-sepia {
    background: #f4f1ea;
    border-color: #d4c5a9;
}

.ebook-reader-container.theme-sepia .ebook-controls {
    background: #ede6d3;
    border-color: #d4c5a9;
}

.ebook-reader-container.theme-sepia .ebook-title {
    color: #5c4b37;
}

.ebook-reader-container.theme-sepia .ebook-btn {
    background: #f4f1ea;
    border-color: #d4c5a9;
    color: #5c4b37;
}

.ebook-reader-container.theme-sepia .ebook-btn:hover {
    background: #ede6d3;
}

.ebook-reader-container.theme-sepia .ebook-sidebar {
    background: #ede6d3;
    border-color: #d4c5a9;
}

.ebook-reader-container.theme-sepia .ebook-toc-container h4 {
    color: #5c4b37;
}

.ebook-reader-container.theme-sepia .ebook-toc-link {
    color: #5c4b37;
}

.ebook-reader-container.theme-sepia .ebook-toc-link:hover {
    background: #d4c5a9;
}

.ebook-reader-container.theme-sepia .ebook-viewer {
    background: #f4f1ea;
    color: #5c4b37;
}

/* Fullscreen mode */
.ebook-reader-container.ebook-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999;
    border-radius: 0;
    border: none;
}

.ebook-reader-container.ebook-fullscreen .ebook-content-wrapper {
    height: calc(100vh - 60px);
}

/* Responsive design */
@media (max-width: 768px) {
    .ebook-controls {
        padding: 8px 15px;
        flex-wrap: wrap;
        min-height: auto;
        justify-content: center;
    }
    
    .ebook-controls-center {
        order: -1;
        width: 100%;
        margin: 0 0 10px 0;
    }
    
    .ebook-title {
        font-size: 14px;
    }
    
    .ebook-btn {
        padding: 6px 8px;
        min-width: 32px;
        height: 32px;
        font-size: 12px;
    }
    
    .ebook-sidebar {
        width: 240px;
    }
    
    .ebook-settings-panel {
        width: 240px;
    }
    
    .ebook-location {
        font-size: 12px;
        margin-left: 10px;
    }
}

@media (max-width: 480px) {
    .ebook-controls {
        padding: 8px 10px;
    }
    
    .ebook-controls-left,
    .ebook-controls-right {
        gap: 5px;
        flex-wrap: wrap;
    justify-content: center;
    }
    
    .ebook-sidebar {
        width: 200px;
    }
    
    .ebook-settings-panel {
        width: 200px;
    }
    
    .ebook-toc-container {
        padding: 15px;
    }
    
    .ebook-settings-content {
        padding: 15px;
    }
}

/* Print styles */
@media print {
    .ebook-reader-container {
        border: none;
        box-shadow: none;
    }
    
    .ebook-controls,
    .ebook-sidebar,
    .ebook-settings-panel {
        display: none !important;
    }
    
    .ebook-viewer {
        height: auto !important;
    }
}

