<?php

namespace Database\Seeders;

use App\Models\Product;
use App\Models\Category;
use App\Models\Brand;
use Illuminate\Database\Seeder;
use Illuminate\Support\Str;

class ProductSeeder extends Seeder
{
    public function run(): void
    {
        // Get categories and brands
        $vestidos = Category::where('slug', 'vestidos')->first();
        $blusas = Category::where('slug', 'blusas')->first();
        $camisas = Category::where('slug', 'camisas')->first();
        $tenis = Category::where('slug', 'tenis')->first();
        $bolsas = Category::where('slug', 'bolsas')->first();

        $nike = Brand::where('slug', 'nike')->first();
        $zara = Brand::where('slug', 'zara')->first();
        $hm = Brand::where('slug', 'hm')->first();
        $lacoste = Brand::where('slug', 'lacoste')->first();

        $products = [
            // Vestidos
            [
                'name' => 'Vestido Floral Primavera',
                'slug' => 'vestido-floral-primavera',
                'sku' => 'VEST-001',
                'description' => 'Vestido leve e elegante com estampa floral',
                'category_id' => $vestidos?->id ?? 1,
                'brand_id' => $zara?->id,
                'price' => 1200.00,
                'compare_at_price' => 1500.00,
                'cost_price' => 800.00,
                'images' => ['/images/products/vestido-floral-1.jpg'],
                'sizes' => ['P', 'M', 'G', 'GG'],
                'colors' => ['Azul', 'Rosa', 'Branco'],
                'materials' => ['Algodão', 'Poliéster'],
                'is_active' => true,
                'is_featured' => true,
                'is_new' => true,
                'rating' => 4.5,
                'reviews_count' => 12,
            ],
            [
                'name' => 'Vestido Longo Elegante',
                'slug' => 'vestido-longo-elegante',
                'sku' => 'VEST-002',
                'description' => 'Vestido longo perfeito para ocasiões especiais',
                'category_id' => $vestidos?->id ?? 1,
                'brand_id' => $hm?->id,
                'price' => 1800.00,
                'compare_at_price' => 2200.00,
                'cost_price' => 1200.00,
                'images' => ['/images/products/vestido-longo-1.jpg'],
                'sizes' => ['P', 'M', 'G'],
                'colors' => ['Preto', 'Vermelho', 'Azul Marinho'],
                'materials' => ['Seda', 'Poliéster'],
                'is_active' => true,
                'is_featured' => true,
                'rating' => 4.8,
                'reviews_count' => 25,
            ],
            
            // Blusas
            [
                'name' => 'Blusa Básica Cotton',
                'slug' => 'blusa-basica-cotton',
                'sku' => 'BLUS-001',
                'description' => 'Blusa básica 100% algodão, confortável para o dia a dia',
                'category_id' => $blusas?->id ?? 2,
                'brand_id' => $hm?->id,
                'price' => 450.00,
                'cost_price' => 250.00,
                'images' => ['/images/products/blusa-cotton-1.jpg'],
                'sizes' => ['P', 'M', 'G', 'GG'],
                'colors' => ['Branco', 'Preto', 'Cinza', 'Azul'],
                'materials' => ['Algodão'],
                'is_active' => true,
                'is_new' => true,
                'rating' => 4.3,
                'reviews_count' => 45,
            ],
            
            // Camisas Masculinas
            [
                'name' => 'Camisa Social Slim Fit',
                'slug' => 'camisa-social-slim-fit',
                'sku' => 'CAM-001',
                'description' => 'Camisa social moderna com corte slim fit',
                'category_id' => $camisas?->id ?? 3,
                'brand_id' => $lacoste?->id,
                'price' => 950.00,
                'compare_at_price' => 1200.00,
                'cost_price' => 600.00,
                'images' => ['/images/products/camisa-social-1.jpg'],
                'sizes' => ['P', 'M', 'G', 'GG', 'XG'],
                'colors' => ['Branco', 'Azul', 'Preto'],
                'materials' => ['Algodão', 'Elastano'],
                'is_active' => true,
                'is_featured' => true,
                'rating' => 4.6,
                'reviews_count' => 33,
            ],
            [
                'name' => 'Camisa Polo Clássica',
                'slug' => 'camisa-polo-classica',
                'sku' => 'CAM-002',
                'description' => 'Polo clássica de alta qualidade',
                'category_id' => $camisas?->id ?? 3,
                'brand_id' => $lacoste?->id,
                'price' => 750.00,
                'cost_price' => 450.00,
                'images' => ['/images/products/polo-1.jpg'],
                'sizes' => ['P', 'M', 'G', 'GG'],
                'colors' => ['Azul Marinho', 'Preto', 'Verde', 'Vermelho'],
                'materials' => ['Algodão'],
                'is_active' => true,
                'rating' => 4.7,
                'reviews_count' => 56,
            ],
            
            // Tênis
            [
                'name' => 'Tênis Nike Air Max',
                'slug' => 'tenis-nike-air-max',
                'sku' => 'TENIS-001',
                'barcode' => '7891234567890',
                'description' => 'Tênis esportivo confortável e estiloso',
                'category_id' => $tenis?->id ?? 4,
                'brand_id' => $nike?->id,
                'price' => 2200.00,
                'compare_at_price' => 2800.00,
                'cost_price' => 1500.00,
                'images' => ['/images/products/nike-air-max-1.jpg'],
                'sizes' => ['38', '39', '40', '41', '42', '43', '44'],
                'colors' => ['Branco', 'Preto', 'Cinza'],
                'materials' => ['Sintético', 'Borracha'],
                'weight' => 450.00,
                'is_active' => true,
                'is_featured' => true,
                'is_new' => true,
                'rating' => 4.9,
                'reviews_count' => 120,
            ],
            [
                'name' => 'Tênis Casual Urbano',
                'slug' => 'tenis-casual-urbano',
                'sku' => 'TENIS-002',
                'description' => 'Tênis casual para o dia a dia',
                'category_id' => $tenis?->id ?? 4,
                'brand_id' => $nike?->id,
                'price' => 1600.00,
                'cost_price' => 1000.00,
                'images' => ['/images/products/tenis-casual-1.jpg'],
                'sizes' => ['38', '39', '40', '41', '42', '43'],
                'colors' => ['Preto', 'Branco', 'Azul'],
                'materials' => ['Couro', 'Borracha'],
                'is_active' => true,
                'rating' => 4.4,
                'reviews_count' => 67,
            ],
            
            // Bolsas
            [
                'name' => 'Bolsa Feminina Elegante',
                'slug' => 'bolsa-feminina-elegante',
                'sku' => 'BOLSA-001',
                'description' => 'Bolsa de mão elegante e espaçosa',
                'category_id' => $bolsas?->id ?? 5,
                'brand_id' => $zara?->id,
                'price' => 1400.00,
                'compare_at_price' => 1800.00,
                'cost_price' => 900.00,
                'images' => ['/images/products/bolsa-elegante-1.jpg'],
                'colors' => ['Preto', 'Marrom', 'Bege'],
                'materials' => ['Couro Sintético'],
                'is_active' => true,
                'is_featured' => true,
                'rating' => 4.6,
                'reviews_count' => 89,
            ],
            [
                'name' => 'Mochila Urbana Moderna',
                'slug' => 'mochila-urbana-moderna',
                'sku' => 'BOLSA-002',
                'description' => 'Mochila prática e estilosa para o dia a dia',
                'category_id' => $bolsas?->id ?? 5,
                'brand_id' => $nike?->id,
                'price' => 850.00,
                'cost_price' => 550.00,
                'images' => ['/images/products/mochila-1.jpg'],
                'colors' => ['Preto', 'Cinza', 'Azul'],
                'materials' => ['Nylon', 'Poliéster'],
                'is_active' => true,
                'is_new' => true,
                'rating' => 4.5,
                'reviews_count' => 43,
            ],
            [
                'name' => 'Carteira de Couro Premium',
                'slug' => 'carteira-couro-premium',
                'sku' => 'CART-001',
                'description' => 'Carteira masculina de couro legítimo',
                'category_id' => $bolsas?->id ?? 5,
                'brand_id' => $lacoste?->id,
                'price' => 380.00,
                'cost_price' => 200.00,
                'images' => ['/images/products/carteira-1.jpg'],
                'colors' => ['Preto', 'Marrom'],
                'materials' => ['Couro Legítimo'],
                'is_active' => true,
                'rating' => 4.7,
                'reviews_count' => 156,
            ],
        ];

        foreach ($products as $product) {
            Product::create($product);
        }
    }
}
