<?php require __DIR__ . '/../../layouts/header.php'; $lang=current_lang(); ?>
<div class="container">
  <div class="d-flex justify-content-between align-items-center mb-3 flex-wrap gap-2">
    <h4 class="mb-0"><i class="fa-solid fa-user-pen me-2"></i><?= e($lang==='ar'?'المحررون (Track Chairs)':'Editors (Track Chairs)') ?></h4>
    <a class="btn btn-primary btn-rounded" href="<?= e(base_path('admin/editors/create')) ?>"><i class="fa-solid fa-plus me-2"></i><?= e($lang==='ar'?'إضافة':'Add') ?></a>
  </div>

  <div class="card border-0 shadow-sm"><div class="card-body">
    <div class="table-responsive">
      <table class="table align-middle">
        <thead><tr><th>#</th><th>Email</th><th><?= e($lang==='ar'?'الاسم':'Name') ?></th><th><?= e($lang==='ar'?'مفعل':'Active') ?></th><th></th></tr></thead>
        <tbody>
          <?php foreach (($rows??[]) as $r): ?>
            <tr>
              <td><?= e((string)$r['id']) ?></td>
              <td><?= e((string)$r['email']) ?></td>
              <td><?= e(trim((string)($r['first_name']??'').' '.(string)($r['last_name']??''))) ?></td>
              <td><?= e((string)$r['is_active']) ?></td>
              <td>
                <form method="post" action="<?= e(base_path('admin/editors/toggle')) ?>">
                  <input type="hidden" name="_csrf" value="<?= e(csrf_token()) ?>">
                  <input type="hidden" name="id" value="<?= e((string)$r['id']) ?>">
                  <button class="btn btn-sm btn-outline-secondary"><?= e($lang==='ar'?'تفعيل/تعطيل':'Toggle') ?></button>
                </form>
              </td>
            </tr>
          <?php endforeach; ?>
          <?php if (empty($rows)): ?><tr><td colspan="5" class="text-center text-muted py-4">—</td></tr><?php endif; ?>
        </tbody>
      </table>
    </div>
  </div></div>
</div>
<?php require __DIR__ . '/../../layouts/footer.php'; ?>
