<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\Models\Product;
use App\Models\Category;

class ProductSeeder extends Seeder
{
    public function run(): void
    {
        $mdfCategory = Category::where('slug', 'mdf')->first();
        $mfcCategory = Category::where('slug', 'melamine-faced-chipboard')->first();
        $osbCategory = Category::where('slug', 'osb')->first();
        $marineCategory = Category::where('slug', 'marine-plywood')->first();

        $products = [
            // MDF Products
            [
                'category_id' => $mdfCategory->id,
                'name' => 'Standard MDF Board',
                'slug' => 'standard-mdf-board',
                'description' => 'The versatile nature of MDF makes it suitable to be used for many projects such as kitchens, furniture, shelving, decorative moulding and doors.',
                'features' => 'Can be cut in any direction and made into any shape. Often used when a nice clean look is desired from the finished product. Best for cabinetry.',
                'sizes' => ['1220x2440x9mm', '1220x2440x15mm'],
                'colors' => ['Natural', 'White', 'Cream White'],
                'featured_image' => 'products/mdf-standard.jpg',
                'price' => 150.00,
                'sku' => 'MDF-001',
                'stock' => 100,
                'is_featured' => true,
                'is_active' => true,
                'order' => 1,
            ],
            [
                'category_id' => $mdfCategory->id,
                'name' => 'Colored MDF',
                'slug' => 'colored-mdf',
                'description' => 'Premium colored MDF boards available in various vibrant colors.',
                'features' => 'Pre-colored throughout the board, no need for painting. Ideal for modern furniture designs.',
                'sizes' => ['1220x2440x15mm', '1220x2440x18mm'],
                'colors' => ['Grey Glass', 'Dark Grey', 'Beige', 'Maple', 'Walnut', 'Green', 'Blue', 'Red', 'Yellow', 'Black'],
                'featured_image' => 'products/mdf-colored.jpg',
                'price' => 250.00,
                'sku' => 'MDF-002',
                'stock' => 50,
                'is_featured' => true,
                'is_active' => true,
                'order' => 2,
            ],

            // MFC Products
            [
                'category_id' => $mfcCategory->id,
                'name' => 'Melamine Faced Chipboard',
                'slug' => 'melamine-faced-chipboard',
                'description' => 'High-quality melamine surface perfect for furniture making.',
                'features' => 'Scratch resistant, easy to clean, moisture resistant.',
                'sizes' => ['1220x2440x15mm', '1220x2440x18mm'],
                'colors' => ['White', 'Beige', 'Grey', 'Wood patterns'],
                'featured_image' => 'products/mfc.jpg',
                'price' => 180.00,
                'sku' => 'MFC-001',
                'stock' => 75,
                'is_featured' => true,
                'is_active' => true,
                'order' => 3,
            ],

            // OSB Products
            [
                'category_id' => $osbCategory->id,
                'name' => 'OSB3 Board',
                'slug' => 'osb3-board',
                'description' => 'Load-bearing board for use in humid conditions. Suitable for structural applications.',
                'features' => 'High strength, moisture resistant, cost-effective.',
                'specifications' => [
                    'Grade' => 'OSB/3',
                    'Density' => '650 kg/m³',
                    'Formaldehyde' => 'E1',
                ],
                'sizes' => ['1220x2440x9mm', '1220x2440x12mm', '1220x2440x15mm'],
                'featured_image' => 'products/osb.jpg',
                'price' => 120.00,
                'sku' => 'OSB-001',
                'stock' => 200,
                'is_featured' => true,
                'is_active' => true,
                'order' => 4,
            ],

            // Marine Plywood Products
            [
                'category_id' => $marineCategory->id,
                'name' => 'DiamondPly - 13 Plies',
                'slug' => 'diamondply-13',
                'description' => 'Film-faced plywood with Dynea brown film. Premium quality for construction.',
                'features' => '13 plies full hardwood, Dynea Phenolic WBP glue, Density: 652KG/M3.',
                'specifications' => [
                    'Cores' => '13 plies full hardwood',
                    'Film' => 'Dynea brown film',
                    'Glue' => 'Dynea Phenolic WBP glue',
                    'Density' => '652KG/M3',
                    'Size' => '2440x1220mm',
                    'Thickness' => '15mm, 19mm',
                ],
                'sizes' => ['2440x1220x15mm', '2440x1220x19mm'],
                'featured_image' => 'products/marine-diamond.jpg',
                'price' => 450.00,
                'sku' => 'MARINE-001',
                'stock' => 80,
                'is_featured' => true,
                'is_active' => true,
                'order' => 5,
            ],
            [
                'category_id' => $marineCategory->id,
                'name' => 'GoldPly - 11 Plies',
                'slug' => 'goldply-11',
                'description' => 'High-quality marine plywood with 11 ply construction.',
                'features' => 'Board 8 Layer Hardwood + 2 Brown Film.',
                'specifications' => [
                    'Cores' => '11 Ply Board 8 Layer Hardwood + 3 Layer Brown Film',
                    'Film' => 'Brown 120g/m2',
                    'Glue' => 'WBP Glue',
                    'Size' => '2440x1220mm',
                    'Thickness' => '18mm',
                ],
                'sizes' => ['2440x1220x18mm'],
                'featured_image' => 'products/marine-gold.jpg',
                'price' => 380.00,
                'sku' => 'MARINE-002',
                'stock' => 60,
                'is_featured' => false,
                'is_active' => true,
                'order' => 6,
            ],
            [
                'category_id' => $marineCategory->id,
                'name' => 'SilverPly - 11 Plies',
                'slug' => 'silverply-11',
                'description' => 'Economy marine plywood option with reliable quality.',
                'features' => '11 plies poplar wood construction.',
                'specifications' => [
                    'Cores' => '11 plies poplar wood',
                    'Film' => 'Brown film 120g/m2',
                    'Glue' => 'WBP glue',
                    'Density' => '530KG/M3',
                    'Size' => '2440x1220mm',
                    'Thickness' => '18mm',
                ],
                'sizes' => ['2440x1220x18mm'],
                'featured_image' => 'products/marine-silver.jpg',
                'price' => 320.00,
                'sku' => 'MARINE-003',
                'stock' => 90,
                'is_featured' => false,
                'is_active' => true,
                'order' => 7,
            ],
            [
                'category_id' => $marineCategory->id,
                'name' => 'BronzePly - 11 Plies',
                'slug' => 'bronzeply-11',
                'description' => 'Finger Joint Core marine plywood for construction.',
                'features' => '11 plies Finger Joint Core construction.',
                'specifications' => [
                    'Cores' => '11 plies Finger Joint Core',
                    'Film' => 'Brown film 120g/m2',
                    'Edge Treatment' => 'Brown Water Proof',
                    'Insect repellent Paint' => 'Yes',
                    'Size' => '2440x1220mm',
                    'Thickness' => '18mm',
                ],
                'sizes' => ['2440x1220x18mm'],
                'featured_image' => 'products/marine-bronze.jpg',
                'price' => 280.00,
                'sku' => 'MARINE-004',
                'stock' => 100,
                'is_featured' => false,
                'is_active' => true,
                'order' => 8,
            ],
        ];

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