/**
 * E-Majalah (Flipbook) Viewer Stylesheet
 * Desain bergaya pembaca majalah digital interaktif Polri (Korbrimob / Tribratanews)
 */

.emagazine-wrapper {
    position: relative;
    width: 100%;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #e6edf3;
    user-select: none;
    -webkit-user-select: none;
}

.emagazine-container {
    position: relative;
    width: 100%;
    min-height: 650px;
    background: #0f1217;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    transition: all 0.25s ease;
}

/* Fullscreen Mode */
.emagazine-container.is-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    z-index: 999999 !important;
    margin: 0 !important;
}

/* TOP TOOLBAR */
.emagazine-topbar {
    height: 58px;
    background: #161a22;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 60;
    flex-shrink: 0;
    position: relative;
}

.emagazine-topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.emagazine-home-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, transform 0.15s;
    flex-shrink: 0;
}

.emagazine-home-btn:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
    transform: scale(1.05);
}

.emagazine-title-box {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.emagazine-doc-title {
    font-size: 13.5px;
    font-weight: 700;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 320px;
    line-height: 1.25;
}

.emagazine-doc-subtitle {
    font-size: 11px;
    color: #8b949e;
    margin-top: 2px;
}

.emagazine-topbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* Mode Switcher Pill */
.emagazine-mode-pill {
    display: inline-flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 3px;
    margin-right: 6px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.emagazine-mode-btn {
    background: transparent;
    border: none;
    color: #8b949e;
    font-size: 11.5px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.emagazine-mode-btn:hover {
    color: #ffffff;
}

.emagazine-mode-btn.active {
    background: #be0106;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(190, 1, 6, 0.4);
}

/* Tool Buttons */
.emagazine-tool-btn {
    height: 36px;
    min-width: 36px;
    padding: 0 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    color: #c9d1d9;
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12.5px;
    transition: all 0.18s;
    text-decoration: none;
    gap: 5px;
}

.emagazine-tool-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.18);
}

.emagazine-tool-btn.active {
    background: rgba(190, 1, 6, 0.3);
    color: #ff6b6b;
    border-color: rgba(190, 1, 6, 0.5);
}

.emagazine-zoom-indicator {
    font-size: 11.5px;
    font-weight: 600;
    color: #c9d1d9;
    min-width: 44px;
    text-align: center;
    padding: 4px 6px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.emagazine-zoom-indicator:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

/* MAIN STAGE / VIEWPORT */
.emagazine-stage {
    position: relative;
    flex: 1 1 auto;
    width: 100%;
    min-height: 560px;
    background: radial-gradient(circle at center, #181d26 0%, #0c0e13 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 24px 60px;
    box-sizing: border-box;
    cursor: default;
}

.emagazine-container.is-fullscreen .emagazine-stage {
    min-height: calc(100vh - 106px);
    padding: 16px 60px;
}

/* Ketika di-zoom: kursor menjadi grab untuk panning */
.emagazine-stage.is-zoomed {
    cursor: grab;
}

.emagazine-stage.is-zoomed.is-panning {
    cursor: grabbing;
}

/* Centered Book Stage */
.emagazine-book-stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.18s cubic-bezier(0.2, 0, 0, 1);
    transform-origin: center center;
    will-change: transform;
}

/* Nonaktifkan transisi saat sedang di-drag/pan agar responsif */
.emagazine-stage.is-panning .emagazine-book-stage {
    transition: none !important;
}

.emagazine-book {
    margin: 0 auto;
    box-shadow: 0 15px 45px rgba(0, 0, 0, 0.65), 0 2px 10px rgba(0, 0, 0, 0.4);
    background: #ffffff;
}

/* Page inner styles */
.emagazine-page {
    background-color: #ffffff;
    box-sizing: border-box;
    overflow: hidden;
    position: relative;
}

.emagazine-page-inner {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.emagazine-canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    background-color: #ffffff;
}

/* Center spine shadow (lipatan tengah buku) */
.emagazine-page.--left .emagazine-page-inner::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 28px;
    background: linear-gradient(to left, rgba(0, 0, 0, 0.18), transparent);
    pointer-events: none;
    z-index: 5;
}

.emagazine-page.--right .emagazine-page-inner::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 28px;
    background: linear-gradient(to right, rgba(0, 0, 0, 0.18), transparent);
    pointer-events: none;
    z-index: 5;
}

/* Floating Navigation Arrows (Selalu Fixed di Pinggir & di Atas Zoom) */
.emagazine-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 56px;
    background: #ffffff;
    color: #111418;
    border: none;
    border-radius: 6px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    z-index: 50;
    transition: all 0.2s;
    opacity: 0.92;
}

.emagazine-nav-btn:hover {
    background: #ffffff;
    color: #be0106;
    transform: translateY(-50%) scale(1.08);
    opacity: 1;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6);
}

.emagazine-nav-btn:disabled,
.emagazine-nav-btn.disabled {
    opacity: 0.2;
    cursor: not-allowed;
    pointer-events: none;
}

.emagazine-nav-prev {
    left: 14px;
}

.emagazine-nav-next {
    right: 14px;
}

/* Hint Banner ketika Zoom > 100% */
.emagazine-zoom-hint {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(22, 26, 34, 0.92);
    color: #c9d1d9;
    font-size: 11.5px;
    padding: 5px 14px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    z-index: 45;
    display: none;
    align-items: center;
    gap: 6px;
    animation: emagazine-fadein 0.3s ease;
}

