namespace MealPlan.Api.DTOs.Diet;

public class UserDailyGoalsDto
{
    public int? CalorieGoal { get; set; }
    public decimal? ProteinGoalG { get; set; }
    public decimal? FatGoalG { get; set; }
    public decimal? CarbsGoalG { get; set; }
    public int? WaterGoalMl { get; set; }
}

public class MacroRemainingDto
{
    public int? Goal { get; set; }
    public int Consumed { get; set; }
    public int? Remaining { get; set; }
    public decimal? ProgressPercent { get; set; }
}

public class DecimalMacroRemainingDto
{
    public decimal? Goal { get; set; }
    public decimal Consumed { get; set; }
    public decimal? Remaining { get; set; }
    public decimal? ProgressPercent { get; set; }
}

public class DailySummaryDto
{
    public DateOnly Date { get; set; }
    public UserDailyGoalsDto? Goals { get; set; }
    public MacroRemainingDto Calories { get; set; } = new();
    public DecimalMacroRemainingDto ProteinG { get; set; } = new();
    public DecimalMacroRemainingDto FatG { get; set; } = new();
    public DecimalMacroRemainingDto CarbsG { get; set; } = new();
    public MacroRemainingDto WaterMl { get; set; } = new();
    public IReadOnlyList<MealConsumptionDto> Meals { get; set; } = Array.Empty<MealConsumptionDto>();
    public IReadOnlyList<DrinkConsumptionDto> Drinks { get; set; } = Array.Empty<DrinkConsumptionDto>();
}

public class MealConsumptionDto
{
    public int Id { get; set; }
    public int? RecipeId { get; set; }
    public int MealCategory { get; set; }
    public DateOnly LogDate { get; set; }
    public DateTime ConsumedAt { get; set; }
    public string Name { get; set; } = string.Empty;
    public decimal Portions { get; set; }
    public int? Calories { get; set; }
    public decimal? ProteinG { get; set; }
    public decimal? FatG { get; set; }
    public decimal? CarbsG { get; set; }
    public string? Notes { get; set; }
}

public class LogMealDto
{
    public int? RecipeId { get; set; }
    public int? CatalogItemId { get; set; }
    public decimal? Grams { get; set; }
    public string? Name { get; set; }
    public int MealCategory { get; set; }
    public DateOnly? LogDate { get; set; }
    public DateTime? ConsumedAt { get; set; }
    public decimal Portions { get; set; } = 1m;
    public int? Calories { get; set; }
    public decimal? ProteinG { get; set; }
    public decimal? FatG { get; set; }
    public decimal? CarbsG { get; set; }
    public string? Notes { get; set; }
}

public class MealMacroSnapshotDto
{
    public string Name { get; set; } = string.Empty;
    public decimal Portions { get; set; } = 1m;
    public int? Calories { get; set; }
    public decimal? ProteinG { get; set; }
    public decimal? FatG { get; set; }
    public decimal? CarbsG { get; set; }
}

public class RemainingAfterMealDto
{
    public int? Calories { get; set; }
    public decimal? ProteinG { get; set; }
    public decimal? FatG { get; set; }
    public decimal? CarbsG { get; set; }
}

public class MealPreviewDto
{
    public MealMacroSnapshotDto Meal { get; set; } = new();
    public RemainingAfterMealDto RemainingAfter { get; set; } = new();
}

public class DietSuggestionDto
{
    public int CatalogItemId { get; set; }
    public string Name { get; set; } = string.Empty;
    public string? NamePl { get; set; }
    public string CategoryCode { get; set; } = string.Empty;
    public int SuggestedGrams { get; set; }
    public int? Calories { get; set; }
    public decimal? ProteinG { get; set; }
    public decimal? FatG { get; set; }
    public decimal? CarbsG { get; set; }
    public string ReasonKey { get; set; } = string.Empty;
}

public class DrinkCatalogItemDto
{
    public int Id { get; set; }
    public string Code { get; set; } = string.Empty;
    public string Name { get; set; } = string.Empty;
    public int DefaultVolumeMl { get; set; }
    public decimal? CaloriesPer100Ml { get; set; }
    public string? IconEmoji { get; set; }
}

public class DrinkConsumptionDto
{
    public int Id { get; set; }
    public int? DrinkCatalogId { get; set; }
    public DateOnly LogDate { get; set; }
    public DateTime ConsumedAt { get; set; }
    public string Name { get; set; } = string.Empty;
    public int VolumeMl { get; set; }
    public int? Calories { get; set; }
}

public class LogDrinkDto
{
    public int? DrinkCatalogId { get; set; }
    public string? Name { get; set; }
    public int VolumeMl { get; set; }
    public DateOnly? LogDate { get; set; }
    public DateTime? ConsumedAt { get; set; }
    public int? Calories { get; set; }
}

public class DietReminderDto
{
    public int Id { get; set; }
    public int ReminderType { get; set; }
    public string Title { get; set; } = string.Empty;
    public string? Message { get; set; }
    public TimeOnly TimeOfDay { get; set; }
    public int DaysOfWeekMask { get; set; }
    public int? MealCategory { get; set; }
    public bool IsEnabled { get; set; }
}

public class CreateDietReminderDto
{
    public int ReminderType { get; set; }
    public string Title { get; set; } = string.Empty;
    public string? Message { get; set; }
    public TimeOnly TimeOfDay { get; set; }
    public int DaysOfWeekMask { get; set; } = Models.ReminderDaysMask.All;
    public int? MealCategory { get; set; }
    public bool IsEnabled { get; set; } = true;
}

public class UpdateDietReminderDto : CreateDietReminderDto
{
}

public class DueReminderDto
{
    public int Id { get; set; }
    public int ReminderType { get; set; }
    public string Title { get; set; } = string.Empty;
    public string? Message { get; set; }
    public TimeOnly TimeOfDay { get; set; }
    public int? MealCategory { get; set; }
}

public class HistoryDayDto
{
    public DateOnly Date { get; set; }
    public int Calories { get; set; }
    public decimal ProteinG { get; set; }
    public decimal FatG { get; set; }
    public decimal CarbsG { get; set; }
    public int WaterMl { get; set; }
    public int MealCount { get; set; }
}

public class RecentMealDto
{
    public int? RecipeId { get; set; }
    public int? CatalogItemId { get; set; }
    public string Name { get; set; } = string.Empty;
    public int MealCategory { get; set; }
    public decimal Portions { get; set; } = 1m;
    public decimal? Grams { get; set; }
    public int? Calories { get; set; }
    public decimal? ProteinG { get; set; }
    public decimal? FatG { get; set; }
    public decimal? CarbsG { get; set; }
    public DateTime LastLoggedAt { get; set; }
}

public class FavoriteRecipeDto
{
    public int RecipeId { get; set; }
    public string Name { get; set; } = string.Empty;
    public int MealCategory { get; set; }
    public int? Calories { get; set; }
}

public class FavoriteCatalogItemDto
{
    public int CatalogItemId { get; set; }
    public string Name { get; set; } = string.Empty;
    public string? NamePl { get; set; }
    public string CategoryCode { get; set; } = string.Empty;
}

public class CopyMealsResultDto
{
    public DateOnly SourceDate { get; set; }
    public DateOnly TargetDate { get; set; }
    public int CopiedCount { get; set; }
}
