<?php /** @var array $list; @var string $q */ ?>
<div class="p-8">
  <div class="text-xs uppercase tracking-[0.3em] text-gold"><?= e(t('admin.users.kicker')) ?></div>
  <h1 class="mt-2 text-3xl font-display"><?= e(t('admin.users.title')) ?></h1>
  <form class="mt-6 max-w-xl" method="GET" action="<?= url('/admin/users') ?>">
    <input name="q" value="<?= e($q) ?>" placeholder="<?= e(t('admin.users.search')) ?>" class="input">
  </form>
  <div class="mt-6 bg-ink/40 border border-white/10 rounded-xl overflow-hidden">
    <?php if (empty($list)): ?>
      <div class="p-10 text-center text-bone/40"><?= e(t('admin.users.empty')) ?></div>
    <?php else: ?>
      <table class="w-full text-sm">
        <thead class="bg-white/5 text-xs uppercase tracking-widest text-bone/50">
          <tr><th class="text-left px-5 py-3"><?= e(t('form.name')) ?></th>
              <th class="text-left px-5 py-3"><?= e(t('form.email')) ?></th>
              <th class="text-left px-5 py-3"><?= e(t('form.phone')) ?></th>
              <th class="text-left px-5 py-3"><?= e(t('admin.users.joined')) ?></th>
              <th></th></tr>
        </thead>
        <tbody>
          <?php foreach ($list as $u): ?>
            <tr class="border-t border-white/5 hover:bg-white/5">
              <td class="px-5 py-3"><?= e(trim(($u['first_name'] ?? '') . ' ' . ($u['last_name'] ?? ''))) ?></td>
              <td class="px-5 py-3 text-bone/60"><?= e($u['email'] ?? '') ?></td>
              <td class="px-5 py-3 text-bone/60"><?= e($u['phone'] ?? '') ?></td>
              <td class="px-5 py-3 text-bone/40 text-xs"><?= e(substr($u['created_at'] ?? '', 0, 10)) ?></td>
              <td class="px-5 py-3 text-right"><a href="<?= url('/admin/users/' . e($u['id'])) ?>" class="text-gold text-xs hover:underline"><?= e(t('common.open')) ?> →</a></td>
            </tr>
          <?php endforeach; ?>
        </tbody>
      </table>
    <?php endif; ?>
  </div>
</div>
