<?php
/**
 * Binary Options Trading Platform - Landing Page
 */

require_once 'config/config.php';



require_once 'config/database.php';
require_once 'includes/functions.php';
require_once 'includes/SEO.php';

// Handle SEO redirects
handleSEORedirects();

// Get site settings
$siteName = getSetting('site_name', 'BinaryPro');
$siteEmail = getSetting('site_email', 'support@example.com');
$sitePhone = getSetting('site_phone', '+91 9664608792');

// Get some stats for display
$totalUsers = dbCount('users');
$totalTrades = dbCount('trades', "is_demo = 0");
$totalPayout = dbFetch("SELECT COALESCE(SUM(actual_profit), 0) as total FROM trades WHERE result = 'won' AND is_demo = 0")['total'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <?= seo()->renderMetaTags($siteName . ' - Binary Options Trading Platform') ?>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <?= seo()->renderSchema() ?>
    <?= seo()->renderAnalytics() ?>
    <style>
        :root {
            --bg-primary: #0a0e17;
            --bg-secondary: #111827;
            --bg-card: #151c28;
            --bg-tertiary: #1a2332;
            --border-color: #1f2937;
            --accent-green: #00d09c;
            --accent-green-dark: #00a87a;
            --accent-red: #ff5252;
            --accent-blue: #3b82f6;
            --accent-yellow: #fbbf24;
            --accent-purple: #8b5cf6;
            --text-primary: #ffffff;
            --text-secondary: #e5e7eb;
            --text-muted: #6b7280;
            --gradient-green: linear-gradient(135deg, #00d09c 0%, #00a87a 100%);
            --gradient-red: linear-gradient(135deg, #ff5252 0%, #dc2626 100%);
            --shadow-glow: 0 0 40px rgba(0, 208, 156, 0.3);
        }
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'Inter', sans-serif;
            background: var(--bg-primary);
            color: var(--text-primary);
            line-height: 1.6;
            overflow-x: hidden;
        }
        
        a {
            color: var(--accent-green);
            text-decoration: none;
            transition: all 0.3s ease;
        }
        
        a:hover {
            color: var(--accent-green-dark);
        }
        
        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 1.5rem;
        }
        
        /* Header */
        .header {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            z-index: 1000;
            background: rgba(10, 14, 23, 0.95);
            backdrop-filter: blur(10px);
            border-bottom: 1px solid var(--border-color);
        }
        
        .header-inner {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 1rem 0;
        }
        
        .logo {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            font-size: 1.5rem;
            font-weight: 700;
            color: var(--text-primary);
        }
        
        .logo-icon {
            width: 42px;
            height: 42px;
            background: var(--gradient-green);
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.25rem;
        }
        
        .nav {
            display: flex;
            align-items: center;
            gap: 2rem;
        }
        
        .nav-link {
            color: var(--text-secondary);
            font-weight: 500;
            transition: color 0.3s;
        }
        
        .nav-link:hover {
            color: var(--accent-green);
        }
        
        .nav-buttons {
            display: flex;
            gap: 0.75rem;
        }
        
        .btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 0.5rem;
            padding: 0.75rem 1.5rem;
            font-size: 0.9375rem;
            font-weight: 600;
            border-radius: 8px;
            border: none;
            cursor: pointer;
            transition: all 0.3s ease;
        }
        
        .btn-primary {
            background: var(--gradient-green);
            color: white;
        }
        
        .btn-primary:hover {
            box-shadow: var(--shadow-glow);
            transform: translateY(-2px);
        }
        
        .btn-secondary {
            background: transparent;
            color: var(--text-primary);
            border: 1px solid var(--border-color);
        }
        
        .btn-secondary:hover {
            border-color: var(--accent-green);
            color: var(--accent-green);
        }
        
        .btn-lg {
            padding: 1rem 2rem;
            font-size: 1rem;
        }
        
        /* Hero Section */
        .hero {
            min-height: 100vh;
            display: flex;
            align-items: center;
            padding-top: 80px;
            position: relative;
            overflow: hidden;
        }
        
        .hero::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: radial-gradient(circle at 30% 20%, rgba(0, 208, 156, 0.1) 0%, transparent 50%),
                        radial-gradient(circle at 70% 80%, rgba(59, 130, 246, 0.1) 0%, transparent 50%);
            pointer-events: none;
        }
        
        .hero-content {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 4rem;
            align-items: center;
            position: relative;
            z-index: 1;
        }
        
        .hero-badge {
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.5rem 1rem;
            background: rgba(0, 208, 156, 0.1);
            border: 1px solid rgba(0, 208, 156, 0.3);
            border-radius: 50px;
            font-size: 0.875rem;
            color: var(--accent-green);
            margin-bottom: 1.5rem;
        }
        
        .hero-title {
            font-size: 3.5rem;
            font-weight: 800;
            line-height: 1.1;
            margin-bottom: 1.5rem;
        }
        
        .hero-title span {
            background: var(--gradient-green);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        
        .hero-description {
            font-size: 1.25rem;
            color: var(--text-muted);
            margin-bottom: 2rem;
            max-width: 500px;
        }
        
        .hero-buttons {
            display: flex;
            gap: 1rem;
            margin-bottom: 3rem;
        }
        
        .hero-stats {
            display: flex;
            gap: 3rem;
        }
        
        .stat-item {
            text-align: center;
        }
        
        .stat-value {
            font-size: 2rem;
            font-weight: 700;
            color: var(--accent-green);
        }
        
        .stat-label {
            font-size: 0.875rem;
            color: var(--text-muted);
        }
        
        /* Hero Visual */
        .hero-visual {
            position: relative;
        }
        
        .mockup-desktop {
            display: block;
            width: 100%;
            border-radius: 20px;
            box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
            animation: float 6s ease-in-out infinite;
            border: 1px solid var(--border-color);
        }
        
        .mockup-mobile {
            display: none;
            max-width: 70%;
            margin: 0 auto;
            border-radius: 20px;
            box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
            animation: float 6s ease-in-out infinite;
            border: 1px solid var(--border-color);
        }
        
        /* Features Section */
        .features {
            padding: 6rem 0;
            position: relative;
        }
        
        .section-header {
            text-align: center;
            max-width: 600px;
            margin: 0 auto 4rem;
        }
        
        .section-title {
            font-size: 2.5rem;
            font-weight: 700;
            margin-bottom: 1rem;
        }
        
        .section-description {
            color: var(--text-muted);
            font-size: 1.125rem;
        }
        
        .features-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 2rem;
        }
        
        .feature-card {
            background: var(--bg-card);
            border: 1px solid var(--border-color);
            border-radius: 16px;
            padding: 2rem;
            transition: all 0.3s ease;
        }
        
        .feature-card:hover {
            border-color: var(--accent-green);
            transform: translateY(-5px);
        }
        
        .feature-icon {
            width: 56px;
            height: 56px;
            background: rgba(0, 208, 156, 0.1);
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.5rem;
            color: var(--accent-green);
            margin-bottom: 1.5rem;
        }
        
        .feature-title {
            font-size: 1.25rem;
            font-weight: 600;
            margin-bottom: 0.75rem;
        }
        
        .feature-description {
            color: var(--text-muted);
            font-size: 0.9375rem;
        }
        
        /* Assets Section */
        .assets {
            padding: 6rem 0;
            background: var(--bg-secondary);
        }
        
        .assets-grid {
            display: grid;
            grid-template-columns: repeat(6, 1fr);
            gap: 1rem;
        }
        
        .asset-card {
            background: var(--bg-card);
            border: 1px solid var(--border-color);
            border-radius: 12px;
            padding: 1.5rem;
            text-align: center;
            transition: all 0.3s;
        }
        
        .asset-card:hover {
            border-color: var(--accent-green);
        }
        
        .asset-icon {
            width: 48px;
            height: 48px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            margin: 0 auto 1rem;
            font-weight: 700;
            font-size: 0.875rem;
        }
        
        .asset-icon.btc { background: #f7931a; }
        .asset-icon.eth { background: #627eea; }
        .asset-icon.bnb { background: #f3ba2f; color: #000; }
        .asset-icon.xrp { background: #23292f; }
        .asset-icon.sol { background: linear-gradient(135deg, #9945ff, #14f195); }
        .asset-icon.eur { background: #3b82f6; color: #fff; }
        
        .asset-name {
            font-weight: 600;
            margin-bottom: 0.25rem;
        }
        
        .asset-payout {
            color: var(--accent-green);
            font-size: 0.875rem;
        }
        
        /* How It Works */
        .how-it-works {
            padding: 6rem 0;
        }
        
        .steps {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 2rem;
        }
        
        .step {
            text-align: center;
            position: relative;
        }
        
        .step:not(:last-child)::after {
            content: '';
            position: absolute;
            top: 30px;
            right: -1rem;
            width: calc(100% - 60px);
            height: 2px;
            background: linear-gradient(90deg, var(--accent-green), transparent);
        }
        
        .step-number {
            width: 60px;
            height: 60px;
            background: var(--gradient-green);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.5rem;
            font-weight: 700;
            margin: 0 auto 1.5rem;
        }
        
        .step-title {
            font-size: 1.125rem;
            font-weight: 600;
            margin-bottom: 0.5rem;
        }
        
        .step-description {
            color: var(--text-muted);
            font-size: 0.9375rem;
        }
        
        /* CTA Section */
        .cta {
            padding: 6rem 0;
            background: var(--bg-secondary);
        }
        
        .cta-box {
            background: linear-gradient(135deg, rgba(0, 208, 156, 0.1) 0%, rgba(0, 168, 122, 0.1) 100%);
            border: 1px solid rgba(0, 208, 156, 0.3);
            border-radius: 24px;
            padding: 4rem;
            text-align: center;
        }
        
        .cta-title {
            font-size: 2.5rem;
            font-weight: 700;
            margin-bottom: 1rem;
        }
        
        .cta-description {
            color: var(--text-muted);
            font-size: 1.125rem;
            max-width: 600px;
            margin: 0 auto 2rem;
        }
        
        .cta-bonus {
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.75rem 1.5rem;
            background: rgba(251, 191, 36, 0.1);
            border: 1px solid rgba(251, 191, 36, 0.3);
            border-radius: 50px;
            color: var(--accent-yellow);
            font-weight: 600;
            margin-bottom: 2rem;
        }
        
        /* Footer */
        .footer {
            padding: 4rem 0 2rem;
            border-top: 1px solid var(--border-color);
        }
        
        .footer-grid {
            display: grid;
            grid-template-columns: 2fr 1fr 1fr 1fr;
            gap: 3rem;
            margin-bottom: 3rem;
        }
        
        .footer-brand {
            max-width: 300px;
        }
        
        .footer-brand .logo {
            margin-bottom: 1rem;
        }
        
        .footer-brand p {
            color: var(--text-muted);
            font-size: 0.9375rem;
        }
        
        .footer-title {
            font-size: 1rem;
            font-weight: 600;
            margin-bottom: 1.5rem;
        }
        
        .footer-links {
            list-style: none;
        }
        
        .footer-links li {
            margin-bottom: 0.75rem;
        }
        
        .footer-links a {
            color: var(--text-muted);
            font-size: 0.9375rem;
        }
        
        .footer-links a:hover {
            color: var(--accent-green);
        }
        
        .footer-bottom {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding-top: 2rem;
            border-top: 1px solid var(--border-color);
        }
        
        .footer-copyright {
            color: var(--text-muted);
            font-size: 0.875rem;
        }
        
        .footer-social {
            display: flex;
            gap: 1rem;
        }
        
        .footer-social a {
            width: 40px;
            height: 40px;
            background: var(--bg-card);
            border: 1px solid var(--border-color);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--text-muted);
            transition: all 0.3s;
        }
        
        .footer-social a:hover {
            border-color: var(--accent-green);
            color: var(--accent-green);
        }
        
        /* Mobile Menu */
        .mobile-menu-btn {
            display: none;
            background: none;
            border: none;
            color: var(--text-primary);
            font-size: 1.5rem;
            cursor: pointer;
        }
        
        /* Responsive */
        @media (max-width: 1024px) {
            .hero-content {
                grid-template-columns: 1fr;
                text-align: center;
            }
            
            .hero-description {
                margin: 0 auto 2rem;
            }
            
            .hero-buttons {
                justify-content: center;
            }
            
            .hero-stats {
                justify-content: center;
            }
            
            .hero-visual {
                margin-top: 3rem;
            }
            
            .mockup-desktop {
                display: none;
            }
            
            .mockup-mobile {
                display: block;
            }
            
            .features-grid {
                grid-template-columns: repeat(2, 1fr);
            }
            
            .assets-grid {
                grid-template-columns: repeat(3, 1fr);
            }
            
            .steps {
                grid-template-columns: repeat(2, 1fr);
            }
            
            .step::after {
                display: none;
            }
            
            .footer-grid {
                grid-template-columns: repeat(2, 1fr);
            }
        }
        
        @media (max-width: 768px) {
            .nav {
                display: none;
            }
            
            .header-inner {
                gap: 0.5rem;
            }

            .logo {
                font-size: 1.25rem;
            }

            .logo span {
                white-space: nowrap;
            }
            
            .nav-buttons .btn {
                padding: 0.5rem 0.75rem;
                font-size: 0.8rem;
                white-space: nowrap;
            }
            
            .nav-buttons .btn-secondary {
                display: none;
            }
            
            .mobile-menu-btn {
                display: block;
            }
            
            .hero {
                padding-top: 120px;
            }
            
            .hero-title {
                font-size: 2rem;
                line-height: 1.2;
                word-wrap: break-word;
            }

            .hero-description {
                font-size: 1rem;
                padding: 0 0.5rem;
            }
            
            .hero-buttons {
                flex-direction: column;
                gap: 1rem;
                width: 100%;
            }

            .hero-buttons .btn {
                width: 100%;
                justify-content: center;
            }

            .hero-stats {
                flex-wrap: wrap;
                gap: 1.5rem;
                justify-content: space-around;
            }

            .stat-value {
                font-size: 1.5rem;
            }
            
            .features-grid,
            .steps {
                grid-template-columns: 1fr;
            }
            
            .assets-grid {
                grid-template-columns: repeat(2, 1fr);
            }
            
            .cta-box {
                padding: 2rem;
            }
            
            .footer-grid {
                grid-template-columns: 1fr;
            }
            
            .footer-bottom {
                flex-direction: column;
                gap: 1rem;
            }
        }
        
        /* Animations */
        @keyframes float {
            0%, 100% { transform: translateY(0); }
            50% { transform: translateY(-10px); }
        }
        
        .mockup-desktop, .mockup-mobile {
            animation: float 6s ease-in-out infinite;
        }
        
        @keyframes pulse {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.5; }
        }
        
        .chart-line::before {
            animation: pulse 1.5s ease-in-out infinite;
        }
    </style>
</head>
<body>
    <!-- Header -->
    <header class="header">
        <div class="container">
            <div class="header-inner">
                <a href="<?= SITE_URL ?>" class="logo">
                    <div class="logo-icon">
                        <i class="fas fa-chart-line"></i>
                    </div>
                    <span><?= $siteName ?></span>
                </a>
                
                <nav class="nav">
                    <a href="#features" class="nav-link">Features</a>
                    <a href="#assets" class="nav-link">Assets</a>
                    <a href="#how-it-works" class="nav-link">How It Works</a>
                    <?php if(isset($_SESSION['user_id'])): ?>
                        <a href="user/dashboard.php" class="nav-link">Dashboard</a>
                    <?php endif; ?>
                </nav>
                
                <div class="nav-buttons">
                    <?php if(isset($_SESSION['user_id'])): ?>
                        <a href="user/trade.php" class="btn btn-secondary">Trade Now</a>
                        <a href="user/dashboard.php" class="btn btn-primary">
                            <i class="fas fa-user-circle"></i>
                            Dashboard
                        </a>
                    <?php else: ?>
                        <a href="user/login.php" class="btn btn-secondary">Login</a>
                        <a href="user/register.php" class="btn btn-primary">
                            <i class="fas fa-rocket"></i>
                            Start Trading
                        </a>
                    <?php endif; ?>
                </div>
                
                <button class="mobile-menu-btn" id="mobileMenuBtn">
                    <i class="fas fa-bars"></i>
                </button>
            </div>
        </div>
    </header>
    
    <!-- Hero Section -->
    <section class="hero">
        <div class="container">
            <div class="hero-content">
                <div class="hero-text">
                    <div class="hero-badge">
                        <i class="fas fa-bolt"></i>
                        <span>Live Trading • 24/7 Markets</span>
                    </div>
                    
                    <h1 class="hero-title">
                        Trade Crypto with<br>
                        <span>Up to 95% Profit</span>
                    </h1>
                    
                    <p class="hero-description">
                        Start trading cryptocurrencies in seconds. Real-time charts, instant execution, and withdrawals within 24 hours.
                    </p>
                    
                    <div class="hero-buttons">
                        <?php if(isset($_SESSION['user_id'])): ?>
                            <a href="user/trade.php" class="btn btn-primary btn-lg">
                                <i class="fas fa-chart-line"></i>
                                Go to Trading Chart
                            </a>
                            <a href="user/dashboard.php" class="btn btn-secondary btn-lg">
                                <i class="fas fa-wallet"></i>
                                View Dashboard
                            </a>
                        <?php else: ?>
                            <a href="user/register.php" class="btn btn-primary btn-lg">
                                <i class="fas fa-user-plus"></i>
                                Create Free Account
                            </a>
                            <a href="user/register.php?demo=1" class="btn btn-secondary btn-lg">
                                <i class="fas fa-play"></i>
                                Try Demo Account
                            </a>
                        <?php endif; ?>
                    </div>
                    
                    <div class="hero-stats">
                        <div class="stat-item">
                            <div class="stat-value"><?= number_format($totalUsers) ?>+</div>
                            <div class="stat-label">Active Traders</div>
                        </div>
                        <div class="stat-item">
                            <div class="stat-value"><?= number_format($totalTrades) ?>+</div>
                            <div class="stat-label">Trades Executed</div>
                        </div>
                        <div class="stat-item">
                            <div class="stat-value"><?= formatCurrency($totalPayout) ?></div>
                            <div class="stat-label">Total Payouts</div>
                        </div>
                    </div>
                </div>
                
                <div class="hero-visual">
                    <img src="assets/images/dashboard.png" alt="Trading Dashboard" class="mockup-desktop">
                    <img src="assets/images/app-mockup.png" alt="Mobile Trading App" class="mockup-mobile">
                </div>
            </div>
        </div>
    </section>
    
    <!-- Features Section -->
    <section class="features" id="features">
        <div class="container">
            <div class="section-header">
                <h2 class="section-title">Why Choose <?= $siteName ?>?</h2>
                <p class="section-description">
                    We provide the best trading experience with cutting-edge technology and unmatched features.
                </p>
            </div>
            
            <div class="features-grid">
                <div class="feature-card">
                    <div class="feature-icon">
                        <i class="fas fa-bolt"></i>
                    </div>
                    <h3 class="feature-title">Instant Execution</h3>
                    <p class="feature-description">
                        Trade execution in milliseconds with real-time price feeds from Binance.
                    </p>
                </div>
                
                <div class="feature-card">
                    <div class="feature-icon">
                        <i class="fas fa-chart-line"></i>
                    </div>
                    <h3 class="feature-title">Live Charts</h3>
                    <p class="feature-description">
                        Professional TradingView charts with multiple timeframes and indicators.
                    </p>
                </div>
                
                <div class="feature-card">
                    <div class="feature-icon">
                        <i class="fas fa-percentage"></i>
                    </div>
                    <h3 class="feature-title">High Payouts</h3>
                    <p class="feature-description">
                        Earn up to 95% profit on successful trades. Industry-leading payout rates.
                    </p>
                </div>
                
                <div class="feature-card">
                    <div class="feature-icon">
                        <i class="fas fa-wallet"></i>
                    </div>
                    <h3 class="feature-title">Fast Withdrawals</h3>
                    <p class="feature-description">
                        Withdraw your profits within 24 hours via UPI, bank transfer, or crypto.
                    </p>
                </div>
                
                <div class="feature-card">
                    <div class="feature-icon">
                        <i class="fas fa-shield-alt"></i>
                    </div>
                    <h3 class="feature-title">Secure Platform</h3>
                    <p class="feature-description">
                        Bank-grade security with SSL encryption and two-factor authentication.
                    </p>
                </div>
                
                <div class="feature-card">
                    <div class="feature-icon">
                        <i class="fas fa-headset"></i>
                    </div>
                    <h3 class="feature-title">24/7 Support</h3>
                    <p class="feature-description">
                        Our dedicated support team is available around the clock to assist you.
                    </p>
                </div>
            </div>
        </div>
    </section>
    
    <!-- Assets Section -->
    <section class="assets" id="assets">
        <div class="container">
            <div class="section-header">
                <h2 class="section-title">Trade Popular Assets</h2>
                <div style="display: flex; justify-content: center; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1.5rem;">
                    <span class="hero-badge" style="margin-bottom: 0;">Crypto</span>
                    <span class="hero-badge" style="margin-bottom: 0;">Forex</span>
                    <span class="hero-badge" style="margin-bottom: 0;">Stocks</span>
                    <span class="hero-badge" style="margin-bottom: 0;">Commodities</span>
                    <span class="hero-badge" style="margin-bottom: 0;">Indices</span>
                </div>
                <p class="section-description">
                    Trade the most popular Crypto, Forex, Stocks, Commodities, and Indices with high payout rates.
                </p>
            </div>
            
            <div class="assets-grid">
                <div class="asset-card">
                    <div class="asset-icon btc">₿</div>
                    <div class="asset-name">Bitcoin</div>
                    <div class="asset-payout">Up to 95%</div>
                </div>
                
                <div class="asset-card">
                    <div class="asset-icon eth">Ξ</div>
                    <div class="asset-name">Ethereum</div>
                    <div class="asset-payout">Up to 92%</div>
                </div>
                
                <div class="asset-card">
                    <div class="asset-icon bnb">BNB</div>
                    <div class="asset-name">BNB</div>
                    <div class="asset-payout">Up to 90%</div>
                </div>
                
                <div class="asset-card">
                    <div class="asset-icon xrp">XRP</div>
                    <div class="asset-name">Ripple</div>
                    <div class="asset-payout">Up to 88%</div>
                </div>
                
                <div class="asset-card">
                    <div class="asset-icon sol">SOL</div>
                    <div class="asset-name">Solana</div>
                    <div class="asset-payout">Up to 90%</div>
                </div>
                
                <div class="asset-card">
                    <div class="asset-icon eur">€</div>
                    <div class="asset-name">EUR/USD</div>
                    <div class="asset-payout">Up to 85%</div>
                </div>
            </div>
        </div>
    </section>
    
    <!-- How It Works -->
    <section class="how-it-works" id="how-it-works">
        <div class="container">
            <div class="section-header">
                <h2 class="section-title">How It Works</h2>
                <p class="section-description">
                    Start trading in just 4 simple steps. It's fast, easy, and secure.
                </p>
            </div>
            
            <div class="steps">
                <div class="step">
                    <div class="step-number">1</div>
                    <h3 class="step-title">Create Account</h3>
                    <p class="step-description">Sign up for free in under a minute. No documents required to start.</p>
                </div>
                
                <div class="step">
                    <div class="step-number">2</div>
                    <h3 class="step-title">Deposit Funds</h3>
                    <p class="step-description">Add funds using UPI, bank transfer, or cryptocurrency. Min ₹500.</p>
                </div>
                
                <div class="step">
                    <div class="step-number">3</div>
                    <h3 class="step-title">Start Trading</h3>
                    <p class="step-description">Choose an asset, predict UP or DOWN, and place your trade.</p>
                </div>
                
                <div class="step">
                    <div class="step-number">4</div>
                    <h3 class="step-title">Withdraw Profits</h3>
                    <p class="step-description">Win up to 95% profit. Withdraw anytime, processed in 24 hours.</p>
                </div>
            </div>
        </div>
    </section>
    
    <!-- CTA Section -->
    <section class="cta">
        <div class="container">
            <div class="cta-box">
                <div class="cta-bonus">
                    <i class="fas fa-gift"></i>
                    Get 100% Welcome Bonus on First Deposit!
                </div>
                
                <h2 class="cta-title">Ready to Start Trading?</h2>
                <p class="cta-description">
                    Join thousands of traders and start earning today. Create your free account and get ₹10,000 demo balance to practice.
                </p>
                
                <a href="user/register.php" class="btn btn-primary btn-lg">
                    <i class="fas fa-rocket"></i>
                    Create Free Account Now
                </a>
            </div>
        </div>
    </section>
    
    <!-- Footer -->
    <footer class="footer">
        <div class="container">
            <div class="footer-grid">
                <div class="footer-brand">
                    <a href="<?= SITE_URL ?>" class="logo">
                        <div class="logo-icon">
                            <i class="fas fa-chart-line"></i>
                        </div>
                        <span><?= $siteName ?></span>
                    </a>
                    <p>The most trusted binary options trading platform. Trade cryptocurrencies with confidence.</p>
                </div>
                
                <div>
                    <h4 class="footer-title">Quick Links</h4>
                    <ul class="footer-links">
                        <li><a href="user/register.php">Create Account</a></li>
                        <li><a href="user/login.php">Login</a></li>
                        <li><a href="#features">Features</a></li>
                        <li><a href="#assets">Assets</a></li>
                    </ul>
                </div>
                
                <div>
                    <h4 class="footer-title">Legal</h4>
                    <ul class="footer-links">
                        <li><a href="terms.php">Terms & Conditions</a></li>
                        <li><a href="privacy.php">Privacy Policy</a></li>
                        <li><a href="risk.php">Risk Disclosure</a></li>
                        <li><a href="aml.php">AML Policy</a></li>
                    </ul>
                </div>
                
                <div>
                    <h4 class="footer-title">Support</h4>
                    <ul class="footer-links">
                        <li><a href="#" onclick="openLiveChat()"><i class="fas fa-comments"></i> Live Chat</a></li>
                        <li><a href="user/support.php"><i class="fas fa-headset"></i> Help Center</a></li>
                        <li><a href="tel:<?= $sitePhone ?>"><i class="fas fa-phone"></i> <?= $sitePhone ?></a></li>
                    </ul>
                </div>
            </div>
            
            <div class="footer-bottom">
                <div class="footer-copyright">
                    © <?= date('Y') ?> <?= $siteName ?>. All rights reserved. Powered by <a href="https://arbudahost.com" target="_blank">Arbuda IT</a>
                </div>
                
                <div class="footer-social">
                    <a href="#" title="Facebook"><i class="fab fa-facebook-f"></i></a>
                    <a href="#" title="Twitter"><i class="fab fa-twitter"></i></a>
                    <a href="#" title="Instagram"><i class="fab fa-instagram"></i></a>
                    <a href="#" title="Telegram"><i class="fab fa-telegram-plane"></i></a>
                </div>
            </div>
        </div>
    </footer>
    
    <!-- Real Live Chat Widget for Logged In Users -->
    <?php if (isset($_SESSION['user_id'])): ?>
    <div id="liveChatWidget" class="live-chat-widget">
        <div class="chat-header">
            <div class="chat-header-info">
                <div class="chat-avatar"><i class="fas fa-headset"></i></div>
                <div><div class="chat-title">Live Support</div><div class="chat-status">Online</div></div>
            </div>
            <button class="chat-close" onclick="closeLiveChat()"><i class="fas fa-times"></i></button>
        </div>
        <div class="chat-messages" id="chatMessages">
            <div class="chat-loading"><i class="fas fa-spinner fa-spin"></i> Connecting...</div>
        </div>
        <div class="chat-input-area">
            <input type="text" id="chatInput" placeholder="Type your message..." onkeypress="if(event.key==='Enter')sendChatMessage()">
            <button onclick="sendChatMessage()"><i class="fas fa-paper-plane"></i></button>
        </div>
    </div>
    
    <button class="live-chat-btn" id="liveChatBtn" onclick="openLiveChat()">
        <i class="fas fa-comments"></i>
    </button>
    
    <style>
        .live-chat-widget{position:fixed;bottom:20px;right:20px;width:350px;height:450px;background:var(--bg-card);border-radius:16px;box-shadow:0 10px 40px rgba(0,0,0,0.3);display:none;flex-direction:column;z-index:9999;overflow:hidden;border:1px solid var(--border-color)}
        .live-chat-widget.active{display:flex}
        .chat-header{display:flex;align-items:center;justify-content:space-between;padding:1rem;background:var(--accent-green);color:#000}
        .chat-header-info{display:flex;align-items:center;gap:0.75rem}
        .chat-avatar{width:40px;height:40px;border-radius:50%;background:#fff;display:flex;align-items:center;justify-content:center;font-size:1.2rem;color:var(--accent-green)}
        .chat-title{font-weight:600}
        .chat-status{font-size:0.75rem;opacity:0.8}
        .chat-close{background:none;border:none;color:#000;font-size:1.2rem;cursor:pointer}
        .chat-messages{flex:1;padding:1rem;overflow-y:auto}
        .chat-message{margin-bottom:1rem;display:flex;flex-direction:column}
        .chat-message.user{align-items:flex-end}
        .chat-message.bot{align-items:flex-start}
        .message-content{max-width:80%;padding:0.75rem 1rem;border-radius:12px;font-size:0.9rem}
        .chat-message.user .message-content{background:var(--accent-green);color:#000;border-bottom-right-radius:4px}
        .chat-message.bot .message-content{background:var(--bg-tertiary);border-bottom-left-radius:4px}
        .message-time{font-size:0.7rem;color:var(--text-muted);margin-top:0.25rem}
        .chat-input-area{display:flex;padding:1rem;border-top:1px solid var(--border-color);gap:0.5rem}
        .chat-input-area input{flex:1;padding:0.75rem;border-radius:8px;border:1px solid var(--border-color);background:var(--bg-primary);color:var(--text-primary);outline:none}
        .chat-input-area button{width:40px;height:40px;border-radius:8px;border:none;background:var(--accent-green);color:#000;cursor:pointer}
        .live-chat-btn{position:fixed;bottom:20px;right:20px;width:60px;height:60px;border-radius:50%;background:var(--accent-green);color:#000;border:none;font-size:1.5rem;cursor:pointer;box-shadow:0 4px 20px rgba(0,208,156,0.4);z-index:9998}
        @media(max-width:768px){.live-chat-widget{width:100%;height:100%;bottom:0;right:0;border-radius:0}}
    </style>
    
    <script>
        // Real Chat Functions
        let chatOpen = false;
        let chatId = null;
        let lastMessageId = 0;
        let chatPollInterval = null;

        function openLiveChat() {
            document.getElementById('liveChatWidget').classList.add('active');
            chatOpen = true;
            initChat();
        }
        
        function closeLiveChat() {
            document.getElementById('liveChatWidget').classList.remove('active');
            chatOpen = false;
        }
        
        function initChat() {
            fetch('user/live-chat.php', {
                method: 'POST',
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                body: 'action=init'
            })
            .then(r => r.json())
            .then(d => {
                if (d.success) {
                    chatId = d.chat_id;
                    const container = document.getElementById('chatMessages');
                    container.innerHTML = '';
                    
                    if (d.messages && d.messages.length > 0) {
                        d.messages.forEach(msg => appendMessage(msg));
                        lastMessageId = d.messages[d.messages.length - 1].id;
                    } else {
                        container.innerHTML = `
                            <div class="chat-message bot">
                                <div class="message-content">Hello! 👋 How can I help you today?</div>
                                <div class="message-time">Just now</div>
                            </div>
                        `;
                    }
                    scrollToBottom();
                    startPolling();
                }
            });
        }
        
        function appendMessage(msg) {
            const container = document.getElementById('chatMessages');
            const isUser = msg.is_admin == 0;
            const type = isUser ? 'user' : 'bot';
            const time = new Date(msg.created_at).toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'});
            
            const div = document.createElement('div');
            div.className = `chat-message ${type}`;
            div.innerHTML = `<div class="message-content">${msg.message}</div><div class="message-time">${time}</div>`;
            container.appendChild(div);
        }
        
        function scrollToBottom() {
            const container = document.getElementById('chatMessages');
            if(container) container.scrollTop = container.scrollHeight;
        }
        
        function sendChatMessage() {
            const input = document.getElementById('chatInput');
            const msg = input.value.trim();
            if (!msg || !chatId) return;
            
            const container = document.getElementById('chatMessages');
            const time = new Date().toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'});
            container.innerHTML += `<div class="chat-message user"><div class="message-content">${msg}</div><div class="message-time">${time}</div></div>`;
            scrollToBottom();
            input.value = '';
            
            fetch('user/live-chat.php', {
                method: 'POST',
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                body: `action=send_message&chat_id=${chatId}&message=${encodeURIComponent(msg)}`
            });
        }
        
        function startPolling() {
            if (chatPollInterval) clearInterval(chatPollInterval);
            chatPollInterval = setInterval(() => {
                if (!chatOpen || !chatId) return;
                
                fetch('user/live-chat.php', {
                    method: 'POST',
                    headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                    body: `action=get_messages&chat_id=${chatId}&last_id=${lastMessageId}`
                })
                .then(r => r.json())
                .then(d => {
                    if (d.success && d.messages && d.messages.length > 0) {
                        d.messages.forEach(msg => {
                            if (msg.is_admin == 1) {
                                appendMessage(msg);
                            }
                            lastMessageId = Math.max(lastMessageId, msg.id);
                        });
                        scrollToBottom();
                    }
                });
            }, 3000);
        }
    </script>
    <?php else: ?>
    <!-- Guest Chat Button (Redirects to Login) -->
    <button class="live-chat-btn" onclick="location.href='user/login.php'" title="Login to Chat">
        <i class="fas fa-comments"></i>
    </button>
    <style>
        .live-chat-btn{position:fixed;bottom:20px;right:20px;width:60px;height:60px;border-radius:50%;background:var(--accent-green);color:#000;border:none;font-size:1.5rem;cursor:pointer;box-shadow:0 4px 20px rgba(0,208,156,0.4);z-index:9998;transition:transform 0.3s}
        .live-chat-btn:hover{transform:scale(1.1)}
    </style>
    <?php endif; ?>

    <script>
        // Smooth scroll
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function(e) {
                e.preventDefault();
                const target = document.querySelector(this.getAttribute('href'));
                if (target) {
                    target.scrollIntoView({ behavior: 'smooth', block: 'start' });
                }
            });
        });
        
        // Live BTC price
        async function updateBtcPrice() {
            try {
                const res = await fetch('https://api.binance.com/api/v3/ticker/price?symbol=BTCUSDT');
                const data = await res.json();
                const price = parseFloat(data.price).toLocaleString('en-US', {
                    style: 'currency',
                    currency: 'USD'
                });
                document.getElementById('btcPrice').textContent = price;
            } catch (e) {}
        }
        
        updateBtcPrice();
        setInterval(updateBtcPrice, 5000);
        
        // Mobile menu
        const mobileBtn = document.getElementById('mobileMenuBtn');
        const nav = document.querySelector('.nav');
        if(mobileBtn && nav) {
            mobileBtn.addEventListener('click', function() {
                nav.style.display = nav.style.display === 'flex' ? 'none' : 'flex';
                if(nav.style.display === 'flex') {
                    nav.style.flexDirection = 'column';
                    nav.style.position = 'absolute';
                    nav.style.top = '100%';
                    nav.style.left = '0';
                    nav.style.right = '0';
                    nav.style.background = 'rgba(10, 14, 23, 0.95)';
                    nav.style.padding = '1rem';
                    nav.style.borderBottom = '1px solid var(--border-color)';
                }
            });
        }
    </script>
</body>
</html>
