namespace WishNinja.Configuration;

/// <summary>Strongly-typed app configuration bound from the "WishNinja" section + env vars.</summary>
public class WishNinjaOptions
{
    public const string SectionName = "WishNinja";

    /// <summary>Public base URL used to build absolute links in emails (no trailing slash).</summary>
    public string BaseUrl { get; set; } = "https://localhost:5001";

    /// <summary>Filesystem directory for the SQLite db, uploads and data-protection keys.</summary>
    public string DataPath { get; set; } = "Data";

    public SmtpOptions Smtp { get; set; } = new();
    public UploadOptions Uploads { get; set; } = new();
    public InviteOptions Invites { get; set; } = new();
}

public class SmtpOptions
{
    public string? Host { get; set; }
    public int Port { get; set; } = 587;
    public bool UseStartTls { get; set; } = true;
    public string? User { get; set; }
    public string? Password { get; set; }
    public string FromAddress { get; set; } = "wishninja@localhost";
    public string FromName { get; set; } = "WishNinja";

    /// <summary>True when a host is configured; otherwise emails are logged instead of sent.</summary>
    public bool IsConfigured => !string.IsNullOrWhiteSpace(Host);
}

public class UploadOptions
{
    /// <summary>Max accepted upload size in bytes (default 5 MB).</summary>
    public long MaxBytes { get; set; } = 5 * 1024 * 1024;
}

public class InviteOptions
{
    /// <summary>How long an invite link remains valid.</summary>
    public int ExpiryHours { get; set; } = 168; // 7 days
}
