/* WBLBR FlipBook - Flipbook Viewer with Page Flip */
:root {
    --fb-bg: #2d2d2d;
    --fb-toolbar: #1a1a1a;
    --fb-text: #e0e0e0;
    --fb-accent: #4a9eff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--fb-bg); color: var(--fb-text); }

#flipbook-app { display: flex; flex-direction: column; height: 100vh; }

/* Header */
.flipbook-header {
    display: flex; align-items: center; gap: 1rem; padding: .5rem 1rem;
    background: var(--fb-toolbar); min-height: 48px; z-index: 10;
}
.flipbook-back { color: var(--fb-text); display: flex; align-items: center; text-decoration: none; }
.flipbook-logo { max-height: 28px; margin-right: .25rem; }
.flipbook-header h1 { font-size: 1rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flipbook-page-info { margin-left: auto; font-size: .85rem; white-space: nowrap; color: #999; }

/* Container */
.flipbook-container {
    flex: 1; display: flex; align-items: center; justify-content: center;
    position: relative; overflow: hidden; padding: 10px 0;
}

/* Nav buttons */
.flipbook-nav {
    position: absolute; top: 50%; transform: translateY(-50%); z-index: 20;
    background: rgba(0,0,0,.4); border: none; color: #fff; cursor: pointer;
    width: 48px; height: 80px; display: flex; align-items: center; justify-content: center;
    border-radius: 4px; transition: background .2s;
}
.flipbook-nav:hover { background: rgba(0,0,0,.7); }
.flipbook-nav:disabled { opacity: .3; cursor: default; }
.flipbook-nav-prev { left: 8px; }
.flipbook-nav-next { right: 8px; }

/* Viewport */
#flipbook-viewport {
    display: flex; align-items: center; justify-content: center;
    width: 100%; height: 100%;
    transition: transform .2s ease;
    transform-origin: center center;
}

/* Book container */
#flipbook-book {
    position: relative;
    margin: 0 auto;
}

/* Page styling */
.flipbook-page {
    position: relative;
    background: #fff;
    overflow: hidden;
}
.flipbook-page img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
}

/* Hotspot overlay per page */
.hotspot-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: 5;
}
.hotspot-area {
    position: absolute; cursor: pointer; pointer-events: all;
    border: 2px solid rgba(74, 158, 255, .4);
    background: rgba(74, 158, 255, .06);
    border-radius: 3px; transition: all .2s;
}
.hotspot-area:hover {
    background: rgba(74, 158, 255, .2);
    border-color: rgba(74, 158, 255, .8);
}
.hotspot-area .hotspot-tooltip {
    display: none; position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
    background: #333; color: #fff; padding: .3rem .6rem; border-radius: 4px;
    font-size: .75rem; white-space: nowrap; z-index: 10;
    pointer-events: none;
}
.hotspot-area:hover .hotspot-tooltip { display: block; }

