using Microsoft.AspNetCore.Identity;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace NexusReader.Domain.Entities;

public class NexusUser : IdentityUser
{
    /// <summary>
    /// User's display name or full name.
    /// </summary>
    [MaxLength(100)]
    public string? DisplayName { get; set; }

    /// <summary>
    /// Total AI tokens available for the user (depends on subscription).
    /// </summary>
    public int AITokenLimit { get; set; }

    /// <summary>
    /// AI tokens consumed by the user in the current billing period.
    /// </summary>
    public int AITokensUsed { get; set; }

    /// <summary>
    /// Date when the user last performed an AI-related action.
    /// </summary>
    public DateTime? LastAiActionDate { get; set; }

    /// <summary>
    /// Multi-tenant identifier.
    /// </summary>
    [Required]
    [MaxLength(128)]
    public string TenantId { get; set; } = "global";

    /// <summary>
    /// Foreign key for the current subscription plan.
    /// </summary>
    [Required]
    public int SubscriptionPlanId { get; set; }

    /// <summary>
    /// Navigation property for the current subscription plan.
    /// </summary>
    public SubscriptionPlan? SubscriptionPlan { get; set; }

    /// <summary>
    /// Collection of e-books owned by the user.
    /// </summary>
    public ICollection<Ebook> Ebooks { get; set; } = new List<Ebook>();

    /// <summary>
    /// Collection of quiz results completed by the user.
    /// </summary>
    public ICollection<QuizResult> QuizResults { get; set; } = new List<QuizResult>();

    /// <summary>
    /// ID of the last page read by the user.
    /// </summary>
    [MaxLength(255)]
    public string? LastReadPageId { get; set; }

    /// <summary>
    /// Last read timestamp.
    /// </summary>
    public DateTime? LastReadAt { get; set; }
}
