<?php
require_once __DIR__ . '/../db/config.php';

header('Content-Type: application/json');

try {
    $pdo = db();
    $stmt = $pdo->query("SELECT username, total_likes, custom_color FROM user_likes ORDER BY total_likes DESC LIMIT 5");
    $fans = $stmt->fetchAll(PDO::FETCH_ASSOC);

    echo json_encode(['success' => true, 'fans' => $fans]);
} catch (Exception $e) {
    echo json_encode(['error' => $e->getMessage()]);
}
