/* ==================================================
   OpenPDF Flipbook - CSS Definitivo e Completo
   ================================================== */

:root {
    --primary-color: #6366f1;
    --secondary-color: #8b5cf6;
    --accent-color: #ec4899;
    --light-bg: #e5e7eb;
    --light-surface: #f3f4f6;
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(255, 255, 255, 0.9);
    --text-primary: #1f2937;
    --shadow-medium: 0 10px 30px -10px rgba(0, 0, 0, 0.2);
}

.openpdf-container {
    position: relative;
    background: linear-gradient(135deg, var(--light-bg) 0%, var(--light-surface) 100%);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    box-shadow: var(--shadow-medium);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

/* 1. LA TUA ANIMAZIONE DI SFONDO (INTEGRATA) */
.openpdf-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(circle at 20% 80%, rgba(99, 102, 241, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(139, 92, 246, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(236, 72, 153, 0.05) 0%, transparent 50%);
    animation: backgroundShift 20s ease-in-out infinite;
    pointer-events: none;
    z-index: 1;
}

@keyframes backgroundShift {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(-20px, -20px) rotate(120deg); }
    66% { transform: translate(20px, -10px) rotate(240deg); }
}

/* Layout e Toolbar */
.openpdf-toolbar {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--glass-border);
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    order: 2;
    width: 100%;
    z-index: 3; /* Sopra lo sfondo animato */
}

.openpdf-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border: none;
    color: white;
    padding: 8px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    min-width: 38px;
    min-height: 38px;
}
.openpdf-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
}
.openpdf-btn svg {
    width: 20px;
    height: 20px;
}

.openpdf-page-info {
    color: var(--text-primary);
    padding: 8px 16px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}
.page-number {
    color: var(--primary-color);
    font-weight: 600;
}

.openpdf-zoom-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}
.zoom-slider {
    width: 80px;
}
#zoom-level {
    color: var(--text-primary);
    font-weight: 500;
    min-width: 45px;
    text-align: center;
}

.openpdf-viewport {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    order: 1;
    z-index: 2; /* Sopra lo sfondo animato */
}

#flipbook-canvas {
    display: block;
    user-select: none;
    touch-action: none; /* Cruciale per gestire gli eventi touch in JS */
    filter: drop-shadow(0 8px 25px rgba(0, 0, 0, 0.2));
}

/* Frecce di Navigazione */
.nav-area {
    position: absolute;
    /* --- MODIFICA: Rimosso top: 0 e bottom: 0. Ora sono gestiti via JS --- */
    width: 20%;
    cursor: pointer;
    z-index: 50;
    /* Assicura che l'area sia cliccabile/toccabile ma la freccia no */
    pointer-events: auto; 
}
.nav-left {
    left: 0;
}
.nav-right {
    right: 0;
}
.nav-area::after {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 24px;
    color: white;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none; /* La freccia non deve intercettare i click */
}
.nav-left::after {
    content: '❮';
    left: 20px;
}
.nav-right::after {
    content: '❯';
    right: 20px;
}
/* Mostra le frecce su desktop con hover */
@media (hover: hover) {
    .nav-area:hover::after {
        opacity: 1;
    }
}
/* Mostra sempre le frecce su dispositivi touch per indicare la funzionalità */
@media (hover: none) {
    .nav-area::after {
        opacity: 0.7;
    }
}


/* Animazione di Caricamento */
.openpdf-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    z-index: 100;
}
.loader-container {
    position: relative;
    width: 60px;
    height: 60px;
}
.loader-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid transparent;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: loaderSpin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}
@keyframes loaderSpin {
    to {
        transform: rotate(360deg);
    }
}
.loading-text {
    color: var(--text-primary);
}

/* Altri Stili */
.openpdf-error-container {
    text-align: center;
    color: var(--text-primary);
}
.openpdf-container:fullscreen .openpdf-toolbar {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    border-radius: 20px;
}