namespace DramaLing.Api.Models.DTOs;

public class GenerationRequest
{
    public Guid UserId { get; set; }
    public string Style { get; set; } = "cartoon";
    public string Priority { get; set; } = "normal";
    public int Width { get; set; } = 512;
    public int Height { get; set; } = 512;
    public string ReplicateModel { get; set; } = "ideogram-v2a-turbo";
    public GenerationOptionsDto Options { get; set; } = new();
}

public class GenerationOptionsDto
{
    public bool UseGeminiCache { get; set; } = true;
    public bool UseImageCache { get; set; } = true;
    public int MaxRetries { get; set; } = 3;
    public string LearnerLevel { get; set; } = "B1";
    public string Scenario { get; set; } = "daily";
    public List<string> VisualPreferences { get; set; } = new();
}

public class GenerationRequestResult
{
    public Guid RequestId { get; set; }
    public string OverallStatus { get; set; } = string.Empty;
    public string CurrentStage { get; set; } = string.Empty;
    public EstimatedTimeDto EstimatedTimeMinutes { get; set; } = new();
    public CostEstimateDto CostEstimate { get; set; } = new();
    public int? QueuePosition { get; set; }
}

public class EstimatedTimeDto
{
    public double Gemini { get; set; } = 0.5;
    public double Replicate { get; set; } = 2.0;
    public double Total { get; set; } = 2.5;
}

public class CostEstimateDto
{
    public decimal Gemini { get; set; } = 0.001m;
    public decimal Replicate { get; set; } = 0.025m;
    public decimal Total { get; set; } = 0.026m;
}

public class ImageDescriptionResult
{
    public bool Success { get; set; }
    public string? Description { get; set; }
    public string? OptimizedPrompt { get; set; }
    public decimal Cost { get; set; }
    public int ProcessingTimeMs { get; set; }
    public string? Error { get; set; }
}

public class ImageGenerationResult
{
    public bool Success { get; set; }
    public string? ImageUrl { get; set; }
    public string? ImageId { get; set; }
    public decimal Cost { get; set; }
    public int ProcessingTimeMs { get; set; }
    public string? ModelVersion { get; set; }
    public string? Error { get; set; }
    public Dictionary<string, object>? Metadata { get; set; }
}

public class GenerationStatusResponse
{
    public Guid RequestId { get; set; }
    public string OverallStatus { get; set; } = string.Empty;
    public StageStatusDto Stages { get; set; } = new();
    public decimal? TotalCost { get; set; }
    public DateTime? CompletedAt { get; set; }
    public GenerationResultDto? Result { get; set; }
}

public class StageStatusDto
{
    public GeminiStageDto Gemini { get; set; } = new();
    public ReplicateStageDto Replicate { get; set; } = new();
}

public class GeminiStageDto
{
    public string Status { get; set; } = string.Empty;
    public DateTime? StartedAt { get; set; }
    public DateTime? CompletedAt { get; set; }
    public int? ProcessingTimeMs { get; set; }
    public decimal? Cost { get; set; }
    public string? GeneratedDescription { get; set; }
}

public class ReplicateStageDto
{
    public string Status { get; set; } = string.Empty;
    public DateTime? StartedAt { get; set; }
    public DateTime? CompletedAt { get; set; }
    public int? ProcessingTimeMs { get; set; }
    public decimal? Cost { get; set; }
    public string? Model { get; set; }
    public string? ModelVersion { get; set; }
    public string? Progress { get; set; }
}

public class GenerationResultDto
{
    public string? ImageUrl { get; set; }
    public string? ImageId { get; set; }
    public decimal? QualityScore { get; set; }
    public DimensionsDto? Dimensions { get; set; }
    public int? FileSize { get; set; }
}

public class DimensionsDto
{
    public int Width { get; set; }
    public int Height { get; set; }
}