using System.ComponentModel.DataAnnotations;

namespace FutureMailAPI.DTOs
{
    public class TimeCapsuleCreateDto
    {
        [Required(ErrorMessage = "邮件ID是必填项")]
        public int SentMailId { get; set; }
        
        // 胶囊位置信息(X, Y, Z坐标)
        public double PositionX { get; set; } = 0;
        public double PositionY { get; set; } = 0;
        public double PositionZ { get; set; } = 0;
        
        // 胶囊大小
        [Range(0.1, 5.0, ErrorMessage = "胶囊大小必须在0.1-5.0之间")]
        public double Size { get; set; } = 1.0;
        
        // 胶囊颜色
        [StringLength(20, ErrorMessage = "颜色代码长度不能超过20个字符")]
        public string? Color { get; set; }
        
        // 胶囊透明度
        [Range(0.1, 1.0, ErrorMessage = "透明度必须在0.1-1.0之间")]
        public double Opacity { get; set; } = 1.0;
        
        // 胶囊旋转角度
        [Range(0, 360, ErrorMessage = "旋转角度必须在0-360度之间")]
        public double Rotation { get; set; } = 0;
        
        // 胶囊类型: 0-普通, 1-特殊, 2-限时
        [Range(0, 2, ErrorMessage = "胶囊类型必须是0、1或2")]
        public int Type { get; set; } = 0;
    }
    
    public class TimeCapsuleUpdateDto
    {
        // 胶囊位置信息(X, Y, Z坐标)
        public double? PositionX { get; set; }
        public double? PositionY { get; set; }
        public double? PositionZ { get; set; }
        
        // 胶囊大小
        [Range(0.1, 5.0, ErrorMessage = "胶囊大小必须在0.1-5.0之间")]
        public double? Size { get; set; }
        
        // 胶囊颜色
        [StringLength(20, ErrorMessage = "颜色代码长度不能超过20个字符")]
        public string? Color { get; set; }
        
        // 胶囊透明度
        [Range(0.1, 1.0, ErrorMessage = "透明度必须在0.1-1.0之间")]
        public double? Opacity { get; set; }
        
        // 胶囊旋转角度
        [Range(0, 360, ErrorMessage = "旋转角度必须在0-360度之间")]
        public double? Rotation { get; set; }
    }
    
    public class TimeCapsuleResponseDto
    {
        public int Id { get; set; }
        public int UserId { get; set; }
        public int SentMailId { get; set; }
        public string MailTitle { get; set; } = string.Empty;
        public double PositionX { get; set; }
        public double PositionY { get; set; }
        public double PositionZ { get; set; }
        public double Size { get; set; }
        public string? Color { get; set; }
        public double Opacity { get; set; }
        public double Rotation { get; set; }
        public int Status { get; set; }
        public int Type { get; set; }
        public DateTime CreatedAt { get; set; }
        public DateTime DeliveryTime { get; set; }
        
        // 计算属性
        public string StatusText { get; set; } = string.Empty;
        public string TypeText { get; set; } = string.Empty;
        public int DaysUntilDelivery { get; set; }
        public double DistanceFromNow { get; set; } // 距离"现在"的距离，用于3D可视化
    }
    
    public class TimeCapsuleListQueryDto
    {
        public int PageIndex { get; set; } = 1;
        public int PageSize { get; set; } = 50;
        public int? Status { get; set; }
        public int? Type { get; set; }
        public bool? IncludeExpired { get; set; } = false;
    }
    
    public class TimeCapsuleViewResponseDto
    {
        public List<TimeCapsuleViewDto> Capsules { get; set; } = new List<TimeCapsuleViewDto>();
        public string Scene { get; set; } = "SPACE"; // 场景类型: SPACE | OCEAN
        public string Background { get; set; } = string.Empty; // 背景配置
    }
    
    public class TimeCapsuleViewDto
    {
        public int CapsuleId { get; set; }
        public int MailId { get; set; }
        public string Title { get; set; } = string.Empty;
        public DateTime SendTime { get; set; }
        public DateTime DeliveryTime { get; set; }
        public double Progress { get; set; } // 0-1 的进度
        public TimeCapsulePosition Position { get; set; } = new TimeCapsulePosition();
        public string Style { get; set; } = string.Empty;
        public double GlowIntensity { get; set; } // 发光强度
    }
    
    public class TimeCapsulePosition
    {
        public double X { get; set; } // 0-1 相对位置
        public double Y { get; set; }
        public double Z { get; set; }
    }
    
    public class TimeCapsuleStyleUpdateDto
    {
        [Required(ErrorMessage = "样式是必填项")]
        [StringLength(50, ErrorMessage = "样式长度不能超过50个字符")]
        public string Style { get; set; } = string.Empty;
        
        [Range(0.0, 1.0, ErrorMessage = "发光强度必须在0.0-1.0之间")]
        public double? GlowIntensity { get; set; }
    }
}