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

<div class="page-toolbar">
    <div class="header-spacer"></div>
    <a href="<?php echo $baseUrl; ?>/admin/articles/create" class="admin-btn admin-btn-primary">
        <i class="fa fa-plus-circle"></i> Yeni İçerik
    </a>
</div>

<div class="admin-card" style="padding:0;overflow:hidden;">
    <div class="admin-table-wrap">
        <table class="admin-table">
            <thead>
                <tr>
                    <th>Başlık</th>
                    <th>Kategori</th>
                    <th>Marka</th>
                    <th>Gösterim</th>
                    <th>Öne Çıkan</th>
                    <th style="text-align:right;width:120px;">İşlemler</th>
                </tr>
            </thead>
            <tbody>
                <?php foreach ($articles as $art): ?>
                <tr>
                    <td style="font-weight:600;color:var(--text-1);"><?php echo htmlspecialchars($art->title); ?></td>
                    <td><?php echo htmlspecialchars($art->getCategory()->name ?? 'Genel'); ?></td>
                    <td><?php echo htmlspecialchars($art->getBrand()->name ?? 'Diğer'); ?></td>
                    <td><?php echo $art->view_count; ?></td>
                    <td>
                        <?php if ($art->is_featured): ?>
                        <span class="badge badge-success">Evet</span>
                        <?php else: ?>
                        <span class="badge badge-secondary">Hayır</span>
                        <?php endif; ?>
                    </td>
                    <td style="text-align:right;">
                        <div style="display:flex;justify-content:flex-end;gap:4px;">
                            <a href="<?php echo $baseUrl; ?>/admin/articles/edit/<?php echo $art->id; ?>" class="admin-action-btn edit"><i class="fa fa-pencil"></i></a>
                            <a href="<?php echo $baseUrl; ?>/admin/articles/delete/<?php echo $art->id; ?>" onclick="return confirm('Bu içeriği silmek istediğinize emin misiniz?')" class="admin-action-btn delete"><i class="fa fa-trash"></i></a>
                        </div>
                    </td>
                </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
    </div>
</div>

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