* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ═══════════════════════════
   SHIMMER KEYFRAMES
═══════════════════════════ */
@keyframes spin {
    to {
        transform: rotate(360deg)
    }
}

@keyframes shimmer {
    0% {
        background-position: 200% 0
    }

    100% {
        background-position: -200% 0
    }
}

@keyframes shimmerD {
    0% {
        background-position: 200% 0
    }

    100% {
        background-position: -200% 0
    }
}

/* ═══════════════════════════
   E-PAPER GRID
═══════════════════════════ */
.epaper-section {
    background: #f5f4f0;
    padding: 5px 0 0 0;
    min-height: 75vh;
    font-family: 'DM Sans', sans-serif;
}

.thumb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 24px;
    padding-left: 10px;
}

.thumb-card {
    cursor: pointer;
    background: #fff;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #e3e2de;
    transition: transform .2s ease, box-shadow .2s ease;
    position: relative;
}

.thumb-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, .12);
}

.thumb-canvas-wrap {
    background: #eae9e5;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 240px;
    position: relative;
    overflow: hidden;
}

/* Thumbnail image — fills full card width */
.thumb-canvas-wrap img.pdf-thumb {
    display: none;
    width: 100%;
    height: auto;
    object-fit: cover;
    position: relative;
    z-index: 1;
}


/* ── Grid skeleton loader ── */
.thumb-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px;
    gap: 9px;
    background: #eae9e5;
    transition: opacity .35s;
}

.sk {
    border-radius: 4px;
    background: linear-gradient(90deg, #d4d1cb 25%, #e3e0d9 50%, #d4d1cb 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.sk-img {
    width: 100%;
    flex: 1;
    min-height: 150px;
}

.sk-line {
    width: 75%;
    height: 10px;
}

.sk-line.s {
    width: 48%;
}

.thumb-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
    z-index: 2;
}

.thumb-label {
    padding: 10px 12px;
    font-weight: 500;
    border-top: 1px solid #eee;
    background: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    font-size: 16px;
    background: #FFCC00;
    color: #000;

}

/* ═══════════════════════════
   FULL-SCREEN VIEWER
═══════════════════════════ */
#viewerSection {
    position: relative;
    width: 100%;
    min-height: 85vh;
    height: auto;
    background: #f1f3f5;
    display: flex;
    flex-direction: column;
    font-family: 'DM Sans', sans-serif;
    border: 1px solid #dee2e6;
}

/* ── Top bar ── */
.viewer-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 52px;
    background: #ffffff;
    border-bottom: 1px solid #dee2e6;
    flex-shrink: 0;
    gap: 12px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.topbar-center {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    justify-content: center;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.topbar-title {
    font-size: 13px;
    color: #495057;
    font-weight: 500;
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tb-btn {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    color: #495057;
    border-radius: 5px;
    padding: 5px 10px;
    font-size: 12px;
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background .15s, color .15s;
    white-space: nowrap;
    text-decoration: none;
}

.tb-btn:hover {
    background: #e9ecef;
    color: #212529;
}

.tb-btn.icon-only {
    padding: 6px 8px;
}

.tb-btn svg {
    flex-shrink: 0;
}

.tb-text {
    font-size: 13px;
    color: #495057;
    font-weight: 500;
}

.page-counter {
    font-size: 12px;
    color: #495057;
    min-width: 80px;
    text-align: center;
}

/* ── Viewer body ── */
.viewer-body {
    display: flex;
    flex: 1;
    overflow: visible;
}

/* ── Sidebar ── */
.sidebar {
    width: 160px;
    flex-shrink: 0;
    background: #f8f9fa;
    border-right: 1px solid #dee2e6;
    overflow-y: auto;
    padding: 12px 8px;
    display: none; /* hidden by default */
    flex-direction: column;
    gap: 8px;
    scrollbar-width: thin;
    scrollbar-color: #adb5bd transparent;
}

.sidebar::-webkit-scrollbar {
    width: 4px
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .12);
    border-radius: 4px
}

.sidebar-thumb {
    cursor: pointer;
    border-radius: 4px;
    overflow: hidden;
    border: 1.5px solid #dee2e6;
    transition: border-color .15s;
    position: relative;
    min-height: 90px;
    background: #ffffff;
}

.sidebar-thumb:hover {
    border-color: #adb5bd;
}

.sidebar-thumb.active {
    border-color: #5b8aff;
}

.sidebar-thumb canvas {
    display: block;
    width: 100%;
}

/* Sidebar skeleton */
.sidebar-sk {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, #e9ecef 25%, #f8f9fa 50%, #e9ecef 75%);
    background-size: 200% 100%;
    animation: shimmerD 1.5s infinite;
}

.sidebar-page-num {
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, .9);
    color: #212529;
    border: 1px solid #dee2e6;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
    z-index: 2;
    white-space: nowrap;
}

