/* PDF.js viewer container */
.pdfjs-viewer {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    background: #525659;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}

.pdfjs-viewer .pdfjs-toolbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    background: rgba(50, 54, 57, 0.95);
    border-radius: 6px;
    margin-bottom: 4px;
    backdrop-filter: blur(4px);
    flex-shrink: 0;
}

.pdfjs-viewer .pdfjs-toolbar button {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #ccc;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: background 0.15s;
}

.pdfjs-viewer .pdfjs-toolbar button:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

.pdfjs-viewer .pdfjs-toolbar .pdfjs-page-info {
    color: #bbb;
    font-size: 12px;
    min-width: 80px;
    text-align: center;
    user-select: none;
}

/* Page wrapper: contains both the canvas and text layer */
.pdfjs-page-wrapper {
    position: relative;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    background: #fff;
    flex-shrink: 0;
}

.pdfjs-page-wrapper canvas {
    display: block;
}

/* ============================================================
   Text layer — Official PDF.js CSS (adapted from pdfjs-dist)
   This MUST override any inherited Bootstrap / app styles.
   ============================================================ */
.pdfjs-page-wrapper .textLayer {
    position: absolute;
    inset: 0;
    overflow: hidden;
    line-height: 1;
    text-align: initial;
    text-size-adjust: none;
    -webkit-text-size-adjust: none;
    -moz-text-size-adjust: none;
    forced-color-adjust: none;
    transform-origin: 0 0;
    z-index: 2;
    /* Hover-to-drag UX: no manual text selection needed */
    user-select: none;
    -webkit-user-select: none;
}

.pdfjs-page-wrapper .textLayer :is(span, br) {
    color: transparent;
    position: absolute;
    white-space: pre;
    cursor: grab;
    transform-origin: 0% 0%;
    /* Reset any inherited styles from Bootstrap/app */
    margin: 0;
    padding: 0;
    border: 0;
    line-height: 1;
    font-weight: normal;
    font-style: normal;
    letter-spacing: normal;
    word-spacing: normal;
    text-indent: 0;
    text-decoration: none;
    text-transform: none;
    box-sizing: content-box;
    border-radius: 3px;
    transition: background 0.12s, color 0.12s;
}

/* Hover: highlight the block + reveal text + grab cursor */
.pdfjs-page-wrapper .textLayer span:hover {
    background: rgba(59, 130, 246, 0.22);
    color: rgba(0, 0, 0, 0.80);
    cursor: grab;
}

.pdfjs-page-wrapper .textLayer span:active {
    cursor: grabbing;
    background: rgba(59, 130, 246, 0.35);
}

.pdfjs-page-wrapper .textLayer span.markedContent {
    top: 0;
    height: 0;
}

/* Loading state */
.pdfjs-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #aaa;
    gap: 12px;
    font-size: 13px;
}

.pdfjs-loading .spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255,255,255,0.2);
    border-top-color: #aaa;
    border-radius: 50%;
    animation: pdfjs-spin 0.8s linear infinite;
}

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

/* Drag hint */
.pdfjs-viewer .pdfjs-drag-hint {
    color: #999;
    font-size: 11px;
    text-align: center;
    padding: 4px 12px;
    user-select: none;
    flex-shrink: 0;
}
