<?php
require_once '../includes/auth.php';
require_once '../../includes/config.php';

$prompts = $pdo->query("SELECT * FROM mega_prompts ORDER BY id DESC")->fetchAll();
?>

<h2>📌 مگاپرامپت‌ها</h2>
<a href="create.php">➕ ساخت پرامپت جدید</a>

<table border="1" cellpadding="8">
<tr>
  <th>ID</th>
  <th>عنوان</th>
  <th>Slug</th>
  <th>وضعیت</th>
  <th>لینک</th>
  <th>عملیات</th>
</tr>

<?php foreach($prompts as $p): ?>
<tr>
  <td><?= $p['id'] ?></td>
  <td><?= htmlspecialchars($p['title']) ?></td>
  <td><?= $p['slug'] ?></td>
  <td><?= $p['status'] ?></td>
  <td>
    <code>/start <?= $p['slug'] ?></code>
  </td>
  <td>
    <a href="edit.php?id=<?= $p['id'] ?>">✏️</a>
    <a href="questions.php?id=<?= $p['id'] ?>">❓ سوالات</a>
    <a href="delete.php?id=<?= $p['id'] ?>" onclick="return confirm('حذف شود؟')">🗑</a>
  </td>
</tr>
<?php endforeach; ?>
</table>
