/* ✅ Wrapper - ZERO PADDING & MARGIN */
.topup-iframe-wrapper {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0 !important;
    background-color: transparent;
    overflow: hidden;
    box-sizing: border-box;
    line-height: 0; /* ✅ FIX: Hilangkan line-height spacing */
}

/* ✅ Iframe - FIXED HEIGHT (Desktop) */
.topup-iframe-wrapper .topup-iframe {
    width: 100%;
    max-width: 100%;
    
    /* Fixed height - bukan vh */
    height: 580px;
    min-height: 400px;
    max-height: 600px;
    
    margin: 0;
    padding: 0;
    border: none;
    overflow: auto;
    display: block; /* ✅ PENTING: Block untuk hilangkan spacing */
    box-sizing: border-box;
    background: white;
    vertical-align: top; /* ✅ FIX: Hilangkan vertical spacing */
    line-height: normal; /* ✅ FIX: Reset line-height */
}

/* ✅ Override parent containers jika ada */
.topup-iframe-wrapper,
.topup-iframe-wrapper * {
    box-sizing: border-box;
}

/* Reset any parent spacing */
.wrap > .topup-iframe-wrapper {
    margin: 0 !important;
    padding: 0 !important;
}

/* ✅ FIX: Hilangkan spacing setelah wrapper */
.topup-iframe-wrapper::after {
    content: '';
    display: block;
    clear: both;
    height: 0;
    line-height: 0;
}

/* 🎨 MODAL FULLSCREEN OVERLAY */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 9998;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: block;
    opacity: 1;
}

/* 🎨 MODAL CONTAINER */
.modal-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    display: none;
    opacity: 0;
    transform: scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-container.active {
    display: block;
    opacity: 1;
    transform: scale(1);
}

/* 🎨 MODAL IFRAME - FULLSCREEN DI SEMUA DEVICE */
.modal-iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    background: white;
    z-index: 9999;
}

/* 🎨 CLOSE BUTTON */
.modal-close-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: white;
    z-index: 10000;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    pointer-events: auto;
    touch-action: manipulation;
}

.modal-close-btn:hover {
    background: rgba(237, 28, 36, 0.9);
    transform: rotate(90deg) scale(1.1);
}

.modal-close-btn:active {
    transform: rotate(90deg) scale(0.95);
}

.modal-close-btn svg {
    width: 24px;
    height: 24px;
    pointer-events: none;
}

/* ✅ Responsive untuk tablet */
@media (max-width: 1024px) {
    .topup-iframe-wrapper {
        padding: 0 !important;
        line-height: 0; /* ✅ FIX */
    }
    
    .topup-iframe-wrapper .topup-iframe {
        width: 100%;
        height: 550px;
        min-height: 400px;
        max-height: 700px;
        border-radius: 0;
        display: block; /* ✅ FIX */
        vertical-align: top; /* ✅ FIX */
    }
}

/* ✅ Responsive untuk mobile */
@media (max-width: 768px) {
    .topup-iframe-wrapper {
        padding: 0 !important;
        line-height: 0; /* ✅ FIX */
    }
    
    .topup-iframe-wrapper .topup-iframe {
        width: 100%;
        height: 500px;
        min-height: 400px;
        max-height: 600px;
        display: block; /* ✅ FIX */
        vertical-align: top; /* ✅ FIX */
    }
    
    .modal-container {
        width: 100vw !important;
        height: 100vh !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .modal-iframe {
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
    }
    
    .modal-close-btn {
        width: 44px;
        height: 44px;
        top: 16px;
        right: 16px;
        z-index: 10001;
    }
}

/* ✅ Responsive untuk mobile kecil */
@media (max-width: 480px) {
    .topup-iframe-wrapper {
        padding: 0 !important;
        line-height: 0; /* ✅ FIX */
    }
    
    .topup-iframe-wrapper .topup-iframe {
        width: 100%;
        height: 450px;
        min-height: 350px;
        max-height: 550px;
        border-radius: 0;
        display: block; /* ✅ FIX */
        vertical-align: top; /* ✅ FIX */
    }
}

/* ✅ Landscape mode untuk mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .topup-iframe-wrapper .topup-iframe {
        width: 100%;
        height: 400px;
        min-height: 300px;
        max-height: 500px;
        display: block; /* ✅ FIX */
        vertical-align: top; /* ✅ FIX */
    }
}

/* ✅ Safe area untuk modal close button SAJA */
@supports (top: env(safe-area-inset-top)) {
    .modal-close-btn {
        top: max(20px, env(safe-area-inset-top));
        right: max(20px, env(safe-area-inset-right));
    }
    
    @media (max-width: 768px) {
        .modal-close-btn {
            top: max(16px, env(safe-area-inset-top));
            right: max(16px, env(safe-area-inset-right));
        }
    }
}

/* 🎨 PREVENT BODY SCROLL WHEN MODAL ACTIVE */
body.modal-active {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}
