/* ======== PDF System - Технічний редизайн з авіаційно-кібернетичною тематикою (v5.0) ======== */
/* Додано: Схемотехнічні елементи, градієнти, анімації, адаптивність */

/* ======== Статуси системи (для налагодження) ======== */
/* ======== Налагоджувальний режим ======== */
[data-pdf-system="enhanced"] {
    border: 1px solid transparent;
}

/* ======== Блок превʼю PDF ======== */
.pdf-preview-block {
    position: relative;
}

/* ======== Статус: thumbnail / fallback ======== */
.pdf-preview-block[data-preview-status="thumbnail"]::after,
.pdf-preview-block[data-preview-status="fallback"]::after {
    content: "🖼️"; /* або 🔄 */
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 12px;
    right: 6px;
    width: 20px;
    height: 20px;
    color: #000;
    font-weight: bold;
    border-radius: 4px;
    z-index: 30;
    pointer-events: none;
    font-size: 14px;
    line-height: 1;
}

/* Індивідуальні стилі контенту та фону */
.pdf-preview-block[data-preview-status="thumbnail"]::after {
    content: "🖼️";
    background: rgba(0, 255, 150, 0.9);
    padding: 1px 2px 1px 2px;
}

.pdf-preview-block[data-preview-status="fallback"]::after {
    content: "🔄";
    background: rgba(255, 165, 0, 0.9);
    padding: 1px 2px 1px 2px;
}

/* Сховати в продакшені */
.production .pdf-preview-block[data-preview-status]::after {
    display: none !important;
}

.pdf-loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #00f5ff;
    background: rgba(20, 20, 40, 0.75);
    border: 1px solid rgba(0, 255, 255, 0.3);
    border-radius: 10px;
    padding: 8px 16px;
    z-index: 1000;
    box-shadow:
            0 0 4px rgba(0, 255, 255, 0.6),
            0 0 8px rgba(0, 255, 255, 0.4) inset;
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: none;
    backdrop-filter: blur(6px);
}

.pdf-loading-indicator i {
    font-size: 18px;
    animation: pulse-glow 1.2s infinite ease-in-out;
    color: #00e6e6;
}

@keyframes pulse-glow {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
}


.preview-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 160px;
    border-radius: 14px;
    background: rgba(60, 0, 0, 0.65);
    color: #ffcccc;
    font-size: 14px;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    border: 1px solid rgba(255, 0, 0, 0.2);
    box-shadow:
            0 0 6px rgba(255, 60, 60, 0.3),
            inset 0 0 10px rgba(255, 0, 0, 0.2);
    padding: 18px;
    text-align: center;
    backdrop-filter: blur(4px);
}

.preview-error i {
    font-size: 28px;
    margin-bottom: 8px;
    color: #ff4d4d;
    animation: flicker 1.5s infinite alternate;
}

@keyframes flicker {
    0% { opacity: 1; }
    25% { opacity: 0.7; }
    50% { opacity: 0.3; }
    100% { opacity: 0.8; }
}




/* ======== Базові стилі системи ======== */
.pdf-thumbnail-container {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    box-shadow:
            0 8px 32px rgba(0, 100, 200, 0.2),
            inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(0, 200, 255, 0.3);
}

.pdf-thumbnail-img {
    width: 100%;
    height: auto;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    border-radius: 12px;
    display: block;
    filter: brightness(1.1) contrast(1.05);
}

.pdf-thumbnail-img:hover {
    transform: scale(1.03) rotateY(2deg);
    filter: brightness(1.2) contrast(1.1);
}

.pdf-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    border: 2px dashed rgba(0, 200, 255, 0.5);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.4s ease;
    min-height: 160px;
    color: #ecf0f1;
    position: relative;
}

.pdf-placeholder::before {
    content: '';
    position: absolute;
    top: 10px;
    right: 10px;
    width: 20px;
    height: 20px;
    background: radial-gradient(circle, #00ff96 0%, #00cc77 100%);
    border-radius: 50%;
    animation: pulse-tech 2s ease-in-out infinite;
}

@keyframes pulse-tech {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
}

.pdf-placeholder:hover {
    background: linear-gradient(135deg, #34495e 0%, #2c3e50 100%);
    border-color: #00ff96;
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 255, 150, 0.2);
}

.pdf-placeholder-icon {
    font-size: 48px;
    margin-bottom: 8px;
    opacity: 0.8;
    color: #00d4ff;
}

.pdf-placeholder-text {
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    font-family: 'Courier New', monospace;
}

.pdf-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 12px;
    padding: 20px;
    min-height: 160px;
    position: relative;
}

