<?php
declare(strict_types=1);

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

$id = (int)($_GET['id'] ?? 0);
if ($id <= 0) Response::error('Invalid ID');

$db = Database::getInstance();

$stmt = $db->prepare("
SELECT s.*, p.title AS product_title
FROM hospitality_product_sections s
JOIN hospitality_products p ON p.id = s.hospitality_product_id
WHERE s.id = :id
");
$stmt->execute(['id'=>$id]);

$section = $stmt->fetch();
if (!$section) Response::error('Not found',404);

Response::success('OK',['section'=>$section]);
