<?php

namespace Database\Seeders;

use App\Models\KnowledgeBaseCategory;
use Illuminate\Database\Seeder;
use Illuminate\Support\Str;

/**
 * KnowledgeBaseCategorySeeder
 *
 * Seeds five root-level knowledge base categories for the SSHIA Q&A
 * knowledge platform. These categories organise the structured knowledge
 * base that serves both SSHIA members and the general public, providing
 * authoritative answers to frequently asked questions about SSHIA services,
 * programmes, and health informatics resources.
 *
 * Categories are crafted with SEO-optimised metadata to maximise
 * discoverability through Google Search Console and organic search.
 *
 * Uses updateOrCreate keyed on slug for idempotency — safe to re-run.
 */
class KnowledgeBaseCategorySeeder extends Seeder
{
    public function run(): void
    {
        $categories = [
            [
                'name'             => 'Membership',
                'slug'             => 'membership',
                'description'      => 'Comprehensive answers to frequently asked questions about SSHIA membership — covering application procedures, membership categories, eligibility requirements, renewal processes, member benefits, contribution obligations, and the member portal. Whether you are a prospective member or an existing member with questions, this category provides clear, authoritative guidance.',
                'parent_id'        => null,
                'icon'             => 'fa-id-card',
                'color'            => 'green',
                'is_active'        => true,
                'sort_order'       => 1,
                'meta_title'       => 'SSHIA Membership FAQ — Knowledge Base',
                'meta_description' => 'Find answers to all your questions about SSHIA membership, including how to apply, membership categories, fees, benefits, and renewal procedures.',
                'meta_keywords'    => 'SSHIA membership, how to join SSHIA, membership application, membership categories, South Sudan health informatics',
            ],
            [
                'name'             => 'Training',
                'slug'             => 'training',
                'description'      => 'Detailed information about SSHIA training programmes, including how to register for training sessions, payment procedures, attendance requirements, certificate eligibility, and how to verify a training certificate. This category also covers the different training categories offered by SSHIA and the professional development pathways available to members.',
                'parent_id'        => null,
                'icon'             => 'fa-graduation-cap',
                'color'            => 'blue',
                'is_active'        => true,
                'sort_order'       => 2,
                'meta_title'       => 'SSHIA Training Programmes FAQ — Knowledge Base',
                'meta_description' => 'Get answers about SSHIA training programmes, registration, certificates, and professional development opportunities for health informatics professionals in South Sudan.',
                'meta_keywords'    => 'SSHIA training, health informatics training, training certificate, professional development, South Sudan',
            ],
            [
                'name'             => 'Mentorship',
                'slug'             => 'mentorship',
                'description'      => 'Guidance on SSHIA\'s mentorship programmes, including how to apply as a mentor or mentee, the matching process, session scheduling, payment for paid programmes, and certificate verification. This category explains the different mentorship tracks available and the eligibility criteria for each programme.',
                'parent_id'        => null,
                'icon'             => 'fa-user-friends',
                'color'            => 'purple',
                'is_active'        => true,
                'sort_order'       => 3,
                'meta_title'       => 'SSHIA Mentorship Programmes FAQ — Knowledge Base',
                'meta_description' => 'Learn about SSHIA mentorship programmes, how to apply, the mentor-mentee matching process, and how to verify a mentorship certificate.',
                'meta_keywords'    => 'SSHIA mentorship, health informatics mentorship, mentor application, mentee application, South Sudan',
            ],
            [
                'name'             => 'Technical Support',
                'slug'             => 'technical-support',
                'description'      => 'Step-by-step guidance for resolving common technical issues with the SSHIA platform, including account access problems, password resets, two-factor authentication, browser compatibility, and system requirements. This category also covers how to report bugs, request new features, and contact the SSHIA technical support team.',
                'parent_id'        => null,
                'icon'             => 'fa-tools',
                'color'            => 'red',
                'is_active'        => true,
                'sort_order'       => 4,
                'meta_title'       => 'SSHIA Platform Technical Support — Knowledge Base',
                'meta_description' => 'Find solutions to common technical issues with the SSHIA platform, including login problems, account access, and system requirements.',
                'meta_keywords'    => 'SSHIA technical support, login help, account access, password reset, SSHIA platform',
            ],
            [
                'name'             => 'Health Resources',
                'slug'             => 'health-resources',
                'description'      => 'A curated knowledge base of health informatics resources, guidelines, standards, and best practices relevant to health professionals in South Sudan. This category covers topics such as health information system standards, data quality frameworks, digital health tools, national health policies, and links to authoritative health informatics resources from WHO, AFRO, and other global health organisations.',
                'parent_id'        => null,
                'icon'             => 'fa-heartbeat',
                'color'            => 'orange',
                'is_active'        => true,
                'sort_order'       => 5,
                'meta_title'       => 'Health Informatics Resources — SSHIA Knowledge Base',
                'meta_description' => 'Access curated health informatics resources, guidelines, standards, and best practices for health professionals in South Sudan.',
                'meta_keywords'    => 'health informatics resources, health information systems, digital health, South Sudan health, WHO guidelines',
            ],
        ];

        foreach ($categories as $data) {
            KnowledgeBaseCategory::updateOrCreate(
                ['slug' => $data['slug']],
                $data
            );
        }

        $this->command->info('KnowledgeBaseCategorySeeder: 5 knowledge base categories seeded successfully.');
    }
}
