<?= $this->extend('admin/layout/main') ?>
<?= $this->section('content') ?>

<div class="d-flex justify-content-between align-items-center mb-3">
    <h3><?= lang('App.clients') ?></h3>
    <a href="/admin/clients/create" class="btn btn-dark btn-sm"><?= lang('App.add_new') ?></a>
</div>

<div class="card p-3">
<table class="table">
    <thead><tr>
        <th><?= lang('App.name') ?></th><th><?= lang('App.email') ?></th>
        <th><?= lang('App.phone') ?></th><th><?= lang('App.status') ?></th><th><?= lang('App.actions') ?></th>
    </tr></thead>
    <tbody>
    <?php foreach ($clients as $c): ?>
        <tr>
            <td><?= esc($c['name']) ?></td>
            <td><?= esc($c['email']) ?></td>
            <td><?= esc($c['phone']) ?></td>
            <td><?= $c['is_active'] ? '✅' : '❌' ?></td>
            <td>
                <a href="/admin/clients/<?= $c['id'] ?>/edit" class="btn btn-sm btn-outline-primary"><?= lang('App.edit') ?></a>
                <form method="post" action="/admin/clients/<?= $c['id'] ?>/delete" class="d-inline" onsubmit="return confirm('?')">
                    <?= csrf_field() ?>
                    <button class="btn btn-sm btn-outline-danger"><?= lang('App.delete') ?></button>
                </form>
            </td>
        </tr>
    <?php endforeach; ?>
    <?php if (empty($clients)): ?><tr><td colspan="5" class="text-center text-muted"><?= lang('App.no_data') ?></td></tr><?php endif; ?>
    </tbody>
</table>
<?= $pager->links() ?>
</div>
<?= $this->endSection() ?>
