/* =========================================================
   Modal visualitzador PDF (targeta "Informació estàndard")
   ========================================================= */

body.pdf-modal-open {
    overflow: hidden;
}

.pdf-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .78);
    padding: 24px;
}

.pdf-modal.is-open {
    display: flex;
}

.pdf-modal__canvas {
    max-width: 92vw;
    max-height: 88vh;
    width: auto;
    height: auto;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 25px 70px rgba(0, 0, 0, .55);
}

.pdf-modal__scroll {
    max-width: 92vw;
    max-height: 88vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.pdf-modal__scroll-page {
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 25px 70px rgba(0, 0, 0, .55);
}

.pdf-modal__close {
    position: fixed;
    top: 18px;
    right: 22px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, .95);
    color: #1f1f1f;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
}

.pdf-modal__close:hover {
    filter: brightness(1.05);
}

.pdf-modal__nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, .95);
    color: #1f1f1f;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
}

.pdf-modal__nav:hover {
    filter: brightness(1.05);
}

.pdf-modal__nav[disabled],
.pdf-modal__nav[hidden] {
    display: none;
}

.pdf-modal__nav--prev {
    left: 18px;
}

.pdf-modal__nav--next {
    right: 18px;
}

.pdf-modal__indicator {
    position: fixed;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    padding: .35rem .9rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, .95);
    color: #1f1f1f;
    font-family: "Montserrat", sans-serif;
    font-weight: 600;
    font-size: .85rem;
}

@media (max-width: 768px) {
    .pdf-modal {
        padding: 12px;
    }

    .pdf-modal__canvas {
        max-width: 94vw;
        max-height: 80vh;
        max-height: 80dvh;
    }

    .pdf-modal__scroll {
        max-width: 94vw;
        max-height: 80vh;
        max-height: 80dvh;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    .pdf-modal__close {
        top: 10px;
        right: 10px;
        top: max(10px, env(safe-area-inset-top));
        right: max(10px, env(safe-area-inset-right));
        width: 44px;
        height: 44px;
        font-size: 1.35rem;
    }

    .pdf-modal__nav {
        width: 44px;
        height: 44px;
        font-size: 1.15rem;
    }

    .pdf-modal__indicator {
        bottom: max(18px, env(safe-area-inset-bottom));
    }

    .pdf-modal__nav--prev {
        left: 6px;
    }

    .pdf-modal__nav--next {
        right: 6px;
    }
}

@media (max-height: 500px) {
    .pdf-modal__canvas,
    .pdf-modal__scroll {
        max-height: calc(100vh - 112px);
        max-height: calc(100dvh - 112px);
    }
}

/* Apri in nuova scheda: solo su schermi piccoli */
.pdf-modal__external {
    display: none;
}

@media (max-width: 768px) {
    .pdf-modal__external:not([hidden]) {
        position: fixed;
        top: 10px;
        top: max(10px, env(safe-area-inset-top));
        left: 10px;
        left: max(10px, env(safe-area-inset-left));
        right: 64px;
        right: calc(max(10px, env(safe-area-inset-right)) + 54px);
        z-index: 2;
        display: inline-flex;
        align-items: center;
        width: fit-content;
        max-width: calc(100vw - 80px);
        min-height: 44px;
        padding: .5rem 1rem;
        border-radius: 999px;
        background: rgba(255, 255, 255, .95);
        color: #1f1f1f;
        font-family: "Montserrat", sans-serif;
        font-weight: 600;
        font-size: .85rem;
        line-height: 1.2;
        text-decoration: none;
        box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
    }
}
