/* ============================================================
   Flipbook — visor tipo libro para PDFs (PDF.js + StPageFlip).
   Marcado: Views/Shared/_Flipbook.cshtml · Lógica: js/flipbook.js
   ============================================================ */

.fb-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 18, 13, 0.9);
    z-index: 3000;
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 220ms ease, visibility 220ms ease;
}

.fb-overlay.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

body.fb-sin-scroll {
    overflow: hidden;
}

.fb-modal {
    width: 100%;
    max-width: 1280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    min-height: 0;
    transform: scale(0.97) translateY(8px);
    transition: transform 240ms ease;
}

.fb-overlay.open .fb-modal {
    transform: scale(1) translateY(0);
}

@media (prefers-reduced-motion: reduce) {
    .fb-overlay, .fb-modal { transition: none; }
}

/* ---------- Barra superior ---------- */

.fb-topbar {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: #FFFFFF;
    flex: 0 0 auto;
}

.fb-topbar h3 {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #FFFFFF;
}

.fb-topbar-actions {
    display: flex;
    gap: 8px;
    flex: 0 0 auto;
}

.fb-icon-btn,
.fb-close {
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: #FFFFFF;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 150ms ease;
}

.fb-icon-btn:hover,
.fb-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

.fb-icon-btn:focus-visible,
.fb-nav-btn:focus-visible {
    outline: 3px solid var(--inst-accent, #F97316);
    outline-offset: 2px;
}

/* ---------- Libro ---------- */

/* Ocupa todo el alto libre; flipbook.js mide este espacio para
   calcular el tamaño de página que cabe sin hacer scroll. */
.fb-book {
    position: relative;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 0;
}

.fb-pages {
    width: 100%;
    display: flex;
    justify-content: center;
}

.fb-flip-root {
    margin: 0 auto;
}

.fb-pdf-page {
    background: #FFFFFF;
    overflow: hidden;
}

.fb-pdf-page-inner {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Placeholder mientras la página se dibuja. */
    background: linear-gradient(110deg, #F3F6F4 8%, #FAFBFA 18%, #F3F6F4 33%);
    background-size: 200% 100%;
    animation: fb-shimmer 1.4s linear infinite;
}

.fb-pdf-page--lista .fb-pdf-page-inner {
    background: #FFFFFF;
    animation: none;
}

.fb-pdf-page-inner canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.fb-pdf-page-num {
    font-size: 28px;
    font-weight: 700;
    color: #D3E5DA;
}

.fb-pdf-page--lista .fb-pdf-page-num {
    display: none;
}

@keyframes fb-shimmer {
    to { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
    .fb-pdf-page-inner { animation: none; }
}

/* ---------- Cargando / error ---------- */

.fb-estado {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #EAF6EF;
    text-align: center;
    padding: 24px;
}

.fb-estado[hidden] {
    display: none;
}

.fb-estado p {
    margin: 0;
    font-size: 15px;
}

.fb-estado-error i {
    font-size: 44px;
    color: var(--inst-accent, #F97316);
}

.fb-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--inst-accent, #F97316);
    border-radius: 50%;
    animation: fb-girar 0.8s linear infinite;
}

@keyframes fb-girar {
    to { transform: rotate(360deg); }
}

/* ---------- Controles ---------- */

.fb-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 0 0 auto;
}

.fb-nav-btn {
    background: #FFFFFF;
    border: none;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    color: var(--inst-primary, #0E4429);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 150ms ease, color 150ms ease, opacity 150ms ease;
}

.fb-nav-btn:hover {
    background: var(--inst-accent, #F97316);
    color: #FFFFFF;
}

.fb-nav-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    background: #FFFFFF;
    color: var(--inst-primary, #0E4429);
}

.fb-page-indicator {
    color: #FFFFFF;
    font-size: 15px;
    font-weight: 600;
    min-width: 150px;
    text-align: center;
}

.fb-download-link {
    color: #EAF6EF;
    font-size: 13px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}

.fb-download-link:hover {
    color: var(--inst-accent, #F97316);
}

/* Pantalla completa: el overlay ya es fijo, solo se quita el relleno. */
.fb-overlay:fullscreen {
    padding: 12px;
    background: #0B1A12;
}

@media (max-width: 576px) {
    .fb-overlay { padding: 10px; }
    .fb-topbar h3 { font-size: 15px; }
    .fb-controls { gap: 12px; }
    .fb-page-indicator { min-width: 120px; font-size: 14px; }
}

/* ---------- Botón "Vista previa" en las tarjetas ---------- */

.fb-preview-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1.5px solid var(--inst-border, #D9EAE0);
    color: var(--inst-primary, #0E4429);
    font-weight: 600;
    font-size: 13.5px;
    padding: 9px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 150ms ease, color 150ms ease;
}

.fb-preview-btn:hover {
    border-color: var(--inst-accent, #F97316);
    color: var(--inst-accent, #F97316);
}
