<?php

namespace Database\Seeders;

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

class ProductSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        $microChain = Category::where('slug', 'micro-chains')->first();
        $bridalSet = Category::where('slug', 'bridal-set')->first();
        $anklet = Category::where('slug', 'anklets')->first();

        $products = [
            [
                'name' => '24 Inch Moppu Chain',
                'slug' => '24-inch-moppu-chain',
                'sku' => 'DWR-CHN-001',
                'category_id' => $microChain?->id,
                'price' => 650.00,
                'original_price' => 1199.00,
                'discount' => 45,
                'stock' => 45,
                'status' => 'active',
                'is_featured' => true,
                'is_best_seller' => true,
                'badge' => 'BEST SELLER',
                'image' => 'https://images.unsplash.com/photo-1599643478518-a784e5dc4c8f?auto=format&fit=crop&w=800&q=80',
                'hover_image' => 'https://images.unsplash.com/photo-1611591475143-be2329357e84?auto=format&fit=crop&w=800&q=80',
                'short_description' => 'Classic 24-inch micro gold chain featuring intricate floral moppu motif.',
                'description' => 'Classic 24-inch micro gold chain featuring intricate floral moppu motif. Plated with 18k long-lasting micro gold finish for daily elegance and durability.',
            ],
            [
                'name' => 'AD Bridal Set and Choker',
                'slug' => 'ad-bridal-set-and-choker',
                'sku' => 'DWR-BDL-002',
                'category_id' => $bridalSet?->id,
                'price' => 2499.00,
                'original_price' => 4500.00,
                'discount' => 44,
                'stock' => 18,
                'status' => 'active',
                'is_new' => true,
                'is_featured' => true,
                'badge' => 'ROYAL EDITION',
                'image' => 'https://images.unsplash.com/photo-1605100804763-247f67b3557e?auto=format&fit=crop&w=800&q=80',
                'hover_image' => 'https://images.unsplash.com/photo-1535632066927-ab7c9ab60908?auto=format&fit=crop&w=800&q=80',
                'short_description' => 'Breathtaking American Diamond bridal choker set with matching chandelier jhumkas.',
                'description' => 'Breathtaking American Diamond bridal choker set with matching chandelier jhumkas and maang tikka. Handcrafted for grand wedding occasions.',
            ],
            [
                'name' => 'Gold Plated Traditional Anklets',
                'slug' => 'gold-plated-traditional-anklets',
                'sku' => 'DWR-ANK-003',
                'category_id' => $anklet?->id,
                'price' => 450.00,
                'original_price' => 799.00,
                'discount' => 43,
                'stock' => 0,
                'status' => 'sold_out',
                'is_sold_out' => true,
                'badge' => '18K GOLD FINISH',
                'image' => 'https://images.unsplash.com/photo-1535632066927-ab7c9ab60908?auto=format&fit=crop&w=800&q=80',
                'short_description' => 'Graceful gold-plated ghungroo anklet set.',
                'description' => 'Graceful gold-plated ghungroo anklet set designed with anti-tarnish micro coating for festive and daily wear.',
            ]
        ];

        foreach ($products as $prod) {
            Product::updateOrCreate(['slug' => $prod['slug']], $prod);
        }
    }
}