.pdf-loading::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 12px;
    background: linear-gradient(45deg, transparent, rgba(0, 200, 255, 0.1), transparent);
    animation: scan-line 2s linear infinite;
}

@keyframes scan-line {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.pdf-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 200, 255, 0.2);
    border-top: 3px solid #00d4ff;
    border-right: 3px solid #00ff96;
    border-radius: 50%;
    animation: pdf-spin-tech 1s linear infinite;
    z-index: 1;
}

@keyframes pdf-spin-tech {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ======== Сітка та блоки прев'ю PDF ======== */
.pdf-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
    margin: 24px 0;
    justify-items: center;
    align-items: start;
    padding: 0 12px;
}

/* === Блок превʼю одного PDF === */
.pdf-preview-block {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    text-align: center;
    padding: 20px;
    border-radius: 16px;
    background: linear-gradient(135deg, #2a2a45 0%, #26314e 50%, #1c4278 100%);
    border: 1px solid rgba(0, 200, 255, 0.2);
    box-shadow:
            0 6px 20px rgba(0, 0, 0, 0.15),
            0 1px 4px rgba(0, 200, 255, 0.08),
            inset 0 1px 0 rgba(255, 255, 255, 0.08);

    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    width: 100%;
    max-width: 360px;
    height: 100%;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
}

/* Технічні декоративні элементи */
.pdf-preview-block::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: linear-gradient(90deg,
    transparent,
    #00ff96 20%,
    #00d4ff 50%,
    #0099ff 80%,
    transparent
    );
    animation: circuit-flow 3s ease-in-out infinite;
}



@keyframes circuit-flow {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

.pdf-preview-block:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow:
            0 20px 60px rgba(0, 0, 0, 0.4),
            0 8px 25px rgba(0, 200, 255, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.2);
    border-color: rgba(0, 255, 150, 0.6);
}

.pdf-preview-block:hover::before {
    animation-duration: 1s;
}

/* === Заголовок === */
.pdf-preview-block h3 {
    font-size: 15px;
    font-weight: 600;
    color: #ecf0f1;
    padding: 12px 8px;
    margin: 0 0 18px 0;
    height: 100px;
    overflow: hidden;
    border-bottom: 2px dashed rgba(0, 200, 255, 0.3);
    display: -webkit-box;
    -webkit-line-clamp: 6;
    -webkit-box-orient: vertical;
    line-height: 1.3;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    position: relative;
}

/*.pdf-preview-block h3::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 2px;
    background: linear-gradient(90deg, #00ff96, #00d4ff);
    border-radius: 1px;
}*/

/* === Превʼю як <canvas> або <img> === */
.pdf-canvas-preview,
.pdf-preview-block img[class*="pdf-canvas"] {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto !important; /* ключовий момент */
    aspect-ratio: unset; /* або видалити повністю */
    object-fit: contain;
    object-position: center;
    background: linear-gradient(135deg, #2c3e50 0%, #275786 100%);
    border: 2px solid rgba(0, 200, 255, 0.4);
    border-radius: 12px;
    box-shadow:
            0 8px 24px rgba(0, 0, 0, 0.3),
            0 2px 8px rgba(0, 200, 255, 0.2),
            inset 0 1px 0 rgba(255, 255, 255, 0.1);
    margin-bottom: 18px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
    overflow: hidden;
}



.pdf-canvas-preview::before,
.pdf-preview-block img[class*="pdf-canvas"]::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
    transparent,
    rgba(0, 212, 255, 0.1) 50%,
    transparent
    );
    transition: left 0.6s ease;
    pointer-events: none;
}

.pdf-canvas-preview:hover::before,
.pdf-preview-block img[class*="pdf-canvas"]:hover::before {
    left: 100%;
}

