@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ============================
   Viewer Global Styles
   ============================ */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; }
body { background: #0a0a14; color: #fff; }

/* ============================
   Top Bar
   ============================ */
.viewer-topbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    height: 52px;
    background: linear-gradient(180deg, rgba(10,10,20,0.95) 0%, rgba(10,10,20,0.85) 100%);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.topbar-left, .topbar-center, .topbar-right { display: flex; align-items: center; gap: 6px; }
.topbar-left { min-width: 180px; }
.topbar-right { min-width: 180px; justify-content: flex-end; }

.topbar-title {
    font-size: 0.88rem; font-weight: 600; opacity: 0.85; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; max-width: 200px; letter-spacing: -0.3px;
}

.topbar-btn {
    background: none; border: none; color: rgba(255,255,255,0.6); cursor: pointer;
    padding: 8px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s; text-decoration: none;
}
.topbar-btn svg { stroke-linecap: round; stroke-linejoin: round; }
.topbar-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.topbar-btn.active { background: rgba(74,144,217,0.2); color: #7cb8f0; }

.topbar-separator {
    width: 1px; height: 20px; background: rgba(255,255,255,0.08); margin: 0 2px;
}

/* Page indicator */
.page-indicator {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.82rem; color: rgba(255,255,255,0.5); font-weight: 500;
    background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.06);
    padding: 4px 8px; border-radius: 8px;
}

.page-indicator input {
    width: 36px; text-align: center;
    background: transparent; border: none;
    color: #fff; padding: 0; font-size: 0.88rem; font-weight: 700;
    font-family: inherit;
    -moz-appearance: textfield; outline: none;
}
.page-indicator input:focus { color: #7cb8f0; }
.page-indicator input::-webkit-outer-spin-button,
.page-indicator input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ============================
   Thumbnail Panel
   ============================ */
.thumbs-panel {
    position: fixed; top: 52px; left: 0; bottom: 0; width: 200px; z-index: 90;
    background: rgba(12,12,22,0.97); backdrop-filter: blur(12px);
    border-right: 1px solid rgba(255,255,255,0.06);
    transform: translateX(-100%); transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    overflow-y: auto; overscroll-behavior: contain;
}
.thumbs-panel::-webkit-scrollbar { width: 4px; }
.thumbs-panel::-webkit-scrollbar-track { background: transparent; }
.thumbs-panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.thumbs-panel.open { transform: translateX(0); }

.thumbs-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 12px; font-size: 0.78rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: rgba(255,255,255,0.4);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    position: sticky; top: 0; background: rgba(12,12,22,0.97); z-index: 1;
}

.thumbs-grid { padding: 10px; display: flex; flex-direction: column; gap: 8px; }

.thumb-item {
    cursor: pointer; border-radius: 8px; overflow: hidden;
    border: 2px solid transparent;
    transition: all 0.25s; position: relative;
    opacity: 0.7;
}
.thumb-item:hover { border-color: rgba(255,255,255,0.2); opacity: 1; }
.thumb-item.active { border-color: #4a90d9; opacity: 1; box-shadow: 0 0 16px rgba(74,144,217,0.25); }
.thumb-item img { width: 100%; display: block; }
.thumb-item .thumb-num {
    position: absolute; bottom: 6px; right: 6px;
    background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
    color: #fff; font-size: 0.68rem; font-weight: 700;
    padding: 2px 7px; border-radius: 4px;
}

/* ============================
   Main Viewer Area
   ============================ */
.viewer-main {
    position: fixed; top: 52px; left: 0; right: 0; bottom: 0;
    display: flex; align-items: center; justify-content: center;
    transition: left 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    background:
        radial-gradient(ellipse at 50% 50%, rgba(20,20,40,1) 0%, rgba(10,10,20,1) 70%);
}
.viewer-main.shifted { left: 200px; }

.flipbook-container {
    display: flex; align-items: center; justify-content: center;
    width: 100%; height: 100%; padding: 24px;
}

/* StPageFlip overrides */
.stf__parent { margin: 0 auto !important; }
.stf__wrapper {
    box-shadow:
        0 2px 8px rgba(0,0,0,0.3),
        0 10px 40px rgba(0,0,0,0.4),
        0 0 80px rgba(0,0,0,0.2) !important;
    border-radius: 4px !important;
}

.page-content {
    width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
    background: #fff; overflow: hidden; position: relative;
}
.page-content img {
    width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none;
}
.page-content.has-link { cursor: pointer; }
.page-link-icon {
    position: absolute; bottom: 10px; right: 10px;
    background: rgba(74,144,217,0.9); backdrop-filter: blur(4px);
    color: #fff; width: 30px; height: 30px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 14px;
    pointer-events: none; box-shadow: 0 2px 8px rgba(74,144,217,0.4);
}

/* ============================
   Navigation Arrows (floating)
   ============================ */
.nav-arrow {
    position: fixed; top: 50%; transform: translateY(-50%);
    z-index: 50; background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.3); cursor: pointer;
    width: 44px; height: 72px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.25s; backdrop-filter: blur(8px);
}
.nav-arrow:hover { background: rgba(255,255,255,0.08); color: #fff; border-color: rgba(255,255,255,0.12); }
.nav-arrow svg { stroke-linecap: round; stroke-linejoin: round; }
.nav-arrow-left { left: 12px; }
.nav-arrow-right { right: 12px; }

/* ============================
   Progress Bar
   ============================ */
.progress-bar-container {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 80;
    height: 3px; background: rgba(255,255,255,0.04);
}
.progress-bar-fill {
    height: 100%; background: linear-gradient(90deg, #4a90d9, #7c5ce0);
    transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    border-radius: 0 2px 2px 0;
}

/* ============================
   Loader
   ============================ */
.loader {
    text-align: center; color: rgba(255,255,255,0.5);
}
.loader p { font-size: 0.88rem; font-weight: 500; }
.spinner {
    width: 36px; height: 36px;
    border: 3px solid rgba(255,255,255,0.06);
    border-top-color: #4a90d9;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================
   Zoom overlay
   ============================ */
.zoom-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 200;
    background: rgba(5,5,10,0.95); display: none; cursor: zoom-out;
    overflow: auto; -webkit-overflow-scrolling: touch;
    backdrop-filter: blur(4px);
}
.zoom-overlay.active { display: flex; align-items: flex-start; justify-content: center; padding: 20px; }
.zoom-overlay img { max-width: none; width: 150%; cursor: zoom-out; }

.zoom-close {
    position: fixed; top: 16px; right: 16px; z-index: 210;
    background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15);
    color: #fff; width: 40px; height: 40px; border-radius: 10px;
    display: none; align-items: center; justify-content: center;
    cursor: pointer; transition: background 0.2s; backdrop-filter: blur(8px);
}
.zoom-close:hover { background: rgba(255,255,255,0.2); }
.zoom-overlay.active ~ .zoom-close { display: flex; }

/* ============================
   Toast
   ============================ */
.toast-msg {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(10px);
    background: rgba(30,30,50,0.95); backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.08);
    color: #fff; padding: 12px 24px; border-radius: 12px;
    font-size: 0.85rem; font-weight: 500;
    opacity: 0; pointer-events: none;
    transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1); z-index: 300;
    display: flex; align-items: center; gap: 8px;
}
.toast-msg svg { width: 16px; height: 16px; color: #4ade80; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.toast-msg.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================
   Responsive
   ============================ */
@media (max-width: 767px) {
    .viewer-topbar { height: 48px; padding: 0 10px; }
    .viewer-main { top: 48px; }
    .topbar-title { max-width: 90px; font-size: 0.82rem; }
    .topbar-left { min-width: auto; }
    .topbar-right { min-width: auto; }
    .thumbs-panel { width: 160px; top: 48px; }
    .viewer-main.shifted { left: 160px; }
    .flipbook-container { padding: 10px; }
    .topbar-center { gap: 2px; }
    .nav-arrow { display: none; }
    .topbar-separator { display: none; }
}

@media (max-width: 480px) {
    .topbar-title { display: none; }
    .topbar-right #btnShare { display: none; }
}
