// ✅ Top Tab Switcher — HOT GAMES / FAVORITES / SLOTS
let currentTopTab = 'hot';

function switchTopTab(tab) {
    currentTopTab = tab;
    const tabs = { hot: 'topTabHot', favorites: 'topTabFav', slots: 'topTabSlots' };
    Object.keys(tabs).forEach(key => {
        const btn = document.getElementById(tabs[key]);
        if (!btn) return;
        if (key === tab) {
            btn.className = 'bg-[#053d3d] text-cyan-300 px-2 py-3 rounded-2xl flex items-center justify-center gap-2 text-base font-extrabold border border-teal-600 whitespace-nowrap';
        } else {
            btn.className = 'bg-[#022828] text-gray-300 px-2 py-3 rounded-2xl flex items-center justify-center gap-2 text-base font-bold border border-teal-900/60 whitespace-nowrap';
        }
    });

    const grid = document.getElementById('hotGamesGrid');
    const title = document.getElementById('topSectionTitle');
    const seeAll = document.getElementById('topSectionSeeAll');
    if (!grid || !title || !seeAll) return;

    if (tab === 'hot') {
        title.textContent = 'HOT GAMES';
        seeAll.style.display = 'inline-block';
        seeAll.href = '/newcategorygames.php?category=popular&title=Hot%20Games';
        loadGameSection('hotGamesGrid', '/get_all_games_merged.php?category=popular&page=1&limit=6');
    } else if (tab === 'slots') {
        title.textContent = 'SLOTS';
        seeAll.style.display = 'inline-block';
        seeAll.href = '/newslots.php';
        loadPopularSlots('hotGamesGrid', 6);
    } else if (tab === 'favorites') {
        title.textContent = 'FAVORITES';
        seeAll.style.display = 'none';
        renderGameCards(grid, getFavorites());
    }
}