/* Loading */
.flipbook-loading {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    text-align: center; z-index: 30;
    background: rgba(30,30,30,.9); padding: 2rem 3rem; border-radius: 8px;
}
.spinner {
    width: 40px; height: 40px; border: 3px solid rgba(255,255,255,.2);
    border-top-color: var(--fb-accent); border-radius: 50%;
    animation: spin .8s linear infinite; margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-progress { color: #888; font-size: .8rem; margin-top: .5rem; }

/* Toolbar */
.flipbook-toolbar {
    display: flex; align-items: center; justify-content: center; gap: .25rem;
    padding: .5rem 1rem; background: var(--fb-toolbar); z-index: 10;
}
.toolbar-btn {
    background: transparent; border: 1px solid rgba(255,255,255,.15); color: var(--fb-text);
    width: 36px; height: 36px; border-radius: 4px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: 1rem;
}
.toolbar-btn:hover { background: rgba(255,255,255,.1); }
.toolbar-sep { width: 1px; height: 24px; background: rgba(255,255,255,.15); margin: 0 .5rem; }
.page-input {
    width: 50px; text-align: center; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2);
    color: var(--fb-text); border-radius: 4px; padding: .3rem; font-size: .85rem;
}
.page-input:focus { outline: none; border-color: var(--fb-accent); }

/* Mute button */
.toolbar-btn.muted { color: #666; }
.toolbar-btn.muted svg { opacity: .4; }

/* StPageFlip overrides - book shadow */
.stf__parent { margin: 0 auto; position: relative; }
.stf__wrapper {
    box-shadow: 0 8px 40px rgba(0,0,0,.6) !important;
}

/* Book spine / center fold effect */
.book-spine {
    position: absolute;
    top: 0; left: 50%; transform: translateX(-50%);
    width: 36px; height: 100%;
    pointer-events: none;
    z-index: 10;
    transition: opacity .25s ease;
    background: linear-gradient(to right,
        rgba(0,0,0,0) 0%,
        rgba(0,0,0,.08) 15%,
        rgba(0,0,0,.18) 35%,
        rgba(0,0,0,.25) 46%,
        rgba(255,255,255,.08) 49%,
        rgba(255,255,255,.15) 50%,
        rgba(255,255,255,.08) 51%,
        rgba(0,0,0,.25) 54%,
        rgba(0,0,0,.18) 65%,
        rgba(0,0,0,.08) 85%,
        rgba(0,0,0,0) 100%
    );
}

/* Page inner shadow (left page right edge, right page left edge) */
.stf__wrapper .stf__item:nth-child(even)::after,
.stf__wrapper .stf__item:nth-child(odd)::after {
    content: '';
    position: absolute;
    top: 0; width: 20px; height: 100%;
    pointer-events: none;
    z-index: 5;
}
/* Right edge of left page */
.stf__wrapper .stf__item:nth-child(even)::after {
    right: 0;
    background: linear-gradient(to left, rgba(0,0,0,.06) 0%, rgba(0,0,0,0) 100%);
}
/* Left edge of right page */
.stf__wrapper .stf__item:nth-child(odd)::after {
    left: 0;
    background: linear-gradient(to right, rgba(0,0,0,.06) 0%, rgba(0,0,0,0) 100%);
}

/* Share/Embed Modal */
.modal-overlay {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(0,0,0,.7); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
    background: #1e1e1e; border: 1px solid #333; border-radius: 10px;
    width: 90%; max-width: 520px; max-height: 90vh; overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem 1.25rem; border-bottom: 1px solid #333;
}
.modal-header h2 { font-size: 1rem; color: #e0e0e0; font-weight: 600; }
.modal-close {
    background: none; border: none; color: #888; font-size: 1.5rem;
    cursor: pointer; padding: 0 .25rem; line-height: 1;
}
.modal-close:hover { color: #fff; }
.modal-body { padding: 1.25rem; }

.share-section { margin-bottom: 1.25rem; }
.share-section:last-child { margin-bottom: 0; }
.share-section h3 { font-size: .8rem; color: #999; text-transform: uppercase; letter-spacing: .04em; margin-bottom: .5rem; }

.share-input-group { display: flex; gap: .4rem; }
.share-input {
    flex: 1; background: #111; border: 1px solid #333; border-radius: 6px;
    color: #ccc; padding: .5rem .7rem; font-size: .82rem; font-family: monospace;
    outline: none; resize: none;
}
.share-input:focus { border-color: #4a9eff; }
.share-textarea { height: 60px; font-size: .78rem; }
.share-copy-btn {
    background: #333; border: 1px solid #444; border-radius: 6px;
    color: #ddd; padding: .5rem .75rem; font-size: .8rem; cursor: pointer;
    white-space: nowrap; transition: all .15s;
}
.share-copy-btn:hover { background: #444; }
.share-copy-btn.copied { background: #10b981; border-color: #10b981; color: #fff; }
.share-hint { font-size: .75rem; color: #666; margin-top: .35rem; }

.share-buttons { display: flex; gap: .5rem; flex-wrap: wrap; }
.share-btn {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .5rem .9rem; border-radius: 6px; font-size: .82rem;
    text-decoration: none; cursor: pointer; border: 1px solid #333;
    background: #282828; color: #ddd; transition: all .15s;
}
.share-btn:hover { background: #353535; border-color: #555; }
.share-email { color: #93c5fd; }
.share-whatsapp { color: #4ade80; }

/* Pages Panel */
#flipbook-app { position: relative; }
.pages-panel {
    position: absolute; top: 0; left: -320px; width: 300px; height: 100%;
    background: rgba(20,20,20,.92);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    z-index: 50; transition: left .3s cubic-bezier(.16,1,.3,1);
    display: flex; flex-direction: column;
    box-shadow: 4px 0 24px rgba(0,0,0,.4);
}
.pages-panel.open { left: 0; }
.pages-panel-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: .75rem 1rem; border-bottom: 1px solid rgba(255,255,255,.08);
}
.pages-panel-header h3 { font-size: .85rem; color: #e0e0e0; font-weight: 600; }
.pages-panel-close {
    background: none; border: none; color: #888; font-size: 1.3rem;
    cursor: pointer; padding: 0 .2rem; line-height: 1;
}
.pages-panel-close:hover { color: #fff; }
.pages-panel-grid {
    flex: 1; overflow-y: auto; padding: .75rem;
    display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem;
    align-content: start;
}
.pages-panel-grid::-webkit-scrollbar { width: 4px; }
.pages-panel-grid::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px; }
.page-thumb {
    cursor: pointer; border-radius: 4px; overflow: hidden;
    border: 2px solid transparent; transition: all .2s;
    position: relative;
}
.page-thumb:hover { border-color: rgba(74,158,255,.5); }
.page-thumb.active { border-color: #4a9eff; }
.page-thumb img {
    width: 100%; display: block; background: #fff;
    aspect-ratio: 210/297; object-fit: cover;
}
.page-thumb-num {
    position: absolute; bottom: 2px; right: 3px;
    font-size: .55rem; color: #fff; background: rgba(0,0,0,.6);
    padding: .05rem .25rem; border-radius: 3px; font-weight: 600;
}
.page-thumb-placeholder {
    width: 100%; aspect-ratio: 210/297; background: #333;
    display: flex; align-items: center; justify-content: center;
    color: #666; font-size: .65rem;
}

/* Responsive */
@media (max-width: 768px) {
    .flipbook-nav { width: 36px; height: 60px; }
    .flipbook-header h1 { font-size: .9rem; }
    .flipbook-toolbar { gap: .15rem; padding: .4rem .5rem; }
    .toolbar-btn { width: 32px; height: 32px; }
    .modal { width: 95%; }
}
