using Baya.Domain.Common;
using Microsoft.AspNetCore.Identity;

namespace Baya.Domain.Entities.User;

public class User:IdentityUser<int>,IEntity
{
    public User()
    {
        this.GeneratedCode = Guid.NewGuid().ToString().Substring(0, 8);
    }

    public string Name { get; set; }
    public string FamilyName { get; set; }
    public string GeneratedCode { get; set; }

    /// <summary>
    /// "male" / "female". Load-bearing for same-gender caregiver matching — never defaulted. Not
    /// collected at OTP signup; populated later via the profile flow (b3).
    /// </summary>
    public string Gender { get; set; }

    /// <summary>Encrypted at rest. Stays NULL until the KYC pipeline (b6) verifies it — an unverified
    /// registration must never look KYC-complete.</summary>
    public string NationalId { get; set; }
    public DateTimeOffset? NationalIdVerifiedAt { get; set; }

    /// <summary>When the phone↔national-id binding was confirmed via Shahkar. Reset to NULL whenever
    /// the stored phone changes so b6 re-verifies (enforced centrally on SaveChanges).</summary>
    public DateTimeOffset? ShahkarVerifiedAt { get; set; }

    /// <summary>Deterministic keyed hash of the (encrypted) phone — carries the UNIQUE index and all
    /// equality lookups, since the ciphertext itself is non-deterministic. Synced on SaveChanges.</summary>
    public string PhoneHash { get; set; }

    public DateTimeOffset? PhoneVerifiedAt { get; set; }

    public bool IsActive { get; set; }
    public DateTimeOffset? DeletedAt { get; set; }

    public ICollection<UserRole> UserRoles { get; set; }
    public ICollection<UserLogin> Logins { get; set; }
    public ICollection<UserClaim> Claims { get; set; }
    public ICollection<UserToken> Tokens { get; set; }
    public ICollection<UserRefreshToken> UserRefreshTokens { get; set; }
    public ICollection<UserSession> Sessions { get; set; }
}