<!DOCTYPE html>
<html lang="bn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Moto AI Predictor - Hybrid</title>
    <style>
        :root { --accent: #00ff96; --bg: #0a0a0a; --card: #151515; }
        body { background: var(--bg); color: #fff; font-family: 'Segoe UI', sans-serif; display: flex; justify-content: center; align-items: center; min-height: 100vh; margin: 0; padding: 15px; }
        .container { background: var(--card); width: 100%; max-width: 450px; padding: 35px; border-radius: 30px; border: 1px solid #222; text-align: center; box-shadow: 0 15px 40px rgba(0,0,0,0.5); }
        h2 { color: var(--accent); letter-spacing: 2px; margin-bottom: 30px; text-transform: uppercase; }
        .input-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 15px; margin-bottom: 25px; }
        .input-box { width: 100%; height: 75px; background: #222; border: 2px solid #333; border-radius: 18px; color: var(--accent); font-size: 32px; font-weight: bold; text-align: center; outline: none; transition: 0.3s; }
        .input-box:focus { border-color: var(--accent); box-shadow: 0 0 15px rgba(0, 255, 150, 0.3); }
        .btn { background: var(--accent); color: #000; border: none; width: 100%; padding: 20px; border-radius: 50px; font-size: 18px; font-weight: 800; cursor: pointer; transition: 0.3s; box-shadow: 0 8px 20px rgba(0, 255, 150, 0.2); }
        .btn:hover { transform: scale(1.02); }
        .result-panel { margin-top: 35px; padding: 25px; background: #111; border-radius: 20px; border: 1px dashed #444; display: none; }
        .ball-wrap { display: flex; justify-content: center; gap: 15px; margin-top: 15px; }
        .ball { width: 55px; height: 55px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: bold; box-shadow: inset -4px -4px 8px rgba(0,0,0,0.4); }
        .c1 { background: #e74c3c; } .c2 { background: #3498db; } .c3 { background: #f1c40f; } .c4 { background: #2ecc71; } .c6 { background: #9b59b6; } .c10 { background: #e67e22; }
        .details { font-size: 11px; color: #555; margin-top: 20px; border-top: 1px solid #222; padding-top: 10px; }
    </style>
</head>
<body>

<div class="container">
    <h2>MOTO PRO AI</h2>
    <form method="POST">
        <div class="input-row">
            <input type="number" name="v1" class="input-box" placeholder="1" required>
            <input type="number" name="v2" class="input-box" placeholder="2" required>
            <input type="number" name="v3" class="input-box" placeholder="3" required>
        </div>
        <button type="submit" name="go" class="btn">অ্যানালাইসিস শুরু করুন</button>
    </form>

    <?php
    if (isset($_POST['go'])) {
        $v1 = (int)$_POST['v1']; $v2 = (int)$_POST['v2']; $v3 = (int)$_POST['v3'];
        $input_key = "$v1-$v2-$v3";
        $source = "AI Analysis Engine";

        // এডমিন ডাটাবেস চেক করা
        $db = json_decode(file_get_contents('database.json'), true);
        
        if (isset($db[$input_key])) {
            $res = $db[$input_key];
            $source = "Master Control Database (100% Correct)";
        } else {
            // যদি এডমিন সেট করা না থাকে তবে AI লজিক (হিস্ট্রি বেসড)
            $r1 = ($v2 + 3) % 10 ?: 10;
            $r2 = ($v1 + 5) % 10 ?: 10;
            $r3 = ($v3 + 1) % 10 ?: 10;
            $res = [$r1, $r2, $r3];
        }
        echo "<script>document.addEventListener('DOMContentLoaded', function() { document.querySelector('.result-panel').style.display = 'block'; });</script>";
    }
    ?>

    <div class="result-panel">
        <div style="color: var(--accent); font-weight: bold; font-size: 13px;">ফলাফল বিশ্লেষণ সম্পন্ন:</div>
        <div class="ball-wrap">
            <?php if(isset($res)): ?>
                <div class="ball c<?php echo $res[0]; ?>"><?php echo $res[0]; ?></div>
                <div class="ball c<?php echo $res[1]; ?>"><?php echo $res[1]; ?></div>
                <div class="ball c<?php echo $res[2]; ?>"><?php echo $res[2]; ?></div>
            <?php endif; ?>
        </div>
        <div class="details">
            বিশ্লেষণ টাইপ: <?php echo $source; ?><br>
            টাইমস্ট্যাম্প: <?php echo date("Y-m-d H:i:s"); ?>
        </div>
    </div>
</div>

</body>
</html>