.pdf-canvas-preview:hover,
.pdf-preview-block img[class*="pdf-canvas"]:hover {
    transform: scale(1.05) rotateX(5deg);
    border-color: rgba(0, 255, 150, 0.8);
    box-shadow:
            0 12px 35px rgba(0, 0, 0, 0.4),
            0 4px 15px rgba(0, 255, 150, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.2);
}


/* ======== Кнопки та навігація ======== */
.nav-button {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.nav-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
    );
    transition: left 0.4s ease;
}

.nav-button:hover::before {
    left: 100%;
}

.nav-button i {
    margin-right: 5px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

.nav-button:focus {
    outline: 2px solid #00ff96;
    outline-offset: 2px;
}

.nav-button:hover {
    transform: scale(1.05) translateY(-2px);
}

.pdf-preview-block .preview-buttons-container {
    display: flex;
    justify-content: center;
    gap: clamp(8px, 2.5vw, 12px);
    margin-top: auto;
    padding-top: 18px;
    flex-wrap: nowrap;
    align-items: center;
}

/* Адаптивні кнопки */
.pdf-preview-block .nav-button {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    font-size: 0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    width: clamp(40px, 12vw, 50px);
    height: clamp(40px, 12vw, 50px);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
    overflow: hidden;
}

.pdf-preview-block .nav-button i {
    font-size: clamp(16px, 4vw, 20px);
    line-height: 1;
    margin: 0;
    color: white;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
    z-index: 1;
}

.pdf-preview-block .nav-button:hover {
    transform: scale(1.1) translateY(-3px);
}

/* Специфічні стилі кнопок з технічними градієнтами */
.pdf-preview-block .open-modal {
    background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.3);
}

