<?php
 
$roleColors = [
    'admin' => 'bg-red-100 text-red-600',
    'moderator' => 'bg-purple-100 text-purple-600',
    'user' => 'bg-gray-100 text-gray-600',
];
?>
<div class="flex items-center justify-between mb-2">
    <span class="text-xs text-gray-500">Recent registrations</span>
    <a href="/admin/users" class="text-[11px] text-primary-600 hover:text-primary-700 font-medium">View all</a>
</div>
<?php if (!empty($data)): ?>
<div class="space-y-0">
    <?php foreach ($data as $user): ?>
    <div class="py-2 border-b border-gray-50 last:border-b-0 flex items-center justify-between">
        <div class="flex items-center gap-2 min-w-0">
            <div class="w-7 h-7 rounded-full bg-gray-100 flex items-center justify-center shrink-0">
                <span class="text-xs font-bold text-gray-500"><?= strtoupper(mb_substr($user['username'] ?? '?', 0, 1)) ?></span>
            </div>
            <div class="min-w-0">
                <div class="text-xs font-medium text-gray-800 truncate"><?= htmlspecialchars($user['username']) ?></div>
                <div class="text-[10px] text-gray-400 truncate"><?= htmlspecialchars($user['email']) ?></div>
            </div>
        </div>
        <div class="flex items-center gap-2 shrink-0">
            <span class="inline-flex items-center px-1.5 py-0.5 rounded text-[9px] font-medium <?= $roleColors[$user['role']] ?? $roleColors['user'] ?>"><?= ucfirst($user['role']) ?></span>
            <span class="text-[10px] text-gray-300"><?= htmlspecialchars(substr($user['created_at'] ?? '', 0, 10)) ?></span>
        </div>
    </div>
    <?php endforeach; ?>
</div>
<?php else: ?>
<div class="text-center py-8 text-gray-300 text-xs">No users yet</div>
<?php endif; ?>
