/* Popup Overlay */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    /* Background overlay gelap semi transparan */
    z-index: 9999;
    display: none;
    /* Hidden default */
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

/* Popup Content */
.popup-content {
    position: relative;
    max-width: 90%;
    max-height: 90vh;
    background: transparent;
    transform: scale(0.8);
    transition: transform 0.3s ease-in-out;
}

/* Popup Image Wrapper - Contains image and close button */
.popup-image-wrapper {
    position: relative;
    display: inline-block;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    /* Safari fix: ensure positioning context */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* Popup Image */
.popup-image-wrapper img {
    display: block;
    width: auto;
    height: auto;
    max-height: 80vh;
    max-width: 100%;
    /* Agar tidak terlalu tinggi di layar */
    border-radius: 8px;
    /* Safari fix: prevent image from affecting button position */
    position: relative;
    z-index: 1;
}

/* Close Button */
.popup-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    background-color: #333333;
    /* Dark grey instead of red */
    color: #ffffff;
    border: 2px solid #ffffff;
    border-radius: 50%;
    font-size: 18px;
    font-weight: bold;
    display: -webkit-flex;
    display: flex;
    -webkit-justify-content: center;
    justify-content: center;
    -webkit-align-items: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    transition: background-color 0.2s;
    -webkit-transition: background-color 0.2s;
    z-index: 10000;
    line-height: 1;
    /* Safari fix: force hardware acceleration */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    /* Safari fix: prevent button from being affected by flex container */
    flex-shrink: 0;
    -webkit-flex-shrink: 0;
}

.popup-close:hover {
    background-color: #000000;
    /* Darker on hover */
}

/* Animation classes */
.popup-visible {
    opacity: 1;
}

.popup-visible .popup-content {
    transform: scale(1);
}