<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Download Bet Tips App</title>
    <meta name="description" content="Download Bet Tips - Expert betting tips and predictions">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="icon" type="image/svg+xml" href="/favicon.svg">
    <link rel="icon" type="image/x-icon" href="/favicon.ico">
    <link rel="apple-touch-icon" href="/favicon.svg">

    <style {csp-style-nonce}>
        * {
            transition: background-color 300ms ease, color 300ms ease;
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        html, body {
            color: rgba(33, 37, 41, 1);
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
            font-size: 16px;
            margin: 0;
            padding: 0;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
            text-rendering: optimizeLegibility;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
        }
        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 40px 20px;
        }
        header {
            text-align: center;
            color: white;
            margin-bottom: 60px;
        }
        header h1 {
            font-size: 3.5rem;
            font-weight: 700;
            margin-bottom: 15px;
            text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
        }
        header p {
            font-size: 1.3rem;
            opacity: 0.95;
            max-width: 600px;
            margin: 0 auto;
        }
        .download-section {
            background: white;
            border-radius: 20px;
            padding: 50px;
            box-shadow: 0 20px 60px rgba(0,0,0,0.3);
            margin-bottom: 30px;
        }
        .download-section h2 {
            font-size: 2rem;
            color: #333;
            margin-bottom: 30px;
            text-align: center;
            border-bottom: 3px solid #dd4814;
            padding-bottom: 15px;
        }
        .download-links {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 20px;
            margin-top: 30px;
        }
        .download-link {
            display: flex;
            align-items: center;
            padding: 20px;
            background: #f8f9fa;
            border: 2px solid #e9ecef;
            border-radius: 12px;
            text-decoration: none;
            color: #333;
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
        }
        .download-link:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0,0,0,0.15);
            border-color: #dd4814;
            background: #fff;
        }
        .download-link::before {
            content: '';
            position: absolute;
            top: 0;
            left: -100%;
            width: 100%;
            height: 100%;
            background: linear-gradient(90deg, transparent, rgba(221, 72, 20, 0.1), transparent);
            transition: left 0.5s;
        }
        .download-link:hover::before {
            left: 100%;
        }
        .download-icon {
            font-size: 2.5rem;
            margin-right: 15px;
            width: 60px;
            text-align: center;
        }
        .download-info {
            flex: 1;
        }
        .download-info h3 {
            font-size: 1.2rem;
            margin-bottom: 5px;
            color: #dd4814;
        }
        .download-info p {
            font-size: 0.9rem;
            color: #666;
            margin: 0;
        }
        .no-links {
            text-align: center;
            padding: 40px;
            color: #666;
        }
        .no-links p {
            font-size: 1.1rem;
            margin-bottom: 10px;
        }
        .features {
            background: white;
            border-radius: 20px;
            padding: 50px;
            box-shadow: 0 20px 60px rgba(0,0,0,0.3);
            margin-top: 30px;
        }
        .features h2 {
            font-size: 2rem;
            color: #333;
            margin-bottom: 30px;
            text-align: center;
            border-bottom: 3px solid #dd4814;
            padding-bottom: 15px;
        }
        .features-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 30px;
            margin-top: 30px;
        }
        .feature-item {
            text-align: center;
            padding: 20px;
        }
        .feature-icon {
            font-size: 3rem;
            margin-bottom: 15px;
        }
        .feature-item h3 {
            font-size: 1.3rem;
            color: #333;
            margin-bottom: 10px;
        }
        .feature-item p {
            color: #666;
            line-height: 1.6;
        }
        footer {
            text-align: center;
            color: white;
            margin-top: 50px;
            padding: 30px 20px;
        }
        footer a {
            color: white;
            text-decoration: none;
            margin: 0 15px;
            opacity: 0.9;
            transition: opacity 0.3s;
        }
        footer a:hover {
            opacity: 1;
            text-decoration: underline;
        }
        @media (max-width: 768px) {
            header h1 {
                font-size: 2.5rem;
            }
            header p {
                font-size: 1.1rem;
            }
            .download-section, .features {
                padding: 30px 20px;
            }
            .download-links {
                grid-template-columns: 1fr;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <header>
            <h1>🎯 Bet Tips</h1>
            <p>Expert betting tips and predictions from verified tipsters. Download now and start making smarter betting decisions!</p>
        </header>

        <div class="download-section">
            <h2>📱 Download the App</h2>
            <?php 
            // Filter out any null/empty/invalid values from the array
            $validLinks = array_filter($downloadLinks, function($link) {
                return !empty($link) && 
                       $link !== 'null' && 
                       trim($link) !== '' &&
                       filter_var(trim($link), FILTER_VALIDATE_URL) !== false;
            });
            
            if (empty($validLinks)): ?>
                <div class="no-links">
                    <p>Download links are currently being configured.</p>
                    <p>Please check back soon or contact support for assistance.</p>
                </div>
            <?php else: ?>
                <div class="download-links">
                    <?php 
                    // Only show links that are set and not empty/null - use the original array but with strict checks
                    if (isset($downloadLinks['apk']) && !empty($downloadLinks['apk']) && $downloadLinks['apk'] !== 'null' && trim($downloadLinks['apk']) !== '' && filter_var(trim($downloadLinks['apk']), FILTER_VALIDATE_URL) !== false): 
                        $apkUrl = trim($downloadLinks['apk']);
                    ?>
                        <a href="<?= esc($apkUrl, 'attr') ?>" class="download-link" target="_blank" rel="noopener noreferrer">
                            <div class="download-icon">📦</div>
                            <div class="download-info">
                                <h3>Direct APK Download</h3>
                                <p>Download APK file directly</p>
                            </div>
                        </a>
                    <?php endif; ?>

                    <?php if (isset($downloadLinks['googlePlay']) && !empty($downloadLinks['googlePlay']) && $downloadLinks['googlePlay'] !== 'null' && trim($downloadLinks['googlePlay']) !== '' && filter_var(trim($downloadLinks['googlePlay']), FILTER_VALIDATE_URL) !== false): 
                        $googlePlayUrl = trim($downloadLinks['googlePlay']);
                    ?>
                        <a href="<?= esc($googlePlayUrl, 'attr') ?>" class="download-link" target="_blank" rel="noopener noreferrer">
                            <div class="download-icon">🟢</div>
                            <div class="download-info">
                                <h3>Google Play Store</h3>
                                <p>Download from Play Store</p>
                            </div>
                        </a>
                    <?php endif; ?>

                    <?php if (isset($downloadLinks['appStore']) && !empty($downloadLinks['appStore']) && $downloadLinks['appStore'] !== 'null' && trim($downloadLinks['appStore']) !== '' && filter_var(trim($downloadLinks['appStore']), FILTER_VALIDATE_URL) !== false): 
                        $appStoreUrl = trim($downloadLinks['appStore']);
                    ?>
                        <a href="<?= esc($appStoreUrl, 'attr') ?>" class="download-link" target="_blank" rel="noopener noreferrer">
                            <div class="download-icon">🍎</div>
                            <div class="download-info">
                                <h3>Apple App Store</h3>
                                <p>Download from App Store</p>
                            </div>
                        </a>
                    <?php endif; ?>

                    <?php if (isset($downloadLinks['huawei']) && !empty($downloadLinks['huawei']) && $downloadLinks['huawei'] !== 'null' && trim($downloadLinks['huawei']) !== '' && filter_var(trim($downloadLinks['huawei']), FILTER_VALIDATE_URL) !== false): 
                        $huaweiUrl = trim($downloadLinks['huawei']);
                    ?>
                        <a href="<?= esc($huaweiUrl, 'attr') ?>" class="download-link" target="_blank" rel="noopener noreferrer">
                            <div class="download-icon">🔴</div>
                            <div class="download-info">
                                <h3>Huawei AppGallery</h3>
                                <p>Download from AppGallery</p>
                            </div>
                        </a>
                    <?php endif; ?>

                    <?php if (isset($downloadLinks['oppo']) && !empty($downloadLinks['oppo']) && $downloadLinks['oppo'] !== 'null' && trim($downloadLinks['oppo']) !== '' && filter_var(trim($downloadLinks['oppo']), FILTER_VALIDATE_URL) !== false): 
                        $oppoUrl = trim($downloadLinks['oppo']);
                    ?>
                        <a href="<?= esc($oppoUrl, 'attr') ?>" class="download-link" target="_blank" rel="noopener noreferrer">
                            <div class="download-icon">🟠</div>
                            <div class="download-info">
                                <h3>OPPO App Market</h3>
                                <p>Download from OPPO Store</p>
                            </div>
                        </a>
                    <?php endif; ?>
                </div>
            <?php endif; ?>
        </div>

        <div class="features">
            <h2>✨ Key Features</h2>
            <div class="features-grid">
                <div class="feature-item">
                    <div class="feature-icon">📊</div>
                    <h3>Expert Tipsters</h3>
                    <p>Access tips from verified tipsters with transparent success rates and detailed statistics</p>
                </div>
                <div class="feature-item">
                    <div class="feature-icon">⚽</div>
                    <h3>Multi-Sport Coverage</h3>
                    <p>Get predictions for Soccer, NBA, Tennis, and more major sports leagues</p>
                </div>
                <div class="feature-item">
                    <div class="feature-icon">💎</div>
                    <h3>Premium Tips</h3>
                    <p>Unlock premium tickets for expert predictions with flexible payment options</p>
                </div>
                <div class="feature-item">
                    <div class="feature-icon">💰</div>
                    <h3>Secure Payments</h3>
                    <p>Quick and secure Mobile Money integration with MTN and Airtel support</p>
                </div>
                <div class="feature-item">
                    <div class="feature-icon">📈</div>
                    <h3>Betting Calculator</h3>
                    <p>Calculate potential winnings and odds with our built-in calculator</p>
                </div>
                <div class="feature-item">
                    <div class="feature-icon">🔔</div>
                    <h3>Smart Notifications</h3>
                    <p>Stay informed about new tips, updates, and opportunities</p>
                </div>
            </div>
        </div>

        <footer>
            <p>
                <a href="/privacy-policy.html">Privacy Policy</a> |
                <a href="mailto:support@bettips.com">Contact Support</a>
            </p>
            <p style="margin-top: 15px; opacity: 0.8;">
                &copy; <?= date('Y') ?> Bet Tips. All rights reserved.
            </p>
            <p style="margin-top: 10px; font-size: 0.9rem; opacity: 0.7;">
                Please gamble responsibly. Bet Tips provides information for entertainment purposes only.
            </p>
        </footer>
    </div>
</body>
</html>
