/* ==========================================================================
   FOCAPLAY LEITOR DIGITAL 2.0 — ESTILO KINDLE / APPLE BOOKS / BIBLIOTECA
   Paleta Oficial: Midnight #09090F, Electric Purple #7628F5, Neon Violet #C34AFF,
   Cloud White #F5F2FF, Fresh Mint #21E6B5, Dark Surface #242331
   ========================================================================== */

/* Container Principal do Leitor */
.fpb-reader {
    --fpb-bg: #0c0c14;
    --fpb-surface: #171624;
    --fpb-surface-2: #222134;
    --fpb-border: rgba(255, 255, 255, 0.1);
    --fpb-text: #f5f2ff;
    --fpb-muted: rgba(245, 242, 255, 0.65);
    --fpb-accent: #7628f5;
    --fpb-accent-2: #c34aff;
    --fpb-mint: #21e6b5;
    --fpb-canvas-filter: invert(0.9) hue-rotate(180deg) brightness(0.95) contrast(0.93);
    --fpb-page-shadow: 0 20px 55px rgba(0, 0, 0, 0.72);

    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 82vh;
    min-height: 580px;
    max-height: 920px;
    background: var(--fpb-bg);
    color: var(--fpb-text);
    border: 1px solid var(--fpb-border);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    user-select: none;
    -webkit-user-select: none;
}

.fpb-reader * {
    box-sizing: border-box;
}

/* Temas de Leitura (Noturno, Sépia, Claro) */
.fpb-reader.fpb-theme-dark {
    --fpb-bg: #0b0b12;
    --fpb-surface: #151422;
    --fpb-surface-2: #212033;
    --fpb-border: rgba(255, 255, 255, 0.1);
    --fpb-text: #f5f2ff;
    --fpb-muted: rgba(245, 242, 255, 0.65);
    --fpb-canvas-filter: invert(0.9) hue-rotate(180deg) brightness(0.95) contrast(0.93);
}

.fpb-reader.fpb-theme-sepia {
    --fpb-bg: #e7dcc4;
    --fpb-surface: #f4ecd8;
    --fpb-surface-2: #e6d9be;
    --fpb-border: rgba(91, 70, 54, 0.18);
    --fpb-text: #3a2d21;
    --fpb-muted: rgba(58, 45, 33, 0.68);
    --fpb-canvas-filter: sepia(0.32) contrast(0.96) brightness(0.98);
    --fpb-page-shadow: 0 18px 45px rgba(74, 56, 36, 0.24);
}

.fpb-reader.fpb-theme-light {
    --fpb-bg: #e9ecf2;
    --fpb-surface: #ffffff;
    --fpb-surface-2: #f1f3f8;
    --fpb-border: rgba(15, 23, 42, 0.12);
    --fpb-text: #111827;
    --fpb-muted: rgba(17, 24, 39, 0.62);
    --fpb-canvas-filter: none;
    --fpb-page-shadow: 0 16px 42px rgba(15, 23, 42, 0.16);
}

/* Modo Imersivo (Full-Window / Fullscreen universal — funciona em iPhone, Android e PC) */
.fpb-reader.fpb-is-immersive,
.fpb-reader:fullscreen {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: none !important;
    min-height: 0 !important;
    border-radius: 0 !important;
    border: 0 !important;
    z-index: 9999999 !important;
}

body.fpb-immersive-open {
    overflow: hidden !important;
}

/* Barra Superior do Leitor */
.fpb-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    background: var(--fpb-surface);
    border-bottom: 1px solid var(--fpb-border);
    z-index: 20;
    flex-shrink: 0;
}

.fpb-topbar-left,
.fpb-topbar-center,
.fpb-topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.fpb-topbar-left {
    min-width: 0;
    flex: 1;
}

