<?php

namespace Database\Seeders;

use App\Models\Service;
use App\Models\TeamMember;
use App\Models\Testimonial;
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;

    public function run(): void
    {
        User::query()->updateOrCreate(
            ['email' => 'admin@sharaussie.com.au'],
            [
                'name' => 'Site Administrator',
                'password' => Hash::make('password'),
                'is_admin' => true,
            ]
        );

        $this->seedServices();
        $this->seedTestimonials();
        $this->seedTeam();
    }

    private function seedServices(): void
    {
        if (Service::query()->exists()) {
            return;
        }

        $services = [
            ['Student Enrolment', "End-to-end admission support into Australia's leading colleges and universities.", 'M22 10 12 5 2 10l10 5 10-5ZM6 12v5c0 1 2.5 3 6 3s6-2 6-3v-5'],
            ['Visa Applications', 'Student, graduate, skilled and family visa lodgement handled with precision.', 'M4 4h16v16H4zM4 9h16M9 4v16'],
            ['Skilled Migration', 'Points-tested permanent residency pathways mapped to your profile.', 'M12 2l2.4 7.4H22l-6 4.6 2.3 7.4L12 17l-6.3 4.4L8 14 2 9.4h7.6z'],
            ['Professional Year', 'Boost your points and job-readiness with accredited PY programs.', 'M20 7h-4V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2Z'],
            ['Health Insurance', 'OSHC and OVHC cover arranged quickly so you meet visa conditions.', 'M20.8 4.6a5.5 5.5 0 0 0-7.8 0L12 5.7l-1-1a5.5 5.5 0 1 0-7.8 7.8L12 21l8.8-8.5a5.5 5.5 0 0 0 0-7.9Z'],
            ['Citizenship', 'Guidance and document preparation for your citizenship application.', 'M12 2 4 6v6c0 5 3.4 8.5 8 10 4.6-1.5 8-5 8-10V6z'],
            ['Graduate Visa (485)', 'Stay, work and gain experience after study with a smooth post-study work visa.', 'M20 7h-4V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2Z'],
            ['Family & Partner Visas', 'Partner, parent and child visa applications prepared with sensitivity and care.', 'M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8Z'],
            ['Airport & Settlement', 'Airport pickup, accommodation and settlement support for a smooth landing.', 'M17.8 19.2 16 11l3.5-3.5a2.1 2.1 0 0 0-3-3L13 8 4.8 6.2a1 1 0 0 0-.9 1.7L9 12l-2 3H4l-1 1 3 2 2 3 1-1v-3l3-2 4.1 5.1a1 1 0 0 0 1.7-.9Z'],
        ];

        foreach ($services as $i => [$title, $description, $icon]) {
            Service::query()->create([
                'title' => $title,
                'description' => $description,
                'icon' => $icon,
                'sort_order' => $i,
            ]);
        }
    }

    private function seedTestimonials(): void
    {
        if (Testimonial::query()->exists()) {
            return;
        }

        $testimonials = [
            ['Aisha Rahman', "Master's student, UNSW", 'From my offer letter to my student visa grant, the team handled everything. I never felt lost in the process.'],
            ['Daniel Okoye', 'Skilled migrant (189)', 'They mapped out my points, timed my invitation perfectly and my PR came through faster than I expected.'],
            ['Priya & Karan', 'Family visa, Sydney', 'Warm, patient and genuinely knowledgeable. They treated our case like it was their own family.'],
        ];

        foreach ($testimonials as $i => [$name, $role, $quote]) {
            Testimonial::query()->create([
                'name' => $name,
                'role' => $role,
                'quote' => $quote,
                'rating' => 5,
                'sort_order' => $i,
            ]);
        }
    }

    private function seedTeam(): void
    {
        if (TeamMember::query()->exists()) {
            return;
        }

        $team = [
            ['S. Ahmed', 'Principal Migration Agent', 'from-brand-500 to-brand-800'],
            ['M. Chen', 'Education Counsellor', 'from-sky-400 to-sky-700'],
            ['L. Nguyen', 'Visa Case Manager', 'from-amber-400 to-amber-700'],
            ['R. Kapoor', 'Client Success Lead', 'from-emerald-400 to-emerald-700'],
        ];

        foreach ($team as $i => [$name, $role, $gradient]) {
            TeamMember::query()->create([
                'name' => $name,
                'role' => $role,
                'gradient' => $gradient,
                'sort_order' => $i,
            ]);
        }
    }
}
