/* Stage Container Setup */
.kbt-issuu-stage {
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px 10px;
    position: relative;
    margin-bottom: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
    user-select: none;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.kbt-stage-viewport {
    width: 100%;
    height: 640px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

#kbt-flipbook-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: relative;
}

#kbt-flipbook-container {
    margin: 0 auto !important;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.5s cubic-bezier(0.25, 1, 0.5, 1);
    transform-origin: center center;
}

/* Defensive centering for StPageFlip's own internal wrapper element,
   regardless of whether it is showing a spread or a single page */
#kbt-flipbook-container .stf__parent,
#kbt-flipbook-container .stf__wrapper {
    margin: 0 auto !important;
}

/* DESKTOP UNFURL EFFECT ON LOAD */
@media screen and (min-width: 769px) {
    #kbt-flipbook-container {
        transform: scale(0.98);
        animation: kbtUnfurl 0.4s ease forwards;
    }
}

@keyframes kbtUnfurl {
    from { transform: scale(0.94); opacity: 0.6; }
    to { transform: scale(1); opacity: 1; }
}

.kbt-page-item {
    background-color: #ffffff;
    box-shadow: 0 4px 14px rgba(0,0,0,0.12);
    overflow: hidden;
}

.kbt-page-item canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
    object-fit: contain;
}

/* =========================================================
   SINGLE-PAGE PDF MODE (no book mechanics — just centered)
   ========================================================= */
.kbt-single-page-mode #kbt-flipbook-container {
    width: auto !important;
}

.kbt-single-page-mode .kbt-page-item {
    margin: 0 auto;
}

/* =========================================================
   MOBILE: real StPageFlip single-page spread, centered by
   the flex rules on #kbt-flipbook-wrapper / -container above.
   ========================================================= */
@media screen and (max-width: 768px) {
    .kbt-issuu-stage {
        padding: 10px 5px;
    }

    .kbt-stage-viewport {
        height: 380px;
    }

    .kbt-nav-btn {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }

    #kbt-btn-prev { left: 5px; }
    #kbt-btn-next { right: 5px; }
}

/* Navigation Controls */
.kbt-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 50;
    background: rgba(255, 255, 255, 0.9);
    color: #222222;
    border: 1px solid rgba(0, 0, 0, 0.15);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    font-size: 22px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

.kbt-nav-btn:hover { 
    background: #ffffff; 
    color: #000000;
}

#kbt-btn-prev { left: 10px; }
#kbt-btn-next { right: 10px; }

/* Fullscreen Toggle Button */
.kbt-fullscreen-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 60;
    background: rgba(255, 255, 255, 0.9);
    color: #222222;
    border: 1px solid rgba(0, 0, 0, 0.15);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
    transition: all 0.2s ease;
}

.kbt-fullscreen-btn:hover {
    background: #ffffff;
}

.kbt-fullscreen-btn svg {
    width: 18px;
    height: 18px;
}

/* Fullscreen Mode */
.kbt-issuu-stage:fullscreen,
.kbt-issuu-stage:-webkit-full-screen,
.kbt-issuu-stage:-ms-fullscreen {
    width: 100vw;
    height: 100vh;
    max-width: none;
    border-radius: 0;
    background: #1a1a1a;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 20px 10px;
}

.kbt-issuu-stage:fullscreen .kbt-stage-viewport,
.kbt-issuu-stage:-webkit-full-screen .kbt-stage-viewport,
.kbt-issuu-stage:-ms-fullscreen .kbt-stage-viewport {
    height: calc(100vh - 90px);
}

.kbt-issuu-stage:fullscreen .kbt-bottom-bar,
.kbt-issuu-stage:-webkit-full-screen .kbt-bottom-bar,
.kbt-issuu-stage:-ms-fullscreen .kbt-bottom-bar {
    color: #dddddd;
    border-top-color: rgba(255,255,255,0.15);
}

.kbt-issuu-stage:fullscreen .kbt-download-btn,
.kbt-issuu-stage:-webkit-full-screen .kbt-download-btn,
.kbt-issuu-stage:-ms-fullscreen .kbt-download-btn {
    color: #ffffff;
}

.kbt-bottom-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 12px;
    margin-top: 10px;
    border-top: 1px solid #e0e0e0;
    color: #555555;
    font-size: 13px;
    font-family: sans-serif;
}

.kbt-download-btn {
    color: #333333;
    text-decoration: none;
    font-weight: 600;
}

/* Loading Overlay */
#kbt-status-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(245, 245, 245, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #222222;
    font-size: 13px;
    font-family: sans-serif;
    letter-spacing: 1px;
    font-weight: 600;
    z-index: 100;
    backdrop-filter: blur(2px);
    border-radius: 8px;
}

/* Switcher Thumbnails */
.kbt-pdf-switcher {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.kbt-pdf-thumb-card {
    cursor: pointer;
    border: 2px solid #e2e2e2;
    border-radius: 6px;
    padding: 3px;
    background: #ffffff;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100px;
    height: 130px;
    flex-shrink: 0;
    user-select: none;
}

.kbt-pdf-thumb-card.active {
    border-color: #000000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.kbt-thumb-canvas-box {
    width: 100%;
    height: 100%;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kbt-thumb-canvas-box canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}