/* PDF Viewer Overlay Styles */

.pdf-viewer-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: #000;
    z-index: 999999 !important;
    display: flex;
    flex-direction: column;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease;
    /* Предотвращаем выделение и вызов клавиатуры */
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

.pdf-viewer-overlay[style*="display: flex"],
.pdf-viewer-overlay[style*="display:flex"] {
    visibility: visible !important;
    opacity: 1 !important;
}

.pdf-viewer-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.pdf-viewer-header {
    height: 60px;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1000000 !important;
    transform: translateZ(0) scale(1);
    -webkit-transform: translateZ(0) scale(1);
    will-change: transform;
    touch-action: manipulation;
    pointer-events: auto;
    /* Защита от зума */
    transform-origin: top left;
    -webkit-transform-origin: top left;
}

.pdf-viewer-back-btn,
.pdf-viewer-share-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.pdf-viewer-share-btn {
    background: #007AFF;
}

.pdf-viewer-back-btn:active {
    background: rgba(255, 255, 255, 0.2);
}

.pdf-viewer-share-btn:active {
    background: #0051D5;
}

.pdf-viewer-content {
    flex: 1;
    width: 100%;
    overflow: hidden;
    position: relative;
    margin-top: 60px;
    /* Изолируем зум только для контента */
    isolation: isolate;
}

.pdf-viewer-pages {
    width: 100%;
    height: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
    /* Разрешаем зум только для этого контейнера */
    touch-action: pan-x pan-y pinch-zoom;
    transform-origin: center center;
    /* Предотвращаем выделение текста и вызов клавиатуры */
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    /* Блокируем редактирование */
    -webkit-user-modify: read-only;
    -moz-user-modify: read-only;
    user-modify: read-only;
}

.pdf-viewer-page-container {
    margin-bottom: 10px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    position: relative;
    /* Предотвращаем выделение */
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.pdf-viewer-page-container canvas {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    height: auto;
    /* Предотвращаем выделение canvas */
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    pointer-events: auto;
    /* Блокируем редактирование */
    -webkit-user-modify: read-only;
    -moz-user-modify: read-only;
    user-modify: read-only;
}

/* Блокируем текстовый слой PDF.js если он есть */
.pdf-viewer-page-container .textLayer {
    display: none !important;
    pointer-events: none !important;
}

.pdf-viewer-page-container .annotationLayer {
    display: none !important;
    pointer-events: none !important;
}

.pdf-viewer-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 18px;
    text-align: center;
}

.pdf-viewer-spinner {
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid #fff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: pdf-viewer-spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes pdf-viewer-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.pdf-viewer-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ff4444;
    font-size: 16px;
    text-align: center;
    padding: 20px;
}

.pdf-viewer-controls {
    position: fixed !important;
    bottom: 20px !important;
    left: 50% !important;
    transform: translateX(-50%) translateZ(0) scale(1);
    -webkit-transform: translateX(-50%) translateZ(0) scale(1);
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 10px 20px;
    border-radius: 20px;
    display: flex;
    gap: 15px;
    align-items: center;
    z-index: 999998 !important;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    will-change: transform, opacity;
    touch-action: manipulation;
    /* Защита от зума */
    transform-origin: center bottom;
    -webkit-transform-origin: center bottom;
}

.pdf-viewer-controls.visible {
    opacity: 1;
    pointer-events: all;
}

.pdf-viewer-control-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.pdf-viewer-control-btn:active {
    background: rgba(255, 255, 255, 0.3);
}

.pdf-viewer-control-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.pdf-viewer-page-info {
    color: #fff;
    font-size: 14px;
    min-width: 60px;
    text-align: center;
}

/* Специальные правила для PWA режима */
@media (display-mode: standalone) {
    .pdf-viewer-overlay {
        position: fixed !important;
        inset: 0 !important;
        z-index: 999999 !important;
    }
    
    .pdf-viewer-header {
    height: 60px;
    box-sizing: border-box;
        position: fixed !important;
        z-index: 1000000 !important;
    }
    
    .pdf-viewer-controls {
        position: fixed !important;
        z-index: 999998 !important;
    }
}

/* Для iOS PWA */
@supports (-webkit-touch-callout: none) {
    @media (display-mode: standalone) {
        .pdf-viewer-overlay {
            position: fixed !important;
            top: 0 !important;
            left: 0 !important;
            width: 100vw !important;
            height: 100vh !important;
            height: -webkit-fill-available !important;
        }
        
        .pdf-viewer-content {
            height: calc(100vh - 60px) !important;
            height: calc(-webkit-fill-available - 60px) !important;
        }
    }
}
