/* ==========================================================================
   PDF Viewer GTM - Stili
   Design moderno: angoli arrotondati, leggero effetto rilievo, toolbar pulita
   Versione 1.3-test mobile compat
   ========================================================================== */

/* --------------------------------------------------------------------
   RESET DI ISOLAMENTO
   Neutralizza eredità di stili aggressivi da tema/builder.
   -------------------------------------------------------------------- */

.pvg-container,
.pvg-container * {
    box-sizing: border-box;
}

.pvg-container ul,
.pvg-container li {
    list-style: none;
    margin: 0;
    padding: 0;
}

.pvg-container button {
    font-family: inherit;
    margin: 0;
    -webkit-appearance: none;
    appearance: none;
}

.pvg-container a {
    box-shadow: none;
}

.pvg-container h4 {
    line-height: 1.3;
}

/* --------------------------------------------------------------------
   CONTAINER PRINCIPALE
   -------------------------------------------------------------------- */

.pvg-container {
    --pvg-radius: 8px;
    --pvg-border: #e0e0e0;
    --pvg-bg-toolbar: #f7f7f8;
    --pvg-bg-canvas: #525659;
    --pvg-accent: #2271b1;
    --pvg-text: #333;

    width: 100%;
    max-width: 850px;
    margin: 24px auto;
    border: 1px solid var(--pvg-border);
    border-radius: var(--pvg-radius);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #fff;
    position: relative;
    isolation: isolate;

    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.04),
        0 4px 12px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

/* --------------------------------------------------------------------
   TOOLBAR
   -------------------------------------------------------------------- */

.pvg-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    background: var(--pvg-bg-toolbar);
    border-bottom: 1px solid var(--pvg-border);
    flex-wrap: wrap;
    position: relative;
    z-index: 5;
}

.pvg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    border: 1px solid var(--pvg-border);
    border-radius: 4px;
    background: #fff;
    color: var(--pvg-text);
    font-size: 16px;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.03);

    touch-action: manipulation;
    -ms-touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.pvg-btn:hover {
    background: #f0f0f1;
    border-color: #c9c9c9;
}

.pvg-btn:active {
    background: #e6e6e7;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08);
}

.pvg-btn:focus-visible {
    outline: 2px solid var(--pvg-accent);
    outline-offset: 1px;
}

.pvg-icon {
    display: inline-block;
    pointer-events: none;
}

/* Stato attivo autoplay */
.pvg-autoplay[data-state="playing"] {
    background: var(--pvg-accent);
    border-color: var(--pvg-accent);
    color: #fff;
}

.pvg-autoplay[data-state="playing"]:hover {
    background: #1a5a8a;
}

/* --------------------------------------------------------------------
   INFO PAGINA / ZOOM
   -------------------------------------------------------------------- */

.pvg-page-info {
    margin: 0 8px;
    font-size: 13px;
    font-weight: 500;
    color: #555;
    min-width: 58px;
    text-align: center;
    white-space: nowrap;
}

.pvg-zoom-level {
    font-size: 12px;
    font-weight: 500;
    color: #555;
    min-width: 42px;
    text-align: center;
    white-space: nowrap;
}

/* Download spinto a destra su desktop */
.pvg-download {
    margin-left: auto;
}

/* --------------------------------------------------------------------
   PANNELLO INDICE (TOC)
   -------------------------------------------------------------------- */

.pvg-toc-panel {
    background: #fafafa;
    border-bottom: 1px solid var(--pvg-border);
    padding: 14px 18px;
    max-height: 260px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    animation: pvg-fade-in 0.15s ease;
    position: relative;
    z-index: 4;
}

.pvg-toc-panel h4 {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #888;
}

.pvg-toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.pvg-toc-list li {
    margin-bottom: 6px;
}

.pvg-toc-loading {
    font-size: 13px;
    color: #999;
}

