<?php
/*
|--------------------------------------------------------------------------
| RadyoHost.BiZ / Okey Platformu
|--------------------------------------------------------------------------
| Sayfa Adı : Premium Paket Talep Et
| Dosya     : customer/renew-package.php
|--------------------------------------------------------------------------
| Açıklama:
| Üyenin packages tablosundaki aktif Gold, Premium ve VIP paketleri
| görüp seçerek yönetimden paket talebi oluşturduğu premium sayfadır.
|--------------------------------------------------------------------------
| Modül     : Müşteri Paneli
| Yetki     : Üye
| Sürüm     : V2.0
|--------------------------------------------------------------------------
| Developed By VoLKaN75
|--------------------------------------------------------------------------
*/

declare(strict_types=1);

require_once __DIR__ . '/../config/db.php';

if (session_status() !== PHP_SESSION_ACTIVE) {
    session_start();
}

$pdo = $pdo ?? $db ?? null;

if (!$pdo instanceof PDO) {
    die('Veritabanı bağlantısı bulunamadı.');
}

if (empty($_SESSION['user_id']) && empty($_SESSION['customer_id'])) {
    header('Location: ../login.php');
    exit;
}

$userId = (int)($_SESSION['user_id'] ?? $_SESSION['customer_id']);

function e(string $v): string
{
    return htmlspecialchars($v, ENT_QUOTES, 'UTF-8');
}

function tr_date(?string $date): string
{
    if (!$date || $date === '0000-00-00' || $date === '0000-00-00 00:00:00') {
        return 'Belirtilmemiş';
    }

    try {
        return (new DateTime($date))->format('d.m.Y H:i');
    } catch (Throwable $e) {
        return $date;
    }
}

$success = '';
$error   = '';

$stmt = $pdo->prepare("SELECT * FROM users WHERE id = :id LIMIT 1");
$stmt->execute(['id' => $userId]);
$user = $stmt->fetch(PDO::FETCH_ASSOC);

if (!$user) {
    session_destroy();
    header('Location: ../login.php');
    exit;
}

$name  = $user['name'] ?? $user['username'] ?? 'Üye';
$email = $user['email'] ?? '-';
$phone = $user['phone'] ?? '-';
$image = !empty($user['image']) ? '../uploads/user/' . $user['image'] : '../assets/img/default-user.png';

