<?php include __DIR__ . '/../layout/header.php'; ?>

<div class="admin-card">
    <div class="admin-card-header">
        <h2 class="admin-card-title">Sabit Sayfalar</h2>
        <a href="<?php echo $baseUrl; ?>/admin/pages/create" class="admin-action-btn" style="width:auto; padding: 0 16px; background: var(--orange); color: white; border-radius: var(--r-md); font-weight: 600;">
            <i class="fa fa-plus" style="margin-right: 8px;"></i> Yeni Sayfa Ekle
        </a>
    </div>

    <div class="admin-table-wrap">
        <table class="admin-table">
            <thead>
                <tr>
                    <th>ID</th>
                    <th>Sayfa Başlığı</th>
                    <th>URL (Slug)</th>
                    <th style="text-align: right;">İşlemler</th>
                </tr>
            </thead>
            <tbody>
                <?php if (empty($pages)): ?>
                <tr>
                    <td colspan="4" style="text-align: center; padding: 40px; color: var(--text-3);">
                        <i class="fa fa-file-text-o" style="font-size: 48px; opacity: 0.2; margin-bottom: 15px; display:block;"></i>
                        Henüz hiç sayfa eklenmemiş.
                    </td>
                </tr>
                <?php else: foreach ($pages as $p): ?>
                <tr>
                    <td style="font-weight:600; color:var(--text-3);">#<?php echo htmlspecialchars(isset($p->id) ? $p->id : ''); ?></td>
                    <td style="font-weight: 500; color:var(--text-1);"><?php echo htmlspecialchars(isset($p->title) ? $p->title : ''); ?></td>
                    <td style="color: var(--text-3); font-family:monospace;">/<?php echo htmlspecialchars(isset($p->slug) ? $p->slug : ''); ?></td>
                    <td style="text-align: right;">
                        <a href="<?php echo $baseUrl; ?>/admin/pages/edit/<?php echo $p->id; ?>" class="admin-action-btn edit" title="Düzenle">
                            <i class="fa fa-edit"></i>
                        </a>
                        <a href="<?php echo $baseUrl; ?>/admin/pages/delete/<?php echo $p->id; ?>" onclick="return confirm('Bu sayfayı silmek istediğinize emin misiniz?')" class="admin-action-btn delete" style="margin-left:8px;" title="Sil">
                            <i class="fa fa-trash"></i>
                        </a>
                    </td>
                </tr>
                <?php endforeach; endif; ?>
            </tbody>
        </table>
    </div>
</div>

<?php include __DIR__ . '/../layout/footer.php'; ?>
