/**
 * Custom PDF.js viewer: desktop = two pages per row (spread); mobile = one page per row.
 */

.doc-viewer-wrapper.doc-viewer-wrapper--custom-pdf {
    display: flex;
    flex-direction: column;
    height: 80vh;
    max-height: min(80vh, 920px);
    overflow: hidden;
    padding: 0;
}

.doc-pdf-viewer-root {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    background: #e5e4df;
}

.doc-pdf-toolbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 14px;
    background: linear-gradient(180deg, #fafaf8 0%, #f0efe9 100%);
    border-bottom: 1px solid var(--doc-border, #e5e7eb);
    font-size: 12px;
    font-weight: 600;
    color: var(--doc-text-muted, #64748b);
    font-family: var(--font-ui, 'Inter', system-ui, sans-serif);
}

.doc-pdf-toolbar span strong {
    color: var(--doc-text, #0f172a);
    font-weight: 700;
}

.doc-pdf-scroll {
    flex: 1;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px 12px 24px;
}

.doc-pdf-spread {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
    max-width: 100%;
}

.doc-pdf-spread:last-child {
    margin-bottom: 0;
}

.doc-pdf-page-wrap {
    flex: 1 1 50%;
    min-width: 0;
    max-width: calc(50% - 6px);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background: #fff;
    border-radius: 8px;
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.06),
        0 1px 2px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}

.doc-pdf-spread--single .doc-pdf-page-wrap {
    flex: 0 1 auto;
    max-width: min(50%, 520px);
}

.doc-pdf-page-wrap canvas {
    display: block;
    width: 100%;
    height: auto;
    vertical-align: top;
}

/* ── Page skeleton (loading) ─────────────────────────────────────────── */
.doc-pdf-skeleton {
    position: relative;
    width: 100%;
    aspect-ratio: 8.5 / 11;
    min-height: 180px;
    box-sizing: border-box;
    overflow: hidden;
}

.doc-pdf-skeleton__inner {
    padding: 9% 10% 10%;
    height: 100%;
    box-sizing: border-box;
}

.doc-pdf-skeleton__hero {
    width: 55%;
    height: 14%;
    min-height: 28px;
    border-radius: 6px;
    margin-bottom: 10%;
    background: var(--doc-pdf-sk-base, #e8e8e6);
    position: relative;
    overflow: hidden;
}

.doc-pdf-skeleton__line {
    height: 2.2%;
    min-height: 7px;
    border-radius: 4px;
    margin-bottom: 3.8%;
    width: 100%;
    background: var(--doc-pdf-sk-base, #e8e8e6);
    position: relative;
    overflow: hidden;
}

.doc-pdf-skeleton__line--long {
    width: 96%;
}

.doc-pdf-skeleton__line--medium {
    width: 88%;
}

.doc-pdf-skeleton__line--short {
    width: 62%;
}

.doc-pdf-skeleton__line--tiny {
    width: 38%;
    margin-bottom: 0;
}

.doc-pdf-skeleton__hero::after,
.doc-pdf-skeleton__line::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        105deg,
        transparent 0%,
        transparent 40%,
        rgba(255, 255, 255, 0.55) 50%,
        transparent 60%,
        transparent 100%
    );
    background-size: 220% 100%;
    animation: doc-pdf-skeleton-shimmer 1.35s ease-in-out infinite;
}

.doc-pdf-skeleton__badge {
    position: absolute;
    bottom: 10px;
    right: 12px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: rgba(100, 116, 139, 0.55);
    font-family: var(--font-ui, 'Inter', system-ui, sans-serif);
    pointer-events: none;
}

@keyframes doc-pdf-skeleton-shimmer {
    0% {
        background-position: 120% 0;
    }
    100% {
        background-position: -120% 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .doc-pdf-skeleton__hero::after,
    .doc-pdf-skeleton__line::after {
        animation: none;
    }

    .doc-pdf-skeleton__hero,
    .doc-pdf-skeleton__line {
        opacity: 0.85;
    }
}

.doc-pdf-error {
    padding: 48px 24px;
    text-align: center;
    font-size: 13px;
    color: #b91c1c;
}

@media (max-width: 768px) {
    .doc-viewer-wrapper.doc-viewer-wrapper--custom-pdf {
        height: 60vh;
        max-height: 70vh;
    }

    .doc-pdf-spread {
        flex-direction: column;
        align-items: stretch;
    }

    .doc-pdf-page-wrap {
        flex: 1 1 auto;
        max-width: 100%;
    }

    .doc-pdf-spread--single .doc-pdf-page-wrap {
        max-width: 100%;
    }
}
