<?php
session_start();
require 'includes/db.php';

/* ===============================
   🤖 TELEGRAM CONFIG
=============================== */
function sendTelegramNotification($message) {
    $botToken = "";   // 🔴 PUT YOUR BOT TOKEN
    $chatId   = "";     // 🔴 PUT YOUR CHAT ID

    $url = "https://api.telegram.org/bot$botToken/sendMessage";

    $data = [
        'chat_id' => $chatId,
        'text' => $message
    ];

    // cURL (recommended)
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_exec($ch);
    curl_close($ch);
}

/* ===============================
   🚫 CHECK CURRENCY COOKIE
=============================== */
if (!isset($_COOKIE['currency_selected'])) {
    header("Location: choose_currency.php");
    exit;
}

$user_currency = $_COOKIE['currency_selected'];

$symbols = [
    "USD"=>"$","ZAR"=>"R","NGN"=>"₦","EUR"=>"€",
    "GBP"=>"£","CHF"=>"₣","CAD"=>"$","AUD"=>"$","INR"=>"₹"
];

$symbol = $symbols[$user_currency] ?? "";

/* ===============================
   🚀 TELEGRAM NOTIFICATION (ANTI-SPAM)
=============================== */
$ip = $_SERVER['REMOTE_ADDR'];
$user_agent = $_SERVER['HTTP_USER_AGENT'] ?? 'Unknown';

// Detect page name
$page = basename($_SERVER['PHP_SELF']);

// Notify once per IP per day
$today = date('Y-m-d');
$file = __DIR__ . "/visitors.log";
$key = $ip . "_" . $today . "_" . $page;

$logged = file_exists($file) ? file_get_contents($file) : "";

