/* ============================================
   PDF VIEWER LOADER
============================================ */
.pdf-viewer-wrapper {
    position: relative;
    width: 100%;
    min-height: 730px!important;
    border-radius: 10px;
    overflow: hidden;
    background: #f8fafc;
}

.pdf-viewer-wrapper iframe {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: white;
}

.pdf-loader {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #f8fafc 0%, #eef2ff 100%);
    z-index: 10;
    border-radius: 10px;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.pdf-loader-hide {
    opacity: 0;
    transform: scale(1.02);
    pointer-events: none;
}

/* El loader nunca debe capturar eventos fuera del modal */
.modal:not(.in) .pdf-loader {
    pointer-events: none;
}

.pdf-loader-content {
    text-align: center;
    padding: 30px;
    max-width: 320px;
}

.pdf-icon-wrapper {
    position: relative;
    width: 90px;
    height: 90px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pdf-icon {
    font-size: 48px;
    color: #dc2626;
    z-index: 2;
    animation: pdfPulse 2s ease-in-out infinite;
    text-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.pdf-spinner {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 4px solid rgba(37, 99, 235, 0.1);
    border-top-color: #2563eb;
    border-right-color: #3b82f6;
    border-radius: 50%;
    animation: pdfRotate 1.2s linear infinite;
}

.pdf-loader-text {
    font-size: 16px;
    font-weight: 600;
    color: #1e40af;
    margin-bottom: 6px;
    letter-spacing: 0.3px;
}

.pdf-loader-subtext {
    font-size: 12.5px;
    color: #64748b;
    margin-bottom: 18px;
    font-weight: 400;
}

.pdf-progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(37, 99, 235, 0.12);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.pdf-progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 30%;
    background: linear-gradient(90deg, #2563eb, #3b82f6, #60a5fa);
    border-radius: 4px;
    animation: pdfProgress 1.8s ease-in-out infinite;
}

@keyframes pdfRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes pdfPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(0.92); opacity: 0.75; }
}

@keyframes pdfProgress {
    0% { left: -30%; width: 30%; }
    50% { width: 45%; }
    100% { left: 100%; width: 30%; }
}

/* Responsive */
@media (max-width: 767px) {
    .pdf-viewer-wrapper {
        min-height: 500px;
    }
    .pdf-icon-wrapper { width: 70px; height: 70px; }
    .pdf-icon { font-size: 38px; }
    .pdf-loader-text { font-size: 14px; }
    .pdf-loader-subtext { font-size: 11.5px; }
}

/* === Agregar al final de tu CSS actual === */

.modal-body .pdf-viewer-wrapper iframe.pdf-frame {
    width: 100%;
    height: 730px!important;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    display: block;
}

/* Modal: ajustes específicos */
.pdf-modal .modal-dialog {
    max-width: 90vw;
}

.pdf-modal .modal-body {
    background: #f8fafc;
}

.pdf-modal .pdf-viewer-wrapper {
    min-height: 75vh;
}

.pdf-modal .pdf-viewer-wrapper iframe.pdf-frame {
    height: 75vh;
}

/* Botón cerrar del modal alineado con el header */
.pdf-modal .modal-header {
    border-bottom: 1px solid #e2e8f0;
    background: white;
    border-radius: 10px 10px 0 0;
}

/* Responsive del modal */
@media (max-width: 767px) {
    .pdf-modal .modal-dialog {
        max-width: 100vw;
        margin: 0;
    }
    .pdf-modal .pdf-viewer-wrapper iframe.pdf-frame {
        height: 70vh;
    }
}

/* ============================================
   PANEL DE ERROR DEL VISOR PDF
============================================ */

/* Círculo rojo con ícono de advertencia */
.pdf-error-icon-wrapper {
    width: 90px;
    height: 90px;
    margin: 0 auto 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border: 2px solid #fca5a5;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: errorPulse 2.4s ease-in-out infinite;
}

.pdf-error-icon {
    font-size: 42px;
    color: #dc2626;
}

/* Título del error */
.pdf-error-title {
    font-size: 16px;
    font-weight: 700;
    color: #b91c1c;
    margin-bottom: 12px;
    letter-spacing: 0.2px;
}

/* Badge con el mensaje exacto del backend */
.pdf-error-badge {
    display: inline-block;
    background: #fff1f2;
    border: 1px solid #fecaca;
    border-left: 4px solid #dc2626;
    color: #7f1d1d;
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 12.5px;
    line-height: 1.5;
    max-width: 280px;
    text-align: left;
    margin-bottom: 18px;
    word-break: break-word;
}

.pdf-error-badge .fa {
    color: #dc2626;
    margin-right: 6px;
    flex-shrink: 0;
}

/* Botón Reintentar */
.pdf-error-retry-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px 22px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.pdf-error-retry-btn:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.45);
    transform: translateY(-1px);
    color: #fff;
}

.pdf-error-retry-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(37, 99, 235, 0.3);
}

.pdf-error-retry-btn .fa {
    font-size: 13px;
}

@keyframes errorPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.2); }
    50%       { box-shadow: 0 0 0 10px rgba(220, 38, 38, 0); }
}