using System.ComponentModel.DataAnnotations;

namespace DramaLing.Api.Models.Entities;

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

    public Guid UserId { get; set; }

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

    [MaxLength(50)]
    public string Color { get; set; } = "#3B82F6";

    public int UsageCount { get; set; } = 0;

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

    // Navigation Properties
    public virtual User User { get; set; } = null!;
    public virtual ICollection<FlashcardTag> FlashcardTags { get; set; } = new List<FlashcardTag>();
}

public class FlashcardTag
{
    public Guid FlashcardId { get; set; }
    public Guid TagId { get; set; }

    // Navigation Properties
    public virtual Flashcard Flashcard { get; set; } = null!;
    public virtual Tag Tag { get; set; } = null!;
}

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

    public Guid UserId { get; set; }

    public Guid FlashcardId { get; set; }

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

    public string? Description { get; set; }

    [MaxLength(50)]
    public string? StudyMode { get; set; }

    [MaxLength(50)]
    public string Status { get; set; } = "pending"; // pending, resolved, dismissed

    public string? AdminNotes { get; set; }

    public DateTime? ResolvedAt { get; set; }

    public Guid? ResolvedBy { get; set; }

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

    // Navigation Properties
    public virtual User User { get; set; } = null!;
    public virtual Flashcard Flashcard { get; set; } = null!;
    public virtual User? ResolvedByUser { get; set; }
}

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

    public Guid UserId { get; set; }

    [Range(1, 100)]
    public int DailyGoal { get; set; } = 20;

    public TimeOnly ReminderTime { get; set; } = new(9, 0);

    public bool ReminderEnabled { get; set; } = true;

    [MaxLength(20)]
    public string DifficultyPreference { get; set; } = "balanced"; // conservative, balanced, aggressive

    public bool AutoPlayAudio { get; set; } = true;

    public bool ShowPronunciation { get; set; } = true;

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

    // Navigation Properties
    public virtual User User { get; set; } = null!;
}

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

    public Guid UserId { get; set; }

    public DateOnly Date { get; set; }

    // 學習統計
    public int WordsStudied { get; set; } = 0;
    public int WordsCorrect { get; set; } = 0;
    public int StudyTimeSeconds { get; set; } = 0;
    public int SessionCount { get; set; } = 0;

    // 生成統計
    public int CardsGenerated { get; set; } = 0;
    public int AiApiCalls { get; set; } = 0;

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

    // Navigation Properties
    public virtual User User { get; set; } = null!;
}