/**
 * Estilos del plugin Flipbook PDF.
 */

.flipbook-wrapper {
    position: relative;
    margin: 0 auto;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3);
    background: #1a1a1a;
    min-height: 500px;
    overflow: visible;
}

.flipbook-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #1a1a1a;
    color: #ccc;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    z-index: 100;
    transition: opacity 0.3s ease;
    min-height: 500px;
}

.flipbook-wrapper.loaded .flipbook-loading {
    opacity: 0;
    pointer-events: none;
}

.flipbook-spinner {
    /* Forzar circularidad absoluta: mismo width y height explícitos */
    display: block !important;
    width: 48px !important;
    height: 48px !important;
    min-width: 48px !important;
    max-width: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
    aspect-ratio: 1 / 1 !important;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    border: 4px solid rgba(255, 255, 255, 0.15);
    border-top-color: #fff;
    border-radius: 50%;
    box-sizing: border-box;
    animation: flipbook-spin 0.8s linear infinite;
    margin-bottom: 16px;
    padding: 0 !important;
}

@keyframes flipbook-spin {
    to {
        transform: rotate(360deg);
    }
}

/* El contenedor del flipbook */
.c-flipbook {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    min-height: 500px !important;
    background: #d4c9b8;
    box-shadow: inset 0 0 40px rgba(0,0,0,0.15);
    overflow: visible !important;
    cursor: grab;
    will-change: transform;
}

.c-flipbook.grabbing {
    cursor: grabbing;
}

/* Páginas del flipbook */
.c-flipbook__page {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    box-sizing: border-box;
    height: 100% !important;
    background: transparent !important;
}

.c-flipbook__page canvas {
    display: block;
    max-width: 100% !important;
    max-height: 100% !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Anular hover 3D de flipbook-js que causa blur */
.c-flipbook__page:hover,
.c-flipbook__page.is-active:hover,
.c-flipbook__page:nth-child(odd).is-active:hover,
.c-flipbook__page:nth-child(even).is-active:hover {
    transform: rotateY(0deg) !important;
    box-shadow: none !important;
}

/* Alinear páginas para que no haya espacio entre ellas en el centro del libro */
.c-flipbook__page:nth-child(even) {
    justify-content: flex-end !important;
    border-radius: 0 !important;
}
.c-flipbook__page:nth-child(odd):not(.hidden-cover) {
    justify-content: flex-start !important;
    border-radius: 0 !important;
}

/* Eliminar pseudo-elemento de sombra de flipbook-js que crea línea visible */
.c-flipbook__page::before {
    display: none !important;
}

/* Controles personalizados (barra independiente, arriba del wrapper) */
.flipbook-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 16px;
    background: #2a2a2a;
    border-radius: 12px;
    flex-wrap: wrap;
    position: relative;
    z-index: 200;
    margin: 20px auto 0;
    max-width: 100%;
}

.flipbook-controls + .flipbook-wrapper {
    margin-top: 0;
    border-radius: 12px;
}

.flipbook-controls button {
    background: #444;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s, transform 0.1s;
    user-select: none;
    line-height: 1;
}

.flipbook-controls button:hover {
    background: #666;
}

.flipbook-controls button:active {
    transform: scale(0.95);
}

/* Botones de zoom */
.flipbook-zoom-in,
.flipbook-zoom-out {
    font-weight: bold;
    font-size: 16px !important;
    min-width: 34px;
    padding: 6px 10px !important;
}

.zoom-label {
    color: #aaa;
    font-size: 12px;
    min-width: 38px;
    text-align: center;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.flipbook-controls .page-info {
    color: #ccc;
    font-size: 13px;
    min-width: 120px;
    text-align: center;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Responsive */
@media (max-width: 768px) {
    .flipbook-wrapper {
        margin: 0;
        border-radius: 0;
    }

    .c-flipbook {
        min-height: 350px;
    }

    /* Vista de una página en móvil */
    .c-flipbook__page {
        width: 100% !important;
        justify-content: center !important;
        transition: none !important;
    }
    .c-flipbook__page:nth-child(even),
    .c-flipbook__page:nth-child(odd):not(.hidden-cover) {
        justify-content: center !important;
        border-radius: 0 !important;
        transition: none !important;
    }

    .flipbook-controls {
        padding: 8px 10px;
        gap: 6px;
        margin-top: 10px;
        border-radius: 8px;
        flex-wrap: wrap;
        justify-content: center;
        overflow: visible;
    }

    .flipbook-controls button {
        padding: 6px 10px;
        font-size: 13px;
        min-width: 32px;
        min-height: 32px;
        flex-shrink: 0;
    }

    .flipbook-zoom-in,
    .flipbook-zoom-out {
        min-width: 30px !important;
        padding: 5px 10px !important;
        font-size: 15px !important;
    }

    .zoom-label {
        font-size: 12px;
        min-width: 35px;
        flex-shrink: 0;
    }

    .flipbook-controls .page-info {
        font-size: 12px;
        min-width: auto;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .flipbook-controls + .flipbook-wrapper {
        border-radius: 8px;
    }
}
