/* ============================================================================
   PDF MODAL & SOURCE OPEN BUTTON STYLES
   Matches the main design system (slate palette, clean transitions)
   ============================================================================ */

/* Button "Открыть" in sources */
.source-open-btn {
    padding: 4px 10px;
    background: var(--slate-800, #1e293b);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    margin-left: 6px;
}

.source-open-btn:hover {
    background: var(--slate-700, #334155);
}

.source-open-btn:active {
    transform: scale(0.96);
}

/* PDF Modal */
.pdf-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

.pdf-modal.active {
    display: flex;
    animation: pdf-fade-in 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.pdf-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
}

.pdf-modal-content {
    position: relative;
    width: 90%;
    max-width: 1200px;
    height: 90vh;
    background: white;
    border-radius: 14px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: pdf-slide-up 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes pdf-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes pdf-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.pdf-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--slate-200, #e2e8f0);
    background: var(--slate-900, #0f1629);
}

.pdf-modal-title {
    font-size: 16px;
    font-weight: 600;
    color: white;
    margin: 0;
    max-width: calc(100% - 56px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pdf-modal-close {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.pdf-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.pdf-modal-body {
    flex: 1;
    position: relative;
    background: var(--slate-100, #f1f5f9);
}

#pdf-iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Responsive */
@media (max-width: 768px) {
    .pdf-modal-content {
        width: 95%;
        height: 95vh;
        border-radius: 10px;
    }

    .pdf-modal-header {
        padding: 14px 16px;
    }

    .pdf-modal-title {
        font-size: 14px;
    }

    .source-open-btn {
        padding: 3px 8px;
        font-size: 11px;
    }
}

/* Source header layout with button */
.source-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 6px;
}

.source-header strong {
    flex: 1;
    min-width: 150px;
}

/* Loading indicator for iframe */
.pdf-modal-body::after {
    content: "Загрузка документа...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 14px;
    color: var(--slate-400, #94a3b8);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.pdf-modal-body:not(:has(#pdf-iframe[src]))::after {
    opacity: 1;
}

/* PDF Loading State */
.pdf-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--slate-100, #f1f5f9);
    z-index: 10;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--slate-200, #e2e8f0);
    border-top-color: var(--slate-600, #475569);
    border-radius: 50%;
    animation: pdf-spin 0.7s linear infinite;
    margin-bottom: 14px;
}

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

.pdf-loading p {
    font-size: 13px;
    color: var(--slate-500, #64748b);
    margin: 0;
}

/* PDF Error State */
.pdf-error {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--slate-100, #f1f5f9);
    padding: 32px;
    text-align: center;
}

.pdf-error p {
    font-size: 15px;
    color: var(--slate-700, #334155);
    margin: 6px 0;
}

.pdf-error-details {
    font-size: 13px !important;
    color: var(--slate-500, #64748b) !important;
    font-family: 'JetBrains Mono', 'Consolas', monospace;
}

.pdf-error .btn-primary-small {
    margin-top: 14px;
}

/* Page number notification */
.pdf-page-info {
    position: absolute;
    top: 56px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--slate-800, #1e293b);
    color: white;
    padding: 10px 18px;
    border-radius: 8px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
    z-index: 100;
    text-align: center;
    animation: pdf-slide-down 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.pdf-page-info p {
    margin: 3px 0;
    color: white !important;
    font-size: 13px;
}

@keyframes pdf-slide-down {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}