if (strpos($logged, $key) === false) {

    $message = "📄 Return Page Visit\n";
    $message .= "Page: $page\n";
    $message .= "IP: $ip\n";
    $message .= "Currency: $user_currency\n";
    $message .= "Symbol: $symbol\n";
    $message .= "Device: $user_agent\n";
    $message .= "Time: " . date("Y-m-d H:i:s");

    sendTelegramNotification($message);

    file_put_contents($file, $key . PHP_EOL, FILE_APPEND);
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Crypto Investment - Geneva & Exeter Coin</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        html {
            scroll-behavior: smooth;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
            background: linear-gradient(135deg, #4f46e5 0%, #3730a3 100%);
            min-height: 100vh;
            position: relative;
            overflow-x: hidden;
        }

        /* Animated crypto background */
        .crypto-bg {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            overflow: hidden;
            pointer-events: none;
            z-index: 0;
        }

        .crypto-icon {
            position: absolute;
            opacity: 0.05;
            color: white;
            font-size: 48px;
            font-weight: bold;
            animation: float 8s ease-in-out infinite;
        }

        .crypto-icon:nth-child(1) { top: 10%; left: 5%; transform: rotate(-15deg); font-size: 64px; animation-delay: 0s; }
        .crypto-icon:nth-child(2) { top: 70%; left: 15%; transform: rotate(10deg); font-size: 56px; animation-delay: 2s; }
        .crypto-icon:nth-child(3) { top: 30%; right: 10%; transform: rotate(-5deg); font-size: 72px; animation-delay: 4s; }
        .crypto-icon:nth-child(4) { bottom: 20%; right: 25%; transform: rotate(20deg); font-size: 48px; animation-delay: 1s; }
        .crypto-icon:nth-child(5) { top: 50%; left: 40%; transform: rotate(-10deg); font-size: 60px; animation-delay: 3s; }
        .crypto-icon:nth-child(6) { top: 20%; left: 25%; transform: rotate(5deg); font-size: 52px; animation-delay: 5s; }
        .crypto-icon:nth-child(7) { top: 60%; right: 5%; transform: rotate(-10deg); font-size: 60px; animation-delay: 6s; }
        .crypto-icon:nth-child(8) { bottom: 30%; left: 8%; transform: rotate(15deg); font-size: 44px; animation-delay: 7s; }

        @keyframes float {
            0%, 100% { transform: translateY(0) rotate(var(--rotation, 0deg)); }
            50% { transform: translateY(-20px) rotate(var(--rotation, 0deg)); }
        }

        /* Navigation */
        .navbar {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            z-index: 1000;
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 16px 48px;
            background: rgba(79, 70, 229, 0.95);
            backdrop-filter: blur(12px);
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        }

        .nav-left {
            display: flex;
            align-items: center;
            gap: 48px;
        }

       /* Logo container */
.logo {
    display: flex;
    align-items: center;
    text-decoration: none;
}

/* Logo image */
.logo-img {
    width: clamp(120px, 20vw, 180px);
    height: auto;
    display: block;
}
        /* Desktop Navigation */
        .nav-links {
            display: flex;
            gap: 32px;
            list-style: none;
        }

        .nav-links a {
            color: rgba(255, 255, 255, 0.85);
            text-decoration: none;
            font-size: 15px;
            font-weight: 500;
            transition: all 0.2s;
        }

        .nav-links a:hover {
            color: white;
        }

        .nav-right {
            display: flex;
            align-items: center;
            gap: 16px;
        }

        /* Auth Buttons */
        .auth-buttons {
            display: flex;
            gap: 12px;
        }

        .btn-signin {
            padding: 10px 20px;
            background: #22c55e;
            color: white;
            text-decoration: none;
            border-radius: 8px;
            font-size: 14px;
            font-weight: 600;
            transition: all 0.2s;
            border: none;
            cursor: pointer;
        }

        .btn-signin:hover {
            background: #16a34a;
            transform: translateY(-1px);
        }

        .btn-signup {
            padding: 10px 20px;
            background: transparent;
            color: white;
            text-decoration: none;
            border-radius: 8px;
            font-size: 14px;
            font-weight: 600;
            border: 1px solid rgba(255, 255, 255, 0.5);
            transition: all 0.2s;
            cursor: pointer;
        }

        .btn-signup:hover {
            background: rgba(255, 255, 255, 0.1);
            border-color: white;
        }

        .currency-badge {
            display: flex;
            align-items: center;
            gap: 8px;
            color: white;
            font-size: 14px;
            font-weight: 500;
            background: rgba(255, 255, 255, 0.15);
            padding: 8px 16px;
            border-radius: 20px;
        }

        .currency-badge a {
            color: rgba(255, 255, 255, 0.9);
            text-decoration: none;
            font-size: 13px;
            margin-left: 4px;
            transition: color 0.2s;
        }

        .currency-badge a:hover {
            color: white;
            text-decoration: underline;
        }

        /* Mobile Menu Toggle */
        .mobile-menu-toggle {
            display: none;
            flex-direction: column;
            gap: 5px;
            cursor: pointer;
            padding: 8px;
            background: none;
            border: none;
        }

        .mobile-menu-toggle span {
            width: 24px;
            height: 2px;
            background: white;
            transition: all 0.3s;
            border-radius: 2px;
        }

        /* Mobile Navigation Overlay */
        .mobile-nav {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(15, 23, 42, 0.98);
            z-index: 999;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 32px;
            opacity: 0;
            visibility: hidden;
            transition: all 0.3s;
        }

        .mobile-nav.active {
            opacity: 1;
            visibility: visible;
        }

        .mobile-nav-close {
            position: absolute;
            top: 20px;
            right: 20px;
            background: none;
            border: none;
            color: white;
            font-size: 32px;
            cursor: pointer;
            width: 40px;
            height: 40px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .mobile-nav-links {
            display: flex;
            flex-direction: column;
            gap: 24px;
            list-style: none;
            text-align: center;
        }

        .mobile-nav-links a {
            color: white;
            text-decoration: none;
            font-size: 24px;
            font-weight: 600;
            transition: color 0.2s;
        }

        .mobile-nav-links a:hover {
            color: #4f46e5;
        }

        .mobile-auth-buttons {
            display: flex;
            flex-direction: column;
            gap: 16px;
            width: 200px;
        }

        .mobile-auth-buttons .btn-signin,
        .mobile-auth-buttons .btn-signup {
            width: 100%;
            text-align: center;
            padding: 14px 24px;
            font-size: 16px;
        }

        /* Hero Section with Two Columns */
        .hero {
            position: relative;
            z-index: 10;
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 140px 48px 80px;
            max-width: 1400px;
            margin: 0 auto;
            gap: 64px;
            min-height: 100vh;
        }

        /* Left Content */
        .hero-content {
            flex: 1;
            max-width: 600px;
        }

        .hero-badge {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            background: rgba(255, 255, 255, 0.15);
            color: white;
            padding: 8px 16px;
            border-radius: 50px;
            font-size: 14px;
            font-weight: 500;
            margin-bottom: 24px;
            backdrop-filter: blur(10px);
        }

        .hero-badge span {
            background: #22c55e;
            color: white;
            padding: 2px 8px;
            border-radius: 12px;
            font-size: 12px;
            font-weight: 700;
        }

        .hero-title {
            font-size: 56px;
            font-weight: 800;
            color: white;
            line-height: 1.1;
            margin-bottom: 24px;
        }

        .hero-subtitle {
            font-size: 20px;
            color: rgba(255, 255, 255, 0.85);
            line-height: 1.6;
            margin-bottom: 40px;
            max-width: 480px;
        }

        .hero-features {
            display: flex;
            flex-direction: column;
            gap: 16px;
            margin-bottom: 40px;
        }

        .hero-feature {
            display: flex;
            align-items: center;
            gap: 12px;
            color: rgba(255, 255, 255, 0.9);
            font-size: 16px;
        }

        .hero-feature-icon {
            width: 24px;
            height: 24px;
            background: rgba(255, 255, 255, 0.2);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 14px;
            flex-shrink: 0;
        }

        .hero-cta {
            display: flex;
            gap: 16px;
            flex-wrap: wrap;
        }

        .btn-primary {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            padding: 16px 32px;
            background: white;
            color: #4f46e5;
            text-decoration: none;
            border-radius: 50px;
            font-size: 15px;
            font-weight: 700;
            transition: all 0.2s;
            border: none;
            cursor: pointer;
        }

        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
        }

        .btn-secondary {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            padding: 16px 32px;
            background: transparent;
            color: white;
            text-decoration: none;
            border-radius: 50px;
            font-size: 15px;
            font-weight: 600;
            border: 2px solid rgba(255, 255, 255, 0.5);
            transition: all 0.2s;
        }

        .btn-secondary:hover {
            background: rgba(255, 255, 255, 0.1);
            border-color: white;
        }

        /* Right Card */
        .card {
            background: white;
            border-radius: 20px;
            padding: 40px;
            width: 100%;
            max-width: 460px;
            box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
            flex-shrink: 0;
        }

        .card-header {
            text-align: center;
            margin-bottom: 28px;
        }

        .card-header h3 {
            font-size: 24px;
            font-weight: 800;
            color: #1e1b4b;
            margin-bottom: 8px;
        }

        .card-header p {
            font-size: 14px;
            color: #6b7280;
        }

        /* Form Elements */
        .form-group {
            margin-bottom: 20px;
        }

        .label {
            display: block;
            font-size: 13px;
            font-weight: 600;
            color: #374151;
            margin-bottom: 6px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .select-box {
            display: flex;
            border: 2px solid #e5e7eb;
            border-radius: 12px;
            overflow: hidden;
            transition: all 0.2s;
        }

        .select-box:focus-within {
            border-color: #4f46e5;
            box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
        }

        .icon {
            width: 48px;
            background: #4f46e5;
            color: white;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 18px;
            flex-shrink: 0;
        }

        select, input {
            flex: 1;
            border: none;
            padding: 12px 14px;
            font-size: 15px;
            color: #374151;
            background: white;
            outline: none;
            font-family: inherit;
        }

        select {
            cursor: pointer;
            appearance: none;
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
            background-repeat: no-repeat;
            background-position: right 12px center;
            padding-right: 32px;
        }

        .row {
            display: flex;
            border: 2px solid #e5e7eb;
            border-radius: 12px;
            overflow: hidden;
            transition: all 0.2s;
        }

        .row:focus-within {
            border-color: #4f46e5;
            box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
        }

        .row input {
            width: 50%;
            text-align: center;
            border-right: 1px solid #e5e7eb;
        }

        .row input:last-child {
            border-right: none;
            background: #f3f4f6;
            color: #6b7280;
            font-weight: 500;
        }

        .row input:first-child {
            font-weight: 600;
            color: #1e1b4b;
        }

        /* Results Section */
        .result-box {
            background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
            border: 2px solid #86efac;
            border-radius: 12px;
            padding: 20px;
            margin-top: 20px;
            text-align: center;
        }

        .result-label {
            font-size: 12px;
            font-weight: 700;
            color: #166534;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            margin-bottom: 8px;
        }

        .result-value {
            font-size: 22px;
            font-weight: 800;
            color: #15803d;
            line-height: 1.4;
        }

        .result-value span {
            font-size: 15px;
            font-weight: 600;
            color: #22c55e;
        }

        /* Disclaimer */
        .disclaimer {
            margin-top: 20px;
            padding-top: 16px;
            border-top: 1px solid #e5e7eb;

            font-size: 12px;
            color: #6b7280;
            line-height: 1.5;
            text-align: center;
        }

        .disclaimer a {
            color: #4f46e5;
            text-decoration: none;
            font-weight: 600;
        }

        .disclaimer a:hover {
            text-decoration: underline;
        }

        /* Live indicator */
        .live-indicator {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            font-size: 12px;
            color: #22c55e;
            font-weight: 600;
            margin-top: 12px;
        }

        .live-dot {
            width: 8px;
            height: 8px;
            background: #22c55e;
            border-radius: 50%;
            animation: pulse 2s infinite;
        }

        @keyframes pulse {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.5; }
        }

        /* Simple Footer */
        .footer {
            position: relative;
            z-index: 10;
            background: rgba(15, 23, 42, 0.95);
            padding: 24px 48px;
            text-align: center;
            border-top: 1px solid rgba(255, 255, 255, 0.1);
        }

        .footer p {
            color: rgba(255, 255, 255, 0.6);
            font-size: 14px;
            font-weight: 400;
        }

        /* Responsive Design */
        @media (max-width: 1024px) {
            .navbar {
                padding: 16px 24px;
            }

            .nav-links {
                display: none;
            }

            .auth-buttons {
                display: none;
            }

            .mobile-menu-toggle {
                display: flex;
            }

            .mobile-nav {
                display: flex;
            }

            .hero {
                flex-direction: column;
                padding: 100px 24px 60px;
                gap: 48px;
            }

            .hero-content {
                max-width: 100%;
                text-align: center;
            }

            .hero-title {
                font-size: 40px;
            }

            .hero-subtitle {
                max-width: 100%;
                font-size: 18px;
            }

            .hero-features {
                align-items: center;
            }

            .hero-cta {
                justify-content: center;
            }

            .card {
                max-width: 100%;
                width: 100%;
            }
        }

        @media (max-width: 640px) {
            .navbar {
                padding: 12px 20px;
            }

            .logo {
                font-size: 20px;
            }

            .logo-icon {
                width: 36px;
                height: 36px;
                font-size: 18px;
            }

            .currency-badge {
                padding: 6px 12px;
                font-size: 13px;
            }

            .hero {
                padding: 90px 20px 40px;
            }

            .hero-title {
                font-size: 32px;
            }

            .hero-badge {
                font-size: 12px;
                padding: 6px 12px;
            }

            .hero-feature {
                font-size: 14px;
            }

            .btn-primary, .btn-secondary {
                width: 100%;
                justify-content: center;
                padding: 14px 24px;
            }

            .card {
                padding: 24px;
                border-radius: 16px;
            }

            .card-header h3 {
                font-size: 20px;
            }

            .footer {
                padding: 20px 24px;
            }
        }

        @media (max-width: 380px) {
            .hero-title {
                font-size: 28px;
            }

            .card {
                padding: 20px;
            }
        }
		.btn-learn-more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 90px;
     background: linear-gradient(135deg, #4f46e5 0%, #3730a3 100%); /* Bright green */
    color: white;
    font-size: 18px;
    text-decoration: none;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.btn-learn-more:hover {
    background: #4f46e5;
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 200, 83, 0.3);
}
    </style>
</head>
<body>
    <!-- Crypto Background -->
    <div class="crypto-bg">
        <div class="crypto-icon">₿</div>
        <div class="crypto-icon">₿</div>
        <div class="crypto-icon">₿</div>
        <div class="crypto-icon">₿</div>
        <div class="crypto-icon">◊</div>
        <div class="crypto-icon">◊</div>
        <div class="crypto-icon">◎</div>
        <div class="crypto-icon">◎</div>
    </div>

    <!-- Navigation -->
    <nav class="navbar">
        <div class="nav-left">
            <a href="index.php" target="_self" class="logo">
    <img src="img/logo_white.png" class="logo-img" alt="Logo">
</a>
            <ul class="nav-links">
                <li><a href="index.php" target="_self">Home</a></li>
                <li><a href="benefit.php" target="_self">Benefit</a></li>
                <li><a href="testimonies.php" target="_self">Testimonies</a></li>
                <li><a href="contact.php" target="_self">Contact</a></li>
          </ul>
      </div>
        <div class="nav-right">
            <div class="currency-badge">
                🌍 <?php echo $user_currency; ?>
                <a href="change_currency.php">Change</a>
            </div>
            <div class="auth-buttons">
                <a href="login.php" class="btn-signin">Sign In</a>
                <a href="register.php" class="btn-signup">Sign Up</a>
            </div>
            <button class="mobile-menu-toggle" onclick="toggleMobileMenu()" aria-label="Toggle menu">
                <span></span>
                <span></span>
                <span></span>
            </button>
        </div>
    </nav>

    <!-- Mobile Navigation Overlay -->
    <div class="mobile-nav" id="mobileNav">
        <button class="mobile-nav-close" onclick="toggleMobileMenu()">×</button>
        <ul class="mobile-nav-links">
            <li><a href="index.php">Home</a></li>
            <li><a href="benefit.php">Benefit</a></li>
            <li><a href="testimonies.php">Testimonies</a></li>
            <li><a href="contact.php">Contact</a></li>
        </ul>
        <div class="mobile-auth-buttons">
            <a href="login.php" class="btn-signin">Sign In</a>
            <a href="register.php" class="btn-signup">Sign Up</a>
        </div>
    </div>

    <!-- Hero Section with Two Columns -->
    <section class="hero">
        <!-- Left Content -->
        <div class="hero-content">
            <div class="hero-badge">
                <span>NEW</span> Crypto Investment Plans
            </div>
            <h1 class="hero-title">Grow Your Crypto Assets</h1>
            <p class="hero-subtitle">
                Discover a fast, private, and secure path to grow your cryptocurrency portfolio with guaranteed returns and zero risk.
            </p>

            <div class="hero-features">
                <div class="hero-feature">
                    <div class="hero-feature-icon">✓</div>
                    <span>Guaranteed ROI regardless of market fluctuations</span>
                </div>
                <div class="hero-feature">
                    <div class="hero-feature-icon">✓</div>
                    <span>Instant withdrawals to your external wallet</span>
                </div>
                <div class="hero-feature">
                    <div class="hero-feature-icon">✓</div>
                    <span>100% privacy with encrypted communications</span>
                </div>
                <div class="hero-feature">
                    <div class="hero-feature-icon">✓</div>
                    <span>Secure offline storage for digital assets</span>
                </div>
            </div>

            <div class="hero-cta">
                <a href="#calculator" class="btn-primary">Start Investing →</a>
                <a href="learn-more.php" class="btn-secondary">Learn More</a>
            </div>
        </div>

        <!-- Right Form Card -->
        <div class="card" id="calculator">
            <div class="card-header">
                <h3>Investment Calculator</h3>
                <p>Calculate your returns with live market rates</p>
            </div>

            <!-- Asset Selection -->
            <div class="form-group">
                <label class="label">Select Asset</label>
                <div class="select-box">
                    <div class="icon">🪙</div>
                    <select id="crypto">
                        <option value="bitcoin">BTC - Bitcoin</option>
                        <option value="ethereum">ETH - Ethereum</option>
                        <option value="tether">USDT - Tether</option>
                    </select>
                </div>
            </div>

            <!-- Tenure Selection -->
            <div class="form-group">
                <label class="label">Investment Tenure</label>
                <div class="select-box">
                    <div class="icon">⏱</div>
                    <select id="tenure">
                        <option value="0.10">12 Months (10% ROI)</option>
                        <option value="0.05">6 Months (5% ROI)</option>
                        <option value="0.02">3 Months (2% ROI)</option>
                    </select>
                </div>
            </div>

            <!-- Investment Amount -->
            <div class="form-group">
                <label class="label">Investment Amount</label>
                <div class="row">
                    <input type="number" id="crypto_amount" placeholder="0.00" step="any">
                    <input type="text" id="fiat" readonly placeholder="<?php echo $user_currency; ?>" value="">
                </div>
            </div>

            <!-- Results -->
            <div class="result-box">
                <div class="result-label">Projected Returns</div>
                <div class="result-value" id="returns">
                    0.0000<br>
                    <span>(<?php echo $symbol; ?>0.00 <?php echo $user_currency; ?>)</span>
                </div>
                
            </div><br>

<div align="center"><a href="login.php" class="btn-learn-more">Learn More</a></div>
            <p class="disclaimer">
                * Prices powered by CoinGecko. ROI paid in selected crypto. 
                <a href="change_currency.php">Change currency</a>
            </p>
        </div>
    </section>

    <!-- Simple Footer -->
    <footer class="footer">
        <p>&copy; <?php echo date("Y"); ?>  Geneva & Exeter Coin. All rights reserved.</p>
    </footer>

    <script>
        // Mobile Menu Toggle
        function toggleMobileMenu() {
            const mobileNav = document.getElementById('mobileNav');
            mobileNav.classList.toggle('active');
            document.body.style.overflow = mobileNav.classList.contains('active') ? 'hidden' : '';
        }

        // Close mobile menu when clicking on a link
        document.querySelectorAll('.mobile-nav-links a').forEach(link => {
            link.addEventListener('click', () => {
                toggleMobileMenu();
            });
        });

        // ALL ORIGINAL JAVASCRIPT FUNCTIONALITY PRESERVED EXACTLY AS IS
        let cryptoPriceUSD = 0;
        let currencyRate = 1;
        let ready = false;

        // LOAD ALL RATES
        function getRates() {
            let crypto = document.getElementById("crypto").value;
            document.getElementById("fiat").value = "Loading...";

            // CoinGecko (crypto prices)
            fetch(`https://api.coingecko.com/api/v3/simple/price?ids=${crypto}&vs_currencies=usd`)
            .then(res => res.json())
            .then(data => {
                cryptoPriceUSD = data[crypto].usd;
                // Currency conversion
                return fetch("https://open.er-api.com/v6/latest/USD");
            })
            .then(res => res.json())
            .then(data => {
                currencyRate = data.rates["<?php echo $user_currency; ?>"] || 1;
                ready = true;
                update();
            })
            .catch(() => {
                document.getElementById("fiat").value = "Error loading";
                ready = true;
            });
        }

        // UPDATE EVERYTHING
        function update() {
            let amount = parseFloat(document.getElementById("crypto_amount").value);

            if (!ready) return;

            if (!amount || amount <= 0) {
                document.getElementById("fiat").value = "";
                document.getElementById("returns").innerHTML =
                    "0.0000<br><span>(<?php echo $symbol; ?>0.00 <?php echo $user_currency; ?>)</span>";
                return;
            }

            // Crypto → USD
            let usd = amount * cryptoPriceUSD;

            // USD → local
            let fiat = usd * currencyRate;

            document.getElementById("fiat").value =
                "<?php echo $symbol; ?>" + fiat.toLocaleString(undefined,{minimumFractionDigits:2});

            // ROI
            let rate = document.getElementById("tenure").value;
            let profit = amount * rate;
            let total = amount + profit;

            let totalUSD = total * cryptoPriceUSD;
            let totalFiat = totalUSD * currencyRate;

            let cryptoName = document.getElementById("crypto").selectedOptions[0].text.split(" ")[0];

            document.getElementById("returns").innerHTML =
                total.toFixed(6) + " " + cryptoName + "<br><span>(" +
                "<?php echo $symbol; ?>" +
                totalFiat.toLocaleString(undefined,{minimumFractionDigits:2}) +
                " <?php echo $user_currency; ?>)</span>";
        }

        // EVENTS
        document.getElementById("crypto_amount").addEventListener("input", update);
        document.getElementById("tenure").addEventListener("change", update);
        document.getElementById("crypto").addEventListener("change", () => {
            ready = false;
            getRates();
        });

        // INIT
        document.addEventListener("DOMContentLoaded", getRates);
    </script>
</body>
</html>