/* =====================================================
   Balto Flipbook Viewer – flipbook.css  v2
   ===================================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body.balto-flipbook-body {
    height: 100%;
    overflow: hidden;
    background: #1a1a2e;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #fff;
}

/* ── WRAPPER ── */
#balto-viewer-wrap {
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
}

/* ── TOP BAR ── */
#balto-topbar {
    display: flex;
    align-items: center;
    background: #0f0f23;
    border-bottom: 1px solid #2a2a4a;
    padding: 0 12px;
    height: 52px;
    gap: 12px;
    flex-shrink: 0;
    z-index: 100;
}

#balto-back {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #ccc;
    text-decoration: none;
    font-size: 13px;
    white-space: nowrap;
    transition: color .2s;
    flex-shrink: 0;
}
#balto-back:hover { color: #fff; }
#balto-back svg { width: 18px; height: 18px; fill: currentColor; }

#balto-title-bar {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    color: #e0e0e0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
    min-width: 0;
}

/* ── TOOLBAR ── */
#balto-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.balto-btn {
    background: transparent;
    border: 1px solid #3a3a5c;
    color: #ccc;
    border-radius: 6px;
    padding: 6px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s, border-color .15s;
    flex-shrink: 0;
}
.balto-btn:hover  { background: #2a2a4a; color: #fff; }
.balto-btn.active { background: #3d5af1; border-color: #3d5af1; color: #fff; }
.balto-btn svg    { width: 18px; height: 18px; fill: currentColor; pointer-events: none; }

/* Goto page */
#balto-goto-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #0f0f23;
    border: 1px solid #3a3a5c;
    border-radius: 6px;
    padding: 4px 8px;
}
#balto-goto-input {
    width: 44px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 13px;
    text-align: center;
    outline: none;
    -moz-appearance: textfield;
}
#balto-goto-input::-webkit-inner-spin-button,
#balto-goto-input::-webkit-outer-spin-button { display: none; }
#balto-total-pages { font-size: 12px; color: #888; white-space: nowrap; }

/* ── MAIN ── */
#balto-main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── SIDEBAR ── */
#balto-sidebar {
    width: 140px;
    background: #12122a;
    border-right: 1px solid #2a2a4a;
    overflow-y: auto;
    overflow-x: hidden;
    flex-shrink: 0;
    transition: width .25s ease;
    scrollbar-width: thin;
    scrollbar-color: #3a3a5c transparent;
}
#balto-sidebar.hidden { width: 0; border-right: none; }
#balto-sidebar::-webkit-scrollbar { width: 4px; }
#balto-sidebar::-webkit-scrollbar-thumb { background: #3a3a5c; border-radius: 2px; }

#balto-thumbnails-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 8px;
}

.balto-thumb-item {
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 4px;
    overflow: hidden;
    transition: border-color .15s;
    position: relative;
    background: #fff;
}
.balto-thumb-item:hover { border-color: #5570f3; }
.balto-thumb-item.active { border-color: #3d5af1; }
.balto-thumb-item canvas { width: 100% !important; height: auto !important; display: block; }
.balto-thumb-label {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: rgba(0,0,0,.55);
    font-size: 10px;
    text-align: center;
    padding: 2px 0;
    color: #ddd;
}

/* ── CANVAS AREA ── */
#balto-canvas-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding: 20px 0;
    user-select: none;
}

/* Cursor hints */
#balto-canvas-area { cursor: default; }

/* Nav buttons */
.balto-nav-btn {
    background: rgba(255,255,255,.07);
    border: none;
    color: #fff;
    font-size: 36px;
    line-height: 1;
    width: 48px;
    min-width: 48px;
    height: 80px;
    cursor: pointer;
    border-radius: 8px;
    transition: background .15s;
    flex-shrink: 0;
    z-index: 10;
}
.balto-nav-btn:hover    { background: rgba(255,255,255,.15); }
.balto-nav-btn:disabled { opacity: .2; cursor: default; }

/* Pages wrap – transform target for pan */
#balto-pages-wrap {
    display: flex;
    gap: 2px;
    align-items: stretch;
    justify-content: center;
    max-height: 100%;
    flex: 1;
    will-change: transform;
    /* Drop shadow between pages */
    filter: drop-shadow(0 8px 32px rgba(0,0,0,.65));
}

.balto-page-container {
    background: #fff;
    border-radius: 2px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity .15s;
    /* Gutter shadow to simulate book binding */
    position: relative;
}
/* Right page gets left inner shadow (binding) */
#page-right::before {
    content: '';
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 6px;
    background: linear-gradient(to right, rgba(0,0,0,.18), transparent);
    pointer-events: none;
    z-index: 1;
}
/* Left page gets right inner shadow */
#page-left::after {
    content: '';
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 6px;
    background: linear-gradient(to left, rgba(0,0,0,.18), transparent);
    pointer-events: none;
    z-index: 1;
}
.balto-page-container.empty {
    display: none;
}
.balto-page-container canvas { display: block; }

/* ── SHARE MODAL ── */
#balto-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.7);
    z-index: 200;
}
#balto-modal-overlay.hidden { display: none; }

#balto-share-modal {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%,-50%);
    background: #1e1e3a;
    border: 1px solid #3a3a5c;
    border-radius: 12px;
    padding: 28px 24px;
    width: 460px;
    max-width: 95vw;
    z-index: 201;
}
#balto-share-modal.hidden { display: none; }
#balto-share-modal h3 { margin-bottom: 16px; font-size: 16px; }

#balto-share-url-wrap { display: flex; gap: 8px; }
#balto-share-url {
    flex: 1;
    background: #0f0f23;
    border: 1px solid #3a3a5c;
    color: #e0e0e0;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 13px;
    outline: none;
}
#balto-copy-btn {
    background: #3d5af1; border: none; color: #fff;
    border-radius: 6px; padding: 8px 14px;
    cursor: pointer; font-size: 13px; white-space: nowrap;
}
#balto-copy-btn:hover { background: #5570f3; }
#balto-copy-confirm { margin-top: 10px; font-size: 13px; color: #7fff7f; }
#balto-copy-confirm.hidden { display: none; }
#balto-share-close {
    margin-top: 16px; background: transparent;
    border: 1px solid #3a3a5c; color: #ccc;
    border-radius: 6px; padding: 7px 16px;
    cursor: pointer; font-size: 13px;
}
#balto-share-close:hover { background: #2a2a4a; }

/* ── LOADING ── */
#balto-loading {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    background: #1a1a2e; z-index: 300;
    gap: 16px; font-size: 14px; color: #aaa;
}
.balto-spinner {
    width: 40px; height: 40px;
    border: 4px solid rgba(255,255,255,.1);
    border-top-color: #3d5af1;
    border-radius: 50%;
    animation: balto-spin .8s linear infinite;
}
@keyframes balto-spin { to { transform: rotate(360deg); } }

#balto-nopdf {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; color: #888;
}

/* ── FULLSCREEN ── */
:fullscreen  #balto-viewer-wrap { height: 100vh; }
:-webkit-full-screen #balto-viewer-wrap { height: 100vh; }

/* ── MOBILE ── */
@media (max-width: 640px) {
    #balto-title-bar { display: none; }
    #btn-single-page, #btn-double-page { display: none; }
    .balto-nav-btn { width: 36px; font-size: 26px; height: 60px; }
    #balto-goto-wrap { display: none; }
    #page-left { display: none; }  /* always single on mobile */
}
