/**
 * Stylesheet for Elementor PDF Viewer Widget
 */

.elementor-pdf-viewer-container {
    width: 100%;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.elementor-pdf-viewer {
    width: 100%;
    height: 100%;
    display: block;
    border: none;
    background: #f1f1f1;
}

.elementor-pdf-viewer iframe,
.elementor-pdf-viewer object,
.elementor-pdf-viewer embed {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* Beautiful Placeholder for Editor/Empty states */
.elementor-pdf-viewer-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border: 2px dashed #a0aec0;
    border-radius: 8px;
    text-align: center;
    color: #4a5568;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    min-height: 300px;
    transition: border-color 0.2s ease;
}

.elementor-pdf-viewer-placeholder:hover {
    border-color: #3182ce;
}

.elementor-pdf-viewer-placeholder-icon {
    font-size: 48px;
    margin-bottom: 16px;
    color: #e53e3e; /* Red color for PDF feel */
    animation: pdf-pulse 2s infinite ease-in-out;
}

.elementor-pdf-viewer-placeholder-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #2d3748;
}

.elementor-pdf-viewer-placeholder-text {
    font-size: 14px;
    color: #718096;
    max-width: 320px;
}

@keyframes pdf-pulse {
    0% {
        transform: scale(1);
        opacity: 0.9;
    }
    50% {
        transform: scale(1.05);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 0.9;
    }
}

/* ==========================================================================
   PDF.js Custom Viewer CSS
   ========================================================================== */

.elementor-pdfjs-viewer {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background-color: #525659;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    position: relative;
    user-select: none;
    box-sizing: border-box;
}

.elementor-pdfjs-viewer * {
    box-sizing: border-box;
}

/* Toolbar Style */
.pdfjs-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #323639;
    color: #f1f1f1;
    padding: 8px 16px;
    height: 48px;
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.pdfjs-toolbar-left,
.pdfjs-toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Buttons */
.pdfjs-prev-btn,
.pdfjs-next-btn,
.pdfjs-zoom-out-btn,
.pdfjs-zoom-in-btn {
    background: transparent;
    border: none;
    color: #e2e8f0;
    padding: 6px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, color 0.2s;
    outline: none;
}

.pdfjs-prev-btn:hover,
.pdfjs-next-btn:hover,
.pdfjs-zoom-out-btn:hover,
.pdfjs-zoom-in-btn:hover {
    background-color: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

.pdfjs-prev-btn:disabled,
.pdfjs-next-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background-color: transparent !important;
}

/* Info Texts */
.pdfjs-page-info,
.pdfjs-zoom-info {
    font-size: 14px;
    font-weight: 500;
    min-width: 60px;
    text-align: center;
    color: #cbd5e0;
}

/* Canvas Container */
.pdfjs-canvas-container {
    flex: 1;
    overflow: auto;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    background-color: #525659;
    height: calc(100% - 48px);
}

.pdfjs-canvas {
    background-color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
    max-width: 100%;
    height: auto !important;
    display: block;
    transform-origin: top center;
    transition: transform 0.1s ease;
}

/* Page Wrapper & Annotation Layer */
.pdfjs-page-wrapper {
    position: relative;
    display: inline-block;
    max-width: 100%;
    margin: 0 auto;
}

.annotationLayer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    transform-origin: top left;
}

