<?php

namespace Database\Seeders;

use App\Enums\FormType;
use App\Enums\QuestionType;
use App\Models\FormQuestion;
use App\Models\FormQuestionGroup;
use Illuminate\Database\Seeder;

class FormQuestionSeeder extends Seeder
{
    public function run(): void
    {
        $this->seedAdoptionQuestions();
        $this->seedFosteringQuestions();
        $this->seedAssistanceQuestions();
    }

    private function seedAdoptionQuestions(): void
    {

        $adoptionDetailsGroup = FormQuestionGroup::create([
            'form_type' => FormType::Adoption,
            'name' => 'Adoption Details',
            'icon' => 'heroicon-o-heart',
            'description' => 'Information about the pet you wish to adopt',
            'sort_order' => 2,
            'is_active' => true,
        ]);

        $ageGroup = FormQuestionGroup::create([
            'form_type' => FormType::Adoption,
            'name' => 'Age of Majority',
            'icon' => 'heroicon-o-identification',
            'description' => 'Your age range',
            'sort_order' => 3,
            'is_active' => true,
        ]);

        $housingGroup = FormQuestionGroup::create([
            'form_type' => FormType::Adoption,
            'name' => 'Housing Details',
            'icon' => 'heroicon-o-home',
            'description' => 'Information about your living situation',
            'sort_order' => 4,
            'is_active' => true,
        ]);

        $studentGroup = FormQuestionGroup::create([
            'form_type' => FormType::Adoption,
            'name' => 'Student Details',
            'icon' => 'heroicon-o-academic-cap',
            'description' => 'Information if you are a student',
            'sort_order' => 5,
            'is_active' => true,
        ]);

        $petOwnershipGroup = FormQuestionGroup::create([
            'form_type' => FormType::Adoption,
            'name' => 'Pet Ownership Details',
            'icon' => 'heroicon-o-sparkles',
            'description' => 'Your pet ownership experience and plans',
            'sort_order' => 6,
            'is_active' => true,
        ]);

        $lifestyleGroup = FormQuestionGroup::create([
            'form_type' => FormType::Adoption,
            'name' => 'Lifestyle Details',
            'icon' => 'heroicon-o-clock',
            'description' => 'Your daily routine and lifestyle',
            'sort_order' => 7,
            'is_active' => true,
        ]);

        $referencesGroup = FormQuestionGroup::create([
            'form_type' => FormType::Adoption,
            'name' => 'References',
            'icon' => 'heroicon-o-phone',
            'description' => 'Veterinarian and personal references',
            'sort_order' => 8,
            'is_active' => true,
        ]);

        $employerGroup = FormQuestionGroup::create([
            'form_type' => FormType::Adoption,
            'name' => 'Employer References',
            'icon' => 'heroicon-o-building-office',
            'description' => 'Only required if veterinarian not provided',
            'sort_order' => 9,
            'is_active' => true,
        ]);

        $adoptionQuestions = [
            // Contact Details - Note: Basic contact fields like first_name, last_name, email, phone_number, address, city, province, postal_code are typically handled separately in the form model

            // Adoption Details
            [
                'group_id' => $adoptionDetailsGroup->id,
                'label' => 'Adoption reason',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'Pet/Companion',
                    'Playmate for child',
                    'Other',
                ],
                'is_required' => true,
                'sort_order' => 1,
            ],
            [
                'group_id' => $adoptionDetailsGroup->id,
                'label' => 'Adopting for',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'Myself',
                    'Someone else',
                ],
                'is_required' => true,
                'sort_order' => 2,
            ],

