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

namespace EventsAppQuest.Infrastructure.Services
{
    /// <summary>
    /// Implementacao mock do servico de itens do showroom para desenvolvimento local.
    /// Itens vinculados aos templates existentes (tpl-1, tpl-2, tpl-3).
    /// </summary>
    public class MockShowroomService : IShowroomService
    {
        private readonly List<ShowroomItem> _items = new List<ShowroomItem>
        {
            // Template Aniversário Infantil (tpl-1) — metadados de posicionamento para futura MR/Quest 3
            new ShowroomItem { Id = "shr-1", Name = "Mesa do bolo", Type = ShowroomItemType.Furniture, Description = "Mesa decorada para bolo", SupplierId = "supplier-1", EventTemplateId = "tpl-1", IsIncludedByDefault = true, EstimatedPrice = 350f, PlacementZone = PlacementZoneType.DiningArea, SpatialAnchorType = SpatialAnchorType.Tabletop, DisplayOrder = 1, SeatingProvided = 8, StandingAreaImpact = 0, BlocksCirculation = false, RequiresServiceAccess = false, FootprintWeight = 25, SetupDurationMinutes = 25, RequiresEarlySetup = false, RequiresSupplierOnSite = false, ExecutionPriority = 3 },
            new ShowroomItem { Id = "shr-2", Name = "Decoração infantil", Type = ShowroomItemType.Decoration, Description = "Balões e painéis temáticos", SupplierId = "supplier-1", EventTemplateId = "tpl-1", IsIncludedByDefault = true, EstimatedPrice = 800f, PlacementZone = PlacementZoneType.Center, SpatialAnchorType = SpatialAnchorType.Freestanding, DisplayOrder = 2, BlocksCirculation = true, RequiresServiceAccess = false, FootprintWeight = 40, SetupDurationMinutes = 45, RequiresEarlySetup = false, RequiresSupplierOnSite = true, ExecutionPriority = 4 },
            new ShowroomItem { Id = "shr-3", Name = "Buffet infantil", Type = ShowroomItemType.Buffet, Description = "Doces e salgados", SupplierId = "supplier-3", EventTemplateId = "tpl-1", IsIncludedByDefault = false, EstimatedPrice = 2500f, PlacementZone = PlacementZoneType.DiningArea, SpatialAnchorType = SpatialAnchorType.Tabletop, DisplayOrder = 3, SeatingProvided = 0, StandingAreaImpact = 15, BlocksCirculation = false, RequiresServiceAccess = true, ServiceAccessPriority = 7, FootprintWeight = 50, SetupDurationMinutes = 60, RequiresEarlySetup = false, SetupDependencyTypes = new List<string> { "Power" }, RequiresSupplierOnSite = true, ExecutionPriority = 6 },
            new ShowroomItem { Id = "shr-4", Name = "Iluminação colorida", Type = ShowroomItemType.Lighting, Description = "Luzes e efeitos", SupplierId = "supplier-2", EventTemplateId = "tpl-1", IsIncludedByDefault = false, EstimatedPrice = 600f, PlacementZone = PlacementZoneType.Center, SpatialAnchorType = SpatialAnchorType.Ceiling, DisplayOrder = 4, RequiresServiceAccess = false, FootprintWeight = 10, SetupDurationMinutes = 30, RequiresEarlySetup = false, RequiresSupplierOnSite = false, ExecutionPriority = 5 },
            // Template Casamento (tpl-2)
            new ShowroomItem { Id = "shr-5", Name = "Arco de flores", Type = ShowroomItemType.Decoration, Description = "Arco para cerimônia", SupplierId = "supplier-4", EventTemplateId = "tpl-2", IsIncludedByDefault = true, EstimatedPrice = 1800f, PlacementZone = PlacementZoneType.StageArea, SpatialAnchorType = SpatialAnchorType.Freestanding, DisplayOrder = 5, BlocksCirculation = false, RequiresServiceAccess = false, FootprintWeight = 30, SetupDurationMinutes = 40, RequiresEarlySetup = false, SetupDependencyTypes = new List<string> { "Stage" }, RequiresSupplierOnSite = false, ExecutionPriority = 5 },
            new ShowroomItem { Id = "shr-6", Name = "Mesa de doces", Type = ShowroomItemType.Buffet, Description = "Sweet table", SupplierId = "supplier-3", EventTemplateId = "tpl-2", IsIncludedByDefault = true, EstimatedPrice = 3200f, PlacementZone = PlacementZoneType.DiningArea, SpatialAnchorType = SpatialAnchorType.Tabletop, DisplayOrder = 6, SeatingProvided = 0, StandingAreaImpact = 20, RequiresServiceAccess = true, ServiceAccessPriority = 8, FootprintWeight = 55, SetupDurationMinutes = 90, RequiresEarlySetup = false, RequiresSupplierOnSite = true, ExecutionPriority = 7 },
            new ShowroomItem { Id = "shr-7", Name = "Palco para cerimônia", Type = ShowroomItemType.Stage, Description = "Estrutura e piso", SupplierId = "supplier-2", EventTemplateId = "tpl-2", IsIncludedByDefault = true, EstimatedPrice = 1500f, PlacementZone = PlacementZoneType.StageArea, SpatialAnchorType = SpatialAnchorType.Floor, DisplayOrder = 7, SeatingProvided = 0, StandingAreaImpact = 0, RequiresServiceAccess = true, ServiceAccessPriority = 9, FootprintWeight = 60, SetupDurationMinutes = 120, RequiresEarlySetup = true, SetupDependencyTypes = new List<string> { "Structure" }, RequiresSupplierOnSite = true, ExecutionPriority = 9 },
            new ShowroomItem { Id = "shr-8", Name = "Iluminação ambiente", Type = ShowroomItemType.Lighting, Description = "Spots e dimmer", SupplierId = "supplier-2", EventTemplateId = "tpl-2", IsIncludedByDefault = false, EstimatedPrice = 1200f, PlacementZone = PlacementZoneType.Center, SpatialAnchorType = SpatialAnchorType.Ceiling, DisplayOrder = 8, FootprintWeight = 15, SetupDurationMinutes = 45, RequiresEarlySetup = false, SetupDependencyTypes = new List<string> { "Power" }, RequiresSupplierOnSite = false, ExecutionPriority = 5 },
            // Template Corporativo (tpl-3)
            new ShowroomItem { Id = "shr-9", Name = "Palco para apresentação", Type = ShowroomItemType.Stage, Description = "Palco e escada", SupplierId = "supplier-2", EventTemplateId = "tpl-3", IsIncludedByDefault = true, EstimatedPrice = 2200f, PlacementZone = PlacementZoneType.StageArea, SpatialAnchorType = SpatialAnchorType.Floor, DisplayOrder = 9, RequiresServiceAccess = true, ServiceAccessPriority = 9, FootprintWeight = 70, SetupDurationMinutes = 150, RequiresEarlySetup = true, SetupDependencyTypes = new List<string> { "Structure" }, RequiresSupplierOnSite = true, ExecutionPriority = 9 },
            new ShowroomItem { Id = "shr-10", Name = "Mesas de reunião", Type = ShowroomItemType.Furniture, Description = "Mesas e cadeiras", SupplierId = "supplier-1", EventTemplateId = "tpl-3", IsIncludedByDefault = true, EstimatedPrice = 900f, PlacementZone = PlacementZoneType.Center, SpatialAnchorType = SpatialAnchorType.Floor, DisplayOrder = 10, SeatingProvided = 24, StandingAreaImpact = 0, BlocksCirculation = true, RequiresServiceAccess = false, FootprintWeight = 80, SetupDurationMinutes = 60, RequiresEarlySetup = false, RequiresSupplierOnSite = false, ExecutionPriority = 4 },
            new ShowroomItem { Id = "shr-11", Name = "Coffee break", Type = ShowroomItemType.Buffet, Description = "Café e lanches", SupplierId = "supplier-3", EventTemplateId = "tpl-3", IsIncludedByDefault = false, EstimatedPrice = 1800f, PlacementZone = PlacementZoneType.LoungeArea, SpatialAnchorType = SpatialAnchorType.Tabletop, DisplayOrder = 11, RequiresServiceAccess = true, ServiceAccessPriority = 6, FootprintWeight = 35, SetupDurationMinutes = 75, RequiresEarlySetup = false, RequiresSupplierOnSite = true, ExecutionPriority = 6 },
            new ShowroomItem { Id = "shr-12", Name = "Projetor e tela", Type = ShowroomItemType.Other, Description = "Audiovisual", SupplierId = "supplier-2", EventTemplateId = "tpl-3", IsIncludedByDefault = false, EstimatedPrice = 450f, PlacementZone = PlacementZoneType.StageArea, SpatialAnchorType = SpatialAnchorType.Wall, DisplayOrder = 12, FootprintWeight = 20, SetupDurationMinutes = 40, RequiresEarlySetup = false, SetupDependencyTypes = new List<string> { "Power", "Stage" }, RequiresSupplierOnSite = true, ExecutionPriority = 7 }
        };

        public IReadOnlyList<ShowroomItem> GetAll() => _items;

        public ShowroomItem GetById(string id) => _items.Find(i => i.Id == id);

        public IReadOnlyList<ShowroomItem> GetByTemplateId(string templateId)
        {
            if (string.IsNullOrEmpty(templateId)) return new List<ShowroomItem>();
            var list = new List<ShowroomItem>();
            foreach (var i in _items)
                if (i.EventTemplateId == templateId)
                    list.Add(i);
            return list;
        }

        public IReadOnlyList<ShowroomItem> GetAvailableItemsToAdd(EventProject project)
        {
            if (project == null) return new List<ShowroomItem>();
            var currentIds = new HashSet<string>(project.ShowroomItemIds ?? new List<string>());
            var byTemplate = GetByTemplateId(project.EventTemplateId);
            var list = new List<ShowroomItem>();
            foreach (var item in byTemplate)
                if (!currentIds.Contains(item.Id))
                    list.Add(item);
            return list;
        }
    }
}
