<?php

namespace Database\Seeders;

use App\Models\HeroCard;
use Illuminate\Database\Seeder;

/**
 * HeroCardSeeder
 *
 * Seeds the three homepage info cards displayed immediately below the hero slider.
 * Uses updateOrCreate keyed on `title` for idempotency (Req 11.4).
 *
 * Card colours per spec:
 *   Card 1 — bg-red-600   — SSHIA Membership
 *   Card 2 — bg-green-600 — Training Programmes
 *   Card 3 — bg-blue-900  — Knowledge Base
 *
 * Content: 10-word pitch researched from the existing system models
 *   (MembershipCategory, TrainingCategory, KnowledgeBaseCategory).
 */
class HeroCardSeeder extends Seeder
{
    public function run(): void
    {
        $cards = [
            [
                // Req 11.2: bg-red-600, "SSHIA Membership"
                // Req 11.3: 10-word pitch — researched from MembershipCategory model
                'title'            => 'SSHIA Membership',
                'content'          => 'Join, connect, and grow with South Sudan\'s health informatics community.',
                'background_color' => 'bg-red-600',
                'order'            => 1,
                'is_active'        => true,
            ],
            [
                // Req 11.2: bg-green-600, "Training Programmes"
                // Req 11.3: 10-word pitch — researched from TrainingCategory/TrainingPackage models
                'title'            => 'Training Programmes',
                'content'          => 'Advance your skills through expert-led digital health capacity building.',
                'background_color' => 'bg-green-600',
                'order'            => 2,
                'is_active'        => true,
            ],
            [
                // Req 11.2: bg-yellow-500, "Knowledge Base"
                // Req 11.3: 10-word pitch — researched from KnowledgeBaseCategory/KnowledgeBaseQuestion models
                'title'            => 'Knowledge Base',
                'content'          => 'Access curated health informatics resources, guides, and expert answers.',
                'background_color' => 'bg-yellow-500',
                'order'            => 3,
                'is_active'        => true,
            ],
        ];

        foreach ($cards as $data) {
            HeroCard::updateOrCreate(
                ['title' => $data['title']],   // key — Req 11.4
                [
                    'content'          => $data['content'],
                    'background_color' => $data['background_color'],
                    'order'            => $data['order'],
                    'is_active'        => $data['is_active'],
                ]
            );
        }
    }
}
