using System.ComponentModel.DataAnnotations;

namespace DramaLing.Api.Models.Entities;

public class User
{
    public Guid Id { get; set; }

    [Required]
    [MaxLength(50)]
    public string Username { get; set; } = string.Empty;

    [Required]
    [EmailAddress]
    [MaxLength(255)]
    public string Email { get; set; } = string.Empty;

    [Required]
    [MaxLength(255)]
    public string PasswordHash { get; set; } = string.Empty;

    [MaxLength(100)]
    public string? DisplayName { get; set; }

    public string? AvatarUrl { get; set; }

    [MaxLength(20)]
    public string SubscriptionType { get; set; } = "free";

    public Dictionary<string, object> Preferences { get; set; } = new();

    [MaxLength(10)]
    public string EnglishLevel { get; set; } = "A2"; // A1, A2, B1, B2, C1, C2

    public DateTime LevelUpdatedAt { get; set; } = DateTime.UtcNow;

    public bool IsLevelVerified { get; set; } = false; // 是否通過測試驗證

    [MaxLength(500)]
    public string? LevelNotes { get; set; } // 程度設定備註

    public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
    public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;

    // Navigation Properties
    public virtual ICollection<CardSet> CardSets { get; set; } = new List<CardSet>();
    public virtual ICollection<Flashcard> Flashcards { get; set; } = new List<Flashcard>();
    public virtual UserSettings? Settings { get; set; }
    public virtual ICollection<StudySession> StudySessions { get; set; } = new List<StudySession>();
    public virtual ICollection<ErrorReport> ErrorReports { get; set; } = new List<ErrorReport>();
    public virtual ICollection<DailyStats> DailyStats { get; set; } = new List<DailyStats>();
}