            // Age of Majority
            [
                'group_id' => $ageGroup->id,
                'label' => 'Age',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'Under 19',
                    '19 to 24',
                    '25 to 40',
                    '41 to 65',
                    'over 65',
                ],
                'is_required' => true,
                'sort_order' => 1,
            ],

            // Housing Details
            [
                'group_id' => $housingGroup->id,
                'label' => 'Housing type',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'House',
                    'Apartment',
                    'Condo',
                    'Rural area',
                ],
                'is_required' => true,
                'sort_order' => 1,
            ],
            [
                'group_id' => $housingGroup->id,
                'label' => 'Own/Rent',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'Own',
                    'Rent',
                ],
                'is_required' => true,
                'sort_order' => 2,
            ],
            [
                'group_id' => $housingGroup->id,
                'label' => 'If you rent, do you have your landlord\'s consent?',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'Not Applicable - I own',
                    'No',
                    'Yes',
                ],
                'is_required' => true,
                'sort_order' => 3,
            ],
            [
                'group_id' => $housingGroup->id,
                'label' => 'How many adults live in the home?',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => true,
                'sort_order' => 4,
            ],
            [
                'group_id' => $housingGroup->id,
                'label' => 'How many children live in the home?',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => true,
                'sort_order' => 5,
            ],
            [
                'group_id' => $housingGroup->id,
                'label' => 'Children ages',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => false,
                'sort_order' => 6,
            ],
            [
                'group_id' => $housingGroup->id,
                'label' => 'Do the children have experience with animals?',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => false,
                'sort_order' => 7,
            ],

            // Student Details
            [
                'group_id' => $studentGroup->id,
                'label' => 'Are you a student?',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'No',
                    'Yes',
                ],
                'is_required' => true,
                'sort_order' => 1,
            ],
            [
                'group_id' => $studentGroup->id,
                'label' => 'School name',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => false,
                'sort_order' => 2,
            ],
            [
                'group_id' => $studentGroup->id,
                'label' => 'School year and level',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => false,
                'sort_order' => 3,
            ],

            // Pet Ownership Details
            [
                'group_id' => $petOwnershipGroup->id,
                'label' => 'Will your pet be an outdoor pet?',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'No',
                    'Yes',
                ],
                'is_required' => true,
                'sort_order' => 1,
            ],
            [
                'group_id' => $petOwnershipGroup->id,
                'label' => 'If outdoor, will the pet be free roaming, harnessed, supervised?',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => false,
                'sort_order' => 2,
            ],
            [
                'group_id' => $petOwnershipGroup->id,
                'label' => 'Do you currently have pets?',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'No',
                    'Yes',
                ],
                'is_required' => true,
                'sort_order' => 3,
            ],
            [
                'group_id' => $petOwnershipGroup->id,
                'label' => 'Current pet details - quantity, species, age',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => false,
                'sort_order' => 4,
            ],
            [
                'group_id' => $petOwnershipGroup->id,
                'label' => 'Are they spayed/neutered?',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'Not Applicable',
                    'No',
                    'Yes',
                ],
                'is_required' => true,
                'sort_order' => 5,
            ],
            [
                'group_id' => $petOwnershipGroup->id,
                'label' => 'If not spayed/neutered, why not?',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => false,
                'sort_order' => 6,
            ],
            [
                'group_id' => $petOwnershipGroup->id,
                'label' => 'Are their vaccinations current?',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'Not Applicable',
                    'No',
                    'Yes',
                ],
                'is_required' => true,
                'sort_order' => 7,
            ],
            [
                'group_id' => $petOwnershipGroup->id,
                'label' => 'If vaccinations not current, why not?',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => false,
                'sort_order' => 8,
            ],
            [
                'group_id' => $petOwnershipGroup->id,
                'label' => 'Have you had pets in the past that are no longer with you? What happened to them?',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => true,
                'sort_order' => 9,
            ],
            [
                'group_id' => $petOwnershipGroup->id,
                'label' => 'Have you ever surrendered an animal?',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'No',
                    'Yes',
                ],
                'is_required' => true,
                'sort_order' => 10,
            ],
            [
                'group_id' => $petOwnershipGroup->id,
                'label' => 'Do you plan to declaw your adopted animal?',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'No',
                    'Yes',
                ],
                'is_required' => true,
                'sort_order' => 11,
            ],
            [
                'group_id' => $petOwnershipGroup->id,
                'label' => 'For what reason would you consider giving up your animal?',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => true,
                'sort_order' => 12,
            ],
            [
                'group_id' => $petOwnershipGroup->id,
                'label' => 'Would you permit a home visit by one of our volunteers to ensure a good placement for the cat you wish to adopt?',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'No',
                    'Yes',
                ],
                'is_required' => true,
                'sort_order' => 13,
            ],
            [
                'group_id' => $petOwnershipGroup->id,
                'label' => 'How often do you plan on taking your pet to a veterinarian?',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => true,
                'sort_order' => 14,
            ],
            [
                'group_id' => $petOwnershipGroup->id,
                'label' => 'How much do you expect to spend monthly on food/litter for your pet?',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => true,
                'sort_order' => 15,
            ],
            [
                'group_id' => $petOwnershipGroup->id,
                'label' => 'How much do you expect to spend annually in vet bills for your pet?',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => true,
                'sort_order' => 16,
            ],

            // Lifestyle Details
            [
                'group_id' => $lifestyleGroup->id,
                'label' => 'Employment status',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'Full Time',
                    'Part Time',
                    'Retired',
                    'Unemployed',
                    'Student',
                ],
                'is_required' => true,
                'sort_order' => 1,
            ],
            [
                'group_id' => $lifestyleGroup->id,
                'label' => 'How many hours a day would the pet be left alone?',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => true,
                'sort_order' => 2,
            ],
            [
                'group_id' => $lifestyleGroup->id,
                'label' => 'Please describe your lifestyle & personality',
                'type' => QuestionType::Textarea,
                'options' => null,
                'is_required' => true,
                'sort_order' => 3,
            ],

            // References
            [
                'group_id' => $referencesGroup->id,
                'label' => 'Name of primary vet clinic',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => false,
                'sort_order' => 1,
            ],
            [
                'group_id' => $referencesGroup->id,
                'label' => 'Vet city',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => false,
                'sort_order' => 2,
            ],
            [
                'group_id' => $referencesGroup->id,
                'label' => 'Vet phone number',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => false,
                'sort_order' => 3,
            ],
            [
                'group_id' => $referencesGroup->id,
                'label' => 'Please list any other veterinarian(s) here if pet/s has been seen by more than one veterinarian',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => false,
                'sort_order' => 4,
            ],
            [
                'group_id' => $referencesGroup->id,
                'label' => 'Name of personal reference',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => true,
                'sort_order' => 5,
            ],
            [
                'group_id' => $referencesGroup->id,
                'label' => 'Relationship',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => true,
                'sort_order' => 6,
            ],
            [
                'group_id' => $referencesGroup->id,
                'label' => 'Reference city',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => true,
                'sort_order' => 7,
            ],
            [
                'group_id' => $referencesGroup->id,
                'label' => 'Reference phone',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => true,
                'sort_order' => 8,
            ],

            // Employer References
            [
                'group_id' => $employerGroup->id,
                'label' => 'Name of employer',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => false,
                'sort_order' => 1,
            ],
            [
                'group_id' => $employerGroup->id,
                'label' => 'Employer city',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => false,
                'sort_order' => 2,
            ],
            [
                'group_id' => $employerGroup->id,
                'label' => 'Employer phone',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => false,
                'sort_order' => 3,
            ],
        ];

        $this->bulkInsertQuestions($adoptionQuestions, FormType::Adoption);
    }

    private function seedFosteringQuestions(): void
    {
        $fosterTypeGroup = FormQuestionGroup::create([
            'form_type' => FormType::Fostering,
            'name' => 'Type of fostering you are interested in',
            'icon' => 'heroicon-o-heart',
            'description' => 'Please ask us for more details before deciding on your choices',
            'sort_order' => 1,
            'is_active' => true,
        ]);

        $contactGroup = FormQuestionGroup::create([
            'form_type' => FormType::Fostering,
            'name' => 'Contact Details',
            'icon' => 'heroicon-o-user',
            'description' => 'Your contact information',
            'sort_order' => 2,
            'is_active' => true,
        ]);

        $environmentGroup = FormQuestionGroup::create([
            'form_type' => FormType::Fostering,
            'name' => 'Environment Details',
            'icon' => 'heroicon-o-home',
            'description' => 'Information about your home environment',
            'sort_order' => 3,
            'is_active' => true,
        ]);

        $petDetailsGroup = FormQuestionGroup::create([
            'form_type' => FormType::Fostering,
            'name' => 'Pet Details',
            'icon' => 'heroicon-o-sparkles',
            'description' => 'Information about your current pets',
            'sort_order' => 4,
            'is_active' => true,
        ]);

        $lifestyleGroup = FormQuestionGroup::create([
            'form_type' => FormType::Fostering,
            'name' => 'Lifestyle Details',
            'icon' => 'heroicon-o-clock',
            'description' => 'Your daily routine and living situation',
            'sort_order' => 5,
            'is_active' => true,
        ]);

        $fosteringDetailsGroup = FormQuestionGroup::create([
            'form_type' => FormType::Fostering,
            'name' => 'Fostering Details',
            'icon' => 'heroicon-o-hand-raised',
            'description' => 'Your fostering preferences and capabilities',
            'sort_order' => 6,
            'is_active' => true,
        ]);

        $referencesGroup = FormQuestionGroup::create([
            'form_type' => FormType::Fostering,
            'name' => 'References',
            'icon' => 'heroicon-o-phone',
            'description' => 'Personal and veterinary references',
            'sort_order' => 7,
            'is_active' => true,
        ]);

        $fosteringQuestions = [
            // Type of fostering
            [
                'group_id' => $fosterTypeGroup->id,
                'label' => 'Bottle babies: kittens that are often days/hours old and require bottle/syringe feeding etc. This is very intensive for the first 3 weeks',
                'type' => QuestionType::Switch,
                'options' => null,
                'is_required' => true,
                'sort_order' => 1,
            ],
            [
                'group_id' => $fosterTypeGroup->id,
                'label' => 'Weaned babies: kittens already on solid food, needing socializing',
                'type' => QuestionType::Switch,
                'options' => null,
                'is_required' => true,
                'sort_order' => 2,
            ],
            [
                'group_id' => $fosterTypeGroup->id,
                'label' => 'Socializing: this can apply to any age of kitten or cat and can require much patience',
                'type' => QuestionType::Switch,
                'options' => null,
                'is_required' => true,
                'sort_order' => 3,
            ],
            [
                'group_id' => $fosterTypeGroup->id,
                'label' => 'Mom and kittens/ pregnant mom',
                'type' => QuestionType::Switch,
                'options' => null,
                'is_required' => true,
                'sort_order' => 4,
            ],

            // Contact Details - Note: Basic contact fields like first_name, last_name, address, city, province, postal_code, phone_number, email are typically handled separately in the form model
            [
                'group_id' => $contactGroup->id,
                'label' => 'Spouse name',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => false,
                'sort_order' => 1,
            ],

            // Environment Details
            [
                'group_id' => $environmentGroup->id,
                'label' => 'How many people live in your home?',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => true,
                'sort_order' => 1,
            ],
            [
                'group_id' => $environmentGroup->id,
                'label' => 'Do you have children?',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'No',
                    'Yes',
                ],
                'is_required' => true,
                'sort_order' => 2,
            ],
            [
                'group_id' => $environmentGroup->id,
                'label' => 'Children ages',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => false,
                'sort_order' => 3,
            ],
            [
                'group_id' => $environmentGroup->id,
                'label' => 'Are they used to, and gentle with animals?',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'No',
                    'Yes',
                    'Not Applicable',
                ],
                'is_required' => true,
                'sort_order' => 4,
            ],

            // Pet Details
            [
                'group_id' => $petDetailsGroup->id,
                'label' => 'Do you have pets',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'No',
                    'Yes',
                ],
                'is_required' => true,
                'sort_order' => 1,
            ],
            [
                'group_id' => $petDetailsGroup->id,
                'label' => 'How many pets',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => true,
                'sort_order' => 2,
            ],
            [
                'group_id' => $petDetailsGroup->id,
                'label' => 'Current pet details',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => false,
                'sort_order' => 3,
            ],
            [
                'group_id' => $petDetailsGroup->id,
                'label' => 'Spayed/neutered status',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'No',
                    'Yes',
                    'Not Applicable',
                ],
                'is_required' => true,
                'sort_order' => 4,
            ],
            [
                'group_id' => $petDetailsGroup->id,
                'label' => 'Vaccinations current',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'No',
                    'Yes',
                    'Not Applicable',
                ],
                'is_required' => true,
                'sort_order' => 5,
            ],

            // Lifestyle Details
            [
                'group_id' => $lifestyleGroup->id,
                'label' => 'During the day you are',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'at Work',
                    'at School',
                    'at Home',
                ],
                'is_required' => true,
                'sort_order' => 1,
            ],
            [
                'group_id' => $lifestyleGroup->id,
                'label' => 'If you work, or go to school',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'Full Time',
                    'Part Time',
                    'Not Applicable',
                ],
                'is_required' => true,
                'sort_order' => 2,
            ],
            [
                'group_id' => $lifestyleGroup->id,
                'label' => 'Own/Rent',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'Own',
                    'Rent',
                ],
                'is_required' => true,
                'sort_order' => 3,
            ],
            [
                'group_id' => $lifestyleGroup->id,
                'label' => 'Do you have the landlord\'s consent (if you rent)?',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'No',
                    'Yes',
                    'Not Applicable',
                ],
                'is_required' => true,
                'sort_order' => 4,
            ],
            [
                'group_id' => $lifestyleGroup->id,
                'label' => 'Type of home',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => true,
                'sort_order' => 5,
            ],
            [
                'group_id' => $lifestyleGroup->id,
                'label' => 'Do you have a room where you can you isolate the foster animals?',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'No',
                    'Yes',
                ],
                'is_required' => true,
                'sort_order' => 6,
            ],
            [
                'group_id' => $lifestyleGroup->id,
                'label' => 'Room type?',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'spare bedroom (not in use)',
                    'spare bathroom (not in use)',
                    'your bedroom',
                    'Other (please describe below)',
                    'Not applicable',
                ],
                'is_required' => true,
                'sort_order' => 7,
            ],
            [
                'group_id' => $lifestyleGroup->id,
                'label' => 'Room description',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => false,
                'sort_order' => 8,
            ],
            [
                'group_id' => $lifestyleGroup->id,
                'label' => 'Any plans for moving/renovating in the near future?',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'No',
                    'Yes',
                ],
                'is_required' => true,
                'sort_order' => 9,
            ],

            // Fostering Details
            [
                'group_id' => $fosteringDetailsGroup->id,
                'label' => 'Are you available immediately?',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'No',
                    'Yes',
                ],
                'is_required' => true,
                'sort_order' => 1,
            ],
            [
                'group_id' => $fosteringDetailsGroup->id,
                'label' => 'If not, when?',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => false,
                'sort_order' => 2,
            ],
            [
                'group_id' => $fosteringDetailsGroup->id,
                'label' => 'Have you had any training that may be pertinent for fostering?',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => true,
                'sort_order' => 3,
            ],
            [
                'group_id' => $fosteringDetailsGroup->id,
                'label' => 'Do you require food and supplies?',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'No - I am able to purchase all food and supplies as part of my support',
                    'Yes - I need food and supplies from TFF to foster this animal',
                ],
                'is_required' => true,
                'sort_order' => 4,
            ],
            [
                'group_id' => $fosteringDetailsGroup->id,
                'label' => 'A home visit prior to acceptance as a foster home is required. Are you okay with this?',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'No',
                    'Yes',
                ],
                'is_required' => true,
                'sort_order' => 5,
            ],
            [
                'group_id' => $fosteringDetailsGroup->id,
                'label' => 'Would you be able to transport your foster cat or kitten to veterinarian appointments or adoption events as needed?',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'No',
                    'Yes',
                ],
                'is_required' => true,
                'sort_order' => 6,
            ],
            [
                'group_id' => $fosteringDetailsGroup->id,
                'label' => 'Are you willing to allow potential adopters into your home to meet your foster animal(s)?',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'No',
                    'Yes',
                ],
                'is_required' => true,
                'sort_order' => 7,
            ],
            [
                'group_id' => $fosteringDetailsGroup->id,
                'label' => 'Are you comfortable with the idea that the cats/kittens you foster are not yours to adopt out and that all potential adopters must go through the adoption process?',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'No',
                    'Yes',
                ],
                'is_required' => true,
                'sort_order' => 8,
            ],

            // References
            [
                'group_id' => $referencesGroup->id,
                'label' => 'Personal reference',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => true,
                'sort_order' => 1,
            ],
            [
                'group_id' => $referencesGroup->id,
                'label' => 'Veterinarian reference',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => true,
                'sort_order' => 2,
            ],
            [
                'group_id' => $referencesGroup->id,
                'label' => 'Additional comments',
                'type' => QuestionType::Textarea,
                'options' => null,
                'is_required' => true,
                'sort_order' => 3,
            ],
        ];

        $this->bulkInsertQuestions($fosteringQuestions, FormType::Fostering);
    }

    private function seedAssistanceQuestions(): void
    {

        $catDetailsGroup = FormQuestionGroup::create([
            'form_type' => FormType::Assistance,
            'name' => 'Cat/Kitten Details',
            'icon' => 'heroicon-o-heart',
            'description' => 'Information about the cats needing assistance',
            'sort_order' => 2,
            'is_active' => true,
        ]);

        $howToAssistGroup = FormQuestionGroup::create([
            'form_type' => FormType::Assistance,
            'name' => 'How are you willing to assist',
            'icon' => 'heroicon-o-hand-raised',
            'description' => 'Ways you can help with the TNR/TNA process',
            'sort_order' => 3,
            'is_active' => true,
        ]);

        $additionalInfoGroup = FormQuestionGroup::create([
            'form_type' => FormType::Assistance,
            'name' => 'Additional Information',
            'icon' => 'heroicon-o-information-circle',
            'description' => 'Any additional details',
            'sort_order' => 4,
            'is_active' => true,
        ]);

        $assistanceQuestions = [
            // Contact Details - Note: Basic contact fields like first_name, last_name, address, city, postal_code, phone_number, alt_phone_number, email are typically handled separately in the form model

            // Cat/Kitten Details
            [
                'group_id' => $catDetailsGroup->id,
                'label' => 'Approximately how many cats are in need?',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => true,
                'sort_order' => 1,
            ],
            [
                'group_id' => $catDetailsGroup->id,
                'label' => 'Are they friendly or feral?',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'Friendly',
                    'Feral',
                ],
                'is_required' => true,
                'sort_order' => 2,
            ],
            [
                'group_id' => $catDetailsGroup->id,
                'label' => 'Do any of the cats appear sick or injured?',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'No',
                    'Yes',
                ],
                'is_required' => true,
                'sort_order' => 3,
            ],
            [
                'group_id' => $catDetailsGroup->id,
                'label' => 'Are any of the cats pregnant?',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'No',
                    'Yes',
                ],
                'is_required' => true,
                'sort_order' => 4,
            ],
            [
                'group_id' => $catDetailsGroup->id,
                'label' => 'Are any of the cats nursing kittens?',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'No',
                    'Yes',
                ],
                'is_required' => true,
                'sort_order' => 5,
            ],
            [
                'group_id' => $catDetailsGroup->id,
                'label' => 'Are there kittens?',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'No',
                    'Yes',
                ],
                'is_required' => true,
                'sort_order' => 6,
            ],
            [
                'group_id' => $catDetailsGroup->id,
                'label' => 'Age of kittens',
                'type' => QuestionType::String,
                'options' => null,
                'is_required' => false,
                'sort_order' => 7,
            ],
            [
                'group_id' => $catDetailsGroup->id,
                'label' => 'If feral, can they be returned to this location and are you willing to take care of them for the remainder of their lives? Provide shelter, feed etc?',
                'type' => QuestionType::Textarea,
                'options' => null,
                'is_required' => false,
                'sort_order' => 8,
            ],
            [
                'group_id' => $catDetailsGroup->id,
                'label' => 'Do you own the property?',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'No',
                    'Yes',
                ],
                'is_required' => true,
                'sort_order' => 9,
            ],
            [
                'group_id' => $catDetailsGroup->id,
                'label' => 'If not, do you have the owner\'s permission to TNVR feral cats on this property?',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'No',
                    'Yes',
                    'Not Applicable',
                ],
                'is_required' => true,
                'sort_order' => 10,
            ],

            // How are you willing to assist (checkboxes)
            [
                'group_id' => $howToAssistGroup->id,
                'label' => 'I can contribute financially',
                'type' => QuestionType::Switch,
                'options' => null,
                'is_required' => true,
                'sort_order' => 1,
            ],
            [
                'group_id' => $howToAssistGroup->id,
                'label' => 'I can donate food',
                'type' => QuestionType::Switch,
                'options' => null,
                'is_required' => true,
                'sort_order' => 2,
            ],
            [
                'group_id' => $howToAssistGroup->id,
                'label' => 'I can help with trapping',
                'type' => QuestionType::Switch,
                'options' => null,
                'is_required' => true,
                'sort_order' => 3,
            ],
            [
                'group_id' => $howToAssistGroup->id,
                'label' => 'I can help with transport',
                'type' => QuestionType::Switch,
                'options' => null,
                'is_required' => true,
                'sort_order' => 4,
            ],
            [
                'group_id' => $howToAssistGroup->id,
                'label' => 'I can foster for a few days post surgery',
                'type' => QuestionType::Switch,
                'options' => null,
                'is_required' => true,
                'sort_order' => 5,
            ],
            [
                'group_id' => $howToAssistGroup->id,
                'label' => 'I can foster adoptable cats',
                'type' => QuestionType::Switch,
                'options' => null,
                'is_required' => true,
                'sort_order' => 6,
            ],
            [
                'group_id' => $howToAssistGroup->id,
                'label' => 'I can maintain the colony after TNR',
                'type' => QuestionType::Switch,
                'options' => null,
                'is_required' => true,
                'sort_order' => 7,
            ],
            [
                'group_id' => $howToAssistGroup->id,
                'label' => 'I can\'t help at this time',
                'type' => QuestionType::Switch,
                'options' => null,
                'is_required' => true,
                'sort_order' => 8,
            ],

            // Additional Information
            [
                'group_id' => $additionalInfoGroup->id,
                'label' => 'Have you received help from a local rescue group in the past?',
                'type' => QuestionType::Dropdown,
                'options' => [
                    'No',
                    'Yes',
                ],
                'is_required' => true,
                'sort_order' => 1,
            ],
            [
                'group_id' => $additionalInfoGroup->id,
                'label' => 'Additional information you would like us to know',
                'type' => QuestionType::Textarea,
                'options' => null,
                'is_required' => false,
                'sort_order' => 2,
            ],
        ];

        $this->bulkInsertQuestions($assistanceQuestions, FormType::Assistance);
    }

    /**
     * Bulk insert questions for a form type.
     *
     * @param  array<int, array<string, mixed>>  $questions
     */
    private function bulkInsertQuestions(array $questions, FormType $formType): void
    {
        $now = now();

        $records = array_map(fn (array $questionData) => [
            'form_type' => $formType->value,
            'form_question_group_id' => $questionData['group_id'],
            'label' => $questionData['label'],
            'type' => $questionData['type']->value,
            'options' => $questionData['options'] ? json_encode($questionData['options']) : null,
            'is_required' => $questionData['is_required'],
            'sort_order' => $questionData['sort_order'],
            'is_active' => true,
            'created_at' => $now,
            'updated_at' => $now,
        ], $questions);

        FormQuestion::insert($records);
    }
}