$stmtCurrent = $pdo->prepare("
    SELECT up.*, p.title, p.amount, p.price, p.duration, p.description
    FROM user_packages up
    LEFT JOIN packages p ON p.id = up.package_id
    WHERE up.user_id = :user_id AND up.status = 'active'
    ORDER BY up.id DESC
    LIMIT 1
");
$stmtCurrent->execute(['user_id' => $userId]);
$currentPackage = $stmtCurrent->fetch(PDO::FETCH_ASSOC);

$currentName = $currentPackage['title'] ?? $currentPackage['package_name'] ?? 'Aktif Paket Yok';
$currentType = $currentPackage['package_type'] ?? '-';
$currentEnd  = $currentPackage['end_date'] ?? null;

$stmtPackages = $pdo->query("
    SELECT *
    FROM packages
    WHERE status = 'active'
    ORDER BY FIELD(package_type,'gold','premium','vip'), id DESC
");
$packages = $stmtPackages->fetchAll(PDO::FETCH_ASSOC);

$packagesByType = [
    'gold' => [],
    'premium' => [],
    'vip' => []
];

foreach ($packages as $package) {
    $type = strtolower((string)($package['package_type'] ?? ''));

    if (isset($packagesByType[$type])) {
        $packagesByType[$type][] = $package;
    }
}

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $packageId = (int)($_POST['package_id'] ?? 0);
    $note      = trim((string)($_POST['note'] ?? ''));
    $payment   = trim((string)($_POST['payment_method'] ?? 'Belirtilmedi'));

    if ($packageId <= 0) {
        $error = 'Lütfen talep etmek istediğiniz paketi seçiniz.';
    } else {
        $stmtSelected = $pdo->prepare("SELECT * FROM packages WHERE id = :id AND status = 'active' LIMIT 1");
        $stmtSelected->execute(['id' => $packageId]);
        $selected = $stmtSelected->fetch(PDO::FETCH_ASSOC);

        if (!$selected) {
            $error = 'Seçilen paket bulunamadı veya aktif değil.';
        } else {
            try {
                $ticketNo = 'PKT-' . date('Ymd') . '-' . strtoupper(substr(md5((string)microtime(true) . $userId), 0, 6));

                $message  = "Paket Talebi / Yönetim Onayı\n\n";
                $message .= "Üye Bilgileri\n";
                $message .= "Ad Soyad: {$name}\n";
                $message .= "E-Posta: {$email}\n";
                $message .= "Telefon: {$phone}\n\n";
                $message .= "Mevcut Paket\n";
                $message .= "Paket: {$currentName}\n";
                $message .= "Tür: {$currentType}\n";
                $message .= "Bitiş: " . tr_date($currentEnd) . "\n\n";
                $message .= "Talep Edilen Paket\n";
                $message .= "Paket ID: " . $selected['id'] . "\n";
                $message .= "Paket Türü: " . $selected['package_type'] . "\n";
                $message .= "Paket Adı: " . $selected['title'] . "\n";
                $message .= "Miktar: " . $selected['amount'] . "\n";
                $message .= "Fiyat: " . $selected['price'] . " TL\n";
                $message .= "Süre: " . $selected['duration'] . "\n\n";
                $message .= "Ödeme Tercihi: {$payment}\n\n";
                $message .= "Üye Notu:\n" . ($note !== '' ? $note : 'Not yazılmadı.');

                $insert = $pdo->prepare("
                    INSERT INTO tickets
                    (ticket_no, user_id, department, subject, message, priority, status, last_reply_by, last_reply_at, created_at, updated_at)
                    VALUES
                    (:ticket_no, :user_id, 'Paket Talebi', 'Paket Talebi / Yönetim Onayı', :message, 'medium', 'open', 'customer', NOW(), NOW(), NOW())
                ");

                $insert->execute([
                    'ticket_no' => $ticketNo,
                    'user_id'   => $userId,
                    'message'   => $message
                ]);

                $success = 'Paket talebiniz başarıyla yönetim ekibine gönderildi.';
            } catch (Throwable $e) {
                $error = 'Talep gönderilirken sistem hatası oluştu.';
            }
        }
    }
}

$typeInfo = [
    'gold' => ['title' => 'Gold Paketler', 'icon' => '🪙', 'class' => 'gold'],
    'premium' => ['title' => 'Premium Paketler', 'icon' => '👑', 'class' => 'premium'],
    'vip' => ['title' => 'VIP Paketler', 'icon' => '💎', 'class' => 'vip']
];
?>
<!DOCTYPE html>
<html lang="tr">
<head>
<meta charset="UTF-8">
<title>Paket Talep Et | RadyoHost Okey</title>
<meta name="viewport" content="width=device-width, initial-scale=1">

<style>
*{box-sizing:border-box}
body{
    margin:0;
    font-family:Arial,Helvetica,sans-serif;
    color:#fff;
    background:#070914;
    overflow-x:hidden;
}
body:before{
    content:"";
    position:fixed;
    inset:0;
    z-index:-2;
    background:
        radial-gradient(circle at 12% 10%,#f5b64255,transparent 28%),
        radial-gradient(circle at 88% 22%,#ff5db155,transparent 27%),
        radial-gradient(circle at 50% 92%,#3b82f655,transparent 32%),
        linear-gradient(135deg,#070914,#111827 55%,#090b16);
}
body:after{
    content:"";
    position:fixed;
    inset:0;
    background-image:
        linear-gradient(#ffffff08 1px,transparent 1px),
        linear-gradient(90deg,#ffffff08 1px,transparent 1px);
    background-size:42px 42px;
    opacity:.24;
    z-index:-1;
}
a{text-decoration:none;color:inherit}
.wrap{min-height:100vh;padding:28px}
.topbar{
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:18px;
    margin-bottom:25px;
}
.topbar h1{margin:0;font-size:31px}
.topbar p{margin:8px 0 0;color:#c6cdec;font-size:14px}
.dashboard-btn{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:10px;
    padding:15px 24px;
    border-radius:18px;
    background:linear-gradient(135deg,#f5b642,#ff5d5d,#ff5db1);
    color:#fff;
    font-size:15px;
    font-weight:900;
    box-shadow:0 15px 35px rgba(255,93,93,.38);
}
.hero{
    position:relative;
    overflow:hidden;
    border-radius:36px;
    padding:36px;
    margin-bottom:24px;
    background:linear-gradient(135deg,#151b31dd,#0d1224ee);
    border:1px solid rgba(255,255,255,.12);
    box-shadow:0 25px 90px #0009;
}
.hero:before{
    content:"";
    position:absolute;
    width:430px;
    height:430px;
    right:-145px;
    top:-165px;
    border-radius:50%;
    background:linear-gradient(135deg,#f5b64255,#ff5db155);
    filter:blur(8px);
}
.hero-inner{
    position:relative;
    display:grid;
    grid-template-columns:150px 1fr 300px;
    gap:26px;
    align-items:center;
}
.avatar img{
    width:150px;
    height:150px;
    border-radius:50%;
    object-fit:cover;
    border:5px solid #f5b642;
    box-shadow:0 0 58px #f5b64277;
}
.hero h2{margin:0 0 8px;font-size:36px}
.hero p{margin:0;color:#c6cdec;line-height:1.7}
.current-box{
    padding:24px;
    border-radius:30px;
    background:linear-gradient(135deg,#f5b64222,#ff5db122);
    border:1px solid #f5b64266;
    text-align:center;
    box-shadow:0 20px 65px #f5b64233;
}
.current-box b{display:block;font-size:22px}
.current-box span{display:block;margin-top:8px;color:#ffd37a;font-weight:900}
.alert{
    padding:16px 19px;
    border-radius:18px;
    margin-bottom:20px;
    font-weight:900;
}
.success{background:#158553}
.error{background:#b82845}
.section-title{
    margin:28px 0 16px;
    font-size:27px;
}
.package-section{
    margin-bottom:26px;
}
.package-head{
    display:flex;
    justify-content:space-between;
    align-items:flex-end;
    gap:14px;
    margin-bottom:16px;
}
.package-head h2{margin:0;font-size:26px}
.package-head p{margin:7px 0 0;color:#b8c1df;font-size:14px}
.package-grid{
    display:grid;
    grid-template-columns:repeat(3,1fr);
    gap:18px;
}
.package-option input{display:none}
.package-card{
    min-height:300px;
    cursor:pointer;
    padding:26px;
    border-radius:32px;
    background:linear-gradient(145deg,#151b31cc,#0d1224dd);
    border:1px solid #ffffff18;
    box-shadow:0 25px 80px #0009;
    position:relative;
    overflow:hidden;
    transition:.25s;
    display:flex;
    flex-direction:column;
    justify-content:space-between;
}
.package-card:before{
    content:"";
    position:absolute;
    width:230px;
    height:230px;
    right:-95px;
    top:-95px;
    border-radius:50%;
    background:var(--soft);
}
.package-card.gold{--main:#f5b642;--main2:#ff7a18;--soft:#f5b64222}
.package-card.premium{--main:#38bdf8;--main2:#8b5cf6;--soft:#38bdf822}
.package-card.vip{--main:#ff5db1;--main2:#a855f7;--soft:#ff5db122}
.package-card:hover{
    transform:translateY(-6px);
    border-color:var(--main);
}
.package-option input:checked + .package-card{
    transform:translateY(-8px);
    border-color:var(--main);
    box-shadow:0 0 0 4px var(--soft),0 25px 85px var(--soft);
}
.package-inner{position:relative}
.package-badge{
    display:inline-flex;
    padding:10px 14px;
    border-radius:999px;
    background:var(--soft);
    border:1px solid var(--main);
    color:var(--main);
    font-size:12px;
    font-weight:900;
    margin-bottom:16px;
}
.package-card h3{margin:0 0 10px;font-size:24px}
.package-card p{margin:0;color:#b8c1df;line-height:1.7;font-size:14px}
.package-meta{
    position:relative;
    display:grid;
    grid-template-columns:repeat(3,1fr);
    gap:10px;
    margin-top:18px;
}
.meta{
    padding:13px;
    border-radius:17px;
    background:#ffffff0c;
    border:1px solid #ffffff14;
}
.meta span{display:block;color:#aeb7d4;font-size:11px;margin-bottom:5px}
.meta strong{font-size:14px}
.request-area{
    margin-top:26px;
    display:grid;
    grid-template-columns:1fr 420px;
    gap:24px;
}
.request-card,.summary-card{
    padding:30px;
    border-radius:34px;
    background:linear-gradient(145deg,#151b31cc,#0d1224dd);
    border:1px solid #ffffff18;
    box-shadow:0 25px 80px #0009;
    position:relative;
    overflow:hidden;
}
.request-card:before{
    content:"";
    position:absolute;
    width:260px;
    height:260px;
    right:-120px;
    bottom:-120px;
    border-radius:50%;
    background:#ff5db122;
}
.request-inner{position:relative}
.request-card h2,.summary-card h2{
    margin:0 0 10px;
    font-size:27px;
}
.request-card p,.summary-card p{
    color:#b8c1df;
    line-height:1.7;
    margin:0 0 20px;
}
.form-grid{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:16px;
    margin-bottom:16px;
}
label{
    display:block;
    color:#d8def5;
    font-size:14px;
    font-weight:900;
    margin-bottom:8px;
}
select,textarea{
    width:100%;
    border:1px solid #ffffff18;
    background:#070d1d;
    color:#fff;
    border-radius:18px;
    padding:15px 16px;
    outline:none;
    font-size:15px;
    font-family:Arial,Helvetica,sans-serif;
}
textarea{
    min-height:170px;
    resize:vertical;
}
select:focus,textarea:focus{
    border-color:#f5b642;
    box-shadow:0 0 0 4px #f5b64222;
}
.submit-btn{
    width:100%;
    margin-top:18px;
    border:0;
    cursor:pointer;
    padding:17px 22px;
    border-radius:20px;
    background:linear-gradient(135deg,#f5b642,#ff5d5d,#ff5db1);
    color:#fff;
    font-weight:900;
    font-size:16px;
    box-shadow:0 18px 42px rgba(255,93,93,.38);
}
.process{
    display:grid;
    grid-template-columns:repeat(4,1fr);
    gap:12px;
    margin-top:20px;
}
.step{
    padding:15px;
    border-radius:18px;
    background:#ffffff0c;
    border:1px solid #ffffff14;
    text-align:center;
}
.step b{display:block;font-size:20px;margin-bottom:6px}
.step span{font-size:12px;color:#aeb7d4}
.summary-item{
    padding:16px;
    border-radius:20px;
    background:#ffffff0c;
    border:1px solid #ffffff14;
    margin-bottom:13px;
}
.summary-item span{display:block;color:#aeb7d4;font-size:12px;margin-bottom:6px}
.summary-item strong{font-size:16px}
.empty{
    padding:26px;
    border-radius:28px;
    background:#b8284522;
    border:1px solid #ff5d5d55;
    color:#fff;
    line-height:1.7;
}
.quick-actions{
    display:grid;
    grid-template-columns:repeat(4,1fr);
    gap:16px;
    margin-top:24px;
}
.quick{
    padding:20px;
    border-radius:24px;
    background:linear-gradient(145deg,#151b31cc,#0d1224dd);
    border:1px solid #ffffff14;
    box-shadow:0 18px 55px #0006;
    transition:.25s;
}
.quick:hover{transform:translateY(-5px);border-color:#f5b64288}
.quick b{display:block;font-size:17px;margin-bottom:8px}
.quick span{color:#aeb7d4;font-size:13px}
.admin-footer{
    margin-top:30px;
    padding:18px 24px;
    width:100%;
    display:grid;
    grid-template-columns:minmax(280px,1.25fr) minmax(220px,.9fr) minmax(260px,1fr);
    align-items:center;
    gap:18px;
    border-top:1px solid rgba(255,255,255,.08);
    background:linear-gradient(180deg,rgba(255,255,255,.04),rgba(255,255,255,.015));
    color:#9aa3b2;
    font-size:12px;
    font-weight:800;
    border-radius:24px;
}
.footer-left{display:flex;align-items:center;gap:6px;white-space:nowrap}
.footer-link{color:#f5b642;font-weight:900}
.footer-center{text-align:center;color:#f5b642;font-size:13px;font-weight:900}
.footer-right{display:flex;align-items:center;justify-content:flex-end;white-space:nowrap}
.footer-signature{color:#ff5db1;font-size:14px;font-weight:900}
.footer-whatsapp img{width:52px;height:52px;object-fit:contain;filter:drop-shadow(0 0 10px rgba(37,211,102,.8))}
@media(max-width:1200px){
    .hero-inner{grid-template-columns:150px 1fr}
    .current-box{grid-column:1 / -1}
    .package-grid{grid-template-columns:repeat(2,1fr)}
    .request-area{grid-template-columns:1fr}
}
@media(max-width:900px){
    .hero-inner{display:flex;flex-direction:column;text-align:center}
    .package-grid,.quick-actions{grid-template-columns:1fr}
    .process{grid-template-columns:repeat(2,1fr)}
    .admin-footer{grid-template-columns:1fr;text-align:center;justify-items:center}
    .footer-left,.footer-right{justify-content:center;flex-wrap:wrap}
}
@media(max-width:600px){
    .wrap{padding:18px}
    .topbar{flex-direction:column;align-items:flex-start}
    .hero,.request-card,.summary-card{padding:22px}
    .hero h2{font-size:28px}
    .form-grid,.package-meta,.process{grid-template-columns:1fr}
}
</style>
</head>
<body>

<div class="wrap">

    <div class="topbar">
        <div>
            <h1>Paket Talep Merkezi</h1>
            <p>Gold, Premium ve VIP paketlerden birini seç, yönetim onayına gönder.</p>
        </div>
        <a class="dashboard-btn" href="index.php">⚡ Kontrol Merkezine Dön</a>
    </div>

    <?php if ($success !== ''): ?>
        <div class="alert success"><?= e($success) ?></div>
    <?php endif; ?>

    <?php if ($error !== ''): ?>
        <div class="alert error"><?= e($error) ?></div>
    <?php endif; ?>

    <section class="hero">
        <div class="hero-inner">
            <div class="avatar">
                <img src="<?= e((string)$image) ?>" alt="Profil Resmi">
            </div>

            <div>
                <h2><?= e((string)$name) ?></h2>
                <p><?= e((string)$email) ?></p>
                <p>
                    Paketi sen seçersin, yönetim onaylar. Onay sonrası paket hesabına tanımlanır.
                    Bu alan sadece talep oluşturur, otomatik paket değiştirme yapmaz.
                </p>
            </div>

            <div class="current-box">
                <b><?= e((string)$currentName) ?></b>
                <span>Mevcut Paket • <?= e(strtoupper((string)$currentType)) ?></span>
                <span>Bitiş: <?= e(tr_date($currentEnd)) ?></span>
            </div>
        </div>
    </section>

    <?php if (empty($packages)): ?>
        <div class="empty">
            Yönetim tarafından aktif edilmiş paket bulunamadı.
            Admin panelinden `packages` tablosunda paket durumu aktif yapılınca burada görünecektir.
        </div>
    <?php else: ?>

    <form method="post" id="packageForm">

        <?php foreach ($typeInfo as $type => $info): ?>
            <section class="package-section">
                <div class="package-head">
                    <div>
                        <h2><?= e($info['icon'] . ' ' . $info['title']) ?></h2>
                        <p>Yönetim tarafından aktif edilen <?= e($info['title']) ?> listesi.</p>
                    </div>
                </div>

                <?php if (empty($packagesByType[$type])): ?>
                    <div class="empty">Bu kategoride aktif paket bulunmuyor.</div>
                <?php else: ?>
                    <div class="package-grid">
                        <?php foreach ($packagesByType[$type] as $package): ?>
                            <label class="package-option">
                                <input
                                    type="radio"
                                    name="package_id"
                                    value="<?= (int)$package['id'] ?>"
                                    data-name="<?= e((string)$package['title']) ?>"
                                    data-type="<?= e((string)$package['package_type']) ?>"
                                    data-amount="<?= e((string)$package['amount']) ?>"
                                    data-price="<?= e((string)$package['price']) ?>"
                                    data-duration="<?= e((string)$package['duration']) ?>"
                                >

                                <div class="package-card <?= e($info['class']) ?>">
                                    <div class="package-inner">
                                        <span class="package-badge"><?= e($info['icon'] . ' ' . strtoupper($type)) ?></span>
                                        <h3><?= e((string)$package['title']) ?></h3>
                                        <p><?= e((string)$package['description']) ?></p>
                                    </div>

                                    <div class="package-meta">
                                        <div class="meta">
                                            <span>Miktar</span>
                                            <strong><?= e((string)$package['amount']) ?></strong>
                                        </div>

                                        <div class="meta">
                                            <span>Fiyat</span>
                                            <strong><?= e((string)$package['price']) ?> ₺</strong>
                                        </div>

                                        <div class="meta">
                                            <span>Süre</span>
                                            <strong><?= e((string)$package['duration']) ?></strong>
                                        </div>
                                    </div>
                                </div>
                            </label>
                        <?php endforeach; ?>
                    </div>
                <?php endif; ?>
            </section>
        <?php endforeach; ?>

        <section class="request-area">

            <div class="request-card">
                <div class="request-inner">
                    <h2>Yönetimden Talep Et</h2>
                    <p>
                        Seçtiğin paket admin paneline detaylı destek talebi olarak gönderilir.
                        Yönetim ödemeyi ve paketi kontrol ettikten sonra üyeliğine tanımlar.
                    </p>

                    <div class="form-grid">
                        <div>
                            <label>Ödeme Tercihi</label>
                            <select name="payment_method">
                                <option value="Havale / EFT">Havale / EFT</option>
                                <option value="Admin ile Görüşeceğim">Admin ile Görüşeceğim</option>
                                <option value="Daha Sonra Bildireceğim">Daha Sonra Bildireceğim</option>
                            </select>
                        </div>

                        <div>
                            <label>Talep Önceliği</label>
                            <select disabled>
                                <option>Yönetim Onayı Bekler</option>
                            </select>
                        </div>
                    </div>

                    <label>Yönetim Notu</label>
                    <textarea name="note" placeholder="Örn: Bu paketi almak istiyorum. Ödeme dekontunu adminle paylaşacağım."></textarea>

                    <div class="process">
                        <div class="step"><b>1</b><span>Paket Seç</span></div>
                        <div class="step"><b>2</b><span>Talep Gönder</span></div>
                        <div class="step"><b>3</b><span>Admin Onayı</span></div>
                        <div class="step"><b>4</b><span>Paket Aktif</span></div>
                    </div>

                    <button class="submit-btn" type="submit">🚀 Seçili Paketi Yönetimden Talep Et</button>
                </div>
            </div>

            <div class="summary-card">
                <h2>Seçilen Paket Özeti</h2>
                <p>Talep göndermeden önce seçili paketi kontrol et.</p>

                <div class="summary-item">
                    <span>Paket Adı</span>
                    <strong id="summaryName">Paket seçilmedi</strong>
                </div>

                <div class="summary-item">
                    <span>Paket Türü</span>
                    <strong id="summaryType">-</strong>
                </div>

                <div class="summary-item">
                    <span>Miktar</span>
                    <strong id="summaryAmount">-</strong>
                </div>

                <div class="summary-item">
                    <span>Fiyat</span>
                    <strong id="summaryPrice">-</strong>
                </div>

                <div class="summary-item">
                    <span>Süre</span>
                    <strong id="summaryDuration">-</strong>
                </div>

                <div class="summary-item">
                    <span>Talep Durumu</span>
                    <strong>Yönetim Onayı Bekler</strong>
                </div>
            </div>

        </section>

    </form>

    <?php endif; ?>

    <section class="quick-actions">
        <a class="quick" href="profile.php">
            <b>👤 Profilim</b>
            <span>Profil ve şifre bilgilerini yönet.</span>
        </a>

        <a class="quick" href="my-package.php">
            <b>🎁 Paketlerim</b>
            <span>Aktif ve kapalı paket geçmişini gör.</span>
        </a>

        <a class="quick" href="support.php">
            <b>💬 Admin Destek</b>
            <span>Yönetim ekibiyle iletişim kur.</span>
        </a>

        <a class="quick" href="logout.php">
            <b>🚪 Güvenli Çıkış</b>
            <span>Hesabından güvenli şekilde çık.</span>
        </a>
    </section>

    <footer class="admin-footer">
        <div class="footer-left">
            <span>Powered By <?= date('Y') ?></span>
            <a href="https://www.radyohost.biz" target="_blank" rel="noopener" class="footer-link">🌐 RadyoHost.BiZ</a>
            <span>Web Teknolojileri</span>
        </div>

        <div class="footer-center">Premium Okey Üye Paneli</div>

        <div class="footer-right">
            <span class="footer-signature">Developed By VoLKaN75</span>
            <a href="https://wa.me/905415917536" target="_blank" rel="noopener" class="footer-whatsapp">
                <img src="../uploads/footer/whatsapp.png" alt="WhatsApp">
            </a>
        </div>
    </footer>

</div>

<script>
function updateSummary(){
    const selected = document.querySelector('input[name="package_id"]:checked');

    if(!selected){
        return;
    }

    document.getElementById('summaryName').textContent = selected.dataset.name || '-';
    document.getElementById('summaryType').textContent = (selected.dataset.type || '-').toUpperCase();
    document.getElementById('summaryAmount').textContent = selected.dataset.amount || '-';
    document.getElementById('summaryPrice').textContent = (selected.dataset.price || '-') + ' ₺';
    document.getElementById('summaryDuration').textContent = selected.dataset.duration || '-';
}

document.querySelectorAll('input[name="package_id"]').forEach(function(item){
    item.addEventListener('change', updateSummary);
});

const firstPackage = document.querySelector('input[name="package_id"]');
if(firstPackage){
    firstPackage.checked = true;
    updateSummary();
}
</script>

</body>
</html>