.pvg-toc-list a {
    display: inline-block;
    padding: 4px 8px;
    margin: -4px -8px;
    border-radius: 4px;
    color: var(--pvg-accent);
    text-decoration: none;
    font-size: 13.5px;
    transition: background 0.12s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.pvg-toc-list a:hover {
    background: rgba(34, 113, 177, 0.08);
    text-decoration: underline;
}

@keyframes pvg-fade-in {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --------------------------------------------------------------------
   AREA CANVAS / VISUALIZZAZIONE PDF
   -------------------------------------------------------------------- */

.pvg-canvas-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background: var(--pvg-bg-canvas);
    padding: 20px;
    min-height: 320px;
    overflow: auto;
    width: 100%;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.pvg-canvas {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    box-shadow:
        0 2px 6px rgba(0, 0, 0, 0.25),
        0 8px 24px rgba(0, 0, 0, 0.18);
    background: #fff;

    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    will-change: transform, opacity;
}

.pvg-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.02em;
    z-index: 3;
    text-align: center;
    pointer-events: none;
}

/* --------------------------------------------------------------------
   FULLSCREEN
   -------------------------------------------------------------------- */

.pvg-container:fullscreen {
    border-radius: 0;
    box-shadow: none;
    background: var(--pvg-bg-canvas);
    max-width: 100%;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.pvg-container:fullscreen .pvg-toolbar {
    flex: 0 0 auto;
}

.pvg-container:fullscreen .pvg-canvas-wrapper {
    flex: 1 1 auto;
    min-height: 0;
    align-items: center;
}

/* --------------------------------------------------------------------
   MODALITÀ PERSISTENT
   -------------------------------------------------------------------- */

.pvg-mode-persistent {
    max-width: 100%;
}

.pvg-mode-persistent .pvg-canvas-wrapper {
    min-height: 480px;
}

@media (min-width: 900px) {
    .pvg-mode-persistent .pvg-canvas-wrapper {
        min-height: 640px;
    }
}

/* Toolbar fissa opzionale */
.pvg-sticky .pvg-toolbar {
    position: sticky;
    top: 0;
    z-index: 10;
}

/* --------------------------------------------------------------------
   RESPONSIVE TABLET
   -------------------------------------------------------------------- */

@media (max-width: 768px) {
    .pvg-container {
        max-width: 100%;
    }

    .pvg-toolbar {
        justify-content: center;
    }

    .pvg-download {
        margin-left: 0;
    }

    .pvg-canvas-wrapper {
        padding: 14px;
        min-height: 300px;
    }
}

/* --------------------------------------------------------------------
   RESPONSIVE SMARTPHONE
   -------------------------------------------------------------------- */

@media (max-width: 600px) {
    .pvg-container {
        width: auto;
        max-width: calc(100% - 24px);
        margin: 12px;
        border-radius: 6px;
    }

    .pvg-toolbar {
        padding: 8px;
        gap: 4px;
        justify-content: center;
        align-items: center;
    }

    .pvg-btn {
        width: 38px;
        height: 38px;
        min-width: 38px;
        min-height: 38px;
        font-size: 15px;
    }

    .pvg-page-info,
    .pvg-zoom-level {
        font-size: 12px;
        min-width: 42px;
        margin-left: 4px;
        margin-right: 4px;
    }

    .pvg-canvas-wrapper {
        padding: 10px;
        min-height: 260px;
        justify-content: flex-start;
    }

    .pvg-canvas {
        max-width: none;
        width: auto;
        height: auto;
        margin: 0 auto;
    }

    .pvg-mode-persistent .pvg-canvas-wrapper {
        min-height: 360px;
    }

    .pvg-toc-panel {
        padding: 12px;
        max-height: 220px;
    }
}

/* --------------------------------------------------------------------
   SMARTPHONE MOLTO STRETTI
   -------------------------------------------------------------------- */

@media (max-width: 420px) {
    .pvg-toolbar {
        gap: 3px;
    }

    .pvg-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
        font-size: 14px;
    }

    .pvg-page-info,
    .pvg-zoom-level {
        min-width: 38px;
        font-size: 11.5px;
    }

    .pvg-canvas-wrapper {
        padding: 8px;
    }
}

/* --------------------------------------------------------------------
   RIDUZIONE ANIMAZIONI
   -------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .pvg-btn,
    .pvg-toc-list a {
        transition: none;
    }

    .pvg-toc-panel {
        animation: none;
    }
}