<?php
/**
 * ═══════════════════════════════════════════════════════════════════════════
 * OpenVPN | L2TP Bot - Main Entry Point
 * ═══════════════════════════════════════════════════════════════════════════
 * 
 * این فایل همه درخواست‌ها را به webhook.php هدایت می‌کند.
 * آدرس اصلی وبهوک: /webhook.php
 */

// For POST requests (Telegram webhook), redirect to webhook.php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    require __DIR__ . '/webhook.php';
    exit;
}

// For GET requests, show info page
header('Content-Type: text/html; charset=utf-8');
?>
<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>OpenVPN | L2TP Bot</title>
    <style>
        * { box-sizing: border-box; margin: 0; padding: 0; }
        body {
            font-family: Tahoma, Arial, sans-serif;
            background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 20px;
        }
        .container {
            text-align: center;
            color: #fff;
            max-width: 500px;
        }
        .logo {
            font-size: 80px;
            margin-bottom: 20px;
        }
        h1 {
            font-size: 28px;
            margin-bottom: 15px;
            text-shadow: 0 2px 10px rgba(0,0,0,0.3);
        }
        p {
            opacity: 0.8;
            line-height: 1.8;
            margin-bottom: 30px;
        }
        .links {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            justify-content: center;
        }
        .links a {
            background: rgba(255,255,255,0.1);
            color: #fff;
            text-decoration: none;
            padding: 12px 24px;
            border-radius: 8px;
            font-size: 14px;
            transition: all 0.3s;
            border: 1px solid rgba(255,255,255,0.2);
        }
        .links a:hover {
            background: rgba(255,255,255,0.2);
            transform: translateY(-2px);
        }
        .status {
            margin-top: 40px;
            padding: 15px;
            background: rgba(255,255,255,0.1);
            border-radius: 8px;
            font-size: 13px;
        }
        .status.ok { border: 1px solid #4CAF50; }
        .status.error { border: 1px solid #f44336; }
    </style>
</head>
<body>
    <div class="container">
        <div class="logo">🤖</div>
        <h1>OpenVPN | L2TP Bot</h1>
        <p>
            ربات فروش اشتراک OpenVPN | L2TP<br>
            این صفحه فقط برای اطلاعات است.
        </p>
        
        <div class="links">
            <a href="mini_app/">مینی اپ</a>
            <a href="health.php">تست سلامت</a>
            <a href="telegram_test.php">تست تلگرام</a>
        </div>
        
        <?php
        // Quick status check
        $envExists = file_exists(dirname(__DIR__) . '/.env');
        $installed = file_exists(dirname(__DIR__) . '/storage/installed.lock');
        ?>
        
        <div class="status <?= $installed ? 'ok' : 'error' ?>">
            <?php if ($installed): ?>
                ✅ ربات نصب شده و آماده استفاده است
            <?php else: ?>
                ⚠️ ربات هنوز نصب نشده - <a href="install.php" style="color: #fff;">نصب</a>
            <?php endif; ?>
        </div>
    </div>
</body>
</html>
