<?php
 
?>
<div class="flex items-center justify-between mb-2">
    <span class="text-xs text-gray-500">By video count</span>
    <a href="/admin/performers" 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 $i => $performer): ?>
    <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.5 min-w-0">
            <span class="text-xs font-bold w-5 text-center <?= $i < 3 ? 'text-primary-600' : 'text-gray-400' ?>"><?= $i + 1 ?></span>
            <?php
            $perfThumb = '';
            if (!empty($performer['photo'])) {
                $perfThumb = str_starts_with($performer['photo'], 'http') ? $performer['photo'] : '/uploads/performers/' . $performer['photo'];
            } elseif (!empty($performer['best_video_folder'])) {
                $perfThumb = VideoAsset::thumbUrlFromFolder($performer['best_video_folder'], true, $performer['best_video_storage_id'] ?? null);
            } elseif (!empty($performer['best_video_thumbnail'])) {
                $perfThumb = $performer['best_video_thumbnail'];
            }
            ?>
            <?php if ($perfThumb !== ''): ?>
                <img src="<?= htmlspecialchars($perfThumb) ?>" alt="" class="w-7 h-7 rounded-full object-cover">
            <?php else: ?>
                <div class="w-7 h-7 rounded-full bg-pink-50 flex items-center justify-center">
                    <i class="fa-solid fa-user text-pink-300 text-[10px]"></i>
                </div>
            <?php endif; ?>
            <a href="/admin/performers/<?= (int)$performer['id'] ?>/edit" class="text-xs font-medium text-gray-800 hover:text-blue-600 truncate"><?= htmlspecialchars($performer['name']) ?></a>
        </div>
        <div class="flex items-center gap-3 shrink-0 text-[10px] text-gray-400">
            <span><i class="fa-solid fa-video mr-0.5"></i> <?= number_format((int)($performer['video_count'] ?? 0)) ?></span>
            <span class="hide-mobile"><i class="fa-solid fa-eye mr-0.5"></i> <?= Format::number((int)($performer['total_views'] ?? 0)) ?></span>
        </div>
    </div>
    <?php endforeach; ?>
</div>
<?php else: ?>
<div class="text-center py-8 text-gray-300 text-xs">No performers yet</div>
<?php endif; ?>
