<?php
/**
 * A compact "top N" ranked list card.
 *
 * @var \BotGuard\Core\View $this
 * @var string $title
 * @var array<int,array<string,mixed>> $rows  each: label,total
 */
?>
<div class="card border-0 shadow-sm h-100">
    <div class="card-body">
        <h6 class="card-title mb-3"><?= e($title) ?></h6>
        <?php if (empty($rows)): ?>
            <p class="text-secondary small mb-0">No data yet.</p>
        <?php else: $max = max(array_map(static fn ($r) => (int) $r['total'], $rows)) ?: 1; ?>
            <?php foreach ($rows as $row): ?>
                <div class="mb-2">
                    <div class="d-flex justify-content-between small">
                        <span><?= e($row['label'] ?: 'Unknown') ?></span>
                        <span class="text-secondary"><?= e($row['total']) ?></span>
                    </div>
                    <div class="progress mt-1" style="height:5px">
                        <div class="progress-bar" style="width: <?= (int) round((int) $row['total'] / $max * 100) ?>%"></div>
                    </div>
                </div>
            <?php endforeach; ?>
        <?php endif; ?>
    </div>
</div>
