<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;

class DatabaseSeeder extends Seeder
{
    /**
     * Seed the application's database.
     */
    public function run(): void
    {
        // Create admin user
        DB::table('users')->insert([
            'name' => 'Admin User',
            'email' => 'admin@alrunan.com',
            'password' => Hash::make('password'),
            'role' => 'admin',
            'created_at' => now(),
            'updated_at' => now(),
        ]);

        // Create car makes
        DB::table('car_makes')->insert([
            ['name' => 'Toyota', 'created_at' => now(), 'updated_at' => now()],
            ['name' => 'Honda', 'created_at' => now(), 'updated_at' => now()],
            ['name' => 'Ford', 'created_at' => now(), 'updated_at' => now()],
            ['name' => 'BMW', 'created_at' => now(), 'updated_at' => now()],
            ['name' => 'Mercedes-Benz', 'created_at' => now(), 'updated_at' => now()],
        ]);

        // Create car models
        DB::table('car_models')->insert([
            ['make_id' => 1, 'name' => 'Corolla', 'created_at' => now(), 'updated_at' => now()],
            ['make_id' => 1, 'name' => 'Camry', 'created_at' => now(), 'updated_at' => now()],
            ['make_id' => 1, 'name' => 'RAV4', 'created_at' => now(), 'updated_at' => now()],
            ['make_id' => 2, 'name' => 'Civic', 'created_at' => now(), 'updated_at' => now()],
            ['make_id' => 2, 'name' => 'Accord', 'created_at' => now(), 'updated_at' => now()],
        ]);

        // Create product categories
        DB::table('product_categories')->insert([
            ['name' => 'Window Tinting', 'description' => 'Automotive window tinting services', 'created_at' => now(), 'updated_at' => now()],
            ['name' => 'Paint Protection', 'description' => 'Paint protection film services', 'created_at' => now(), 'updated_at' => now()],
            ['name' => 'Ceramic Coating', 'description' => 'Ceramic coating services', 'created_at' => now(), 'updated_at' => now()],
        ]);

        // Create products
        DB::table('products')->insert([
            [
                'name' => 'Standard Window Tint',
                'description' => 'Basic window tinting for all vehicle types',
                'category_id' => 1,
                'price' => 18000.00,
                'original_price' => 20000.00,
                'sku' => 'WT001',
                'stock_quantity' => 100,
                'image_url' => '/assets/images/automotive_tint.png',
                'duration' => 120,
                'status' => 'active',
                'created_by' => 1,
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'name' => 'Premium Ceramic Tint',
                'description' => 'High-performance ceramic window tinting',
                'category_id' => 1,
                'price' => 35000.00,
                'original_price' => 40000.00,
                'sku' => 'WT002',
                'stock_quantity' => 50,
                'image_url' => '/assets/images/commercial_tint.png',
                'duration' => 180,
                'status' => 'active',
                'created_by' => 1,
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'name' => 'Paint Protection Film',
                'description' => 'Clear protective film for vehicle paint',
                'category_id' => 2,
                'price' => 45000.00,
                'original_price' => 50000.00,
                'sku' => 'PP001',
                'stock_quantity' => 25,
                'image_url' => '/assets/images/paint_protection.png',
                'duration' => 240,
                'status' => 'active',
                'created_by' => 1,
                'created_at' => now(),
                'updated_at' => now(),
            ],
        ]);

        // Create system settings
        DB::table('system_settings')->insert([
            [
                'setting_key' => 'company_name',
                'setting_value' => 'Al-runan Automotive Services',
                'setting_type' => 'string',
                'description' => 'Company name displayed throughout the application',
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'setting_key' => 'company_logo',
                'setting_value' => '/assets/logos/company_logo.png',
                'setting_type' => 'string',
                'description' => 'Path to company logo image',
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'setting_key' => 'theme_mode',
                'setting_value' => 'light',
                'setting_type' => 'string',
                'description' => 'Application theme mode (light/dark)',
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'setting_key' => 'mpesa_consumer_key',
                'setting_value' => 'your_mpesa_consumer_key',
                'setting_type' => 'string',
                'description' => 'M-Pesa API consumer key',
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'setting_key' => 'mpesa_consumer_secret',
                'setting_value' => 'your_mpesa_consumer_secret',
                'setting_type' => 'string',
                'description' => 'M-Pesa API consumer secret',
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'setting_key' => 'pesapal_consumer_key',
                'setting_value' => 'your_pesapal_consumer_key',
                'setting_type' => 'string',
                'description' => 'Pesapal API consumer key',
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'setting_key' => 'pesapal_consumer_secret',
                'setting_value' => 'your_pesapal_consumer_secret',
                'setting_type' => 'string',
                'description' => 'Pesapal API consumer secret',
                'created_at' => now(),
                'updated_at' => now(),
            ],
        ]);
    }
}