.pdf-preview-block .open-modal:hover {
    background: linear-gradient(135deg, #f7931e 0%, #ff6b35 100%);
    box-shadow: 0 6px 20px rgba(255, 107, 53, 0.4);
}

.pdf-preview-block .copy-link-button {
    background: linear-gradient(135deg, #00d4aa 0%, #00a085 100%);
    box-shadow: 0 4px 15px rgba(0, 212, 170, 0.3);
}

.pdf-preview-block .copy-link-button:hover {
    background: linear-gradient(135deg, #00a085 0%, #00d4aa 100%);
    box-shadow: 0 6px 20px rgba(0, 212, 170, 0.4);
}

.pdf-preview-block .download-button {
    background: linear-gradient(135deg, #0099ff 0%, #0066cc 100%);
    box-shadow: 0 4px 15px rgba(0, 153, 255, 0.3);
}

.pdf-preview-block .download-button:hover {
    background: linear-gradient(135deg, #0066cc 0%, #0099ff 100%);
    box-shadow: 0 6px 20px rgba(0, 153, 255, 0.4);
}

.pdf-preview-block .open-tab-button {
    background: linear-gradient(135deg, #00c4ff 0%, #0099cc 100%);
    box-shadow: 0 4px 15px rgba(0, 196, 255, 0.3);
}

.pdf-preview-block .open-tab-button:hover {
    background: linear-gradient(135deg, #0099cc 0%, #00c4ff 100%);
    box-shadow: 0 6px 20px rgba(0, 196, 255, 0.4);
}

.pdf-preview-block .regen-thumb-button {
    background: linear-gradient(135deg, #ff9500 0%, #cc7700 100%);
    box-shadow: 0 4px 15px rgba(255, 149, 0, 0.3);
}

.pdf-preview-block .regen-thumb-button:hover {
    background: linear-gradient(135deg, #cc7700 0%, #ff9500 100%);
    box-shadow: 0 6px 20px rgba(255, 149, 0, 0.4);
}


/* ======== Анімації завантаження та статусів ======== */
@keyframes data-stream {
    0% { opacity: 0; transform: translateX(-20px); }
    50% { opacity: 1; transform: translateX(0); }
    100% { opacity: 0; transform: translateX(20px); }
}

.pdf-preview-block[data-preview-status="loading"] {
    animation: data-stream 2s ease-in-out infinite;
}

/* ======== Додаткові технічні ефекти ======== */
.pdf-preview-block:nth-child(odd)::before {
    background: linear-gradient(90deg,
    transparent,
    #00ff96 20%,
    #0099ff 50%,
    #00d4ff 80%,
    transparent
    );
}

.pdf-preview-block:nth-child(even)::before {
    background: linear-gradient(90deg,
    transparent,
    #ff6b35 20%,
    #f7931e 50%,
    #00d4aa 80%,
    transparent
    );
}

/* Глітч-ефект при завантаженні */
@keyframes glitch {
    0%, 100% { transform: translate(0); }
    20% { transform: translate(-1px, 1px); }
    40% { transform: translate(-1px, -1px); }
    60% { transform: translate(1px, 1px); }
    80% { transform: translate(1px, -1px); }
}

.pdf-preview-block[data-preview-status="fallback"] {
    animation: glitch 0.3s ease-in-out;
}



/* ========= МОБІЛЬНА АДАПТАЦІЯ (768px та менше) ========= */
@media (max-width: 768px) {
    .pdf-grid {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 0 8px;
    }

    .pdf-preview-block {
        padding: 16px;
        max-width: 100%;
    }

    .pdf-preview-block h3 {
        font-size: 14px;
        height: 90px;
        -webkit-line-clamp: 5;
    }

    .pdf-preview-block .preview-buttons-container {
        gap: clamp(6px, 2vw, 10px);
    }

    .pdf-preview-block .nav-button {
        width: clamp(35px, 10vw, 45px);
        height: clamp(35px, 10vw, 45px);
    }

    .pdf-preview-block .nav-button i {
        font-size: clamp(14px, 3.5vw, 18px);
    }

    .pdf-canvas-preview,
    .pdf-preview-block img[class*="pdf-canvas"] {
        height: auto;
        max-height: 80vh;
    }
}

@media (max-width: 480px) {
    .pdf-preview-block {
        padding: 12px;
        border-radius: 12px;
    }

    .pdf-preview-block h3 {
        font-size: 13px;
        height: 80px;
        -webkit-line-clamp: 5;
        padding: 8px 4px;
    }

    .pdf-canvas-preview,
    .pdf-preview-block img[class*="pdf-canvas"] {
        border-radius: 8px;
        margin-bottom: 12px;
    }

}



/* ======== МОДАЛЬНЕ ВІКНО - БАЗОВА СТРУКТУРА ======== */
.modal.hidden {
    display: none;
}

.modal {
    display: flex;
    justify-content: center;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.92);
    z-index: 9999;
    overflow: hidden;
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: #1a1a1a;
    border-radius: 12px;
    width: 90vw;
    height: 90vh;
    max-width: 1400px;
    max-height: 950px;
    overflow: hidden;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.7);
    border: 1px solid #3982e9;
}

/* ======== АДАПТИВНА СТРУКТУРА (ПК + МОБІЛКА) ======== */

/* ПК версія: панель зліва */
@media (min-width: 769px) {
    .modal-content.has-side-panel {
        display: flex !important;
        flex-direction: row !important;
        padding: 0 !important;
    }

    .page-counter {
        position: relative;
        flex-shrink: 0;
        order: -1;
        height: 100%;
        overflow: hidden;
    }

    .navigation-panel {
        position: relative;
        width: 100px;
        height: 100%;
        background: #1a1f2e;
        border-right: 1px solid #2d3548;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        padding: 20px 10px;
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
        overflow-y: auto;
        overflow-x: hidden;
        z-index: 1002;
        box-sizing: border-box;
    }

    .modal-content.has-side-panel #pdf-container-modal {
        flex: 1;
        width: 100% !important;
        height: 100% !important;
        padding: 20px !important;
        box-sizing: border-box !important;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .modal-content.has-side-panel .close-button {
        right: 15px;
        left: auto;
    }
}

/* МОБІЛЬНА версія: панель знизу */
@media (max-width: 768px) {
    .modal-content.has-side-panel {
        display: flex !important;
        flex-direction: column !important;
        padding: 0 !important;
        height: 100%;
    }

    .page-counter {
        order: 2;
        width: 100%;
        height: auto;
        position: relative;
        flex-shrink: 0;
    }

    .navigation-panel {
        width: 100%;
        max-width: 100%;
        height: auto;
        min-height: auto;
        background: #1a1f2e;
        border-top: 1px solid #2d3548;
        border-right: none;
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        align-items: center;
        justify-items: center;
        gap: 8px 6px;
        padding: 12px 8px;
        overflow: hidden;
        z-index: 1002;
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.2);
        box-sizing: border-box;
    }

    /* ФІКСУЄМО ПОЗИЦІЇ ГРУП ЕЛЕМЕНТІВ */

    /* Ряд 1: Навігація сторінками */
    #prev-page {
        grid-column: 1;
        grid-row: 1;
    }

    .page-indicator {
        grid-column: 2;
        grid-row: 1;
    }

    #next-page {
        grid-column: 3;
        grid-row: 1;
    }

    .page-input-field {
        grid-column: 4;
        grid-row: 1;
    }

    #go-to-page {
        grid-column: 5;
        grid-row: 1;
    }

    /* Ряд 2: Zoom controls */
    #zoom-in {
        grid-column: 1;
        grid-row: 2;
    }

    .zoom-indicator {
        grid-column: 2;
        grid-row: 2;
    }

    #zoom-out {
        grid-column: 3;
        grid-row: 2;
    }

    #zoom-reset {
        grid-column: 4;
        grid-row: 2;
    }

    #refresh-modal {
        grid-column: 5;
        grid-row: 2;
    }

    /* Прибираємо на мобілці */
    .nav-divider,
    .render-mode-badge,
    .progress-embed-container {
        display: none !important;
    }

    .modal-content.has-side-panel #pdf-container-modal {
        flex: 1;
        width: 100% !important;
        height: 0 !important;
        min-height: 0 !important;
        padding: 15px !important;
        box-sizing: border-box !important;
        overflow-y: auto;
        overflow-x: hidden;
        order: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .modal-content.has-side-panel .close-button {
        right: 10px;
        top: 10px;
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .circuit-board {
        display: none;
    }

    /* Адаптуємо розмір кнопок */
    .nav-btn {
        width: 40px;
        height: 40px;
        flex-shrink: 0;
    }

    .nav-btn i {
        font-size: 15px;
    }

    /* Page indicator - компактніший */
    .page-indicator {
        padding: 0 6px;
        width: 70px;
        height: 36px;
        gap: 3px;
    }

    .current-page-num,
    .page-divider,
    .total-pages-num {
        font-size: 14px;
    }

    /* Zoom indicator - компактніший */
    .zoom-indicator {
        padding: 0 6px;
        width: 70px;
        height: 36px;
    }

    .zoom-display {
        font-size: 14px;
    }

    /* Page input - вужче */
    .page-input-field {
        width: 70px;
        height: 36px;
        font-size: 14px;
    }

    /* Модальне вікно на весь екран на мобілці */
    .modal-content {
        width: 95vw;
        height: 85vh;
        max-width: 95vw;
        max-height: 85vh;
    }
}

