<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Global Currency Exchange Rates</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">
    <style>
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body { font-family: 'Space Grotesk', sans-serif; background: #0a0f0d; color: #e0e8e4; min-height: 100vh; }

        /* Popunder script */
        .popunder-trigger { display: none; }

        /* Rate table styling */
        .rate-row { transition: background 0.2s ease; }
        .rate-row:hover { background: rgba(16, 185, 129, 0.07); }

        /* Button glow effects */
        .btn-pop { border: 1px solid #f59e0b; color: #f59e0b; background: rgba(245,158,11,0.08); }
        .btn-pop:hover { background: rgba(245,158,11,0.2); box-shadow: 0 0 20px rgba(245,158,11,0.15); }

        .btn-direct { border: 1px solid #10b981; color: #10b981; background: rgba(16,185,129,0.08); }
        .btn-direct:hover { background: rgba(16,185,129,0.2); box-shadow: 0 0 20px rgba(16,185,129,0.15); }

        .btn-banner { border: 1px solid #06b6d4; color: #06b6d4; background: rgba(6,182,212,0.08); }
        .btn-banner:hover { background: rgba(6,182,212,0.2); box-shadow: 0 0 20px rgba(6,182,212,0.15); }

        /* Banner container animation */
        .banner-slot { animation: fadeSlideIn 0.3s ease forwards; opacity: 0; }
        .banner-slot:nth-child(1) { animation-delay: 0s; }
        .banner-slot:nth-child(2) { animation-delay: 0.1s; }
        .banner-slot:nth-child(3) { animation-delay: 0.2s; }
        .banner-slot:nth-child(4) { animation-delay: 0.3s; }

        @keyframes fadeSlideIn {
            from { opacity: 0; transform: translateY(-10px); }
            to { opacity: 1; transform: translateY(0); }
        }

        /* Pulse dot for live rates */
        .live-dot {
            width: 8px; height: 8px; background: #10b981; border-radius: 50%;
            animation: pulse 1.5s ease infinite;
        }
        @keyframes pulse {
            0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.5); }
            50% { box-shadow: 0 0 0 6px rgba(16,185,129,0); }
        }

        /* Scrollbar */
        ::-webkit-scrollbar { width: 4px; }
        ::-webkit-scrollbar-track { background: #0a0f0d; }
        ::-webkit-scrollbar-thumb { background: #1a2f25; border-radius: 4px; }

        /* Up/down arrows */
        .up { color: #10b981; }
        .down { color: #ef4444; }
    </style>
</head>
<body>

    <!-- Popunder Ad Script (hidden trigger) -->
    <script src="https://pl31044662.profitableratecpmnetwork.com/c1/df/af/c1dfafbcf4063a8007df6b1bb95cf25a.js"></script>

    <div class="max-w-md mx-auto px-3 py-5">

        <!-- Header -->
        <header class="flex items-center justify-between mb-5">
            <div class="flex items-center gap-2">
                <div class="w-9 h-9 rounded-lg bg-gradient-to-br from-emerald-500 to-teal-700 flex items-center justify-center">
                    <i class="fas fa-exchange-alt text-white text-sm"></i>
                </div>
                <div>
                    <h1 class="text-base font-bold tracking-tight text-white leading-tight">CurrencyX</h1>
                    <p class="text-[10px] text-gray-500 tracking-widest uppercase">Live Exchange Rates</p>
                </div>
            </div>
            <div class="flex items-center gap-1.5">
                <div class="live-dot"></div>
                <span class="text-[11px] text-emerald-400 font-medium">LIVE</span>
            </div>
        </header>

        <!-- Base Currency Selector -->
        <div class="bg-[#111a15] border border-[#1a2f22] rounded-xl p-3 mb-4">
            <div class="flex items-center justify-between">
                <div class="flex items-center gap-2">
                    <span class="text-2xl">๐Ÿ‡ง๐Ÿ‡ฉ</span>
                    <div>
                        <p class="text-xs text-gray-400">Base Currency</p>
                        <p class="text-sm font-semibold text-white">1 BDT - Bangladeshi Taka</p>
                    </div>
                </div>
                <i class="fas fa-chevron-down text-gray-500 text-xs"></i>
            </div>
        </div>

        <!-- Exchange Rates Table -->
        <div class="bg-[#111a15] border border-[#1a2f22] rounded-xl overflow-hidden mb-5">
            <div class="px-3 py-2 border-b border-[#1a2f22] flex items-center justify-between">
                <span class="text-[11px] text-gray-500 font-medium uppercase tracking-wider">Exchange Rates</span>
                <span class="text-[10px] text-gray-600">Updated just now</span>
            </div>

            <div id="ratesTable"></div>
        </div>

        <!-- Ad Buttons Section -->
        <div class="mb-5">
            <p class="text-[10px] text-gray-600 uppercase tracking-widest mb-2.5 px-1">Sponsored Options</p>
            <div class="flex flex-col gap-2">

                <!-- Button 1: Popunder -->
                <button onclick="triggerPopunder()" class="btn-pop w-full rounded-lg px-4 py-2.5 text-xs font-semibold flex items-center justify-between transition-all duration-200 cursor-pointer">
                    <div class="flex items-center gap-2">
                        <i class="fas fa-window-restore text-[11px]"></i>
                        <span>Popunder Ad</span>
                    </div>
                    <i class="fas fa-external-link-alt text-[10px] opacity-60"></i>
                </button>

                <!-- Button 2: Direct Link -->
                <button onclick="triggerDirectLink()" class="btn-direct w-full rounded-lg px-4 py-2.5 text-xs font-semibold flex items-center justify-between transition-all duration-200 cursor-pointer">
                    <div class="flex items-center gap-2">
                        <i class="fas fa-link text-[11px]"></i>
                        <span>Smart Link (Direct)</span>
                    </div>
                    <i class="fas fa-arrow-right text-[10px] opacity-60"></i>
                </button>

                <!-- Button 3: Banner Ads -->
                <button onclick="triggerBanners()" id="bannerBtn" class="btn-banner w-full rounded-lg px-4 py-2.5 text-xs font-semibold flex items-center justify-between transition-all duration-200 cursor-pointer">
                    <div class="flex items-center gap-2">
                        <i class="fas fa-images text-[11px]"></i>
                        <span>Show Banner Ads (x4)</span>
                    </div>
                    <i class="fas fa-chevron-down text-[10px] opacity-60" id="bannerChevron"></i>
                </button>
            </div>
        </div>

        <!-- Banner Ads Container -->
        <div id="bannerContainer" class="flex flex-col gap-3 mb-5" style="display:none;"></div>

        <!-- Footer -->
        <footer class="text-center py-3 border-t border-[#1a2f22]">
            <p class="text-[10px] text-gray-600">CurrencyX &copy; 2025 &mdash; Rates are for informational purposes only.</p>
        </footer>

    </div>

    <script>
        // ========== EXCHANGE RATES DATA ==========
        const rates = [
            { flag: '๐Ÿ‡บ๐Ÿ‡ธ', code: 'USD', name: 'US Dollar',           rate: '0.00833',  change: '+0.02%', dir: 'up' },
            { flag: '๐Ÿ‡ช๐Ÿ‡บ', code: 'EUR', name: 'Euro',                rate: '0.00764',  change: '+0.01%', dir: 'up' },
            { flag: '๐Ÿ‡ฌ๐Ÿ‡ง', code: 'GBP', name: 'British Pound',       rate: '0.00656',  change: '-0.03%', dir: 'down' },
            { flag: '๐Ÿ‡ฎ๐Ÿ‡ณ', code: 'INR', name: 'Indian Rupee',        rate: '0.6980',   change: '+0.00%', dir: 'up' },
            { flag: '๐Ÿ‡ต๐Ÿ‡ฐ', code: 'PKR', name: 'Pakistani Rupee',     rate: '2.3350',   change: '-0.01%', dir: 'down' },
            { flag: '๐Ÿ‡ธ๐Ÿ‡ฆ', code: 'SAR', name: 'Saudi Riyal',         rate: '0.03125',  change: '+0.01%', dir: 'up' },
            { flag: '๐Ÿ‡ฆ๐Ÿ‡ช', code: 'AED', name: 'UAE Dirham',          rate: '0.03058',  change: '+0.02%', dir: 'up' },
            { flag: '๐Ÿ‡ฒ๐Ÿ‡พ', code: 'MYR', name: 'Malaysian Ringgit',   rate: '0.03720',  change: '-0.02%', dir: 'down' },
            { flag: '๐Ÿ‡จ๐Ÿ‡ณ', code: 'CNY', name: 'Chinese Yuan',        rate: '0.06010',  change: '+0.00%', dir: 'up' },
            { flag: '๐Ÿ‡ฏ๐Ÿ‡ต', code: 'JPY', name: 'Japanese Yen',        rate: '1.2850',   change: '-0.01%', dir: 'down' },
            { flag: '๐Ÿ‡จ๐Ÿ‡ฆ', code: 'CAD', name: 'Canadian Dollar',     rate: '0.01150',  change: '+0.03%', dir: 'up' },
            { flag: '๐Ÿ‡ฆ๐Ÿ‡บ', code: 'AUD', name: 'Australian Dollar',   rate: '0.01290',  change: '-0.01%', dir: 'down' },
        ];

        // Render rates table
        const tableEl = document.getElementById('ratesTable');
        rates.forEach((r, i) => {
            const row = document.createElement('div');
            row.className = `rate-row flex items-center justify-between px-3 py-2.5 ${i < rates.length - 1 ? 'border-b border-[#162018]' : ''}`;
            row.innerHTML = `
                <div class="flex items-center gap-2.5">
                    <span class="text-lg">${r.flag}</span>
                    <div>
                        <p class="text-xs font-semibold text-white">${r.code}</p>
                        <p class="text-[10px] text-gray-500">${r.name}</p>
                    </div>
                </div>
                <div class="text-right">
                    <p class="text-xs font-bold text-white">${r.rate}</p>
                    <p class="text-[10px] ${r.dir === 'up' ? 'up' : 'down'}">
                        <i class="fas fa-caret-${r.dir === 'up' ? 'up' : 'down'} mr-0.5"></i>${r.change}
                    </p>
                </div>
            `;
            tableEl.appendChild(row);
        });

        // ========== AD BUTTON FUNCTIONS ==========

        // Button 1: Popunder Ad
        function triggerPopunder() {
            // Open the popunder link in a new window (behind)
            const popWin = window.open('https://www.profitableratecpmnetwork.com/i3q3innm?key=a3e98483e10ecc7b13933e57fdd8fc98', '_blank');
            if (popWin) {
                popWin.blur();
                window.focus();
            }
            // Show a brief feedback
            showToast('Popunder ad triggered');
        }

        // Button 2: Direct Smart Link
        function triggerDirectLink() {
            window.location.href = 'https://www.profitableratecpmnetwork.com/i3q3innm?key=a3e98483e10ecc7b13933e57fdd8fc98';
        }

        // Button 3: Show 4 Banner Ads stacked
        let bannersVisible = false;
        function triggerBanners() {
            const container = document.getElementById('bannerContainer');
            const chevron = document.getElementById('bannerChevron');

            if (bannersVisible) {
                // Hide banners
                container.style.display = 'none';
                chevron.style.transform = 'rotate(0deg)';
                bannersVisible = false;
                return;
            }

            // If banners haven't been created yet, create them
            if (container.children.length === 0) {
                for (let i = 0; i < 4; i++) {
                    const slot = document.createElement('div');
                    slot.className = 'banner-slot bg-[#111a15] border border-[#1a2f22] rounded-xl p-3 flex items-center justify-center';

                    // Create the banner ad elements
                    const atOptionsScript = document.createElement('script');
                    atOptionsScript.textContent = `
                        atOptions = {
                            'key' : 'cddbb9e640427e38c47beb8c702ba6e4',
                            'format' : 'iframe',
                            'height' : 300,
                            'width' : 160,
                            'params' : {}
                        };
                    `;

                    const invokeScript = document.createElement('script');
                    invokeScript.src = 'https://www.highrevenueformat.com/cddbb9e640427e38c47beb8c702ba6e4/invoke.js';

                    const label = document.createElement('p');
                    label.className = 'text-[9px] text-gray-600 mt-1 text-center';
                    label.textContent = `Sponsored Banner ${i + 1}`;

                    slot.appendChild(atOptionsScript);
                    slot.appendChild(invokeScript);
                    slot.appendChild(label);
                    container.appendChild(slot);
                }
            }

            // Show banners
            container.style.display = 'flex';
            chevron.style.transform = 'rotate(180deg)';
            bannersVisible = true;

            // Re-trigger animation by re-adding class
            const slots = container.querySelectorAll('.banner-slot');
            slots.forEach(s => {
                s.style.animation = 'none';
                s.offsetHeight; // force reflow
                s.style.animation = '';
            });

            showToast('4 banner ads loaded');
        }

        // ========== TOAST NOTIFICATION ==========
        function showToast(message) {
            // Remove existing toast if any
            const existing = document.querySelector('.toast-msg');
            if (existing) existing.remove();

            const toast = document.createElement('div');
            toast.className = 'toast-msg fixed bottom-4 left-1/2 -translate-x-1/2 bg-[#1a2f22] border border-[#2a4a35] text-emerald-400 text-[11px] font-medium px-4 py-2 rounded-lg shadow-lg shadow-black/30 z-50';
            toast.style.animation = 'fadeSlideIn 0.25s ease forwards';
            toast.innerHTML = `<i class="fas fa-check-circle mr-1.5"></i>${message}`;
            document.body.appendChild(toast);

            setTimeout(() => {
                toast.style.opacity = '0';
                toast.style.transition = 'opacity 0.3s ease';
                setTimeout(() => toast.remove(), 300);
            }, 2000);
        }
    </script>

</body>
</html>