/* ==========================================================================
   STYLE MODAL FLYER GAMBAR LOKAL - RESPONSIVE UNIVERSAL (ALL SCREEN & RATIOS)
   ========================================================================== */

/* 1. OVERLAY (Latar Belakang Gelap) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.82); /* Optimal untuk panel AMOLED layar smartphone */
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    z-index: 99999;
    padding: 20px;
    box-sizing: border-box;
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

/* 2. KOTAK MODAL (CONTAINER UTAMA) */
.modal-box {
    background-color: #ffffff;
    border-radius: 12px;
    width: 100%;
    max-width: 450px; /* Lebar maksimal ideal kotak pop-up iklan flyer */
    box-shadow: 0 15px 35px rgba(0,0,0,0.5);
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.92) translateY(-10px);
    transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    padding: 0 !important;
}

.modal-overlay.show .modal-box {
    transform: scale(1) translateY(0);
}

/* 3. TOMBOL CLOSE (X) */
.close-btn {
    position: absolute;
    top: 3px;
    right: 3px;
    font-size: 22px;
    background: rgba(255, 255, 255, 0.94); 
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    line-height: 34px;
    cursor: pointer;
    color: #111;
    z-index: 100005; /* Harus berada di atas link gambar */
    box-shadow: 0 3px 12px rgba(0,0,0,0.3);
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

.close-btn:hover {
    color: #ff4757;
    background: #ffffff;
    transform: scale(1.05);
}

/* 4. FLYER LINK & RESPONSIFITAS GAMBAR */
.flyer-link {
    display: block;
    width: 100%;
    text-decoration: none;
    line-height: 0; /* Menghapus celah putih kecil di bawah gambar */
}

.img-flyer-responsive {
    width: 100%;
    height: auto;
    max-height: 75vh; /* Batas tinggi maksimal agar tidak tenggelam di layar desktop/tablet */
    object-fit: contain; /* Gambar mengecil secara proporsional tanpa terpotong */
    display: block;
}

/* ==========================================================================
   MEDIA QUERIES KHUSUS PERANGKAT MOBILE & LAYAR TINGGI (Samsung S24+, dll)
   ========================================================================== */

@media (max-width: 576px) {
    .modal-box {
        width: 90%; /* Memberikan margin di sisi bezel ponsel */
    }
}

/* Deteksi Layar Ultra-Tall (Rasio 19.5:9 ~513 ppi) */
@media screen and (max-aspect-ratio: 1/2) and (max-width: 480px) {
    .modal-box {
        max-width: 360px; /* Disesuaikan agar proporsi flyer terlihat pas */
    }
    .img-flyer-responsive {
        max-height: 62vh; /* Memangkas tinggi gambar secara aman pada layar kurus */
    }
}