.annotationLayer section {
    position: absolute;
    text-align: left;
    pointer-events: auto;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.annotationLayer .linkAnnotation > a {
    position: absolute;
    font-size: 1em;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: transparent;
    border: 1px dashed transparent;
    transition: background-color 0.2s, border-color 0.2s;
}

.annotationLayer .linkAnnotation > a:hover {
    background-color: rgba(255, 255, 0, 0.15); /* Light yellow highlight */
    border-color: rgba(255, 165, 0, 0.4);
}

.annotationLayer .buttonWidgetAnnotation.checkBox input,
.annotationLayer .buttonWidgetAnnotation.radioButton input {
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.annotationLayer .choiceWidgetAnnotation select,
.annotationLayer .textWidgetAnnotation input,
.annotationLayer .textWidgetAnnotation textarea {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    border: 1px solid transparent;
    background-color: rgba(0, 54, 255, 0.05);
    color: #000000;
    font-family: sans-serif;
    font-size: 9px;
    margin: 0;
    padding: 2px;
}

.annotationLayer .textWidgetAnnotation input:focus,
.annotationLayer .textWidgetAnnotation textarea:focus {
    background-color: #ffffff;
    border: 1px solid #3182ce;
    outline: none;
}


/* Loading Spinner */
.pdfjs-loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: #3182ce;
    border-radius: 50%;
    animation: pdfjs-spin 0.8s infinite linear;
    z-index: 5;
    display: none;
}

.pdfjs-loading-spinner.active {
    display: block;
}

@keyframes pdfjs-spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* SVG icon adjustments */
.pdfjs-toolbar svg {
    display: block;
}

/* ==========================================================================
   PDF Modal Lightbox / Popup CSS
   ========================================================================== */

/* Overlay — completely hidden by default */
.elementor-pdf-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 999999;
    display: none;           /* truly hidden */
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Step 1: make it visible (display:flex) */
.elementor-pdf-modal-overlay.open {
    display: flex;
}

/* Step 2: fade it in */
.elementor-pdf-modal-overlay.active {
    opacity: 1;
}

/* Modal content box */
.elementor-pdf-modal-content {
    position: relative;
    width: 100%;
    max-width: 1000px;
    height: 90vh;
    max-height: 850px;
    background-color: #525659;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.5);
    transform: scale(0.92);
    transition: transform 0.3s ease;
}

.elementor-pdf-modal-overlay.active .elementor-pdf-modal-content {
    transform: scale(1);
}

/* The PDF.js viewer inside the modal must fill the remaining space */
.elementor-pdfjs-modal-mode {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.elementor-pdfjs-modal-mode .pdfjs-canvas-container {
    flex: 1;
    height: 0;              /* allow flex to control size */
    min-height: 0;
}

/* Modal Header & Layout */
.elementor-pdf-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #202124;
    color: #ffffff;
    padding: 8px 16px;
    height: 48px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-sizing: border-box;
}

.elementor-pdf-modal-title {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 60px);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.elementor-pdf-modal-body {
    flex: 1;
    height: 0;
    position: relative;
    overflow: hidden;
    background-color: #525659;
}

/* Close Button */
.elementor-pdf-modal-close {
    background-color: rgba(255, 255, 255, 0.12);
    border: none;
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
    padding: 0;
}

.elementor-pdf-modal-close:hover {
    background-color: #ef4444;
    transform: scale(1.05);
}

.elementor-pdf-modal-close:focus {
    outline: none;
}

.elementor-pdf-modal-close svg {
    display: block;
    width: 18px;
    height: 18px;
}

/* Trigger Button Wrapper */
.elementor-pdf-modal-trigger-wrapper {
    display: flex;
    justify-content: center;
}

/* Trigger Button — defaults (all overridable via Elementor Style tab) */
.elementor-pdf-modal-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    border: none;
    outline: none;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    padding: 12px 28px;
    border-radius: 6px;
    background-color: #3182ce;
    color: #ffffff;
    transition: background-color 0.25s ease, transform 0.15s ease;
    text-decoration: none;
    line-height: 1;
}

.elementor-pdf-modal-trigger:hover {
    background-color: #2b6cb0;
    transform: translateY(-1px);
}

.elementor-pdf-modal-trigger:active {
    transform: translateY(0);
}

.elementor-pdf-modal-trigger .btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
}

.elementor-pdf-modal-trigger .btn-icon svg {
    display: block;
    width: 1em;
    height: 1em;
}

/* Toolbar space for close button */
.elementor-pdfjs-modal-mode .pdfjs-toolbar {
    padding-right: 60px;
}

/* Mobile */
@media (max-width: 767px) {
    .elementor-pdf-modal-overlay {
        padding: 8px;
    }
    
    .elementor-pdf-modal-content {
        height: 95vh;
        max-height: none;
        border-radius: 6px;
    }
}