/* ======== СПІЛЬНІ СТИЛІ ДЛЯ ПК + МОБІЛКИ ======== */

/* Кнопка закриття */
.close-button {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(220, 53, 69, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 16px;
    z-index: 1003;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.close-button i {
    font-size: 1.6rem;
}

.close-button:hover {
    background: #ff4444;
    transform: rotate(90deg);
    box-shadow: 0 0 20px rgba(220, 53, 69, 0.6);
}

/* PDF Container */
#pdf-container-modal {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: #1c2530;
    scrollbar-width: thin;
    scrollbar-color: #00eaff #1c2530;
    display: flex;
    text-align: center;
    flex-direction: column;
    align-items: center;
    gap: 35px;
}

#pdf-container-modal::-webkit-scrollbar {
    width: 10px;
}

#pdf-container-modal::-webkit-scrollbar-track {
    background: #2b3b4a;
    border-radius: 6px;
    box-shadow: inset 0 0 5px rgba(0, 255, 255, 0.1);
}

#pdf-container-modal::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #00fff7, #00a0ff);
    border-radius: 6px;
    box-shadow: 0 0 8px #00eaff;
}

#pdf-container-modal::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #00ffff, #0077ff);
    box-shadow: 0 0 12px #00eaff;
}

/* Прибираємо circuit board */
.circuit-board {
    display: none;
}

