<?php
require 'vendor/autoload.php';
$app = require_once 'bootstrap/app.php';
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$kernel->bootstrap();

use App\Models\JobPosting;
use App\Models\Tenant;

try {
    $t = Tenant::first();
    $tenantId = $t ? $t->id : 1;

    $jobsData = [
        [
            'tenant_id' => $tenantId,
            'title' => 'Registered Nurse (RN) - Home Health',
            'company' => 'Signal Health Systems',
            'location' => 'Dallas, TX (Hybrid / Home Visits)',
            'salary' => '$85,000 - $110,000 / yr',
            'department' => 'Healthcare Services',
            'description' => 'Seeking an experienced Registered Nurse to provide high-quality in-home patient assessments, care plan oversight, and clinical support.',
            'primary_screening_question' => 'Do you hold an active State RN license and current CPR/BLS certification?',
            'custom_questions' => [
                'How many years of home health, OASIS assessment, or ICU clinical nursing experience do you have?',
                'What electronic health record (EHR) systems have you used (e.g. Homecare Homebase, Epic, PointClickCare)?',
                'Are you comfortable conducting in-home patient visits and managing patient care plans?'
            ],
            'status' => 'published',
            'posted_at' => now(),
        ],
        [
            'tenant_id' => $tenantId,
            'title' => 'Certified Nursing Assistant (CNA) / Home Care Aide',
            'company' => 'Compass Care Services',
            'location' => 'Houston, TX (On-site / Patient Home)',
            'salary' => '$40,000 - $55,000 / yr',
            'department' => 'Patient Care',
            'description' => 'Provide direct compassionate care, ADL assistance, mobility support, and companionship for senior clients in home care settings.',
            'primary_screening_question' => 'Are you state-certified as a CNA or Home Health Aide (HHA)?',
            'custom_questions' => [
                'How many years of hands-on ADL care (bathing, dressing, transfer assistance) do you have?',
                'Do you have specialized experience caring for patients with Alzheimer\'s, Dementia, or Parkinson\'s?',
                'Do you possess a valid driver\'s license and insured vehicle for patient transportation?'
            ],
            'status' => 'published',
            'posted_at' => now(),
        ],
        [
            'tenant_id' => $tenantId,
            'title' => 'Senior Accountant & Financial Analyst',
            'company' => 'Signal Financial Group',
            'location' => 'Remote / Austin, TX',
            'salary' => '$90,000 - $115,000 / yr',
            'department' => 'Finance & Accounting',
            'description' => 'Oversee financial reporting, month-end closures, tax compliance, budget forecasting, and corporate financial audits.',
            'primary_screening_question' => 'Do you hold a Bachelor\'s degree in Accounting/Finance or an active CPA license?',
            'custom_questions' => [
                'Which ERP and accounting software suites are you proficient in (QuickBooks, NetSuite, SAP, Excel)?',
                'How many years of experience do you have with general ledger reconciliation and corporate tax filings?'
            ],
            'status' => 'published',
            'posted_at' => now(),
        ],
        [
            'tenant_id' => $tenantId,
            'title' => 'Full Stack Developer / AI Solutions Engineer',
            'company' => 'Signal Tech Studio',
            'location' => 'Fully Remote (US / Worldwide)',
            'salary' => '$110,000 - $145,000 / yr',
            'department' => 'Engineering',
            'description' => 'Build modern cloud web applications, REST APIs, and integrate OpenAI LLM microservices into enterprise platforms.',
            'primary_screening_question' => 'What primary programming languages & tech stacks do you specialize in?',
            'custom_questions' => [
                'Do you have hands-on experience integrating REST APIs, OpenAI models, and cloud infrastructure (AWS/GCP)?',
                'How many years of professional full-stack software development experience do you have?'
            ],
            'status' => 'published',
            'posted_at' => now(),
        ],
        [
            'tenant_id' => $tenantId,
            'title' => 'Office Manager & Client Coordinator',
            'company' => 'Enterprise Operations Corp',
            'location' => 'Atlanta, GA (In-office)',
            'salary' => '$52,000 - $68,000 / yr',
            'department' => 'Administration',
            'description' => 'Manage front-office operations, client inquiries, scheduling, records compliance, and staff coordination.',
            'primary_screening_question' => 'How many years of office management or administrative coordination experience do you have?',
            'custom_questions' => [
                'Are you experienced in client scheduling, CRM record management, and phone coordination?',
                'What office productivity tools are you proficient in (MS Office, Google Workspace, Slack)?'
            ],
            'status' => 'published',
            'posted_at' => now(),
        ],
    ];

    foreach ($jobsData as $data) {
        JobPosting::create($data);
    }

    echo "SUCCESSFULLY SEEDED " . count($jobsData) . " REAL JOBS! TOTAL PUBLISHED IN DB: " . JobPosting::where('status', 'published')->count() . "\n";

} catch (\Exception $e) {
    echo "ERROR SEEDING: " . $e->getMessage() . "\n";
}
