<?php
require_once __DIR__ . '/../../config/config.php';

header('Content-Type: application/json');

$theme = $_POST['theme'] ?? 'light';
if (in_array($theme, ['light', 'dark'])) {
    $_SESSION['theme'] = $theme;
    setcookie('shop_theme', $theme, time() + (86400 * 30), "/");
    echo json_encode(['success' => true]);
} else {
    echo json_encode(['success' => false]);
}
