/*
 * File: ShadowedRealms.Core/Models/Admin/AdminActionAudit.cs
 * Created: 2025-11-01
 * Last Modified: 2025-11-01
 * Description: Entity model for admin action audit trail
 * Last Edit Notes: Complete audit model with comprehensive action tracking
 */

using System.ComponentModel.DataAnnotations;

namespace ShadowedRealms.Core.Models.Admin
{
    /// <summary>
    /// Audit trail for all administrative actions
    /// </summary>
    public class AdminActionAudit
    {
        [Key]
        public long Id { get; set; }

        [Required]
        [MaxLength(450)]
        public int AdminUserId { get; set; }

        // Optional - some actions might not be player-specific
        public int? PlayerId { get; set; }

        [Required]
        [MaxLength(100)]
        public string ActionType { get; set; } = string.Empty; // Suspend, Ban, Edit, Message, Login, etc.

        // Detailed description of what was done
        public string? ActionDetails { get; set; }

        // Reason provided by admin
        [MaxLength(500)]
        public string? Reason { get; set; }

        // JSON data for complex actions (before/after values, etc.)
        public string? ActionData { get; set; }

        [Required]
        public DateTime Timestamp { get; set; } = DateTime.UtcNow;

        [Required]
        public int KingdomId { get; set; }

        // IP address of admin when action was performed
        [MaxLength(45)]
        public string? IpAddress { get; set; }

        // User agent string
        [MaxLength(500)]
        public string? UserAgent { get; set; }

        // Success/failure flag
        public bool Success { get; set; } = true;

        // Error message if action failed
        public string? ErrorMessage { get; set; }

        // Duration of action (for performance monitoring)
        public int? DurationMs { get; set; }

        // Session identifier
        public string? SessionId { get; set; }

        // Additional metadata
        public string? AdditionalData { get; set; }
    }
}