@keyframes emagazine-fadein {
    from { opacity: 0; transform: translate(-50%, -6px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* Loading Overlay */
.emagazine-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 18, 23, 0.92);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 55;
    transition: opacity 0.3s ease;
}

.emagazine-loading-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

.emagazine-spinner {
    width: 46px;
    height: 46px;
    border: 3.5px solid rgba(255, 255, 255, 0.15);
    border-top-color: #be0106;
    border-radius: 50%;
    animation: emagazine-spin 0.8s linear infinite;
    margin-bottom: 12px;
}

.emagazine-loading-percent {
    font-size: 26px;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    font-variant-numeric: tabular-nums;
}

.emagazine-loading-text {
    font-size: 13.5px;
    color: #c9d1d9;
    font-weight: 500;
    text-align: center;
    max-width: 80%;
}

.emagazine-loading-subtext {
    font-size: 11.5px;
    color: #8b949e;
    margin-top: 6px;
    text-align: center;
}

.emagazine-loading-bar {
    width: 180px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    margin-top: 12px;
    overflow: hidden;
}

.emagazine-loading-progress {
    width: 0%;
    height: 100%;
    background: #be0106;
    transition: width 0.25s ease;
}

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

/* Page Loader Placeholder */
.emagazine-page-loader {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    color: #6c757d;
    font-size: 12px;
    gap: 8px;
    z-index: 2;
}

.emagazine-page-loader .spinner-border {
    width: 24px;
    height: 24px;
    border-width: 2.5px;
}

/* BOTTOM TOOLBAR */
.emagazine-bottombar {
    height: 48px;
    background: #161a22;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    z-index: 60;
    flex-shrink: 0;
    position: relative;
}

.emagazine-page-badge {
    font-size: 12px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.5px;
    min-width: 80px;
}

.emagazine-slider-container {
    flex: 1 1 auto;
    max-width: 500px;
    margin: 0 20px;
    display: flex;
    align-items: center;
}

.emagazine-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 5px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.15);
    outline: none;
    cursor: pointer;
    transition: background 0.2s;
}

.emagazine-slider:hover {
    background: rgba(255, 255, 255, 0.25);
}

.emagazine-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #ffffff;
    border: 2.5px solid #be0106;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    transition: transform 0.15s;
}

.emagazine-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.emagazine-slider::-moz-range-thumb {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #ffffff;
    border: 2.5px solid #be0106;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.emagazine-bottombar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.emagazine-quick-btn {
    background: transparent;
    border: none;
    color: #8b949e;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    padding: 3px 6px;
    border-radius: 4px;
    transition: color 0.15s;
}

.emagazine-quick-btn:hover {
    color: #ffffff;
}

.emagazine-percent-badge {
    font-size: 12px;
    font-weight: 600;
    color: #8b949e;
    min-width: 38px;
    text-align: right;
}

/* THUMBNAILS DRAWER */
.emagazine-thumbs-drawer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 48px;
    background: rgba(22, 26, 34, 0.96);
    backdrop-filter: blur(12px);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    padding: 16px 20px;
    z-index: 55;
    max-height: 220px;
    overflow-x: auto;
    overflow-y: hidden;
    display: flex;
    gap: 14px;
    transform: translateY(110%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.28s cubic-bezier(0.2, 0, 0, 1), opacity 0.25s ease;
}

.emagazine-thumbs-drawer.is-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.emagazine-thumb-card {
    flex: 0 0 100px;
    height: 155px;
    background: #0d1017;
    border-radius: 8px;
    border: 1.5px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.2s;
    position: relative;
}

.emagazine-thumb-card:hover {
    border-color: #be0106;
    transform: translateY(-4px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

.emagazine-thumb-card.active {
    border-color: #be0106;
    box-shadow: 0 0 0 2px rgba(190, 1, 6, 0.4);
}

.emagazine-thumb-preview {
    width: 100%;
    flex: 1 1 auto;
    object-fit: cover;
    background: #ffffff;
    display: block;
}

.emagazine-thumb-number {
    width: 100%;
    height: 24px;
    line-height: 24px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    background: #161a22;
    color: #c9d1d9;
}

.emagazine-thumb-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border: none;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 60;
}

.emagazine-thumb-close:hover {
    background: #be0106;
}

/* GOOGLE DRIVE EMBED VIEW */
.emagazine-view-gdrive {
    width: 100%;
    min-height: 650px;
    display: none;
    background: #ffffff;
}

.emagazine-view-gdrive.is-active {
    display: block;
}

.emagazine-view-flip.is-hidden {
    display: none !important;
}

/* RESPONSIVE DESIGN */
@media (max-width: 768px) {
    .emagazine-container {
        min-height: 520px;
        border-radius: 10px;
    }

    .emagazine-topbar {
        padding: 0 10px;
        height: 52px;
    }

    .emagazine-doc-title {
        max-width: 160px;
        font-size: 12px;
    }

    .emagazine-doc-subtitle {
        display: none;
    }

    .emagazine-stage {
        padding: 10px 10px;
        min-height: 420px;
    }

    .emagazine-nav-btn {
        width: 36px;
        height: 44px;
        font-size: 15px;
    }

    .emagazine-nav-prev {
        left: 6px;
    }

    .emagazine-nav-next {
        right: 6px;
    }

    .emagazine-slider-container {
        margin: 0 10px;
    }

    .emagazine-zoom-indicator,
    .emagazine-quick-btn {
        display: none;
    }
}
