<?php

namespace Database\Seeders;

use App\Models\Article;
use App\Models\Product;
use App\Models\User;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;

class DatabaseSeeder extends Seeder
{
    use WithoutModelEvents;

    /**
     * Seed the application's database.
     */
    public function run(): void
    {
        User::query()->updateOrCreate([
            'email' => 'test@example.com',
        ], [
            'name' => 'Test User',
            'email' => 'test@example.com',
            'password' => Hash::make('password'),
        ]);

        $products = [
            [
                'name' => 'Heaven Eye Dzi Bead',
                'slug' => 'heaven-eye-dzi-bead',
                'category' => 'Tibetan Treasures',
                'subtitle' => 'Hand-finished agate centerpiece',
                'description' => 'An heirloom-inspired centerpiece with warm mineral tones and a ceremonial silhouette.',
                'price' => 12800,
                'hero_badge' => 'Collector highlight',
                'accent' => '#7E5B34',
                'is_featured' => true,
                'sort_order' => 1,
            ],
            [
                'name' => 'Starlit Sapphire Pendant',
                'slug' => 'starlit-sapphire-pendant',
                'category' => 'Gemstone Classics',
                'subtitle' => 'Sterling silver with sapphire crystal',
                'description' => 'A luminous pendant designed to echo museum display jewelry with a modern chain.',
                'price' => 8500,
                'hero_badge' => 'Curator pick',
                'accent' => '#3F5E9B',
                'is_featured' => true,
                'sort_order' => 2,
            ],
            [
                'name' => 'Ink Jade Bi Disc',
                'slug' => 'ink-jade-bi-disc',
                'category' => 'Jade Collection',
                'subtitle' => 'Polished dark jade ornament',
                'description' => 'A circular jade carving inspired by ceremonial discs and mountain-shadow palettes.',
                'price' => 6200,
                'hero_badge' => 'New arrival',
                'accent' => '#28342B',
                'is_featured' => true,
                'sort_order' => 3,
            ],
            [
                'name' => 'Imperial Ruby Ring',
                'slug' => 'imperial-ruby-ring',
                'category' => 'Imperial Jewels',
                'subtitle' => 'Ruby centerpiece with pavé setting',
                'description' => 'A bright ruby ring framed for a premium showcase and statement gift moments.',
                'price' => 15000,
                'hero_badge' => 'Limited edition',
                'accent' => '#A23E47',
                'is_featured' => true,
                'sort_order' => 4,
            ],
        ];

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

        $articles = [
            [
                'title' => 'How to identify a premium Dzi bead',
                'excerpt' => 'We break down surface texture, eye patterns, and mineral warmth so collectors can spot quality at a glance.',
                'category' => 'Buying guide',
                'reading_time' => '6 min read',
                'accent' => '#7E5B34',
                'sort_order' => 1,
            ],
            [
                'title' => 'Why jade carvings remain timeless',
                'excerpt' => 'A quick look at why jade pieces still carry cultural weight, symbolic meaning, and lasting design appeal.',
                'category' => 'Culture notes',
                'reading_time' => '4 min read',
                'accent' => '#45685A',
                'sort_order' => 2,
            ],
            [
                'title' => 'The art of gemstone craftsmanship',
                'excerpt' => 'From hand polishing to stone setting, this guide shows how premium gemstone pieces are shaped for display and wear.',
                'category' => 'Workshop journal',
                'reading_time' => '5 min read',
                'accent' => '#A23E47',
                'sort_order' => 3,
            ],
        ];

        foreach ($articles as $article) {
            Article::query()->updateOrCreate(
                ['title' => $article['title']],
                $article
            );
        }
    }
}
