<?php
 
?>
<div class="flex items-center justify-between mb-2">
    <span class="text-xs text-gray-500">Latest comments</span>
    <a href="/admin/comments" 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 $comment): ?>
    <div class="py-2 border-b border-gray-50 last:border-b-0">
        <div class="flex items-center gap-1.5 text-xs">
            <span class="font-semibold text-gray-800"><?= htmlspecialchars($comment['username'] ?? 'Anonymous') ?></span>
            <span class="text-gray-300">on</span>
            <a href="/admin/videos/<?= (int)($comment['video_id'] ?? 0) ?>/edit" class="text-blue-600 hover:text-blue-800 font-medium truncate max-w-[140px]"><?= htmlspecialchars($comment['video_title'] ?? '') ?></a>
            <?php if (($comment['status'] ?? '') === 'pending'): ?>
                <span class="inline-flex items-center px-1.5 py-0.5 rounded-full text-[9px] font-medium bg-orange-100 text-orange-600">Pending</span>
            <?php elseif (($comment['status'] ?? '') === 'spam'): ?>
                <span class="inline-flex items-center px-1.5 py-0.5 rounded-full text-[9px] font-medium bg-red-100 text-red-600">Spam</span>
            <?php endif; ?>
        </div>
        <div class="text-xs text-gray-500 mt-0.5 line-clamp-2"><?= htmlspecialchars(mb_strimwidth($comment['body'] ?? '', 0, 120, '...')) ?></div>
        <div class="text-[10px] text-gray-300 mt-0.5"><?= htmlspecialchars(substr($comment['created_at'] ?? '', 0, 16)) ?></div>
    </div>
    <?php endforeach; ?>
</div>
<?php else: ?>
<div class="text-center py-8 text-gray-300 text-xs">No comments yet</div>
<?php endif; ?>