.fpb-title-block {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.fpb-book-name {
    font-family: 'Space Grotesk', -apple-system, sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: var(--fpb-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fpb-status-text {
    font-size: 11px;
    color: var(--fpb-muted);
    white-space: nowrap;
}

/* Botões da Barra */
.fpb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 34px;
    min-width: 34px;
    padding: 0 10px;
    border-radius: 9px;
    border: 1px solid var(--fpb-border);
    background: var(--fpb-surface-2);
    color: var(--fpb-text);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    text-decoration: none;
}

.fpb-btn:hover {
    border-color: var(--fpb-accent-2);
    background: rgba(118, 40, 245, 0.18);
}

.fpb-btn.active {
    background: linear-gradient(135deg, var(--fpb-accent), var(--fpb-accent-2));
    border-color: transparent;
    color: #fff;
}

.fpb-btn:disabled {
    opacity: 0.35;
    pointer-events: none;
}

.fpb-btn-icon {
    padding: 0;
    width: 34px;
}

.fpb-btn-exit-immersive {
    display: none;
    background: rgba(118, 40, 245, 0.22);
    border-color: rgba(195, 74, 255, 0.45);
}

.fpb-reader.fpb-is-immersive .fpb-btn-exit-immersive,
.fpb-reader:fullscreen .fpb-btn-exit-immersive {
    display: inline-flex;
}

/* Grupo de Controles (Zoom / Tema / Modo) */
.fpb-group {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px;
    background: var(--fpb-surface-2);
    border: 1px solid var(--fpb-border);
    border-radius: 10px;
}

.fpb-group .fpb-btn {
    border: 0;
    background: transparent;
    height: 30px;
    min-width: 30px;
    border-radius: 7px;
}

.fpb-group .fpb-btn:hover {
    background: rgba(118, 40, 245, 0.2);
}

.fpb-group .fpb-btn.active {
    background: linear-gradient(135deg, var(--fpb-accent), var(--fpb-accent-2));
    color: #fff;
}

.fpb-zoom-label {
    font-size: 11.5px;
    font-weight: 700;
    min-width: 44px;
    text-align: center;
    color: var(--fpb-text);
    cursor: pointer;
    padding: 0 4px;
}

/* Bolinhas de Tema */
.fpb-theme-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1.5px solid rgba(128, 128, 128, 0.45);
    display: inline-block;
}
.fpb-theme-dot.dark { background: #141320; }
.fpb-theme-dot.sepia { background: #f4ecd8; }
.fpb-theme-dot.light { background: #ffffff; }

/* Corpo do Leitor (Sidebar + Palco) */
.fpb-body {
    position: relative;
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Gaveta Lateral (Sumário / Páginas / Marcadores) */
.fpb-sidebar {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 310px;
    max-width: 88vw;
    background: var(--fpb-surface);
    border-right: 1px solid var(--fpb-border);
    z-index: 30;
    display: flex;
    flex-direction: column;
    transform: translateX(-102%);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.45);
}

.fpb-sidebar.open {
    transform: translateX(0);
}

.fpb-sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--fpb-border);
    padding: 8px;
    gap: 6px;
}

.fpb-stab {
    flex: 1;
    padding: 8px 6px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--fpb-muted);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.18s ease;
}

.fpb-stab.active {
    background: rgba(118, 40, 245, 0.22);
    color: var(--fpb-text);
}

.fpb-sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.fpb-spanel {
    display: none;
}
.fpb-spanel.active {
    display: block;
}

/* Lista de Sumário */
.fpb-toc-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--fpb-text);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}
.fpb-toc-item:hover {
    background: rgba(118, 40, 245, 0.18);
}
.fpb-toc-page {
    font-size: 11px;
    font-weight: 700;
    color: var(--fpb-accent-2);
    flex-shrink: 0;
}

/* Grade de Páginas Rápida */
.fpb-pages-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.fpb-page-chip {
    padding: 8px 4px;
    border-radius: 8px;
    border: 1px solid var(--fpb-border);
    background: var(--fpb-surface-2);
    color: var(--fpb-text);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
}
.fpb-page-chip:hover {
    border-color: var(--fpb-accent-2);
}
.fpb-page-chip.active {
    background: linear-gradient(135deg, var(--fpb-accent), var(--fpb-accent-2));
    border-color: transparent;
    color: #fff;
}

/* Marcadores */
.fpb-bm-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
    border-radius: 10px;
    background: var(--fpb-surface-2);
    border: 1px solid var(--fpb-border);
}
.fpb-bm-jump {
    flex: 1;
    border: 0;
    background: transparent;
    color: var(--fpb-text);
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}
.fpb-bm-del {
    border: 0;
    background: transparent;
    color: #f87171;
    font-size: 15px;
    cursor: pointer;
    padding: 2px 6px;
}

.fpb-empty-note {
    font-size: 12.5px;
    color: var(--fpb-muted);
    text-align: center;
    padding: 24px 12px;
    line-height: 1.5;
}

