<?php
require_once '../config.php';
require_once '../../includes/Auth.php';
require_once '../../includes/Admin.php';
require_once '../../includes/Delivery.php';
require_once '../../includes/Shop.php';

$auth = new Auth();
$auth->requireRole('admin');

$admin = new Admin();
$delivery = new Delivery();
$shop = new Shop();

try {
    $admin_stats = $admin->getStats();
    $delivery_stats = $delivery->getDeliveryStats();
    $shop_stats = $shop->getShopStats();
    
    jsonResponse([
        'success' => true,
        'stats' => array_merge($admin_stats, $delivery_stats, ['total_shops' => $shop_stats])
    ]);
} catch (Exception $e) {
    jsonResponse([
        'success' => false,
        'message' => $e->getMessage()
    ], 500);
}
?>