/* ── Outer viewer ─────────────────────────────────────────────────────────── */
.jet-pdf-viewer {
    width: 100%;
    font-family: inherit;
    display: flex;
    flex-direction: column;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: #fff;
    /* overflow:clip clips children to the border-radius without creating a
       scroll container — keeps position:sticky working on the controls bar */
    overflow: hidden; /* fallback */
    overflow: clip;
    /* Minimum height fills the screen minus typical page chrome (header ~100px).
       min-height interacts with the layout algorithm, so it wins over a smaller
       inline height: value (e.g. the old 600px default) without !important. */
    min-height: calc(100vh - 100px);
    /* height is set via inline style from the widget's Viewer Height setting */
}

/* ── Scrollable PDF area ──────────────────────────────────────────────────── */
.jet-pdf-canvas-wrap {
    /* flex-basis:0 (not auto) so the element always grows from zero to fill the
       remaining space, guaranteeing controls land at the true bottom edge */
    flex: 1 1 0;
    min-height: 0;
    overflow: auto;
    background: #f8f8f8;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
    position: relative; /* contains the absolutely-positioned loading overlay */
}

/* ── Loading spinner ──────────────────────────────────────────────────────── */
.jet-pdf-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f8f8f8;
    z-index: 5;
    gap: 12px;
    color: #999;
    font-size: 13px;
}

.jet-pdf-spinner {
    width: 34px;
    height: 34px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: #555;
    border-radius: 50%;
    animation: jet-pdf-spin 0.75s linear infinite;
}

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

/* ── Canvas container — relative so annotation <a> links sit on top ───────── */
.jet-pdf-canvas-container {
    position: relative;
    flex-shrink: 0;
    line-height: 0;
}

.jet-pdf-canvas {
    display: block;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

/* ── Annotation link overlays (injected by JS) ────────────────────────────── */
.jet-pdf-link {
    position: absolute;
    cursor: pointer;
}

a.jet-pdf-link:hover {
    background: rgba(0, 100, 220, 0.08);
    border-radius: 2px;
    outline: 1px solid rgba(0, 100, 220, 0.2);
}

/* ── Controls bar ─────────────────────────────────────────────────────────── */
.jet-pdf-controls {
    flex-shrink: 0;
    /* On desktop the controls sit at the very bottom of the flex container.
       sticky:bottom keeps them anchored to the viewport bottom if the viewer
       extends beyond the screen. */
    position: sticky;
    bottom: 0;
    top: auto;
    z-index: 10;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 12px;
    background-color: #f5f5f5;
    border-top: 1px solid #e0e0e0;
}

.jet-pdf-controls-sep {
    display: block;
    width: 1px;
    height: 20px;
    background: #d0d0d0;
    margin: 0 2px;
    flex-shrink: 0;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.jet-pdf-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    background-color: #000;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: opacity 0.15s ease;
    line-height: 1;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.jet-pdf-btn:hover  { opacity: 0.75; }
.jet-pdf-btn:active { opacity: 0.55; }
.jet-pdf-btn:disabled { opacity: 0.3; cursor: default; }

.jet-pdf-zoom-in,
.jet-pdf-zoom-out {
    padding: 6px 10px;
    font-size: 17px;
    font-weight: bold;
}

.jet-pdf-page-info {
    font-size: 13px;
    color: #555;
    margin: 0 2px;
}

.jet-pdf-zoom-label {
    font-size: 13px;
    color: #555;
    min-width: 38px;
    text-align: center;
}

/* ── Error box ────────────────────────────────────────────────────────────── */
.jet-pdf-error {
    padding: 16px;
    background: #fff3f3;
    border-top: 1px solid #fcc;
    color: #900;
    font-size: 14px;
}

/* ── Editor placeholder ───────────────────────────────────────────────────── */
.jet-pdf-placeholder {
    padding: 40px 20px;
    border: 2px dashed #ddd;
    border-radius: 6px;
    text-align: center;
    color: #999;
}

/* ── Mobile ───────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {

    /* PDF fills edge-to-edge — no padding so the full width is used.
       The user zooms in to read detail rather than the viewer padding out. */
    .jet-pdf-canvas-wrap {
        padding: 0;
        order: 1; /* canvas below the controls bar */
        background: #fff;
    }

    /* Controls move to the TOP on mobile so they're immediately visible
       without scrolling, and sticky:top keeps them there while reading. */
    .jet-pdf-controls {
        order: -1;
        position: sticky;
        top: 0;
        bottom: auto;
        border-top: none;
        border-bottom: 1px solid #e0e0e0;
        justify-content: center;
        gap: 5px;
        padding: 8px 10px;
    }

    .jet-pdf-canvas {
        box-shadow: none; /* no shadow needed at edge-to-edge */
    }

    .jet-pdf-btn {
        padding: 7px 10px;
        font-size: 12px;
    }

    .jet-pdf-zoom-in,
    .jet-pdf-zoom-out {
        padding: 7px 9px;
    }

    .jet-pdf-controls-sep {
        display: none;
    }

    /* Fill the full screen on mobile regardless of the Elementor height setting.
       100svh = viewport height with browser UI visible (safe minimum — never
       clipped behind the address bar). Falls back to 100vh on older browsers. */
    .jet-pdf-viewer {
        height: 100vh !important;
        height: 100svh !important;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
}
