/* Modern Vertical Document Viewer Styles */
.pdf-image-viewer-container {
    position: relative;
    width: 100%;
    height: 85vh;
    /* Standard desktop max-height */
    display: flex;
    flex-direction: column;
    background: var(--theme-popup-bg);
    overflow-y: auto;
    overflow-x: hidden;
    color: var(--text-light);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    scrollbar-gutter: stable;
}

/* Balanced Pinned Top Header */
.pdf-image-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: var(--theme-glass-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--theme-card-border);
    z-index: 105;
    position: sticky;
    top: 0;
}

.pdf-image-title {
    font-size: 20px;
    font-family: 'Raleway', sans-serif;
    color: var(--primary-orange);
    font-weight: 600;
    margin: 0;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--primary-orange);
    display: inline-block;
    padding-bottom: 2px;
}

.pdf-image-controls-group {
    padding-right: 60px !important;
    /* Pushes controls left to avoid the global [X] Close button */
}

/* Main Viewport Area */
.pdf-image-viewport {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    background: var(--theme-input-bg);
    min-height: 100%;
}

.pdf-page-wrapper {
    position: relative;
    max-width: 100%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    background: #fff;
    line-height: 0;
    transition: max-width 0.3s ease;
    /* Smooth Zoom */
}

.pdf-page-image {
    width: 100%;
    height: auto;
    display: block;
    user-select: none;
    pointer-events: auto;
}

.pdf-zoom-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--theme-glass-bg);
    padding: 8px 18px;
    border-radius: 12px;
    border: 1px solid var(--theme-card-border);
}

.pdf-zoom-btn {
    background: var(--theme-input-bg);
    border: none;
    color: var(--text-light);
    cursor: pointer;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
    font-size: 18px;
}

.pdf-zoom-btn:hover:not(:disabled) {
    background: var(--theme-accent);
    color: #fff;
}

/* Zoom Indicator */
.pdf-zoom-label {
    min-width: 60px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-light);
}

/* Loading Overlay */
.pdf-image-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--theme-popup-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
    transition: opacity 0.5s ease;
}

.pdf-loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 140, 0, 0.2);
    border-top-color: var(--primary-orange, #ff8c00);
    border-radius: 50%;
    animation: pdf-spin 1s linear infinite;
}

@keyframes pdf-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Scrollbar Styling */
.pdf-image-viewer-container::-webkit-scrollbar {
    width: 10px;
}

.pdf-image-viewer-container::-webkit-scrollbar-track {
    background: var(--theme-popup-bg);
}

.pdf-image-viewer-container::-webkit-scrollbar-thumb {
    background: rgba(255, 140, 0, 0.4);
    border-radius: 5px;
    border: 2px solid var(--theme-popup-bg);
}

.pdf-image-viewer-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 140, 0, 0.7);
}

/* Mobile Responsive */
@media (max-width: 600px) {
    .pdf-image-viewer-container {
        height: 85vh !important;
        /* Unified with desktop */
    }

    .pdf-image-header {
        padding: 8px 12px;
        flex-direction: row;
        /* Back to horizontal to match desktop */
        justify-content: space-between;
        align-items: center;
        gap: 8px;
        position: sticky;
        top: 0;
        bottom: auto;
        min-height: 54px;
        backdrop-filter: blur(15px);
    }

    .pdf-image-title {
        font-size: 10px;
        max-width: 100px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        letter-spacing: 0.3px;
    }

    .pdf-image-controls-group {
        width: auto;
        justify-content: flex-end;
        padding-right: 55px !important;
        /* Safety for [X] */
        gap: 8px;
    }

    .pdf-zoom-controls {
        padding: 4px 8px;
        gap: 4px;
        border-radius: 8px;
    }

    .pdf-zoom-btn {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }

    .pdf-zoom-label {
        min-width: 38px;
        font-size: 10px;
    }

    .comparison-wrapper {
        height: 350px !important;
        /* Proper fit for mobile screens */
    }

    .pdf-image-title {
        color: var(--primary-orange) !important;
        font-weight: 700;
    }
}

/* Ensure the main popup-content doesn't interfere with the PDF's internal sticky logic */
.popup-modal:has(.pdf-image-viewer-container) .popup-content {
    padding: 0 !important;
    overflow: hidden !important;
    display: flex;
    flex-direction: column;
}

.popup-modal:has(.pdf-image-viewer-container) .popup-inner {
    padding: 0 !important;
}