/* ─── BeambePrep Interactive PDF Reader (Midnight Hive Styling) ─── */

.beambe-pdf-reader-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 780px;
    background: #09090B;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 1.25rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
    overflow: hidden;
    font-family: inherit;
    color: #F4F4F5;
}

/* Fullscreen Reader Mode */
.beambe-pdf-reader-wrapper.is-fullscreen,
.beambe-pdf-reader-wrapper:fullscreen {
    width: 100vw !important;
    height: 100vh !important;
    border-radius: 0 !important;
    border: none !important;
    z-index: 99999 !important;
    margin: 0 !important;
}

/* ─── Toolbar ─── */
.pdf-reader-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    background: #141416;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 10;
}

.pdf-toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.btn-pdf-ctrl {
    background: #1C1C1F;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #E4E4E7;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.4rem 0.65rem;
    border-radius: 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    cursor: pointer;
    transition: all 0.18s ease;
    user-select: none;
    line-height: 1.2;
}

.btn-pdf-ctrl:hover:not(:disabled) {
    background: #27272A;
    color: #FFFFFF;
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-pdf-ctrl:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-pdf-ctrl.active {
    background: rgba(255, 193, 7, 0.15);
    border-color: rgba(255, 193, 7, 0.5);
    color: #FFC107;
}

.btn-pdf-amber {
    background: linear-gradient(135deg, #FFC107 0%, #FFB300 100%);
    color: #050505 !important;
    font-weight: 800;
    border: none;
}
.btn-pdf-amber:hover {
    background: linear-gradient(135deg, #FFD54F 0%, #FFC107 100%);
    box-shadow: 0 4px 14px rgba(255, 193, 7, 0.35);
}

.input-pdf-page {
    width: 44px;
    background: #0D0D0E;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 0.4rem;
    color: #FFFFFF;
    font-family: monospace;
    font-weight: 700;
    font-size: 0.85rem;
    text-align: center;
    padding: 0.3rem 0.2rem;
}
.input-pdf-page:focus {
    outline: none;
    border-color: #FFC107;
    box-shadow: 0 0 0 2px rgba(255, 193, 7, 0.2);
}

.pdf-page-display {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.85rem;
    color: #A1A1AA;
}

.span-pdf-zoom-val {
    font-family: monospace;
    font-size: 0.82rem;
    color: #D4D4D8;
    min-width: 42px;
    text-align: center;
}

/* ─── Reader Body (Sidebar + Viewport) ─── */
.pdf-reader-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
    background: #09090B;
}

/* ─── Thumbnail Sidebar (Desktop default inline flex, Mobile offcanvas overlay) ─── */
.pdf-thumbnails-sidebar {
    width: 170px;
    flex-shrink: 0;
    background: #111113;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.75rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: width 0.22s ease, padding 0.22s ease, opacity 0.22s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.beambe-pdf-reader-wrapper.sidebar-collapsed .pdf-thumbnails-sidebar {
    width: 0;
    padding: 0;
    opacity: 0;
    pointer-events: none;
    border-right: none;
}

.pdf-thumbnails-backdrop {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(4px);
    z-index: 35;
    cursor: pointer;
}

.pdf-thumbnails-track {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.pdf-thumb-item {
    background: #18181B;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 4px;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s ease;
}

.pdf-thumb-item:hover {
    border-color: rgba(255, 193, 7, 0.4);
    transform: scale(1.02);
}

.pdf-thumb-item.active {
    border-color: #FFC107;
    box-shadow: 0 0 12px rgba(255, 193, 7, 0.35);
    background: rgba(255, 193, 7, 0.08);
}

.pdf-thumb-canvas {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 4px;
    background: #FFFFFF;
}

.pdf-thumb-label {
    font-size: 0.72rem;
    color: #A1A1AA;
    margin-top: 3px;
    font-weight: 600;
}

/* ─── Pages Viewport ─── */
.pdf-pages-viewport {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: radial-gradient(circle at 50% 30%, #151518 0%, #0A0A0C 100%);
    scroll-behavior: smooth;
    position: relative;
    -webkit-overflow-scrolling: touch;
}

.pdf-pages-track {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.75rem;
    width: 100%;
}

.pdf-page-container {
    position: relative;
    background: #FFFFFF;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8), 0 0 1px rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    transition: box-shadow 0.2s ease;
    user-select: none;
}

.pdf-page-canvas {
    display: block;
    border-radius: 4px;
}

.pdf-page-watermark-num {
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.72rem;
    font-family: monospace;
    color: #71717A;
    background: #18181B;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 2px 8px;
    border-radius: 999px;
    pointer-events: none;
}

/* ─── Midnight Hive Night Mode Filter ─── */
.beambe-pdf-reader-wrapper.beambe-pdf-night-mode .pdf-page-container canvas,
.beambe-pdf-reader-wrapper.beambe-pdf-night-mode .pdf-thumb-canvas {
    filter: invert(0.92) hue-rotate(180deg) brightness(0.95) contrast(1.05);
}
.beambe-pdf-reader-wrapper.beambe-pdf-night-mode .pdf-page-container {
    background: #121212;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.9), 0 0 12px rgba(255, 193, 7, 0.15);
}

/* ─── Sticky Action Dock (Midnight Hive Ergonomics) ─── */
.pdf-reader-action-dock {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: #121214;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 10;
}

.pdf-dock-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: #F4F4F5;
}

.pdf-dock-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Primary Action: Swarm Mode */
.btn-dock-swarm,
.btn-dock-sweat {
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.18) 0%, rgba(255, 179, 0, 0.28) 100%);
    border: 1px solid rgba(255, 193, 7, 0.55);
    color: #FFC107 !important;
    font-weight: 800;
    font-size: 0.84rem;
    padding: 0.45rem 0.95rem;
    border-radius: 0.65rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s ease;
    box-shadow: 0 4px 14px rgba(255, 193, 7, 0.15);
}
.btn-dock-swarm:hover,
.btn-dock-sweat:hover {
    background: linear-gradient(135deg, #FFC107 0%, #FFB300 100%);
    color: #050505 !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(255, 193, 7, 0.35);
}

.btn-dock-spaced {
    background: #18181B;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #F4F4F5 !important;
    font-weight: 600;
    font-size: 0.82rem;
    padding: 0.45rem 0.85rem;
    border-radius: 0.65rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: all 0.2s ease;
}
.btn-dock-spaced:hover {
    background: #27272A;
    border-color: rgba(0, 229, 255, 0.4);
    color: #00E5FF !important;
}

.btn-dock-omr {
    background: #18181B;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #F4F4F5 !important;
    font-weight: 600;
    font-size: 0.82rem;
    padding: 0.45rem 0.85rem;
    border-radius: 0.65rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: all 0.2s ease;
}
.btn-dock-omr:hover {
    background: #27272A;
    border-color: rgba(255, 193, 7, 0.4);
    color: #FFC107 !important;
}

.btn-dock-download {
    background: #18181B;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #D4D4D8 !important;
    font-weight: 600;
    font-size: 0.82rem;
    padding: 0.45rem 0.85rem;
    border-radius: 0.65rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: all 0.2s ease;
}
.btn-dock-download:hover {
    background: #27272A;
    color: #FFFFFF !important;
    border-color: rgba(255, 255, 255, 0.25);
}

/* ─── Loading & Error Overlays ─── */
.pdf-loading-indicator {
    position: absolute;
    inset: 0;
    background: rgba(9, 9, 11, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 50;
}

.pdf-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(255, 193, 7, 0.2);
    border-top-color: #FFC107;
    border-radius: 50%;
    animation: pdfSpin 0.75s linear infinite;
}

@keyframes pdfSpin {
    to { transform: rotate(360deg); }
}

.pdf-error-indicator {
    position: absolute;
    inset: 0;
    background: #09090B;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    z-index: 50;
}

/* ─── Responsive Media Queries ─── */
@media (max-width: 991.98px) {
    /* Mobile/Tablet Offcanvas Drawer for Thumbnails: Never squeeze canvas */
    .pdf-thumbnails-sidebar {
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        width: 220px !important;
        z-index: 45;
        background: #111113;
        box-shadow: 6px 0 25px rgba(0, 0, 0, 0.85);
        transform: translateX(-100%);
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    .beambe-pdf-reader-wrapper.sidebar-open .pdf-thumbnails-sidebar {
        transform: translateX(0);
    }

    .beambe-pdf-reader-wrapper.sidebar-open .pdf-thumbnails-backdrop {
        display: block;
    }
}

@media (max-width: 768px) {
    .beambe-pdf-reader-wrapper {
        height: 80vh;
        min-height: 560px;
        max-height: 85vh;
        border-radius: 1rem;
    }

    .pdf-pages-viewport {
        padding: 0.5rem 0.25rem;
    }

    .pdf-reader-toolbar {
        padding: 0.45rem 0.5rem;
        gap: 0.35rem;
    }

    .pdf-toolbar-group {
        gap: 0.25rem;
    }

    .btn-pdf-ctrl {
        padding: 0.35rem 0.45rem;
        font-size: 0.78rem;
        min-height: 36px;
    }

    .input-pdf-page {
        width: 38px;
        padding: 0.25rem 0.1rem;
        font-size: 0.8rem;
    }

    .pdf-page-display {
        font-size: 0.78rem;
        gap: 0.2rem;
    }

    .span-pdf-zoom-val {
        font-size: 0.78rem;
        min-width: 36px;
    }

    .pdf-reader-action-dock {
        padding: 0.6rem 0.75rem;
    }

    .pdf-dock-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.45rem;
    }

    .pdf-dock-actions a {
        width: 100%;
        text-align: center;
        justify-content: center;
        font-size: 0.78rem;
        padding: 0.45rem 0.4rem;
        white-space: nowrap;
    }

    .pdf-dock-title {
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 576px) {
    .beambe-pdf-reader-wrapper {
        height: 82vh;
        border-radius: 0.75rem;
    }

    .pdf-pages-viewport {
        padding: 0.25rem 0 !important;
    }

    .pdf-page-container {
        border-radius: 0;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
    }
}
