.custom-popup-overlay {
    position: fixed;
    z-index: 999999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;

    /* Geen dubbele scrollbars: overlay zelf niet scrollen */
    overflow: hidden;

    background-color: rgba(0,0,0,0.75);

    display: flex;
    align-items: center;
    justify-content: center;

    /* ruimte rondom zodat de lightbox altijd volledig in beeld is */
    padding: 16px;
    box-sizing: border-box;
}

.custom-popup-content {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);

    /* maak de lightbox altijd passend in viewport */
    width: min(980px, calc(100vw - 32px));
    height: calc(100vh - 32px);
    max-height: calc(100vh - 32px);

    /* flex layout zodat de sluitknop altijd onderin zichtbaar blijft */
    display: flex;
    flex-direction: column;

    /* padding binnenin */
    padding: 16px;
    box-sizing: border-box;

    text-align: center;
    z-index: 999999;
}

/* Optioneel: iets minder breed/hoog gevoel bij image-popups */
.custom-popup-content.custom-popup-content--image {
    padding: 10px;

    /* Voor afbeeldingen willen we geen volledige viewport-hoogte. We laten de box krimpen naar de afbeelding. */
    height: auto;
    max-height: calc(100vh - 32px);
}

.custom-popup-header {
    /* header is nu leeg in PHP, dus geen ruimte reserveren */
    display: none;
}

/* Body neemt alle beschikbare ruimte, knop blijft onderin */
.digendo-popup-body {
    flex: 1 1 auto;
    overflow: auto; /* als HTML lang is, scrollt alleen de body */
    -webkit-overflow-scrolling: touch;
}

.digendo-popup-body--image {
    /* bij afbeeldingen geen interne scroll, maar echt passen */
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;

    /* Laat de body niet "oprekken" naar 1fr hoogte. Dit voorkomt grote witruimte. */
    flex: 0 1 auto;
    min-height: 0;
}

.digendo-popup-body--image .digendo-popup-image {
    /* Laat de afbeelding de beschikbare hoogte pakken zonder letterbox in een te hoge container */
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: calc(100vh - 32px - 74px);
    object-fit: contain;
}

/* Zorg dat de afbeelding volledig zichtbaar blijft */
.digendo-popup-image,
.custom-popup-content img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

/* Sluitknop altijd onderin en altijd zichtbaar */
.custom-popup-close {
    flex: 0 0 auto;

    display: block;
    width: 100%;

    margin: 12px 0 0;
    padding: 12px 14px;

    border: none;
    border-radius: 8px;
    background-color: #555;
    color: #fff;

    font-size: 16px;
    line-height: 1;
    cursor: pointer;

    /* als de body scrollt (html), knop blijft in beeld */
    position: sticky;
    bottom: 0;
}

.custom-popup-close:hover {
    background-color: #333;
}

@media (max-width: 576px) {
    .custom-popup-overlay {
        padding: 10px;
    }

    .custom-popup-content {
        width: calc(100vw - 20px);
        height: calc(100vh - 20px);
        max-height: calc(100vh - 20px);
        padding: 12px;
        border-radius: 10px;
        overflow: hidden;
    }

    .custom-popup-close {
        font-size: 16px;
        padding: 12px 14px;
    }

    .custom-popup-content.custom-popup-content--image {
        padding: 8px;
        height: auto;
        max-height: calc(100vh - 20px);
    }

    .custom-popup-close {
        margin-top: 10px;
    }

    .digendo-popup-body--image .digendo-popup-image {
        max-height: calc(100vh - 20px - 74px);
    }
}