/**
* MEGA303 FLOATING MENU (Perfect Flex Architecture Fix)
* Fixed:
* 1. Menghilangkan bug tombol melompat ke atas saat diklik menggunakan 'column-reverse'.
* 2. Posisi tombol utama statis/mati, menu dropdown akan terbuka memanjang ke atas.
* 3. Tidak akan menutupi bottom navigation bar bawaan web asli.
* 4. Live Score sebagai tombol permanen di bawah hamburger (selalu visible).
*/
(function() {
// --- 1. CLEANUP (Hapus menu lama) ---
var oldMenu = document.getElementById('mpo-floating-container');
if (oldMenu) oldMenu.remove();
// --- 2. INJECT ASSETS (FontAwesome & Font) ---
if (!document.querySelector('link[href*="font-awesome"]')) {
var faLink = document.createElement('link');
faLink.rel = 'stylesheet';
faLink.href = 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css';
document.head.appendChild(faLink);
}
if (!document.querySelector('link[href*="fonts.googleapis.com/css2?family=Outfit"]')) {
var fontLink = document.createElement('link');
fontLink.rel = 'stylesheet';
fontLink.href = 'https://fonts.googleapis.com/css2?family=Outfit:wght@700;800&display=swap';
document.head.appendChild(fontLink);
}
// --- 3. CSS STYLES ---
var css = `
:root {
--mpo-yellow: #FFC107;
--mpo-green: #004d40;
--mpo-red: #DC3545;
--mpo-android-green: #3DDC84;
}
/* Container Utama - Menggunakan column-reverse agar menu pop-up ke atas */
#mpo-floating-container {
position: fixed;
bottom: 75px; /* Jarak aman tepat di atas navigasi bawaan web */
left: 10px;
z-index: 99999;
display: flex;
flex-direction: column-reverse; /* Kunci utama: List menu tumbuh ke atas, tombol tetap di bawah */
align-items: center;
width: 60px;
gap: 12px;
}
/* --- TOMBOL TRIGGER UTAMA --- */
#mpo-trigger-btn {
width: 55px; height: 55px;
border-radius: 50%;
border: 3px solid var(--mpo-green);
background: var(--mpo-yellow);
display: flex; flex-direction: column; align-items: center; justify-content: center;
cursor: pointer;
box-shadow: 0 4px 10px rgba(0,0,0,0.5);
transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
position: relative;
box-sizing: border-box;
overflow: hidden;
}
/* --- LOGO MENU HAMBURGER (DEFAULT) --- */
.mpo-content-menu {
display: flex; flex-direction: column; align-items: center; justify-content: center;
width: 100%; height: 100%;
transition: opacity 0.2s;
padding-top: 4px;
}
/* Garis Strip Tiga */
.mpo-burger-strips {
display: flex; flex-direction: column; gap: 3px; margin-bottom: 2px;
}
.mpo-burger-strips span {
display: block; width: 24px; height: 3.5px;
background-color: var(--mpo-green); border-radius: 2px;
}
/* Text MENU */
.mpo-btn-text {
font-family: 'Outfit', sans-serif; font-size: 9px; font-weight: 800;
color: var(--mpo-green); line-height: 1;
}
/* --- LOGO CLOSE X (HIDDEN BY DEFAULT) --- */
.mpo-content-close {
display: none;
align-items: center; justify-content: center;
width: 100%; height: 100%;
font-size: 24px; color: #fff;
}
/* --- STATE: ACTIVE (MENU TERBUKA) --- */
#mpo-trigger-btn.active {
background: var(--mpo-red);
border-color: #fff;
transform: rotate(0deg);
}
#mpo-trigger-btn.active .mpo-content-menu { display: none; }
#mpo-trigger-btn.active .mpo-content-close { display: flex; }
/* --- LIST MENU (POP UP KE ATAS) --- */
#mpo-icon-list {
display: none;
flex-direction: column-reverse; /* List urut naik ke atas */
gap: 10px;
width: 100%;
align-items: center;
}
#mpo-icon-list.show { display: flex; }
/* --- ITEM MENU --- */
.mpo-menu-item {
display: block; width: 50px; height: 50px;
border-radius: 50%; border: 2px solid var(--mpo-yellow);
background: #000; overflow: hidden;
box-shadow: 0 4px 8px rgba(0,0,0,0.6);
transition: transform 0.2s ease;
opacity: 0;
transform: translateY(20px); /* Efek pop-up dari bawah ke atas */
cursor: pointer;
position: relative;
}
.mpo-menu-item:hover { transform: scale(1.15) !important; border-color: #fff; z-index: 10; }
.mpo-menu-item img { width: 100%; height: 100%; object-fit: contain; }
/* Animasi Muncul ke Atas */
@keyframes popUp { to { opacity: 1; transform: translateY(0); } }
/* --- STATIC ITEM (LIVE SCORE - Selalu Visible) --- */
.mpo-static-item {
opacity: 1 !important;
transform: translateY(0) !important;
animation: none !important;
border: 2px solid var(--mpo-yellow);
}
.mpo-static-item:hover { transform: scale(1.15) !important; border-color: #fff; z-index: 10; }
`;
// 4. INJECT CSS
var styleSheet = document.createElement("style");
styleSheet.innerText = css;
document.head.appendChild(styleSheet);
// 5. HTML STRUCTURE
// Urutan visual dari BAWAH ke ATAS (karena column-reverse):
// [Live Score] ↠paling bawah, permanen
// [MENU ðŸ”] ↠tombol hamburger
// [APK] ↠menu pop-up (tersembunyi, muncul ke atas saat dibuka)
// [Spinwheel]
// [dst...]
var htmlContent = `
`;
// 6. INJECT HTML
var container = document.createElement('div');
container.id = 'mpo-floating-container';
container.innerHTML = htmlContent;
document.body.appendChild(container);
// 7. LOGIC
var triggerBtn = document.getElementById('mpo-trigger-btn');
var iconList = document.getElementById('mpo-icon-list');
var items = document.querySelectorAll('#mpo-icon-list .mpo-menu-item'); // Hanya ambil item di dalam list, bukan static item
// -- Toggle Function --
triggerBtn.addEventListener('click', function(e) {
e.stopPropagation();
var isActive = triggerBtn.classList.contains('active');
if (isActive) {
triggerBtn.classList.remove('active');
iconList.classList.remove('show');
} else {
triggerBtn.classList.add('active');
iconList.classList.add('show');
items.forEach(function(item, index) {
item.style.animation = 'none';
item.offsetHeight;
item.style.animation = 'popUp 0.3s forwards ' + (index * 0.08) + 's';
});
}
});
// -- Close on Outside Click --
document.addEventListener('click', function(e) {
if (!container.contains(e.target) && triggerBtn.classList.contains('active')) {
triggerBtn.classList.remove('active');
iconList.classList.remove('show');
}
});
// -- Check-in Button Handler --
function triggerDailyCheckIn() {
if (typeof window.mpocashOpenDailyLogin === 'function') {
window.mpocashOpenDailyLogin();
} else if (typeof window.checkIn === 'function') {
window.checkIn();
} else if (typeof window.openModalCheckin === 'function') {
window.openModalCheckin();
} else {
console.log("Fungsi check-in asli sedang dimuat...");
var originalBtn = document.querySelector('.daily-checkin-btn-original');
if(originalBtn) originalBtn.click();
}
}
var dailyBtn = document.getElementById('mpo-daily-login');
if(dailyBtn){
dailyBtn.addEventListener('click', function(e){
e.preventDefault();
triggerDailyCheckIn();
});
}
})();