/* Modern PDF Viewer Styles */
:root {
    --primary-color: #007bff;
    --primary-hover: #0056b3;
    --background-color: #f8f9fa;
    --text-color: #333;
    --border-radius: 8px;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: auto;
    min-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
}

body {
    height: auto;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #000;
    overflow-y: auto;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
}

.pdf-container {
    width: 100vw;
    height: auto;
    min-height: 100vh;
    position: relative;
    background-color: #000;
    overflow-y: auto;
    overflow-x: hidden;
}

.pdf-viewer {
    width: 100%;
    height: auto;
    min-height: 100vh;
    border: none;
    display: block;
    background-color: #ffffff;
    overflow-y: visible;
    overflow-x: hidden;
}

.pdf-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    background-color: #fff;
}

.pdf-content {
    width: 100%;
    height: auto;
    min-height: 100vh;
    display: block;
    padding: 0;
    margin: 0;
    background: #ffffff;
    overflow: visible;
}

.canvas-container {
    margin: 0;
    text-align: center;
    background: white;
    padding: 0;
    max-width: 100%;
    overflow: hidden;
    border-radius: 0;
    box-shadow: none;
}

.page-label {
    display: none;
}

.pdf-page-canvas {
    width: 100vw;
    height: auto;
    display: block;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    object-fit: contain;
}

.loading-bar {
    width: 200px;
    height: 4px;
    background: rgba(0, 123, 255, 0.2);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 10px;
}

.loading-progress {
    width: 0%;
    height: 100%;
    background: var(--primary-color);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    z-index: 1000;
    text-align: center;
}

.loading::after {
    content: '';
    width: 30px;
    height: 30px;
    margin: 10px auto 0;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: block;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--background-color);
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    text-align: center;
    max-width: 90%;
    max-width: min(400px, 90vw);
    z-index: 1000;
    display: none;
}

.error-message h3 {
    color: var(--text-color);
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.error-message p {
    color: #666;
    margin-bottom: 20px;
    line-height: 1.5;
}

.download-btn {
    background: var(--primary-color);
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    font-size: 1rem;
    transition: background-color 0.3s ease;
}

.download-btn:hover {
    background: var(--primary-hover);
}

/* Responsive Design */
@media screen and (max-width: 768px) {
    .pdf-container {
        height: 100vh;
        height: -webkit-fill-available;
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    .pdf-viewer {
        height: 100vh;
        height: -webkit-fill-available;
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    .pdf-iframe {
        height: 100vh;
        height: -webkit-fill-available;
    }
    
    .pdf-content {
        padding: 0;
        margin: 0;
        min-height: 100vh;
    }
    
    .canvas-container {
        margin: 0;
        padding: 0;
        border-radius: 0;
    }
    
    .page-label {
        display: none;
    }
    
    .pdf-page-canvas {
        width: 100vw;
        border-radius: 0;
    }
    
    .loading {
        padding: 20px;
        font-size: 0.9rem;
    }
    
    .error-message {
        padding: 25px;
        margin: 20px;
        max-width: calc(100vw - 40px);
    }
    
    .error-message h3 {
        font-size: 1.1rem;
    }
    
    .download-btn {
        padding: 12px 20px;
        font-size: 0.9rem;
        display: inline-block;
        margin: 5px;
        text-align: center;
        border-radius: 8px;
    }
}

/* Tablet */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    .pdf-viewer {
        height: 100vh;
        overflow-y: auto;
        overflow-x: hidden;
    }
}

/* Desktop */
@media screen and (min-width: 1025px) {
    html, body {
        overflow-y: auto !important;
        overflow-x: hidden !important;
        height: auto !important;
    }
    
    .pdf-container {
        height: auto !important;
        min-height: 100vh !important;
        overflow-y: visible !important;
        overflow-x: hidden !important;
    }
    
    .pdf-viewer {
        height: auto !important;
        min-height: 100vh !important;
        overflow-y: visible !important;
        overflow-x: hidden !important;
    }
    
    .pdf-content {
        height: auto !important;
        overflow-y: visible !important;
        position: static !important;
    }
}

/* High DPI screens */
@media screen and (-webkit-min-device-pixel-ratio: 2), 
       screen and (min-resolution: 192dpi) {
    .pdf-viewer {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Print styles */
@media print {
    .loading,
    .error-message {
        display: none !important;
    }
    
    .pdf-container {
        height: auto;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .loading::after {
        animation: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .loading {
        background: rgba(40, 40, 40, 0.95);
        color: white;
    }
    
    .error-message {
        background: #2d2d2d;
        color: white;
    }
    
    .error-message p {
        color: #ccc;
    }
}

/* Mobile Touch Optimizations */
@media (hover: none) and (pointer: coarse) {
    .pdf-container {
        overflow: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    
    .pdf-viewer {
        touch-action: pan-x pan-y;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    .pdf-container {
        height: -webkit-fill-available !important;
        overflow: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    .pdf-viewer {
        height: -webkit-fill-available !important;
        min-height: -webkit-fill-available !important;
    }
}
