/* FILE: CSS/pdf_viewer.css */
/* --------------------------------------------------------
   1. OVERLAY (Backdrop)
   -------------------------------------------------------- */
.pdf-modal-overlay,
.pdf-viewer-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0,0,0,0.4);
    display: flex;           /* ADD THIS */
    justify-content: center;
    align-items: center;
    z-index: 11001;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    font-family: 'Nunito', sans-serif;
}


.pdf-modal-overlay.active,
.pdf-viewer-overlay[style*="display: flex"],
.pdf-viewer-overlay.active {
    opacity: 1;
    visibility: visible;
}


/* --------------------------------------------------------
   2. MODAL CONTAINER
   -------------------------------------------------------- */
.pdf-modal-content,
.pdf-viewer-container {
    background: #ffffff;
    width: 95%;
    max-width: 1000px;
    height: 90vh;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);

    /* Reverted to stable about_nir.php animation */
    transform: translateY(20px);
    transition: transform 0.3s ease;
    border: none;
}

/* Entrance / end state: slides up */
.pdf-modal-overlay.active .pdf-modal-content,
.pdf-viewer-overlay[style*="display: flex"] .pdf-viewer-container,
.pdf-viewer-overlay.active .pdf-viewer-container {
    transform: translateY(0);
}


/* --------------------------------------------------------
   3. HEADER
   -------------------------------------------------------- */
.pdf-modal-header,
.pdf-viewer-header {
    padding: 15px 25px;
    background: #f8f9fa;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 12px 12px 0 0;
    flex-shrink: 0; /* Prevents header from collapsing */
}

.pdf-modal-header h4,
.pdf-viewer-title {
    margin: 0;
    color: #03508c;
    font-family: 'Nunito', sans-serif;
    font-size: 1.25rem;
    font-weight: 800;
    flex: 1;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    margin-right: 20px;
}

/* Header Actions Container (JS Viewer) */
.pdf-viewer-actions {
    display: flex;
    gap: 15px;
    align-items: center;
}

/* Close Button */
.pdf-close-btn,
.pdf-viewer-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: #64748b;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.pdf-close-btn:hover,
.pdf-viewer-close:hover {
    color: #ef4444;
    background: transparent;
    border-color: transparent;
}


/* --------------------------------------------------------
   4. CONTENT / IFRAME AREA
   -------------------------------------------------------- */
.pdf-modal-body,
.pdf-content-area {
    flex-grow: 1;
    width: 100%;
    background: #e2e8f0;
    position: relative;
    overflow: hidden;
    /* Explicit height fallback for Safari flex children */
    min-height: 0;
}

#pdfIframe,
.pdf-viewer-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
    display: block; /* Removes inline gap in some browsers */
}


/* --------------------------------------------------------
   5. FOOTER (Static HTML Modals)
   -------------------------------------------------------- */
.pdf-modal-footer {
    padding: 12px 25px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    text-align: right;
    flex-shrink: 0;
}


/* --------------------------------------------------------
   6. UNIVERSAL MODERN BUTTONS
   -------------------------------------------------------- */
a.modern-download-btn,
.pdf-download-btn,
.download-link,
.retry-btn {
    background-color: #ffffff !important;
    border: 2px solid #e2e8f0;
    padding: 10px 25px;
    border-radius: 50px;
    font-size: 0.95rem;
    color: #334155;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    font-family: 'Nunito', sans-serif;
    margin-top: 15px;
}

/* Tighter sizing for footer/header contexts */
.pdf-modal-footer a.modern-download-btn,
.pdf-viewer-header .pdf-download-btn {
    margin: 0;
    padding: 8px 20px;
    font-size: 0.9rem;
}

a.modern-download-btn:hover,
.pdf-download-btn:hover,
.download-link:hover,
.retry-btn:hover {
    border-color: #03508c;
    color: #03508c !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

a.modern-download-btn:active,
.pdf-download-btn:active,
.download-link:active,
.retry-btn:active {
    transform: translateY(0);
}


/* --------------------------------------------------------
   7. LOADING & ERROR STATES (JS Viewer)
   -------------------------------------------------------- */
.pdf-loading {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 1002;
}

.loading-spinner {
    width: 60px; height: 60px;
    border: 4px solid #e2e8f0;
    border-top: 4px solid #03508c;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 24px;
}

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

.pdf-loading p {
    font-size: 16px;
    color: #64748b;
    margin: 0;
    font-weight: 600;
}

.pdf-error {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 1002;
    background: white;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    max-width: 400px;
    width: 90%;
    border: 1px solid #e2e8f0;
}

.pdf-error-icon {
    font-size: 48px;
    color: #ef4444;
    margin-bottom: 16px;
}

.pdf-error h3 {
    color: #03508c;
    margin: 0 0 12px 0;
    font-size: 20px;
    font-weight: 800;
}

.pdf-error p {
    font-size: 14px;
    color: #64748b;
    margin: 0 0 24px 0;
    line-height: 1.5;
    font-weight: 500;
}

.pdf-error-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 15px;
}

/* Icons for JS viewer action buttons */
.retry-btn::before    { content: "↻"; font-size: 16px; }
.download-link::before { content: "📄"; font-size: 16px; }


/* --------------------------------------------------------
   8. MOBILE RESPONSIVENESS
   -------------------------------------------------------- */
@media (max-width: 768px) {
    .pdf-modal-content,
    .pdf-viewer-container {
        width: 98%;
        height: 85vh;
        border-radius: 12px;
    }

    .pdf-modal-header,
    .pdf-viewer-header {
        padding: 12px 16px;
        flex-wrap: wrap;
    }

    .pdf-modal-header h4,
    .pdf-viewer-title {
        font-size: 1.1rem;
        margin-right: 0;
    }

    .pdf-viewer-actions { gap: 10px; }

    .pdf-download-btn,
    .pdf-modal-footer a.modern-download-btn {
        padding: 6px 15px;
        font-size: 0.85rem;
    }

    .pdf-close-btn,
    .pdf-viewer-close { font-size: 1.8rem; }

    .pdf-error { padding: 24px; max-width: 320px; }
    .pdf-error-actions { flex-direction: column; gap: 10px; }

    .retry-btn,
    .download-link {
        width: 100%;
        justify-content: center;
        margin-top: 0;
    }
}