namespace PowderCoating.Core.Entities;

/// <summary>
/// Platform-wide announcements shown as dismissible banners to company users.
/// Not a BaseEntity — SuperAdmin-managed, not per-tenant.
/// </summary>
public class Announcement
{
    public int Id { get; set; }
    public string Title { get; set; } = string.Empty;
    public string Message { get; set; } = string.Empty;

    /// <summary>info | success | warning | danger</summary>
    public string Type { get; set; } = "info";

    /// <summary>All | Plan | Company</summary>
    public string Target { get; set; } = "All";

    /// <summary>Populated when Target == "Plan" (matches Company.SubscriptionPlan int)</summary>
    public int? TargetPlan { get; set; }

    /// <summary>Populated when Target == "Company"</summary>
    public int? TargetCompanyId { get; set; }

    public DateTime StartsAt { get; set; } = DateTime.UtcNow;
    public DateTime? ExpiresAt { get; set; }
    public bool IsDismissible { get; set; } = true;
    public bool IsActive { get; set; } = true;
    public string CreatedByUserId { get; set; } = string.Empty;
    public string CreatedByUserName { get; set; } = string.Empty;
    public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
    public DateTime? UpdatedAt { get; set; }

    public virtual ICollection<AnnouncementDismissal> Dismissals { get; set; } = new List<AnnouncementDismissal>();
}

/// <summary>
/// Records that a specific user has dismissed a specific announcement.
/// </summary>
public class AnnouncementDismissal
{
    public int Id { get; set; }
    public int AnnouncementId { get; set; }
    public string UserId { get; set; } = string.Empty;
    public DateTime DismissedAt { get; set; } = DateTime.UtcNow;

    public virtual Announcement Announcement { get; set; } = null!;
}
