using System.Collections.Generic;
using System.Linq;
using EventsAppQuest.Application.Services;
using EventsAppQuest.Domain.Models;

namespace EventsAppQuest.Infrastructure.Services
{
    /// <summary>
    /// Implementação mock do serviço de temas visuais. Temas por categoria/template.
    /// </summary>
    public class MockVisualThemeService : IVisualThemeService
    {
        private readonly List<EventVisualTheme> _themes = new List<EventVisualTheme>();

        public MockVisualThemeService()
        {
            // Casamento (tpl-2, cat-wedding)
            _themes.Add(new EventVisualTheme
            {
                Id = "theme-wedding-elegant",
                Name = "Casamento clássico elegante",
                EventCategoryId = "cat-wedding",
                EventTemplateId = "tpl-2",
                Description = "Tons neutros, marfim e dourado discreto. Atmosfera refinada.",
                PrimaryColor = "#F5F0E8",
                SecondaryColor = "#2C1810",
                AccentColor = "#C9A962",
                Mood = "Elegante",
                IsDefault = true,
                DisplayOrder = 1
            });
            _themes.Add(new EventVisualTheme
            {
                Id = "theme-wedding-clean",
                Name = "Casamento clean luxury",
                EventCategoryId = "cat-wedding",
                EventTemplateId = "tpl-2",
                Description = "Branco e verde salvia. Minimalista e sofisticado.",
                PrimaryColor = "#FFFFFF",
                SecondaryColor = "#9CAF88",
                AccentColor = "#E8E4DC",
                Mood = "Clean luxury",
                IsDefault = false,
                DisplayOrder = 2
            });
            // Aniversário (tpl-1, cat-birthday)
            _themes.Add(new EventVisualTheme
            {
                Id = "theme-birthday-gold",
                Name = "Aniversário premium gold",
                EventCategoryId = "cat-birthday",
                EventTemplateId = "tpl-1",
                Description = "Dourado e preto. Festa premium.",
                PrimaryColor = "#1A1A1A",
                SecondaryColor = "#D4AF37",
                AccentColor = "#F5E6C8",
                Mood = "Premium",
                IsDefault = true,
                DisplayOrder = 3
            });
            _themes.Add(new EventVisualTheme
            {
                Id = "theme-birthday-neon",
                Name = "Aniversário neon party",
                EventCategoryId = "cat-birthday",
                EventTemplateId = "tpl-1",
                Description = "Neon e escuro. Festa animada.",
                PrimaryColor = "#0D0D0D",
                SecondaryColor = "#00FF88",
                AccentColor = "#FF00AA",
                Mood = "Neon party",
                IsDefault = false,
                DisplayOrder = 4
            });
            // Business (tpl-3, cat-business)
            _themes.Add(new EventVisualTheme
            {
                Id = "theme-business-clean",
                Name = "Business conferência clean",
                EventCategoryId = "cat-business",
                EventTemplateId = "tpl-3",
                Description = "Azul corporativo e branco. Profissional e claro.",
                PrimaryColor = "#1E3A5F",
                SecondaryColor = "#FFFFFF",
                AccentColor = "#4A90D9",
                Mood = "Clean profissional",
                IsDefault = true,
                DisplayOrder = 5
            });
            _themes.Add(new EventVisualTheme
            {
                Id = "theme-business-premium",
                Name = "Business lançamento premium",
                EventCategoryId = "cat-business",
                EventTemplateId = "tpl-3",
                Description = "Preto, dourado e grafite. Lançamento de produto.",
                PrimaryColor = "#1C1C1C",
                SecondaryColor = "#B8860B",
                AccentColor = "#4A4A4A",
                Mood = "Premium lançamento",
                IsDefault = false,
                DisplayOrder = 6
            });
        }

        public EventVisualTheme GetById(string themeId) => _themes.Find(t => t.Id == themeId);

        public IReadOnlyList<EventVisualTheme> GetByTemplateId(string templateId)
        {
            if (string.IsNullOrEmpty(templateId)) return new List<EventVisualTheme>();
            return _themes.Where(t => t.EventTemplateId == templateId).OrderBy(t => t.DisplayOrder).ToList();
        }

        public IReadOnlyList<EventVisualTheme> GetByCategoryId(string categoryId)
        {
            if (string.IsNullOrEmpty(categoryId)) return new List<EventVisualTheme>();
            return _themes.Where(t => t.EventCategoryId == categoryId).OrderBy(t => t.DisplayOrder).ToList();
        }

        public IReadOnlyList<EventVisualTheme> GetAvailableForProject(EventProject project)
        {
            if (project == null) return new List<EventVisualTheme>();
            var list = new List<EventVisualTheme>();
            if (!string.IsNullOrEmpty(project.EventTemplateId))
                list.AddRange(_themes.Where(t => t.EventTemplateId == project.EventTemplateId));
            if (!string.IsNullOrEmpty(project.EventCategoryId))
                list.AddRange(_themes.Where(t => t.EventCategoryId == project.EventCategoryId));
            return list.Distinct().OrderBy(t => t.DisplayOrder).ToList();
        }
    }
}
