/* ============================================================
   Rathore Online - PDF.js viewer styles (PDF material page only)

   Scope note: every rule is nested under .pdfv so no existing
   page, module or the shared style.css is affected. The legacy
   .preview-container rules used by the HTML-material iframe are
   deliberately left untouched.
   ============================================================ */

.pdfv {
    --pdfv-bg: #f3f4f6;
    --pdfv-bar: #1f2937;
    --pdfv-bar-fg: #f9fafb;
    --pdfv-accent: #4f46e5;
    --pdfv-border: #d1d5db;
    margin: 20px 0;
    border: 1px solid var(--pdfv-border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--pdfv-bg);
    /* Never allow the viewer to force horizontal page scroll. */
    max-width: 100%;
}

/* ---------- Toolbar ---------- */
.pdfv-toolbar {
    display: flex;
    flex-wrap: wrap;          /* wraps instead of overflowing on phones */
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px;
    background: var(--pdfv-bar);
    color: var(--pdfv-bar-fg);
}

.pdfv-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;          /* touch-friendly target */
    min-height: 40px;
    padding: 8px 10px;
    border: 1px solid #4b5563;
    border-radius: 8px;
    background: #374151;
    color: var(--pdfv-bar-fg);
    font-size: 0.9rem;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.pdfv-btn:hover:not(:disabled),
.pdfv-btn:focus-visible:not(:disabled) {
    background: var(--pdfv-accent);
    border-color: var(--pdfv-accent);
}

.pdfv-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pdfv-btn--wide {
    padding: 8px 14px;
}

/* ---------- Page indicator ---------- */
.pdfv-pager {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    white-space: nowrap;
}

.pdfv-pager input {
    width: 58px;
    min-height: 40px;
    padding: 6px 8px;
    border: 1px solid #4b5563;
    border-radius: 8px;
    background: #111827;
    color: #fff;
    font-size: 0.9rem;
    text-align: center;
    -moz-appearance: textfield;
}

.pdfv-pager input::-webkit-outer-spin-button,
.pdfv-pager input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.pdfv-zoom-label {
    min-width: 52px;
    text-align: center;
    font-size: 0.85rem;
    white-space: nowrap;
}

/* ---------- Pages viewport ---------- */
.pdfv-pages {
    height: 72vh;
    min-height: 320px;
    max-height: 1000px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    background: #52565c;
    /* Block the browser's own pinch-zoom on the canvas surface so the
       viewer's zoom controls stay predictable, while keeping normal
       page scroll everywhere else on the site. */
    touch-action: pan-x pan-y;
}

.pdfv-page {
    position: relative;
    margin: 10px auto;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    /* Reserve space before the bitmap arrives to avoid layout jump. */
    min-height: 40px;
}

.pdfv-page canvas {
    display: block;
    width: 100%;
    height: auto;
    /* Hindi / Devanagari glyphs render sharper without smoothing off. */
    image-rendering: auto;
}

.pdfv-page--ph {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    font-size: 0.8rem;
    background: #fff;
}

/* ---------- Status / fallback ---------- */
.pdfv-status {
    padding: 14px 16px;
    text-align: center;
    font-size: 0.9rem;
    color: #374151;
    background: #f9fafb;
}

.pdfv-status[hidden] {
    display: none;
}

.pdfv-status--error {
    color: #b91c1c;
    background: #fef2f2;
}

/* Always-present escape hatch: Open PDF + Download PDF. */
.pdfv-fallback {
    padding: 20px 16px;
    text-align: center;
    background: #f9fafb;
}

.pdfv-fallback h4 {
    margin: 0 0 6px;
    color: #111827;
    font-size: 1rem;
}

.pdfv-fallback p {
    margin: 0 0 12px;
    color: #4b5563;
    font-size: 0.88rem;
}

.pdfv-fallback-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.pdfv-fallback-actions .pdfv-btn {
    background: var(--pdfv-accent);
    border-color: var(--pdfv-accent);
    color: #fff;
}

.pdfv-fallback-actions .pdfv-btn:hover {
    background: #4338ca;
}

.pdfv-fallback-actions .pdfv-btn--alt {
    background: #0f766e;
    border-color: #0f766e;
}

/* ---------- Fullscreen ---------- */
.pdfv:fullscreen {
    border-radius: 0;
    max-width: none;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.pdfv:fullscreen .pdfv-pages {
    height: auto;
    max-height: none;
    flex: 1 1 auto;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .pdfv {
        margin: 15px 0;
        border-radius: 8px;
    }

    .pdfv-toolbar {
        gap: 5px;
        padding: 7px 6px;
        justify-content: flex-start;
    }

    .pdfv-btn {
        min-width: 44px;
        min-height: 44px;
        padding: 9px 10px;
    }

    .pdfv-btn--wide {
        padding: 9px 12px;
    }

    .pdfv-pages {
        height: 68vh;
        min-height: 260px;
    }

    .pdfv-page {
        margin: 6px auto;
    }
}

/* Very narrow phones (320px): allow the toolbar to wrap cleanly and
   keep every control fully inside the viewport. */
@media (max-width: 400px) {
    .pdfv-btn {
        min-width: 42px;
        padding: 9px 8px;
        font-size: 0.85rem;
    }

    .pdfv-btn--wide {
        padding: 9px 10px;
    }

    .pdfv-pager input {
        width: 48px;
    }

    .pdfv-zoom-label {
        min-width: 44px;
        font-size: 0.8rem;
    }
}