using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;

namespace QRRapidoApp.Models
{
    public class User
    {
        [BsonId]
        [BsonRepresentation(BsonType.ObjectId)]
        public string Id { get; set; } = string.Empty;

        [BsonElement("email")]
        public string Email { get; set; } = string.Empty;

        [BsonElement("name")]
        public string Name { get; set; } = string.Empty;

        [BsonElement("provider")]
        public string Provider { get; set; } = string.Empty; // Google, Microsoft

        [BsonElement("providerId")]
        public string ProviderId { get; set; } = string.Empty;

        [BsonElement("isPremium")]
        public bool IsPremium { get; set; } = false;

        [BsonElement("createdAt")]
        public DateTime CreatedAt { get; set; } = DateTime.UtcNow;

        [BsonElement("premiumExpiresAt")]
        public DateTime? PremiumExpiresAt { get; set; }

        [BsonElement("premiumCancelledAt")]
        public DateTime? PremiumCancelledAt { get; set; } // ADICIONADO: Data do cancelamento

        [BsonElement("lastLoginAt")]
        public DateTime LastLoginAt { get; set; } = DateTime.UtcNow;

        [BsonElement("qrHistoryIds")]
        public List<string> QRHistoryIds { get; set; } = new();

        [BsonElement("stripeCustomerId")]
        public string? StripeCustomerId { get; set; }

        [BsonElement("stripeSubscriptionId")]
        public string? StripeSubscriptionId { get; set; }

        [BsonElement("preferredLanguage")]
        public string PreferredLanguage { get; set; } = "pt-BR";

        [BsonElement("dailyQRCount")]
        public int DailyQRCount { get; set; } = 0;

        [BsonElement("lastQRDate")]
        public DateTime LastQRDate { get; set; } = DateTime.UtcNow.Date;

        [BsonElement("totalQRGenerated")]
        public int TotalQRGenerated { get; set; } = 0;
    }
}