using System.ComponentModel.DataAnnotations;

namespace DramaLing.Api.Models.DTOs;

public class CreateFlashcardRequest
{
    [Required(ErrorMessage = "詞彙為必填項目")]
    [StringLength(255, ErrorMessage = "詞彙長度不得超過 255 字元")]
    public string Word { get; set; } = string.Empty;

    [Required(ErrorMessage = "翻譯為必填項目")]
    public string Translation { get; set; } = string.Empty;

    [Required(ErrorMessage = "定義為必填項目")]
    public string Definition { get; set; } = string.Empty;

    [StringLength(255, ErrorMessage = "發音長度不得超過 255 字元")]
    public string Pronunciation { get; set; } = string.Empty;

    [RegularExpression("^(noun|verb|adjective|adverb|preposition|interjection|phrase)$",
                      ErrorMessage = "詞性必須為有效值")]
    public string PartOfSpeech { get; set; } = "noun";

    [Required(ErrorMessage = "例句為必填項目")]
    public string Example { get; set; } = string.Empty;

    public string? ExampleTranslation { get; set; }

    [RegularExpression("^(A1|A2|B1|B2|C1|C2)$",
                      ErrorMessage = "CEFR 等級必須為有效值")]
    public string? DifficultyLevel { get; set; } = "A2";
}

public class UpdateFlashcardRequest : CreateFlashcardRequest
{
    // 繼承所有創建請求的欄位，用於更新操作
}

public class FlashcardResponse
{
    public Guid Id { get; set; }
    public string Word { get; set; } = string.Empty;
    public string Translation { get; set; } = string.Empty;
    public string Definition { get; set; } = string.Empty;
    public string? PartOfSpeech { get; set; }
    public string? Pronunciation { get; set; }
    public string? Example { get; set; }
    public string? ExampleTranslation { get; set; }
    public int MasteryLevel { get; set; }
    public int TimesReviewed { get; set; }
    public bool IsFavorite { get; set; }
    public DateTime NextReviewDate { get; set; }
    public string? DifficultyLevel { get; set; }
    public DateTime CreatedAt { get; set; }
    public DateTime? UpdatedAt { get; set; }
}

public class BatchFavoriteRequest
{
    [Required]
    public List<Guid> FlashcardIds { get; set; } = new();

    public bool IsFavorite { get; set; }
}

public class BatchDeleteRequest
{
    [Required]
    public List<Guid> FlashcardIds { get; set; } = new();
}