namespace DramaLing.Core.Entities;

public class LearningStage : BaseEntity
{
    public string Name { get; set; } = string.Empty;
    public string Description { get; set; } = string.Empty;
    public int Order { get; set; }
    public string Level { get; set; } = string.Empty; // A1, A2, B1, etc.
    public bool IsActive { get; set; } = true;
    
    // Navigation Properties
    public virtual ICollection<Scenario> Scenarios { get; set; } = new List<Scenario>();
}

public class Scenario : BaseEntity
{
    public string Name { get; set; } = string.Empty;
    public string Description { get; set; } = string.Empty;
    public string Context { get; set; } = string.Empty;
    public string Objective { get; set; } = string.Empty;
    public string Level { get; set; } = string.Empty;
    public int EstimatedMinutes { get; set; }
    public bool IsActive { get; set; } = true;
    
    // Foreign Key
    public Guid LearningStageId { get; set; }
    
    // Navigation Properties
    public virtual LearningStage LearningStage { get; set; } = null!;
    public virtual ICollection<Vocabulary> TargetVocabularies { get; set; } = new List<Vocabulary>();
    public virtual ICollection<UserProgress> UserProgresses { get; set; } = new List<UserProgress>();
}

public class Vocabulary : BaseEntity
{
    public string Word { get; set; } = string.Empty;
    public string Translation { get; set; } = string.Empty;
    public string Pronunciation { get; set; } = string.Empty;
    public string Definition { get; set; } = string.Empty;
    public string ExampleSentence { get; set; } = string.Empty;
    public string Level { get; set; } = string.Empty;
    public string Category { get; set; } = string.Empty;
    public int Frequency { get; set; } = 0; // Word frequency ranking
    
    // Navigation Properties
    public virtual ICollection<Scenario> Scenarios { get; set; } = new List<Scenario>();
    public virtual ICollection<VocabularyProgress> VocabularyProgresses { get; set; } = new List<VocabularyProgress>();
}

public class UserProgress : BaseEntity
{
    public Guid UserId { get; set; }
    public Guid ScenarioId { get; set; }
    public int Score { get; set; }
    public int Stars { get; set; } // 0-3 stars
    public bool IsCompleted { get; set; }
    public DateTime? CompletedAt { get; set; }
    public int AttemptCount { get; set; } = 0;
    public string? FeedbackData { get; set; } // JSON data
    
    // Navigation Properties
    public virtual User User { get; set; } = null!;
    public virtual Scenario Scenario { get; set; } = null!;
}

public class VocabularyProgress : BaseEntity
{
    public Guid UserId { get; set; }
    public Guid VocabularyId { get; set; }
    public int LearningStage { get; set; } = 1; // 1=Recognition, 2=Familiarity, 3=DialogueApplication
    public int MasteryLevel { get; set; } = 0; // 0-100
    public DateTime? NextReviewAt { get; set; }
    public int ReviewCount { get; set; } = 0;
    public int CorrectCount { get; set; } = 0;
    public int IncorrectCount { get; set; } = 0;
    public DateTime? LastReviewedAt { get; set; }
    
    // Navigation Properties
    public virtual User User { get; set; } = null!;
    public virtual Vocabulary Vocabulary { get; set; } = null!;
}