/* eBook Reader - Dark Theme Styles */

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

.ebook-overlay.active {
    background-color: rgba(0, 0, 0, 0.7);
    opacity: 1;
    visibility: visible;
}

/* Drawer Container */
.ebook-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 50%; /* Reduced to 50% of screen width */
    /* max-width: 900px;  */
    min-width: 500px; /* Minimum width for readability */
    height: 100vh;
    background-color: #1a1a2e;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ebook-drawer.active {
    transform: translateX(0);
}

/* Drawer Header */
.ebook-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background-color: #0f0f1e;
    border-bottom: 1px solid #2d2d3d;
    flex-shrink: 0;
}

.ebook-title {
    color: #ffffff;
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    padding-right: 20px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ebook-close-btn {
    background: none;
    border: none;
    color: #888;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.ebook-close-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

/* Drawer Body */
.ebook-drawer-body {
    flex: 1;
    overflow: hidden;
    position: relative;
    background-color: #1a1a2e;
}

/* Loading State */
.ebook-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #888;
}

.ebook-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #2d2d3d;
    border-top-color: #5e5eff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.ebook-loading p {
    margin: 0;
    font-size: 14px;
    color: #aaa;
}

/* Error State */
.ebook-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 20px;
    text-align: center;
}

.error-icon {
    font-size: 48px;
    margin-bottom: 20px;
}

.error-message {
    color: #aaa;
    margin: 0 0 20px 0;
    font-size: 14px;
    line-height: 1.5;
}

.error-retry-btn {
    background-color: #5e5eff;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.error-retry-btn:hover {
    background-color: #4a4aff;
}

/* PDF Viewer Container */
.ebook-viewer {
    width: 100%;
    height: 100%;
    background-color: #2d2d3d;
}

/* eBook Buttons - Styled to match theme buttons */
.read-ebook-btn.button_wrapper {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: inherit;
    font-size: inherit;
}

.read-ebook-btn.button_wrapper .mdi {
    font-size: 20px;
}

.read-ebook-btn.button_wrapper ._t {
    font-size: 13px;
    font-weight: 500;
}

.read-ebook-btn.button_wrapper:hover {
    opacity: 0.8;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .ebook-drawer {
        width: 100%;
        min-width: unset; /* Remove minimum width on mobile */
    }
    
    .ebook-drawer-header {
        padding: 16px;
    }
    
    .ebook-title {
        font-size: 16px;
    }
    
    .read-ebook-btn {
        font-size: 13px;
        padding: 8px 14px;
    }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    .ebook-drawer {
        width: 70%; /* Adjusted for tablets */
        min-width: 400px;
    }
}

/* Large screens */
@media (min-width: 1600px) {
    .ebook-drawer {
        width: 70%; /* Slightly smaller on very large screens */
    }
}

/* Ensure drawer is above other elements */
body.drawer-open {
    overflow: hidden;
}

/* Smooth scrolling for drawer content */
.ebook-drawer-body {
    -webkit-overflow-scrolling: touch;
}

/* Fix for iOS Safari */
.ebook-drawer {
    -webkit-transform: translateX(100%);
    -ms-transform: translateX(100%);
}

.ebook-drawer.active {
    -webkit-transform: translateX(0);
    -ms-transform: translateX(0);
}

/* Dark scrollbar for webkit browsers */
.ebook-drawer-body::-webkit-scrollbar {
    width: 8px;
}

.ebook-drawer-body::-webkit-scrollbar-track {
    background: #0f0f1e;
}

.ebook-drawer-body::-webkit-scrollbar-thumb {
    background: #2d2d3d;
    border-radius: 4px;
}

.ebook-drawer-body::-webkit-scrollbar-thumb:hover {
    background: #3d3d4d;
}