/* Кнопки навігації */
.nav-btn {
    width: 48px;
    height: 48px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: #e8f1ef;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.nav-btn:hover:not(:disabled) {
    background: #252d3f;
    color: #4a9eff;
}

.nav-btn:active:not(:disabled) {
    background: #2d3650;
    transform: scale(0.95);
}

.nav-btn i {
    font-size: 18px;
    transition: color 0.2s;
}

.nav-btn.disabled {
    opacity: 0.2;
    pointer-events: none;
}

/* Page indicator */
.page-indicator {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    background: #151922;
    border-radius: 6px;
    border: 1px solid #2d3548;
    gap: 4px;
    width: 70px;
    height: 40px;
    z-index: 1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
    flex-shrink: 0;
}

.current-page-num {
    font-size: 14px;
    font-weight: 700;
    color: #3b85ec;
    letter-spacing: -0.3px;
    line-height: 1;
}

.page-divider {
    font-size: 14px;
    color: #4a5568;
    font-weight: 400;
    line-height: 1;
}

.total-pages-num {
    font-size: 14px;
    font-weight: 700;
    color: #6b7a92;
    letter-spacing: -0.3px;
    line-height: 1;
}

/* Zoom indicator */
.zoom-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    background: #151922;
    border-radius: 6px;
    border: 1px solid #2d3548;
    width: 70px;
    height: 40px;
    z-index: 1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
    flex-shrink: 0;
}

.zoom-display {
    font-size: 14px;
    font-weight: 700;
    color: #3b85ec;
    letter-spacing: -0.3px;
    line-height: 1;
}

/* Page input */
.page-input-field {
    width: 70px;
    height: 40px;
    background: #252d3f;
    border: 1px solid #3a4358;
    border-radius: 6px;
    color: #e8edf5;
    text-align: center;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.3px;
    line-height: 1;
    transition: all 0.2s ease;
    z-index: 1;
    box-sizing: border-box;
    flex-shrink: 0;
    padding: 0;
}

.page-input-field::-webkit-outer-spin-button,
.page-input-field::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.page-input-field[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.page-input-field:focus {
    outline: none;
    border-color: #4a9eff;
    background: #2d3650;
}

.page-input-field::placeholder {
    color: #5a6b85;
    opacity: 1;
}

/* Divider */
.nav-divider {
    width: 60%;
    height: 1px;
    background: #1d7793;
    margin: 2px 0;
}

/* Render mode badge */
.render-mode-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 6px;
    background: #252d3f;
    border: 1px solid #3a4358;
    border-radius: 6px;
    color: #8a9cb5;
    min-width: 56px;
    z-index: 1;
}

.pulse-indicator {
    width: 6px;
    height: 6px;
    background: #4a9eff;
    border-radius: 50%;
    animation: pulse-minimal 2s infinite ease-in-out;
}

@keyframes pulse-minimal {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

.mode-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.auto-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #2d3650;
    color: #8a9cb5;
    font-size: 9px;
    text-transform: uppercase;
    padding: 2px 5px;
    border-radius: 3px;
    margin-top: 2px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.auto-badge.hidden {
    display: none;
}

/* Refresh icon rotation */
#refresh-modal:hover i {
    transform: rotate(180deg);
    transition: transform 0.4s ease;
}

/* Progress bar */
.progress-embed-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 15px 0;
    gap: 8px;
}

.progress-bar {
    position: relative;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.progress-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.progress-circle-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.15);
    stroke-width: 2.5;
    stroke-linecap: round;
}

