<?php
/**
 * Recent verification results table.
 *
 * @var \BotGuard\Core\View $this
 * @var array<int,array<string,mixed>> $results
 */
$badge = static fn (string $c): string => match ($c) {
    'human' => 'badge-human', 'suspicious' => 'badge-suspicious', default => 'badge-bot',
};
?>
<div class="table-responsive">
    <table class="table table-sm align-middle mb-0">
        <thead>
            <tr class="text-secondary small text-uppercase">
                <th>Time</th><th>IP</th><th>Browser</th><th>Device</th>
                <th>Score</th><th>Class</th><th>Decision</th>
            </tr>
        </thead>
        <tbody>
            <?php if (empty($results)): ?>
                <tr><td colspan="7" class="text-center text-secondary py-4">No verifications recorded yet.</td></tr>
            <?php else: foreach ($results as $r): ?>
                <tr>
                    <td class="small text-nowrap"><?= e($r['created_at']) ?></td>
                    <td class="small"><?= e($r['ip']) ?></td>
                    <td class="small"><?= e(($r['browser'] ?? '') . ' ' . ($r['browser_version'] ?? '')) ?></td>
                    <td class="small"><?= e($r['device_type'] ?? '') ?></td>
                    <td><span class="fw-bold"><?= e($r['score']) ?></span></td>
                    <td><span class="badge text-white <?= $badge((string) $r['classification']) ?>"><?= e(ucfirst((string) $r['classification'])) ?></span></td>
                    <td class="small text-secondary"><?= e($r['decision']) ?></td>
                </tr>
            <?php endforeach; endif; ?>
        </tbody>
    </table>
</div>
