<?php
include '../db.php';

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

try {
    $stmt = $conn->prepare("SELECT * FROM modifier_templates WHERE is_active = 1 ORDER BY sort_order, name");
    $stmt->execute();
    $result = $stmt->get_result();
    
    $templates = [];
    while ($row = $result->fetch_assoc()) {
        $templates[] = $row;
    }
    
    echo json_encode([
        'success' => true,
        'templates' => $templates
    ]);
    
} catch (Exception $e) {
    echo json_encode(['success' => false, 'message' => 'Database error: ' . $e->getMessage()]);
}
?>
