<?php
require_once __DIR__ . '/../includes/bootstrap.php';
require_post();
require_admin_api();
$config = load_config();
$config['siteTitle'] = trim($_POST['siteTitle'] ?? ($config['siteTitle'] ?? ''));
$config['footerText'] = trim($_POST['footerText'] ?? ($config['footerText'] ?? ''));
if (!empty($_POST['frames'])) {
    $frames = json_decode((string)$_POST['frames'], true);
    if (is_array($frames)) $config['frames'] = $frames;
}
if (save_config($config)) json_response(['ok' => true, 'message' => 'Settings saved successfully.']);
json_response(['ok' => false, 'message' => 'Could not save settings.'], 500);
