<?php
require_once __DIR__ . '/../app/bootstrap.php';
use App\Core\Database;
$slug=trim((string)($_GET['slug'] ?? ''));
$page=$slug!=='' ? Database::safeFetchOne('SELECT * FROM pages WHERE slug=? AND status="active" LIMIT 1',[$slug]) : null;
if(!$page){ http_response_code(404); $page=['title'=>'Page not found','content'=>'The requested page is unavailable.','meta_description'=>'']; }
$pageTitle=($page['meta_title'] ?: $page['title']).' | '.BRAND_NAME; $pageDescription=$page['meta_description'] ?? ''; require ROOT_PATH.'/app/Layouts/frontend_header.php';
?>
<section class="container py-5"><div class="card border-0 shadow-sm"><div class="card-body p-4 p-lg-5"><h1><?= e($page['title']) ?></h1><div class="cms-content mt-4"><?= $page['content'] ?: '<p>No content has been published.</p>' ?></div></div></div></section><?php require ROOT_PATH.'/app/Layouts/frontend_footer.php'; ?>
