<?php
require_once __DIR__ . '/functions.php';
global $PACKAGES;
$mac = clean_value($_GET['mac'] ?? '', 80);
$ip = clean_value($_GET['ip'] ?? '', 80);
$loginUrl = clean_value($_GET['login_url'] ?? $_GET['link-login-only'] ?? '', 500);
$dst = clean_value($_GET['dst'] ?? $_GET['link-orig'] ?? '', 500);
?>
<!doctype html>
<html lang="bn">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Hotspot Package</title>
<style>
body{font-family:Arial,sans-serif;background:#f5f6f8;margin:0;padding:20px;color:#111}.wrap{max-width:520px;margin:20px auto}.card{background:#fff;border-radius:18px;box-shadow:0 10px 30px rgba(0,0,0,.08);padding:22px}h2{margin:0 0 6px}.muted{color:#666;font-size:14px}.pkg{display:flex;align-items:center;justify-content:space-between;border:1px solid #eee;border-radius:14px;padding:14px;margin:10px 0;text-decoration:none;color:#111;background:#fff}.pkg b{font-size:18px}.price{font-weight:700;color:#e2136e}.warn{background:#fff3cd;border:1px solid #ffe69c;border-radius:12px;padding:11px;margin:14px 0;color:#664d03;font-size:14px;line-height:1.45}.btn{background:#e2136e;color:#fff;padding:10px 14px;border-radius:10px;font-weight:bold}
</style>
</head>
<body><div class="wrap"><div class="card">
<h2>SS Telecom Packages</h2>
<p class="muted">Package select করলে bKash payment page open হবে।</p>
<?php if (!$loginUrl): ?>
<div class="warn">এই page hotspot login page থেকে open করলে auto login URL আসবে। Local computer থেকে test করলে payment হবে, কিন্তু payment success এর পর auto login নাও হতে পারে।</div>
<?php endif; ?>
<?php foreach ($PACKAGES as $key => $p):
    $url = APP_URL . '/pay.php?' . http_build_query([
        'package' => $key,
        'mac' => $mac,
        'ip' => $ip,
        'login_url' => $loginUrl,
        'dst' => $dst,
    ]);
?>
<a class="pkg" href="<?=h($url)?>"><span><b><?=h($p['label'])?></b><br><span class="muted">Profile: <?=h($p['profile'])?> / <?=h((string)$p['days'])?> day</span></span><span><span class="price">৳<?=h((string)$p['amount'])?></span><br><span class="btn">Pay</span></span></a>
<?php endforeach; ?>
</div></div></body></html>
