/*
 * EPaper Viewer Styles
 */
.epaper-viewer-container {
    display: flex;
    flex-direction: column;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #f9fafb;
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    overflow: hidden;
    position: relative;
}

/* Toolbar */
.epaper-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #111827;
    padding: 12px 16px;
    color: #fff;
    flex-wrap: wrap;
    gap: 10px;
}

.epaper-toolbar-start,
.epaper-toolbar-center,
.epaper-toolbar-end {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Typography & Info */
.epaper-page-info {
    font-size: 14px;
    font-weight: 500;
}

/* Buttons */
.epaper-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #374151;
    color: #fff;
    border: 1px solid #4b5563;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
}

.epaper-btn:hover:not(:disabled) {
    background: #4b5563;
}

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

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

/* Button-specific tweaks */
.epaper-btn-prev .epaper-icon { margin-right: 6px; }
.epaper-btn-next .epaper-icon { margin-left: 6px; }

.epaper-btn-zoom-in,
.epaper-btn-zoom-out {
    padding: 6px 10px;
    margin-left: 4px;
}

/* Canvas Area */
.epaper-canvas-wrapper {
    position: relative;
    padding: 20px;
    background: #e5e7eb;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: auto;
    min-height: 400px; /* Base height before load */
    max-height: 800px;
}

.epaper-canvas {
    direction: ltr;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    background: #fff;
    max-width: 100%; /* Important to prevent horizontal overflow in narrow containers initially */
    height: auto; /* Initial auto scale */
    transition: opacity 0.3s ease;
}

/* Loading State */
.epaper-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 16px;
    font-weight: bold;
    color: #6b7280;
    z-index: 10;
}

/* Hide loader when canvas is visible */
.epaper-canvas.is-loaded + .epaper-loader,
.epaper-canvas-wrapper.is-loaded .epaper-loader {
    display: none;
}

/* Mobile responsive */
@media (max-width: 600px) {
    .epaper-toolbar {
        flex-direction: column;
        text-align: center;
    }
    
    .epaper-toolbar-start,
    .epaper-toolbar-center,
    .epaper-toolbar-end {
        width: 100%;
        justify-content: center;
    }
}
