<?php
declare(strict_types=1);

require_once __DIR__ . '/../../security/auth_guard_api.php';
require_once __DIR__ . '/../../security/csrf_guard.php';
require_once __DIR__ . '/../../config/database.php';
require_once __DIR__ . '/../../core/Response.php';
require_once __DIR__ . '/../../services/DashboardService.php';

/**
 * Super Admin only
 */
if (($_SESSION['role'] ?? '') !== 'Super Admin') {
    Response::error('Forbidden', 403);
}

$db = Database::getInstance();

$service = new DashboardService($db);
$data    = $service->getDashboardData();

Response::success('Dashboard data fetched successfully', $data);
