/* ==========================================================================
   Secure PDF Viewer Styles - Pro Edition (Centered Fix)
   ========================================================================== */

/* 1. Main Container 
   -------------------------------------------------------------------------- */
.secure-pdf-container {
    display: flex;
    flex-direction: column;
    background: #333;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    
    /* Disable selection */
    user-select: none;
    -webkit-user-select: none;
}

.secure-pdf-container:focus {
    outline: 2px solid #2196f3;
}

/* 2. Header & Controls 
   -------------------------------------------------------------------------- */
.pdf-header {
    background: #222;
    color: #fff;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #444;
    z-index: 20;
    height: 40px;
    flex-shrink: 0;
}

.pdf-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
    opacity: 0.9;
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* Control Groups */
.page-control, .zoom-control {
    display: flex;
    align-items: center;
    background: #444;
    border-radius: 4px;
    padding: 2px;
}

.page-display {
    font-size: 13px;
    padding: 0 8px;
    display: flex;
    align-items: center;
    gap: 4px;
    color: #ccc;
}

input[type="number"] {
    background: transparent;
    border: none;
    color: #fff;
    width: 30px;
    text-align: right;
    padding: 0;
    font-size: 13px;
    -moz-appearance: textfield;
}
input[type="number"]::-webkit-outer-spin-button, 
input[type="number"]::-webkit-inner-spin-button { 
    -webkit-appearance: none; 
    margin: 0; 
}

/* Buttons */
button {
    background: transparent;
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
    font-size: 16px;
    transition: background 0.2s;
}

button:hover { background: #555; }
button:active { background: #666; }

#zoomLevel {
    font-size: 12px;
    min-width: 40px;
    text-align: center;
}

/* 3. Viewport & Scrolling (Fixed Centering)
   -------------------------------------------------------------------------- */
.pdf-viewport {
    flex: 1;
    position: relative;
    overflow: auto;          /* Allow native scrolling */
    background: #525659;     /* Standard viewer background */
    text-align: center;      /* Center child content */
}

/* * The Scroll Container 
 * Uses inline-flex to expand with content (zooming in)
 * while min-width: 100% ensures it fills screen when zoomed out.
 */
.pdf-scroll-container {
    display: inline-flex;
    flex-direction: column;
    align-items: center;     /* Centers pages horizontally */
    min-width: 100%;         /* Ensures full width coverage */
    padding: 30px 0;         /* Vertical spacing */
    box-sizing: border-box;
}

/* Page Wrapper */
.pdf-page-wrapper {
    background: #fff;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4); /* Improved shadow */
    position: relative;
    
    /* Critical for smooth resizing */
    transition: box-shadow 0.3s;
    margin-left: auto;
    margin-right: auto;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* 4. Loading States 
   -------------------------------------------------------------------------- */
.loading-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #333;
    z-index: 50;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #fff;
    transition: opacity 0.3s;
}

.spinner, .mini-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: #2196f3;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.mini-spinner {
    width: 30px;
    height: 30px;
    border-top-color: #555;
}

.page-loader {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5;
}

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

.progress-track {
    width: 200px;
    height: 4px;
    background: #444;
    margin-top: 15px;
    border-radius: 2px;
}
.progress-bar {
    height: 100%;
    background: #2196f3;
    width: 0%;
    transition: width 0.2s;
}

/* 5. Toast Notifications
   -------------------------------------------------------------------------- */
.toast-container {
    position: fixed; /* Fixed relative to viewport for stability */
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    width: max-content;
}

.security-toast {
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
}

.security-toast.visible {
    opacity: 1;
    transform: translateY(0);
}

/* 6. Protection & Fullscreen
   -------------------------------------------------------------------------- */
.secure-pdf-container.fullscreen-mode {
    position: fixed;
    top: 0; left: 0; width: 100vw !important; height: 100vh !important;
    z-index: 99999;
    border-radius: 0;
}

.protection-layer {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 10;
    pointer-events: none; 
}

/* 7. Scrollbar Styling
   -------------------------------------------------------------------------- */
.pdf-viewport::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}
.pdf-viewport::-webkit-scrollbar-track { background: #333; }
.pdf-viewport::-webkit-scrollbar-thumb {
    background: #666;
    border-radius: 6px;
    border: 3px solid #333;
}
.pdf-viewport::-webkit-scrollbar-thumb:hover { background: #888; }

/* 8. Mobile Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 600px) {
    .pdf-header { padding: 8px; }
    .header-left { display: none; }
    .header-controls { width: 100%; justify-content: space-between; }
    .pdf-viewport { padding: 10px 0; }
    .pdf-scroll-container { padding: 15px 0; }
    
    /* Larger touch targets */
    button { width: 36px; height: 36px; font-size: 18px; }
}