/* Palco de Leitura das Páginas */
.fpb-stage {
    position: relative;
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 24px 64px;
    outline: none;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.fpb-pages-wrap {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 0;
    margin: auto;
    position: relative;
}

.fpb-canvas-slot {
    position: relative;
    display: inline-flex;
    background: #fff;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: var(--fpb-page-shadow);
    transition: opacity 0.2s ease;
}

.fpb-pages-wrap.is-spread .fpb-canvas-slot:first-child {
    border-radius: 6px 0 0 6px;
    box-shadow: inset -18px 0 28px -18px rgba(0, 0, 0, 0.35), var(--fpb-page-shadow);
}

.fpb-pages-wrap.is-spread .fpb-canvas-slot:last-child {
    border-radius: 0 6px 6px 0;
    box-shadow: inset 18px 0 28px -18px rgba(0, 0, 0, 0.35), var(--fpb-page-shadow);
}

.fpb-canvas {
    display: block;
    filter: var(--fpb-canvas-filter);
    transition: filter 0.25s ease;
}

/* Zonas Laterais de Virar Página */
.fpb-nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 68px;
    border-radius: 12px;
    border: 1px solid var(--fpb-border);
    background: rgba(15, 14, 26, 0.62);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff;
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 15;
    opacity: 0.72;
    transition: all 0.2s ease;
}
.fpb-nav-arrow:hover {
    opacity: 1;
    background: linear-gradient(135deg, var(--fpb-accent), var(--fpb-accent-2));
    border-color: transparent;
    transform: translateY(-50%) scale(1.06);
}
.fpb-nav-arrow.prev { left: 12px; }
.fpb-nav-arrow.next { right: 12px; }
.fpb-nav-arrow:disabled { opacity: 0.18; pointer-events: none; }

/* Loading Overlay */
.fpb-loading {
    position: absolute;
    inset: 0;
    z-index: 25;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(11, 11, 18, 0.82);
    backdrop-filter: blur(8px);
    color: #f5f2ff;
    font-size: 14px;
    font-weight: 600;
}

.fpb-spinner {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid rgba(195, 74, 255, 0.22);
    border-top-color: #c34aff;
    animation: fpbSpin 0.8s linear infinite;
}
@keyframes fpbSpin { to { transform: rotate(360deg); } }

/* Fallback Iframe (quando PDF externo bloqueia CORS) */
.fpb-fallback-wrap {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 22;
    flex-direction: column;
    background: #111;
}
.fpb-fallback-wrap.active {
    display: flex;
}
.fpb-fallback-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 16px;
    background: rgba(118, 40, 245, 0.25);
    border-bottom: 1px solid rgba(195, 74, 255, 0.3);
    font-size: 12px;
    color: #f5f2ff;
}
.fpb-fallback-iframe {
    flex: 1;
    width: 100%;
    height: 100%;
    border: 0;
    background: #fff;
}

/* Barra Inferior (Scrubber + Navegação + Porcentagem) */
.fpb-bottombar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 18px 12px;
    background: var(--fpb-surface);
    border-top: 1px solid var(--fpb-border);
    z-index: 20;
    flex-shrink: 0;
}

.fpb-scrubber-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.fpb-scrubber {
    position: relative;
    flex: 1;
    height: 22px;
    display: flex;
    align-items: center;
    cursor: pointer;
    touch-action: none;
}

.fpb-scrubber-rail {
    width: 100%;
    height: 5px;
    border-radius: 6px;
    background: rgba(128, 128, 150, 0.26);
    overflow: hidden;
}

.fpb-scrubber-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--fpb-accent), var(--fpb-accent-2));
    border-radius: 6px;
    transition: width 0.15s ease;
}

.fpb-bottom-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.fpb-page-jump {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--fpb-muted);
}

.fpb-page-input {
    width: 54px;
    height: 30px;
    text-align: center;
    border-radius: 7px;
    border: 1px solid var(--fpb-border);
    background: var(--fpb-surface-2);
    color: var(--fpb-text);
    font-size: 13px;
    font-weight: 700;
    padding: 0 4px;
}

.fpb-percent-pill {
    font-size: 12px;
    font-weight: 700;
    color: var(--fpb-mint);
    background: rgba(33, 230, 181, 0.12);
    border: 1px solid rgba(33, 230, 181, 0.25);
    padding: 3px 10px;
    border-radius: 20px;
}

