// PRE-GENERATED (design session). Small persisted app settings (APO path override, etc.).
using System;
using System.IO;
using System.Text.Json;

namespace DansoriEQ.App;

public sealed class AppSettings
{
    public string? ApoConfigDir { get; set; }
    public string? AiProvider { get; set; }   // claude | openai | gemini | ollama
    public string? AiModel { get; set; }
    public bool AutoSwitchEnabled { get; set; }
    public string? Theme { get; set; }   // "dark" | "light" | "system" (default: dark)

    private static string FilePath
    {
        get
        {
            var dir = Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "DansoriEQ");
            Directory.CreateDirectory(dir);
            return Path.Combine(dir, "settings.json");
        }
    }

    public static AppSettings Load()
    {
        try
        {
            return File.Exists(FilePath)
                ? JsonSerializer.Deserialize<AppSettings>(File.ReadAllText(FilePath)) ?? new()
                : new();
        }
        catch { return new(); }
    }

    public void Save() => File.WriteAllText(FilePath, JsonSerializer.Serialize(this));
}
