<?php
require_once __DIR__ . '/../src/bootstrap.php';
$pdo = db();
$campaigns = $pdo->query('SELECT * FROM campaigns ORDER BY id DESC')->fetchAll(PDO::FETCH_ASSOC);
?>
<!doctype html>
<html lang="tr"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Kampanyalar</title>
<style>body{margin:0;background:#0b1120;color:#e5e7eb;font-family:Inter,Arial,sans-serif}.wrap{max-width:1100px;margin:0 auto;padding:20px}.card{background:#111827;border:1px solid #1f2937;border-radius:18px;padding:18px}table{width:100%;border-collapse:collapse}th,td{padding:12px 10px;border-bottom:1px solid #1f2937;text-align:left}a{color:#93c5fd;text-decoration:none}@media(max-width:700px){th,td{font-size:12px;padding:10px 8px}.wrap{padding:14px}}</style>
</head><body><div class="wrap"><div style="display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:12px;margin-bottom:16px"><h1 style="margin:0">Kampanyalar</h1><a href="index.php">Panele dön</a></div><div class="card"><table><thead><tr><th>Konu</th><th>Toplam</th><th>Başarılı</th><th>Başarısız</th><th>Açılan</th><th>Tarih</th></tr></thead><tbody><?php foreach($campaigns as $c): ?><tr><td><a href="campaign.php?id=<?= (int)$c['id'] ?>"><?= e($c['subject']) ?></a></td><td><?= (int)$c['total_recipients'] ?></td><td><?= (int)$c['sent_success'] ?></td><td><?= (int)$c['sent_failed'] ?></td><td><?= (int)$c['total_opened'] ?></td><td><?= e($c['created_at']) ?></td></tr><?php endforeach; ?></tbody></table></div></div></body></html>