/* ==========================================================================
   BIBLIOTECA DIGITAL (ARCHIVE-FOCA_BOOK.PHP) — ESTANTE 3D PROFISSIONAL
   ========================================================================== */
.fpb-library-hero {
    position: relative;
    padding: 110px 0 48px;
    background: radial-gradient(circle at 20% 20%, rgba(118, 40, 245, 0.28), transparent 55%),
                radial-gradient(circle at 80% 10%, rgba(33, 230, 181, 0.12), transparent 50%),
                #09090f;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.fpb-library-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.fpb-library-kicker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #21e6b5;
    background: rgba(33, 230, 181, 0.12);
    border: 1px solid rgba(33, 230, 181, 0.3);
    padding: 5px 12px;
    border-radius: 20px;
    margin-bottom: 14px;
}

.fpb-library-title {
    font-family: 'Space Grotesk', -apple-system, sans-serif;
    font-size: clamp(28px, 4vw, 44px);
    font-weight: 800;
    color: #f5f2ff;
    margin: 0 0 10px;
    letter-spacing: -0.02em;
}

.fpb-library-sub {
    font-size: 15px;
    color: rgba(245, 242, 255, 0.72);
    max-width: 600px;
    margin: 0;
    line-height: 1.5;
}

.fpb-library-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(36, 35, 49, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 12px;
    padding: 6px 14px;
    min-width: 280px;
}

.fpb-library-search input {
    background: transparent;
    border: 0;
    color: #f5f2ff;
    font-size: 14px;
    width: 100%;
    outline: none;
}

.fpb-library-grid-sec {
    padding: 48px 0 80px;
    background: #09090f;
}

.fpb-books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 28px 24px;
}

.fpb-book-card {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    background: rgba(36, 35, 49, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 14px;
    transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.fpb-book-card:hover {
    transform: translateY(-6px);
    border-color: rgba(195, 74, 255, 0.48);
    box-shadow: 0 18px 40px rgba(118, 40, 245, 0.22);
}

.fpb-book-cover-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 2 / 3;
    border-radius: 4px 10px 10px 4px;
    overflow: hidden;
    background: #171624;
    box-shadow: inset 10px 0 18px rgba(0, 0, 0, 0.45), 0 10px 24px rgba(0, 0, 0, 0.55);
    margin-bottom: 14px;
}

.fpb-book-cover-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.35s ease;
}

.fpb-book-card:hover .fpb-book-cover-frame img {
    transform: scale(1.04);
}

.fpb-book-card-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(9, 9, 15, 0.85);
    border: 1px solid rgba(33, 230, 181, 0.4);
    color: #21e6b5;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 6px;
}

.fpb-book-card-progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 4px;
    background: rgba(0, 0, 0, 0.6);
    display: none;
}

.fpb-book-card-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #7628f5, #c34aff);
    width: 0%;
}

.fpb-book-card-title {
    font-family: 'Space Grotesk', -apple-system, sans-serif;
    font-size: 15.5px;
    font-weight: 700;
    color: #f5f2ff;
    margin: 0 0 4px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.fpb-book-card-author {
    font-size: 12.5px;
    color: rgba(245, 242, 255, 0.65);
    margin: 0 0 8px;
}

.fpb-book-card-meta {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11.5px;
    color: #c34aff;
    font-weight: 700;
}

/* ==========================================================================
   RESPONSIVIDADE MOBILE DO LEITOR DIGITAL
   ========================================================================== */
@media (max-width: 768px) {
    .fpb-reader {
        height: 78vh;
        min-height: 480px;
        border-radius: 12px;
    }

    .fpb-topbar {
        padding: 8px 10px;
        gap: 6px;
        flex-wrap: wrap;
    }

    .fpb-topbar-left {
        width: 100%;
        order: 1;
    }

    .fpb-topbar-center {
        order: 2;
        flex: 1;
    }

    .fpb-topbar-right {
        order: 3;
    }

    .fpb-btn-spread {
        display: none !important;
    }

    .fpb-btn-label {
        display: none;
    }

    .fpb-stage {
        padding: 12px 10px;
    }

    .fpb-nav-arrow {
        display: none;
    }

    .fpb-bottombar {
        padding: 8px 12px max(10px, env(safe-area-inset-bottom));
    }

    .fpb-books-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }
}
