<?php include app()->basePath('app/Views/partials/header.php'); ?>

<section class="panel">
    <p class="eyebrow">Catalogo</p>
    <h1>Categorias</h1>

    <form method="post" action="/admin/categories/store" class="form inline-create">
        <?= csrf_field() ?>
        <input name="name" placeholder="Nome da categoria" required>
        <input name="description" placeholder="Descricao curta">
        <button class="button" type="submit">Criar categoria</button>
    </form>

    <div class="table-wrap">
        <table>
            <thead>
                <tr>
                    <th>Nome</th>
                    <th>Descricao</th>
                    <th>Estado</th>
                    <th>Criada em</th>
                </tr>
            </thead>
            <tbody>
                <?php foreach ($categories as $category): ?>
                    <tr>
                        <td><strong><?= e($category['name']) ?></strong></td>
                        <td><?= e($category['description'] ?? '-') ?></td>
                        <td><span class="badge <?= e($category['status']) ?>"><?= e(status_label($category['status'])) ?></span></td>
                        <td><?= e(format_date($category['created_at'] ?? '')) ?></td>
                    </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
    </div>

    <div class="actions">
        <a class="ghost-button" href="/admin/courses">Voltar aos cursos</a>
    </div>
</section>

<?php include app()->basePath('app/Views/partials/footer.php'); ?>
