<?php
require_once __DIR__ . '/config.php';
requireAdmin();
$pdo = getDB();
$pages = $pdo->query("SELECT id, slug, title, is_active FROM pages ORDER BY slug")->fetchAll(PDO::FETCH_ASSOC);
$pageTitle = 'Pages';
require_once __DIR__ . '/includes/header.php';
?>
<div class="admin-page">
    <h1>Pages</h1>
    <table class="admin-table">
        <thead><tr><th>ID</th><th>Slug</th><th>Title</th><th>Status</th><th>Actions</th></tr></thead>
        <tbody>
            <?php foreach ($pages as $p): ?>
            <tr>
                <td><?php echo (int)$p['id']; ?></td>
                <td><?php echo htmlspecialchars($p['slug']); ?></td>
                <td><?php echo htmlspecialchars($p['title']); ?></td>
                <td><?php echo $p['is_active'] ? 'Active' : 'Inactive'; ?></td>
                <td><a href="page-edit.php?id=<?php echo (int)$p['id']; ?>">Edit</a></td>
            </tr>
            <?php endforeach; ?>
        </tbody>
    </table>
</div>
<?php require_once __DIR__ . '/includes/footer.php'; ?>
