<?php

namespace Database\Seeders;

use App\Models\Category;
use App\Models\Product;
use App\Models\User;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;

class DatabaseSeeder extends Seeder
{
    public function run(): void
    {
        // Create Super Admin
        $superAdmin = User::create([
            'name'     => 'Super Admin',
            'email'    => 'admin@shop.com',
            'password' => Hash::make('Admin@1234'),
            'role'     => 'super_admin',
            'is_active' => true,
        ]);

        // Create Content Editor
        User::create([
            'name'     => 'Content Editor',
            'email'    => 'editor@shop.com',
            'password' => Hash::make('Editor@1234'),
            'role'     => 'content_editor',
            'is_active' => true,
        ]);

        // Create Customer
        User::create([
            'name'     => 'Test Customer',
            'email'    => 'customer@shop.com',
            'password' => Hash::make('Customer@1234'),
            'role'     => 'customer',
            'is_active' => true,
        ]);

        // Create categories
        $electronics = Category::create([
            'name'        => 'Electronics',
            'slug'        => 'electronics',
            'description' => 'Electronic devices and accessories',
            'is_active'   => true,
            'sort_order'  => 1,
        ]);

        $clothing = Category::create([
            'name'        => 'Clothing',
            'slug'        => 'clothing',
            'description' => 'Fashion and apparel',
            'is_active'   => true,
            'sort_order'  => 2,
        ]);

        $books = Category::create([
            'name'        => 'Books',
            'slug'        => 'books',
            'description' => 'Books and educational materials',
            'is_active'   => true,
            'sort_order'  => 3,
        ]);

        // Create sample products
        Product::create([
            'name'        => 'Wireless Headphones',
            'slug'        => 'wireless-headphones',
            'description' => 'Premium wireless headphones with noise cancellation',
            'price'       => 299.99,
            'stock'       => 50,
            'category_id' => $electronics->id,
            'created_by'  => $superAdmin->id,
            'is_active'   => true,
        ]);

        Product::create([
            'name'           => 'Smart Watch',
            'slug'           => 'smart-watch',
            'description'    => 'Feature-packed smartwatch with health tracking',
            'price'          => 499.99,
            'discount_price' => 399.99,
            'stock'          => 30,
            'category_id'    => $electronics->id,
            'created_by'     => $superAdmin->id,
            'is_active'      => true,
        ]);

        Product::create([
            'name'        => 'Classic T-Shirt',
            'slug'        => 'classic-t-shirt',
            'description' => 'Comfortable cotton t-shirt in various sizes',
            'price'       => 29.99,
            'stock'       => 100,
            'category_id' => $clothing->id,
            'created_by'  => $superAdmin->id,
            'is_active'   => true,
        ]);

        // Seed banners
        $this->call(BannerSeeder::class);
        
        // Seed pages
        $this->call(PageSeeder::class);
    }
}
