<?php
require_once '../../includes/functions.php';
setCORSHeaders();

// Verify API Hash
verifyAPIHash();

if ($_SERVER['REQUEST_METHOD'] !== 'GET') {
    sendError('Method not allowed', 405);
}

// Get all active categories ordered by priority (highest first), then by name
$stmt = $pdo->query("SELECT id, name, description, priority FROM categories WHERE is_active = 1 ORDER BY priority DESC, name ASC");
$categories = $stmt->fetchAll(PDO::FETCH_ASSOC);

sendResponse([
    'success' => true,
    'data' => $categories
]);
?>
