/* Reset y estilos base */
.st-page-flip {
    position: relative;
    width: 100%;
    height: 100%;
}

.st-page-flip .page {
    background: #f5f5f5;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    border-radius: 4px;
}

.st-page-flip .page img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Efecto de sombra para las páginas */
.st-page-flip .shadow {
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
}

.flipbook-container {
    display: flex;
    flex-direction: column;
    background: #333;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    position: relative;
}

/* ========== OVERLAY DE CARGA CENTRADO ========== */
.flipbook-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #333;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    transition: opacity 0.4s ease-out;
    backdrop-filter: blur(2px);
    border-radius: 12px;
}

.loading-content {
    text-align: center;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    backdrop-filter: blur(10px);
    min-width: 300px;
/*    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);*/
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.loading-progress {
    width: 280px;
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    overflow: hidden;
    margin: 20px auto;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.loading-progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
    border-radius: 10px;
    transition: width 0.3s ease;
    position: relative;
    overflow: hidden;
}

.loading-progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, 
        rgba(255,255,255,0) 0%, 
        rgba(255,255,255,0.3) 50%, 
        rgba(255,255,255,0) 100%);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.flipbook-loading p {
    color: white;
    margin-top: 15px;
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 1px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Barra de herramientas - inicialmente oculta */
.flipbook-toolbar {
    background: rgba(0,0,0,.85);
    padding: 12px 20px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: opacity 0.3s ease, transform 0.3s ease;
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    z-index: 2;
}

.flipbook-toolbar.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.3);
    padding: 5px 12px;
    border-radius: 12px;
    backdrop-filter: blur(5px);
}

.toolbar-group:last-child {
    border-right: none;
    padding-right: 12px;
}

.tool-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
}

.tool-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.tool-btn:active {
    transform: scale(0.95);
}

.tool-label {
    color: white;
    font-size: 13px;
    font-weight: 500;
}

.goto-page-input {
    width: 60px;
    height: 32px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    color: #333;
    padding: 0;
    border-radius: 8px;
    text-align: center;
    font-weight: bold;
}

.goto-page-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px #4facfe;
}

.zoom-level {
    color: #4facfe;
    font-size: 13px;
    min-width: 55px;
    text-align: center;
    font-weight: bold;
    background: rgba(0, 0, 0, 0.5);
    padding: 4px 10px;
    border-radius: 20px;
}

.total-pages {
    color: white;
    font-size: 13px;
    display: inline-block;
    min-width: 60px;
    font-weight: 500;
}

/* Barra de búsqueda */
.search-bar {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 40px;
    padding: 10px 20px;
    display: flex;
    gap: 10px;
    z-index: 100;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.search-input {
    width: 250px;
    padding: 8px 15px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 25px;
    transition: all 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: #4facfe;
    background: rgba(255, 255, 255, 0.15);
}

.search-nav-btn, .search-close-btn {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 20px;
    transition: all 0.2s;
}

.search-nav-btn:hover, .search-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.search-results {
    color: white;
    font-size: 12px;
    display: flex;
    align-items: center;
    padding: 0 8px;
}

/* Contenedor del flipbook */
.flipbook {
    flex: 1;
    min-height: 700px;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s ease;
    z-index: 1;
}

/* Miniaturas - inicialmente ocultas */
.thumbnails-container {
    position: relative;
    bottom: auto;
    left: auto;
    right: auto;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10;
    max-height: inherit;
    transition: opacity 0.3s ease, transform 0.3s ease;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
}

.thumbnails-container.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.thumbnails-header {
    padding: 10px 15px;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 14px;
    font-weight: 500;
}

.thumbnails-toggle {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 18px;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    transition: all 0.2s;
}

.thumbnails-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
}

.thumbnails-grid {
    display: flex;
    gap: 10px;
    padding: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    scroll-behavior: smooth;
}

.thumbnails-grid .thumbnail {
    position: relative;
    flex: 0 0 70px;
    cursor: pointer;
    border-radius: 6px;
    overflow: hidden;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.thumbnail:hover {
    transform: scale(1.05);
}

.thumbnail.active {
    border-color: #4facfe;
    box-shadow: 0 0 10px rgba(79, 172, 254, 0.5);
}

.thumbnails-grid::-webkit-scrollbar {
    height: 8px;
}

.thumbnails-grid::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.thumbnails-grid::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.4);
    border-radius: 20px;
}

.thumbnail img {
    width: 100%;
    height: auto;
    display: block;
}

.thumbnail-page-num {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 10px;
    text-align: center;
    padding: 2px;
}

/* Animación de entrada para el flipbook */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.flipbook {
    animation: fadeInUp 0.5s ease-out;
}

/* Responsive */
@media (max-width: 768px) {
    .flipbook-toolbar {
        padding: 8px 12px;
        gap: 8px;
    }
    
    .tool-btn span {
        display: none;
    }
    
    .tool-label {
        display: none;
    }
    
    .toolbar-group {
        padding: 4px 8px;
    }
    
    .tool-btn {
        padding: 4px 8px;
        font-size: 11px;
    }
    
    .thumbnails-grid .thumbnail {
        flex: 0 0 50px;
    }
    
    .flipbook {
        min-height: 500px;
    }
    
    .loading-content {
        min-width: 250px;
        padding: 1.5rem;
    }
    
    .loading-progress {
        width: 220px;
    }
    
    .search-bar {
        top: 70px;
        padding: 8px 15px;
    }
    
    .search-input {
        width: 180px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .loading-content {
        min-width: 200px;
        padding: 1rem;
    }
    
    .loading-progress {
        width: 180px;
    }
    
    .tool-btn {
        padding: 3px 6px;
        font-size: 10px;
    }
    
    .goto-page-input {
        width: 45px;
        height: 28px;
        font-size: 12px;
    }
}