<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\Models\MilitaryPersonnel;
use App\Models\CombatSkills;
use App\Models\SpecializedSkills;
use App\Models\MilitaryOperations;
use App\Models\EducationHistory;
use App\Models\MilitaryTraining;
use App\Models\Certifications;
use App\Models\UpcomingTraining;

class MilitaryPersonnelSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        // Create sample personnel
        $personnel = MilitaryPersonnel::create([
            'service_number' => '4578-2845-9632',
            'first_name' => 'John',
            'middle_name' => 'Michael',
            'last_name' => 'Anderson',
            'email' => 'j.anderson@military.gov',
            'phone' => '+1 (555) 123-4567',
            'date_of_birth' => '1990-03-15',
            'blood_type' => 'O+',
            'marital_status' => 'Married',
            'dependents' => 2,
            'ssn_last_four' => '1234',
            'rank' => 'Staff Sergeant',
            'pay_grade' => 'E-6',
            'mos' => '11B Infantry',
            'unit' => '1st Battalion, 75th Ranger Regiment',
            'squad_size' => '12 Personnel',
            'enlistment_date' => '2017-08-12',
            'ets_date' => '2025-08-11',
            'years_of_service' => 8,
            'status' => 'Active Duty',
            'security_clearance' => 'Top Secret',
            'current_base' => 'Fort Benning, GA',
            'current_deployment' => 'Kuwait (OIR)',
            'deployment_return_date' => '2025-12-15',
            'next_pcs' => 'Fort Bragg, NC',
            'command' => 'Alpha Company',
            'base_pay' => 3114.00,
            'bah' => 1200.00,
            'tsp_savings' => 45230.00,
            'retirement_points' => 2156,
            'leave_balance' => 23.5,
            'emergency_contact_name' => 'Sarah Anderson',
            'emergency_contact_phone' => '+1 (555) 987-6543',
            'emergency_contact_relationship' => 'Wife',
            'home_address' => '123 Military Base Rd',
            'city' => 'Fort Benning',
            'state' => 'GA',
            'zip_code' => '31905',
            'medical_status' => 'Fit for Duty',
            'last_physical' => '2025-06-15',
            'allergies' => 'Penicillin',
            'immunization_status' => 'Up to Date',
            'dental_class' => 'Class 1',
            'service_brief' => 'Staff Sergeant John Anderson is a dedicated infantry specialist with 8 years of exemplary service. He has completed multiple combat deployments and has demonstrated exceptional leadership capabilities. SGT Anderson is a qualified airborne ranger with specialized training in urban warfare and tactical operations. He currently serves as a squad leader in the 1st Battalion, 75th Ranger Regiment, and is responsible for the training and welfare of 12 soldiers under his command. His commitment to excellence and dedication to the mission has earned him numerous commendations including the Bronze Star Medal and Army Commendation Medal.'
        ]);

        // Create combat skills
        CombatSkills::create([
            'personnel_id' => $personnel->id,
            'combat_strength' => 92,
            'marksmanship' => 95,
            'tactical_operations' => 88,
            'strategic_planning' => 85,
            'leadership' => 90,
            'physical_fitness' => 94
        ]);

        // Create specialized skills
        $specializedSkills = [
            ['skill_name' => 'Airborne Qualified', 'proficiency_level' => 'EXPERT', 'icon' => 'fas fa-parachute-box', 'color' => 'green-500'],
            ['skill_name' => 'Amphibious Operations', 'proficiency_level' => 'ADVANCED', 'icon' => 'fas fa-water', 'color' => 'blue-500'],
            ['skill_name' => 'Mountain Warfare', 'proficiency_level' => 'QUALIFIED', 'icon' => 'fas fa-mountain', 'color' => 'orange-500'],
            ['skill_name' => 'Urban Combat', 'proficiency_level' => 'EXPERT', 'icon' => 'fas fa-city', 'color' => 'red-500'],
            ['skill_name' => 'Special Operations', 'proficiency_level' => 'CLASSIFIED', 'icon' => 'fas fa-user-secret', 'color' => 'purple-500']
        ];

        foreach ($specializedSkills as $skill) {
            SpecializedSkills::create(array_merge($skill, ['personnel_id' => $personnel->id]));
        }

        // Create military operations
        $operations = [
            [
                'operation_name' => 'Operation Desert Shield',
                'description' => 'Counter-terrorism operations in Syria',
                'duration_months' => 6,
                'status' => 'Completed',
                'result' => 'SUCCESS',
                'color' => 'military-green',
                'start_date' => '2024-01-15',
                'end_date' => '2024-07-15'
            ],
            [
                'operation_name' => 'Operation Guardian Angel',
                'description' => 'Humanitarian aid mission in Afghanistan',
                'duration_months' => 4,
                'status' => 'Completed',
                'result' => 'SUCCESS',
                'color' => 'blue-500',
                'start_date' => '2023-08-01',
                'end_date' => '2023-12-01'
            ],
            [
                'operation_name' => 'Operation Iron Fist',
                'description' => 'Border security operations in Iraq',
                'duration_months' => 8,
                'status' => 'In Progress',
                'result' => 'ACTIVE',
                'color' => 'yellow-500',
                'start_date' => '2025-01-01',
                'end_date' => null
            ]
        ];

        foreach ($operations as $operation) {
            MilitaryOperations::create(array_merge($operation, ['personnel_id' => $personnel->id]));
        }

        // Create education history
        $education = [
            [
                'degree_title' => 'Bachelor of Science - Military Science',
                'institution' => 'United States Military Academy',
                'graduation_date' => '2018-05-15',
                'gpa' => 3.8,
                'special_recognition' => 'Graduated: May 2018 | GPA: 3.8/4.0',
                'status' => 'Completed',
                'color' => 'blue-500'
            ],
            [
                'degree_title' => 'Advanced Leadership Course',
                'institution' => 'Fort Leavenworth Command & General Staff College',
                'graduation_date' => '2020-03-15',
                'gpa' => null,
                'special_recognition' => 'Honor Graduate',
                'status' => 'Completed',
                'color' => 'green-500'
            ],
            [
                'degree_title' => 'Master of Arts - Strategic Studies',
                'institution' => 'Naval War College',
                'graduation_date' => '2025-12-15',
                'gpa' => 3.9,
                'special_recognition' => 'Current GPA: 3.9/4.0',
                'status' => 'In Progress',
                'color' => 'purple-500'
            ]
        ];

        foreach ($education as $edu) {
            EducationHistory::create(array_merge($edu, ['personnel_id' => $personnel->id]));
        }

        // Create military training
        $training = [
            ['training_name' => 'Ranger School', 'status' => 'COMPLETED', 'icon' => 'fas fa-shield-alt', 'color' => 'military-green'],
            ['training_name' => 'Airborne School', 'status' => 'COMPLETED', 'icon' => 'fas fa-parachute-box', 'color' => 'blue-500'],
            ['training_name' => 'Mountain Warfare School', 'status' => 'COMPLETED', 'icon' => 'fas fa-mountain', 'color' => 'orange-500'],
            ['training_name' => 'Combat Lifesaver', 'status' => 'CERTIFIED', 'icon' => 'fas fa-fist-raised', 'color' => 'red-500'],
            ['training_name' => 'Language Training (Arabic)', 'status' => 'FLUENT', 'icon' => 'fas fa-language', 'color' => 'yellow-500']
        ];

        foreach ($training as $train) {
            MilitaryTraining::create(array_merge($train, ['personnel_id' => $personnel->id]));
        }

        // Create certifications
        $certifications = [
            [
                'certification_name' => 'Project Management Professional (PMP)',
                'status' => 'ACTIVE',
                'expiration_date' => '2026-06-15',
                'color' => 'green-500'
            ],
            [
                'certification_name' => 'Security+ Certification',
                'status' => 'ACTIVE',
                'expiration_date' => '2025-09-15',
                'color' => 'blue-500'
            ],
            [
                'certification_name' => 'Emergency Medical Technician',
                'status' => 'ACTIVE',
                'expiration_date' => '2026-03-15',
                'color' => 'purple-500'
            ]
        ];

        foreach ($certifications as $cert) {
            Certifications::create(array_merge($cert, ['personnel_id' => $personnel->id]));
        }

        // Create upcoming training
        $upcomingTraining = [
            [
                'training_name' => 'Advanced Tactical Training',
                'status' => 'SCHEDULED',
                'start_date' => '2025-10-15',
                'due_date' => null,
                'color' => 'orange-500'
            ],
            [
                'training_name' => 'Cyber Security Awareness',
                'status' => 'MANDATORY',
                'start_date' => null,
                'due_date' => '2025-09-30',
                'color' => 'red-500'
            ],
            [
                'training_name' => 'Leadership Development Course',
                'status' => 'ENROLLED',
                'start_date' => '2025-11-01',
                'due_date' => null,
                'color' => 'blue-500'
            ]
        ];

        foreach ($upcomingTraining as $upcoming) {
            UpcomingTraining::create(array_merge($upcoming, ['personnel_id' => $personnel->id]));
        }
    }
}
