<?php
// ============================================================
//  api/user_count.php — Returns total user count as JSON
//  Place in: /admin/api/user_count.php
//  Called by footer.php JS to update sidebar badge
// ============================================================
require_once '../includes/auth_check.php';

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

$count = db_fetch_one("SELECT COUNT(*) AS c FROM users")['c'] ?? 0;

echo json_encode(['count' => (int)$count]);
