<?php
declare(strict_types=1);

require_once __DIR__ . '/../../security/auth_guard.php';
require_once __DIR__ . '/../../config/database.php';
require_once __DIR__ . '/../../core/Response.php';

$db = Database::getInstance();

$id = (int) ($_GET['id'] ?? 0);
if ($id <= 0) {
    Response::error('Section ID required', 422);
}

$stmt = $db->prepare("
    SELECT *
    FROM retail_product_sections
    WHERE id = :id
");
$stmt->execute(['id' => $id]);

$section = $stmt->fetch();
if (!$section) {
    Response::error('Section not found', 404);
}

Response::success('Section fetched successfully', $section);
