<?php /** @var array $stats; @var array $recent */ ?>
<div class="p-8">
  <div class="text-xs uppercase tracking-[0.3em] text-gold"><?= e(t('admin.overview.kicker')) ?></div>
  <h1 class="mt-2 text-3xl font-display"><?= e(t('admin.overview.title')) ?></h1>

  <div class="grid grid-cols-2 md:grid-cols-4 gap-4 mt-8">
    <?php foreach ($stats as $k => $n): ?>
      <div class="bg-ink/40 border border-white/10 rounded-xl p-5">
        <div class="text-xs uppercase tracking-widest text-bone/50"><?= e(t('admin.stats.' . $k)) ?></div>
        <div class="text-4xl font-display text-gold mt-2"><?= (int)$n ?></div>
      </div>
    <?php endforeach; ?>
  </div>

  <div class="mt-10">
    <h2 class="text-xl font-display mb-4"><?= e(t('admin.overview.recent')) ?></h2>
    <div class="bg-ink/40 border border-white/10 rounded-xl overflow-hidden">
      <?php if (empty($recent)): ?>
        <div class="p-10 text-center text-bone/40"><?= e(t('admin.overview.no_activity')) ?></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('hub.table.when')) ?></th>
                <th class="text-left px-5 py-3"><?= e(t('hub.table.customer')) ?></th>
                <th class="text-left px-5 py-3"><?= e(t('hub.table.status')) ?></th></tr>
          </thead>
          <tbody>
            <?php foreach ($recent as $a):
              $cust = !empty($a['customer_id']) ? \App\Repositories\Container::users()->find($a['customer_id']) : null;
            ?>
              <tr class="border-t border-white/5">
                <td class="px-5 py-3"><?= !empty($a['start_at']) ? e((new DateTimeImmutable($a['start_at']))->format('M j · g:i A')) : '—' ?></td>
                <td class="px-5 py-3"><?= e(trim(($cust['first_name'] ?? '') . ' ' . ($cust['last_name'] ?? '')) ?: '—') ?></td>
                <td class="px-5 py-3"><span class="pill pill-<?= e(strtolower($a['status'] ?? 'pending')) ?>"><?= e($a['status'] ?? '') ?></span></td>
              </tr>
            <?php endforeach; ?>
          </tbody>
        </table>
      <?php endif; ?>
    </div>
  </div>
</div>
