<?php

namespace Database\Seeders;

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

class AdminSeeder extends Seeder
{
    public function run(): void
    {
        // ── Remove existing admin if re-seeding ───────────────
        DB::table('users')->where('role', 'admin')->delete();

        // ── Create admin account ──────────────────────────────
        DB::table('users')->insert([
            'name'              => 'Mahmoud',
            'nickname'          => 'InPractice_Admin',
            'email'             => 'admin@inpractice.app',
            'email_verified_at' => now(),        // admin is pre-verified
            'password'          => Hash::make('Admin@InPractice2025!'),
            'role'              => 'admin',
            'profession'        => 'Financial & Business Consultant',
            'experience_level'  => 'senior',
            'language'          => 'en',
            'show_real_name'    => false,
            'notify_jobs'       => true,
            'notify_freelance'  => true,
            'notify_forum'      => true,
            'notify_surveys'    => true,
            'notify_documents'  => true,
            'is_active'         => true,
            'created_at'        => now(),
            'updated_at'        => now(),
        ]);

        $this->command->info('✅ Admin account created');
        $this->command->info('   Email:    admin@inpractice.app');
        $this->command->info('   Password: Admin@InPractice2025!');
        $this->command->warn('   ⚠️  Change the password after first login!');
    }
}
