<?php
 
$stats = [
    ['label' => 'Videos', 'value' => $data['videoCount'] ?? 0, 'icon' => 'fa-video', 'color' => 'blue', 'url' => '/admin/videos'],
    ['label' => 'Albums', 'value' => $data['albumCount'] ?? 0, 'icon' => 'fa-images', 'color' => 'fuchsia', 'url' => '/admin/albums'],
    ['label' => 'Categories', 'value' => $data['categoryCount'] ?? 0, 'icon' => 'fa-folder', 'color' => 'amber', 'url' => '/admin/categories'],
    ['label' => 'Tags', 'value' => $data['tagCount'] ?? 0, 'icon' => 'fa-tags', 'color' => 'purple', 'url' => '/admin/tags'],
    ['label' => 'Performers', 'value' => $data['performerCount'] ?? 0, 'icon' => 'fa-users', 'color' => 'pink', 'url' => '/admin/performers'],
    ['label' => 'Channels', 'value' => $data['channelCount'] ?? 0, 'icon' => 'fa-building', 'color' => 'indigo', 'url' => '/admin/channels'],
    ['label' => 'Pages', 'value' => $data['pageCount'] ?? 0, 'icon' => 'fa-file-lines', 'color' => 'cyan', 'url' => '/admin/pages'],
    ['label' => 'Users', 'value' => $data['userCount'] ?? 0, 'icon' => 'fa-user', 'color' => 'green', 'url' => '/admin/users'],
    ['label' => 'Comments', 'value' => $data['commentCount'] ?? 0, 'icon' => 'fa-comments', 'color' => 'orange', 'url' => '/admin/comments'],
];
$totalViews = (int) ($data['totalViews'] ?? 0);
$publishedCount = (int) ($data['publishedCount'] ?? 0);
$draftCount = (int) ($data['draftCount'] ?? 0);
$pendingComments = (int) ($data['pendingComments'] ?? 0);
?>

<div class="grid grid-cols-2 sm:grid-cols-3 xl:grid-cols-9 gap-3 mb-3">
    <?php foreach ($stats as $s): ?>
    <a href="<?= $s['url'] ?>" class="group flex flex-col items-center p-3 rounded-lg border border-gray-100 hover:border-<?= $s['color'] ?>-200 hover:bg-<?= $s['color'] ?>-50/30 transition-all">
        <div class="w-9 h-9 rounded-lg bg-<?= $s['color'] ?>-50 flex items-center justify-center mb-2">
            <i class="fa-solid <?= $s['icon'] ?> text-<?= $s['color'] ?>-500 text-sm"></i>
        </div>
        <span class="text-lg font-bold text-gray-900 leading-tight"><?= number_format((int) $s['value']) ?></span>
        <span class="text-[10px] text-gray-500 mt-0.5"><?= $s['label'] ?></span>
    </a>
    <?php endforeach; ?>
</div>

<div class="grid grid-cols-2 sm:grid-cols-4 gap-3">
    <div class="flex items-center gap-2.5 p-2.5 rounded-lg bg-blue-50/50 border border-blue-100">
        <i class="fa-solid fa-eye text-blue-400 text-xs"></i>
        <div>
            <div class="text-sm font-bold text-gray-900"><?= number_format($totalViews) ?></div>
            <div class="text-[10px] text-gray-500">Total Views</div>
        </div>
    </div>
    <div class="flex items-center gap-2.5 p-2.5 rounded-lg bg-green-50/50 border border-green-100">
        <i class="fa-solid fa-circle-check text-green-400 text-xs"></i>
        <div>
            <div class="text-sm font-bold text-gray-900"><?= number_format($publishedCount) ?></div>
            <div class="text-[10px] text-gray-500">Published</div>
        </div>
    </div>
    <div class="flex items-center gap-2.5 p-2.5 rounded-lg bg-gray-50 border border-gray-100">
        <i class="fa-solid fa-pen text-gray-400 text-xs"></i>
        <div>
            <div class="text-sm font-bold text-gray-900"><?= number_format($draftCount) ?></div>
            <div class="text-[10px] text-gray-500">Drafts</div>
        </div>
    </div>
    <div class="flex items-center gap-2.5 p-2.5 rounded-lg <?= $pendingComments > 0 ? 'bg-orange-50/50 border border-orange-100' : 'bg-gray-50 border border-gray-100' ?>">
        <i class="fa-solid fa-clock text-<?= $pendingComments > 0 ? 'orange' : 'gray' ?>-400 text-xs"></i>
        <div>
            <div class="text-sm font-bold text-gray-900"><?= number_format($pendingComments) ?></div>
            <div class="text-[10px] text-gray-500">Pending</div>
        </div>
    </div>
</div>
