namespace PowderCoating.Core.Entities;

/// <summary>
/// Company-specific quote status lookup table.
/// Replaces hardcoded QuoteStatus enum to enable workflow customization.
/// </summary>
public class QuoteStatusLookup : BaseEntity
{
    /// <summary>
    /// Immutable status code used in code logic (e.g., "DRAFT", "APPROVED", "CONVERTED").
    /// Acts like the old enum name.
    /// </summary>
    public string StatusCode { get; set; } = string.Empty;

    /// <summary>
    /// User-customizable display name shown in UI (e.g., "Pending Approval", "Accepted by Customer").
    /// </summary>
    public string DisplayName { get; set; } = string.Empty;

    /// <summary>
    /// Display order for sorting statuses in dropdowns and reports.
    /// </summary>
    public int DisplayOrder { get; set; }

    /// <summary>
    /// Bootstrap color class for badge styling (primary, secondary, success, danger, warning, info, dark).
    /// Eliminates switch statement duplication for status colors.
    /// </summary>
    public string ColorClass { get; set; } = "secondary";

    /// <summary>
    /// Optional Bootstrap icon class (e.g., "bi-file-earmark", "bi-check-circle").
    /// </summary>
    public string? IconClass { get; set; }

    /// <summary>
    /// Whether this status is currently active and available for selection.
    /// </summary>
    public bool IsActive { get; set; } = true;

    /// <summary>
    /// System-defined statuses cannot be deleted.
    /// </summary>
    public bool IsSystemDefined { get; set; } = true;

    /// <summary>
    /// CRITICAL BUSINESS RULE: Exactly ONE status per company must be marked as the "approved" status.
    /// Only quotes with this status can be converted to jobs.
    /// Enforced by validation in CompanySettingsController.
    /// </summary>
    public bool IsApprovedStatus { get; set; } = false;

    /// <summary>
    /// CRITICAL BUSINESS RULE: Exactly ONE status per company must be marked as the "converted" status.
    /// This status is automatically set after a quote is successfully converted to a job.
    /// </summary>
    public bool IsConvertedStatus { get; set; } = false;

    /// <summary>
    /// Indicates the default draft status (enables expiration date logic, etc.).
    /// </summary>
    public bool IsDraftStatus { get; set; } = false;

    /// <summary>
    /// CRITICAL BUSINESS RULE: Marks the rejected/declined status.
    /// Used by the customer self-service approval portal to set the quote status when a customer declines.
    /// </summary>
    public bool IsRejectedStatus { get; set; } = false;

    /// <summary>
    /// Optional description explaining when to use this status.
    /// </summary>
    public string? Description { get; set; }

    // Navigation properties
    public virtual ICollection<Quote> Quotes { get; set; } = new List<Quote>();
}
