/* MediaHero PDF Viewer Styles */

* { box-sizing: border-box; }

.mhpv-wrapper {
    position: relative;
    max-width: 100%;
    width: 1200px;
    margin: 0 auto;
}

.mhpv-viewer-area {
    position: relative;
    box-shadow: 0 15px 40px rgba(0,0,0,0.25);
}

.mhpv-loader-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 40px;
    background: white;
    z-index: 1001;
    display: flex;
    justify-content: center;
    align-items: center;
}

.mhpv-loader-overlay .loader {
    width: 40px;
    height: 40px;
    border: 5px solid #f3f3f3;
    border-radius: 50%;
    border-top-color: #0073aa;
    animation: spin 1s linear infinite;
}

.mhpv-loader-overlay .mhpv-loading-text {
    margin-top: 15px;
    color: #666;
    font-size: 14px;
    text-align: center;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- CSS PULITO E FUNZIONANTE --- */
.flipbook-viewport {
    width: 1200px;
    height: 800px;
}

.flipbook .page {
    background-color: white;
}

.flipbook .hard {
    background-color: #f0f0f0;
}

.flipbook .turn-page {
    overflow: hidden;
}

.flipbook .page img {
    width: 100%;
    height: 100%;
    /* 'cover' riempie lo spazio, tagliando l'eccesso.
       Con il JS corretto, l'immagine sarà perfettamente centrata. */
    object-fit: cover;
    display: block;
}
/* --- FINE CSS --- */

.mhpv-toolbar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    height: 40px;
    background-color: #fff;
    border-top: 1px solid #ddd;
}

.mhpv-toolbar button {
    background: transparent;
    border: none;
    font-size: 22px;
    color: #555;
    cursor: pointer;
}

.mhpv-page-indicator {
    font-size: 14px;
    color: #666;
}

.mhpv-toc-sidebar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 40px;
    width: 300px;
    background: #fff;
    border-right: 1px solid #ddd;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 2000;
    overflow-y: auto;
}

.mhpv-wrapper.toc-is-open .mhpv-toc-sidebar {
    transform: translateX(0);
}

.mhpv-toc-content {
    padding: 15px;
}

.mhpv-toc-content ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mhpv-toc-content a {
    display: block;
    padding: 8px 5px;
    text-decoration: none;
    color: #333;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
}

.mhpv-toc-content ul ul {
    padding-left: 15px;
}

/* === RESPONSIVE DESIGN FOR MOBILE === */

/* Tablet and smaller screens */
@media (max-width: 1024px) {
    .mhpv-wrapper {
        width: 100%;
        max-width: 900px;
    }

    .flipbook-viewport {
        width: 900px;
        height: 600px;
    }

    .mhpv-toc-sidebar {
        width: 250px;
    }
}

/* Mobile landscape */
@media (max-width: 768px) {
    .mhpv-wrapper {
        width: 100%;
        max-width: 100%;
        padding: 0 10px;
    }

    .flipbook-viewport {
        width: 100%;
        max-width: 700px;
        height: 466px; /* Maintain 3:2 aspect ratio */
    }

    .mhpv-toc-sidebar {
        width: 200px;
    }

    .mhpv-toolbar {
        gap: 10px;
        padding: 0 10px;
    }

    .mhpv-toolbar button {
        font-size: 20px;
        padding: 8px;
    }

    .mhpv-page-indicator {
        font-size: 13px;
    }
}

/* Mobile portrait */
@media (max-width: 480px) {
    .mhpv-wrapper {
        padding: 0 5px;
    }

    .flipbook-viewport {
        width: 100%;
        max-width: 100%;
        height: 400px; /* Smaller height for portrait */
    }

    .mhpv-toc-sidebar {
        width: 180px;
    }

    .mhpv-toolbar {
        flex-wrap: wrap;
        height: auto;
        min-height: 40px;
        gap: 5px;
        padding: 5px;
    }

    .mhpv-toolbar button {
        font-size: 18px;
        padding: 6px;
    }

    .mhpv-page-indicator {
        font-size: 12px;
        order: -1;
        width: 100%;
        text-align: center;
        margin-bottom: 5px;
    }

    .mhpv-toc-content {
        padding: 10px;
    }

    .mhpv-toc-content a {
        font-size: 13px;
        padding: 6px 3px;
    }
}

/* Very small screens */
@media (max-width: 360px) {
    .flipbook-viewport {
        height: 320px;
    }

    .mhpv-toolbar button {
        font-size: 16px;
        padding: 4px;
    }

    .mhpv-page-indicator {
        font-size: 11px;
    }

    .mhpv-toc-sidebar {
        width: 160px;
    }
}