/* ── Stage ── */
.stage {
    flex: 1;
    overflow: visible;
    display: flex;
    align-items: flex-start;
    padding: 0;
    position: relative;
}

.stage::-webkit-scrollbar {
    width: 6px
}

.stage::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .08);
    border-radius: 4px
}

/* ── Vertical paginated view ── */
#singlePageWrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 100%;
}

#singlePageWrap canvas {
    border-radius: 4px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .1);
    display: block;
    max-width: none;
    flex-shrink: 0;
}

/* Page placeholder skeleton */
.page-ph {
    border-radius: 4px;
    background: linear-gradient(90deg, #222225 25%, #2d2d31 50%, #222225 75%);
    background-size: 200% 100%;
    animation: shimmerD 1.5s infinite;
    width: 600px;
    max-width: 90vw;
    flex-shrink: 0;
}

/* ── Loading overlay ── */
#viewerLoading {
    position: absolute;
    inset: 0;
    background: #f1f3f5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: #495057;
    font-size: 13px;
    z-index: 5;
}

.big-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 0, 0, .1);
    border-top-color: #0d6efd;
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

#progressBar {
    width: 200px;
    height: 3px;
    background: rgba(255, 255, 255, .08);
    border-radius: 2px;
    overflow: hidden;
}

#progressFill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #5b8aff, #a78bfa);
    border-radius: 2px;
    transition: width .25s;
}

/* ── Footer ── */
.viewer-footer {
    height: 32px;
    background: #111113;
    border-top: 1px solid rgba(255, 255, 255, .07);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: rgba(255, 255, 255, .25);
    flex-shrink: 0;
    letter-spacing: .04em;
}

#sidebarToggle {
    display: none;
}

/* shown via media query on mobile */

/* ── Responsive ── */
/* ==========================================================================
   WhatsApp Style Viewer Layout
   ========================================================================== */

.wa-floating-bar {
    position: fixed;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    border-radius: 30px;
    padding: 15px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    z-index: 1050;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.wa-floating-bar .page-indicator {
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 5px;
    white-space: nowrap;
}

.wa-floating-bar .wa-btn {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 1.2rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
    outline: none;
}

.wa-floating-bar .wa-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.wa-floating-bar .wa-divider {
    width: 70%;
    height: 1px;
    background: rgba(255, 255, 255, 0.2);
    margin: 5px 0;
}

/* Mobile Fixed Footer */
@media (max-width: 768px) {
    .epaper-section {
        padding-top: 0 !important;
    }

    .wa-floating-bar {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        width: 100%;
        transform: none !important;
        flex-direction: row;
        border-radius: 0;
        justify-content: space-around;
        padding: 10px 20px;
        border-top: 1px solid #e9edef;
        box-shadow: 0 -5px 15px rgba(0,0,0,0.1);
        z-index: 1050 !important;
        background: #ffffff;
    }
    
    .wa-floating-bar .page-indicator {
        color: #54656f;
    }

    .wa-floating-bar .wa-btn {
        width: 45px;
        height: 45px;
        font-size: 1.4rem;
        color: #54656f;
    }

    .wa-floating-bar .wa-btn:hover {
        background: #f0f2f5;
        color: #111b21;
    }
    
    .wa-floating-bar .wa-divider {
        width: 1px;
        height: 30px;
        margin: 0 5px;
        background: #e9edef;
    }
}