.progress-circle {
    fill: none;
    stroke: url(#progressGradient);
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-dasharray: 113;
    stroke-dashoffset: 113;
    transition: stroke-dashoffset 0.3s ease;
}

.progress-text {
    position: absolute;
    font-size: 10px;
    font-weight: 600;
    color: #4a9eff;
    text-align: center;
    line-height: 1.2;
    max-width: 45px;
    word-break: break-all;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Ripple effect */
@keyframes ripple-effect {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* ======== ДОДАТКОВА АДАПТАЦІЯ ДЛЯ ДУЖЕ МАЛЕНЬКИХ ЕКРАНІВ ======== */
@media (max-width: 480px) {
    .navigation-panel {
        padding: 10px 5px;
        gap: 6px;
    }

    .nav-btn {
        width: 36px;
        height: 36px;
    }

    .nav-btn i {
        font-size: 13px;
    }

    .page-indicator,
    .zoom-indicator {
        padding: 0 5px;
        width: 70px;
        height: 32px;
    }

    .current-page-num,
    .page-divider,
    .total-pages-num,
    .zoom-display {
        font-size: 13px;
    }

    .page-input-field {
        width: 70px;
        height: 32px;
        font-size: 13px;
    }

    .close-button {
        width: 32px;
        height: 32px;
        right: 8px;
        top: 8px;
    }

    .close-button i {
        font-size: 1.2rem;
    }
}

/* ======== ПОКРАЩЕНЕ ВІДОБРАЖЕННЯ СТОРІНОК ======== */
.page-wrapper {
    display: block;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto 35px auto;
    position: relative;
    box-sizing: border-box;
}

.pdf-canvas {
    display: block;
    margin: 0 auto;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transition: opacity 0.3s ease;
    background: white;
    border: 1px solid #ddd;
    max-width: none !important;
    height: auto;
}

.pdf-canvas[data-orientation="portrait"],
.pdf-canvas[data-orientation="landscape"] {
    max-width: 100%;
    width: auto;
    height: auto;
}

/* ======== СКЕЛЕТОНИ ДЛЯ СТОРІНОК ======== */
.skeleton-wrapper {
    display: block;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto 15px auto;
    position: relative;
}

.page-skeleton {
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border: 1px solid #ddd;
    padding: 40px;
    min-height: 600px;
    position: relative;
    overflow: hidden;
}

.page-skeleton::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.4) 50%,
    transparent 100%);
    animation: skeleton-shimmer 2s infinite;
}

@keyframes skeleton-shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

.skeleton-header {
    height: 60px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    border-radius: 8px;
    margin-bottom: 30px;
    animation: skeleton-wave 2s infinite ease-in-out;
}

.skeleton-lines {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.skeleton-line {
    height: 20px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    border-radius: 4px;
    animation: skeleton-wave 2s infinite ease-in-out;
}

.skeleton-line.short {
    width: 70%;
}

.skeleton-line.medium {
    width: 85%;
}

.skeleton-page-number {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.1);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

@keyframes skeleton-wave {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.skeleton-lines.mobile .skeleton-line {
    height: 10px;
    margin-bottom: 6px;
}

.skeleton-lines.desktop .skeleton-line {
    height: 14px;
    margin-bottom: 8px;
}

/* ======== MODAL LOADING ======== */
.modal-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #333;
    gap: 20px;
}

.modal-loading-spinner {
    width: 60px;
    height: 60px;
    border: 6px solid #f3f3f3;
    border-top: 6px solid #007bff;
    border-radius: 50%;
    animation: modal-spin 1s linear infinite;
}

@keyframes modal-spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.modal-loading-text {
    font-size: 18px;
    font-weight: 500;
}

.modal-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #dc3545;
    text-align: center;
    gap: 15px;
}

.modal-error i {
    font-size: 48px;
}

.modal-error h3 {
    margin: 0;
    font-size: 24px;
}

.modal-error p {
    margin: 0;
    font-size: 16px;
    opacity: 0.8;
}

/* ======== НОТИФІКАЦІЇ ======== */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 6px;
    color: white;
    font-weight: 500;
    z-index: 2000;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 1;
    transition: opacity 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.success-notification {
    background-color: #28a745;
}

.error-notification {
    background-color: #dc3545;
}

.notification i {
    font-size: 16px;
}



/* ======== ПОКРАЩЕННЯ ДЛЯ ВИСОКИХ DPI ЕКРАНІВ ======== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .pdf-canvas,
    .pdf-canvas-preview,
    .pdf-preview-block img[class*="pdf-canvas"] {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* ======== УТІЛІТИ ======== */
.hidden {
    display: none !important;
}

.loading {
    opacity: 0.7;
}

.error {
    border-color: #dc3545 !important;
    background-color: #f8d7da !important;
}

/* ======== RIPPLE-АНІМАЦІЯ ======== */
@keyframes ripple-effect {
    to {
        transform: scale(2);
        opacity: 0;
    }
}
