<?php
header('Content-Type: application/json; charset=utf-8');
require_once __DIR__ . '/includes/functions.php';

$rows = $db->select('themes', '*', 'is_active = :active', 'id DESC', [':active' => 1]);
if (empty($rows)) $rows = $db->select('themes', '*', '', 'id DESC');
$theme = $rows[0] ?? ['theme_id' => '1', 'layout_name' => 'activity_main'];

echo json_encode([
    'theme_id' => (string)($theme['theme_id'] ?? '1'),
    'layout' => (string)($theme['layout_name'] ?? 'activity_main')
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
