<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
use Carbon\Carbon;

class DemoSeeder extends Seeder
{
    // ─── Hub IDs resolved at runtime ───────────────────────────────────────
    private int $financeHubId;
    private int $marketingHubId;
    private int $salesHubId;
    private array $sectorIds = [];

    // ─── Member buckets ─────────────────────────────────────────────────────
    private array $financeMembers  = [];
    private array $marketingMembers = [];
    private array $salesMembers    = [];
    private array $allMembers      = [];

    // ─── Timestamps helper ──────────────────────────────────────────────────
    private function ts(int $daysAgo = 0, int $hoursAgo = 0): string
    {
        return Carbon::now()
            ->subDays($daysAgo)
            ->subHours($hoursAgo)
            ->toDateTimeString();
    }

    private function randTs(int $maxDaysAgo = 60): string
    {
        return Carbon::now()
            ->subDays(rand(1, $maxDaysAgo))
            ->subHours(rand(0, 23))
            ->subMinutes(rand(0, 59))
            ->toDateTimeString();
    }

    // ════════════════════════════════════════════════════════════════════════
    //  ENTRY POINT
    // ════════════════════════════════════════════════════════════════════════

    public function run(): void
    {
        DB::transaction(function () {
            $this->resolveHubs();
            $this->resolveSectors();
            $this->createMembers();
            $this->createCaseActivity();
            $this->createForumActivity();
            $this->createCvProfiles();
            $this->createJobListings();
            $this->createFreelanceData();
            $this->createDocuments();
        });

        $this->command->info('✅ DemoSeeder complete — 100 members, full platform activity.');
    }

    // ════════════════════════════════════════════════════════════════════════
    //  0. RESOLVE HUBS & SECTORS
    // ════════════════════════════════════════════════════════════════════════

    private function resolveHubs(): void
    {
        $hubs = DB::table('hubs')->whereIn('slug', ['finance', 'marketing', 'sales'])->get()->keyBy('slug');

        if ($hubs->count() < 3) {
            throw new \RuntimeException('Finance, Marketing, and Sales hubs must exist before running DemoSeeder.');
        }

        $this->financeHubId   = $hubs['finance']->id;
        $this->marketingHubId = $hubs['marketing']->id;
        $this->salesHubId     = $hubs['sales']->id;
    }

    private function resolveSectors(): void
    {
        $this->sectorIds = DB::table('sectors')->where('is_active', 1)->pluck('id')->toArray();
    }

    // ════════════════════════════════════════════════════════════════════════
    //  1. CREATE 100 MEMBERS
    // ════════════════════════════════════════════════════════════════════════

    private function createMembers(): void
    {
        $financeProfiles = $this->financeProfileData();
        $marketingProfiles = $this->marketingProfileData();
        $salesProfiles = $this->salesProfileData();

        // Finance: 34 members
        foreach ($financeProfiles as $p) {
            $id = $this->insertUser($p);
            $this->financeMembers[] = $id;
            $this->allMembers[] = $id;
            $this->attachHub($id, $this->financeHubId, true);
            // ~30% also join a second hub
            if (rand(1, 10) <= 3) {
                $secondHub = rand(0, 1) ? $this->marketingHubId : $this->salesHubId;
                $this->attachHub($id, $secondHub, false);
            }
        }

        // Marketing: 33 members
        foreach ($marketingProfiles as $p) {
            $id = $this->insertUser($p);
            $this->marketingMembers[] = $id;
            $this->allMembers[] = $id;
            $this->attachHub($id, $this->marketingHubId, true);
            if (rand(1, 10) <= 3) {
                $secondHub = rand(0, 1) ? $this->financeHubId : $this->salesHubId;
                $this->attachHub($id, $secondHub, false);
            }
        }

        // Sales: 33 members
        foreach ($salesProfiles as $p) {
            $id = $this->insertUser($p);
            $this->salesMembers[] = $id;
            $this->allMembers[] = $id;
            $this->attachHub($id, $this->salesHubId, true);
            if (rand(1, 10) <= 3) {
                $secondHub = rand(0, 1) ? $this->marketingHubId : $this->financeHubId;
                $this->attachHub($id, $secondHub, false);
            }
        }
    }

    private function insertUser(array $p): int
    {
        $now = $this->randTs(90);
        return DB::table('users')->insertGetId([
            'name'                        => $p['name'],
            'nickname'                    => $p['nickname'],
            'email'                       => $p['email'],
            'email_verified_at'           => $now,
            'password'                    => Hash::make('password'),
            'role'                        => 'member',
            'profession'                  => $p['profession'],
            'experience_level'            => $p['level'],
            'sector'                      => $p['sector'],
            'bio'                         => $p['bio'],
            'language'                    => $p['language'] ?? 'en',
            'theme'                       => $p['theme'] ?? 'navy',
            'highly_rated_solutions_count'=> 0,
            'highly_rated_replies_count'  => 0,
            'show_real_name'              => rand(0, 1),
            'notify_jobs'                 => 1,
            'notify_freelance'            => 1,
            'notify_forum'               => 1,
            'notify_surveys'             => 1,
            'notify_documents'           => 1,
            'is_active'                  => 1,
            'phone'                      => '01' . rand(0, 2) . rand(10000000, 99999999),
            'created_at'                 => $now,
            'updated_at'                 => $now,
        ]);
    }

    private function attachHub(int $userId, int $hubId, bool $isPrimary): void
    {
        DB::table('user_hubs')->insert([
            'user_id'    => $userId,
            'hub_id'     => $hubId,
            'is_primary' => $isPrimary ? 1 : 0,
            'joined_at'  => $this->randTs(80),
        ]);
    }

    // ════════════════════════════════════════════════════════════════════════
    //  2. CASE ACTIVITY
    // ════════════════════════════════════════════════════════════════════════

    private function createCaseActivity(): void
    {
        $financeCases  = DB::table('cases')->where('hub_id', $this->financeHubId)->where('status', 'published')->pluck('id')->toArray();
        $marketingCases = DB::table('cases')->where('hub_id', $this->marketingHubId)->where('status', 'published')->pluck('id')->toArray();
        $salesCases    = DB::table('cases')->where('hub_id', $this->salesHubId)->where('status', 'published')->pluck('id')->toArray();

        // Process each hub's members with their hub's cases
        $this->processCaseActivityForHub($this->financeMembers, $financeCases, 28, 30);
        $this->processCaseActivityForHub($this->marketingMembers, $marketingCases, 26, 28);
        $this->processCaseActivityForHub($this->salesMembers, $salesCases, 24, 22);
    }

    private function processCaseActivityForHub(array $members, array $caseIds, int $activeMembers, int $targetSolutions): void
    {
        if (empty($caseIds)) return;

        shuffle($members);
        $activeMembers = min($activeMembers, count($members));
        $activeMemberSlice = array_slice($members, 0, $activeMembers);

        $solutionsSubmitted = 0;
        $allProgressIds = []; // [userId => [caseId => progressId]]
        $solutionIds = [];    // [progressId => solutionId]

        foreach ($activeMemberSlice as $userId) {
            $casesToDo = rand(3, 8);
            $shuffledCases = $caseIds;
            shuffle($shuffledCases);
            $userCases = array_slice($shuffledCases, 0, min($casesToDo, count($shuffledCases)));

            foreach ($userCases as $caseId) {
                $completed   = rand(0, 10) > 3; // 70% complete
                $revealed    = $completed || rand(0, 10) > 5;
                $caseRating  = $completed ? rand(3, 5) : null;
                $completedAt = $completed ? $this->randTs(50) : null;
                $now         = $this->randTs(55);

                $progressId = DB::table('case_progress')->insertGetId([
                    'user_id'          => $userId,
                    'case_id'          => $caseId,
                    'status'           => $completed ? 'completed' : 'started',
                    'solution_revealed'=> $revealed ? 1 : 0,
                    'completed_at'     => $completedAt,
                    'case_rating'      => $caseRating,
                    'case_rated_at'    => $caseRating ? $completedAt : null,
                    'created_at'       => $now,
                    'updated_at'       => $now,
                ]);

                $allProgressIds[$userId][$caseId] = $progressId;

                // Submit a written solution (~40% of completions)
                if ($completed && $solutionsSubmitted < $targetSolutions && rand(0, 10) > 5) {
                    $solutionId = DB::table('case_member_solutions')->insertGetId([
                        'case_id'       => $caseId,
                        'user_id'       => $userId,
                        'content'       => $this->randomSolutionContent(),
                        'avg_rating'    => 0.00,
                        'ratings_count' => 0,
                        'created_at'    => $completedAt,
                        'updated_at'    => $completedAt,
                    ]);
                    $solutionIds[] = ['id' => $solutionId, 'user_id' => $userId, 'case_id' => $caseId];
                    $solutionsSubmitted++;
                }
            }
        }

        // Rate solutions — each solution gets rated by 2–5 other members
        $raterPool = $activeMemberSlice;
        foreach ($solutionIds as $sol) {
            shuffle($raterPool);
            $raterCount = rand(2, 5);
            $ratings = [];
            $totalRating = 0;

            foreach (array_slice($raterPool, 0, $raterCount) as $raterId) {
                if ($raterId === $sol['user_id']) continue;
                $rating = rand(3, 5);
                $totalRating += $rating;
                $ratings[] = $rating;
                $now = $this->randTs(40);
                DB::table('case_solution_ratings')->insert([
                    'solution_id' => $sol['id'],
                    'user_id'     => $raterId,
                    'rating'      => $rating,
                    'created_at'  => $now,
                    'updated_at'  => $now,
                ]);
            }

            if (!empty($ratings)) {
                $avg = round($totalRating / count($ratings), 2);
                DB::table('case_member_solutions')->where('id', $sol['id'])->update([
                    'avg_rating'    => $avg,
                    'ratings_count' => count($ratings),
                ]);

                // Highly rated (4+) → increment author counter
                if ($avg >= 4.0) {
                    DB::table('users')->where('id', $sol['user_id'])->increment('highly_rated_solutions_count');
                }
            }
        }
    }

    // ════════════════════════════════════════════════════════════════════════
    //  3. FORUM ACTIVITY
    // ════════════════════════════════════════════════════════════════════════

    private function createForumActivity(): void
    {
        $posts = $this->forumPostData();

        foreach ($posts as $postData) {
            $hubId = $postData['hub_id'];
            $hubMembers = match($hubId) {
                $this->financeHubId   => $this->financeMembers,
                $this->marketingHubId => $this->marketingMembers,
                $this->salesHubId    => $this->salesMembers,
                default              => $this->allMembers,
            };

            $authorId = $hubMembers[array_rand($hubMembers)];
            $now = $this->randTs(45);

            $postId = DB::table('forum_posts')->insertGetId([
                'user_id'          => $authorId,
                'hub_id'           => $hubId,
                'post_type'        => $postData['post_type'] ?? 'question',
                'source_url'       => $postData['source_url'] ?? null,
                'source_label'     => $postData['source_label'] ?? null,
                'title'            => $postData['title'],
                'body'             => $postData['body'],
                'language'         => $postData['language'] ?? 'en',
                'posted_as_nickname'=> rand(0, 1),
                'visibility'       => $postData['visibility'] ?? 'all',
                'tags'             => json_encode($postData['tags'] ?? []),
                'status'           => 'active',
                'reply_count'      => 0,
                'like_count'       => rand(2, 12),
                'view_count'       => rand(30, 300),
                'is_pinned'        => 0,
                'created_at'       => $now,
                'updated_at'       => $now,
            ]);

            // 3–6 replies per post
            $replyCount = rand(3, 6);
            shuffle($hubMembers);
            $repliers = array_slice(array_filter($hubMembers, fn($id) => $id !== $authorId), 0, $replyCount);
            $bestAnswerSet = false;
            $replyIds = [];

            foreach ($repliers as $i => $replierId) {
                $replyTs = $this->randTs(40);
                $isBest = !$bestAnswerSet && rand(0, 10) > 6;
                if ($isBest) $bestAnswerSet = true;

                $replyId = DB::table('forum_replies')->insertGetId([
                    'forum_post_id'    => $postId,
                    'user_id'          => $replierId,
                    'parent_reply_id'  => null,
                    'body'             => $this->randomReplyBody($postData['title']),
                    'posted_as_nickname'=> rand(0, 1),
                    'status'           => 'active',
                    'is_best_answer'   => $isBest ? 1 : 0,
                    'like_count'       => rand(0, 8),
                    'avg_rating'       => 0.00,
                    'ratings_count'    => 0,
                    'created_at'       => $replyTs,
                    'updated_at'       => $replyTs,
                ]);

                $replyIds[] = ['id' => $replyId, 'user_id' => $replierId];

                // ~40% chance of a nested reply
                if (rand(0, 10) > 5) {
                    $nestedReplier = $hubMembers[array_rand($hubMembers)];
                    $nestedTs = $this->randTs(35);
                    DB::table('forum_replies')->insert([
                        'forum_post_id'    => $postId,
                        'user_id'          => $nestedReplier,
                        'parent_reply_id'  => $replyId,
                        'body'             => $this->randomNestedReply(),
                        'posted_as_nickname'=> rand(0, 1),
                        'status'           => 'active',
                        'is_best_answer'   => 0,
                        'like_count'       => rand(0, 4),
                        'avg_rating'       => 0.00,
                        'ratings_count'    => 0,
                        'created_at'       => $nestedTs,
                        'updated_at'       => $nestedTs,
                    ]);
                }
            }

            // Rate replies — each reply gets rated by 2–4 other members
            foreach ($replyIds as $reply) {
                shuffle($hubMembers);
                $raterCount = rand(2, 4);
                $ratings = [];
                $totalRating = 0;

                foreach (array_slice($hubMembers, 0, $raterCount + 1) as $raterId) {
                    if ($raterId === $reply['user_id']) continue;
                    if (count($ratings) >= $raterCount) break;

                    $rating = rand(3, 5);
                    $totalRating += $rating;
                    $ratings[] = $rating;
                    $ratingTs = $this->randTs(30);

                    DB::table('forum_reply_ratings')->insert([
                        'forum_reply_id' => $reply['id'],
                        'user_id'        => $raterId,
                        'rating'         => $rating,
                        'created_at'     => $ratingTs,
                    ]);
                }

                if (!empty($ratings)) {
                    $avg = round($totalRating / count($ratings), 2);
                    DB::table('forum_replies')->where('id', $reply['id'])->update([
                        'avg_rating'    => $avg,
                        'ratings_count' => count($ratings),
                    ]);

                    if ($avg >= 4.0) {
                        DB::table('users')->where('id', $reply['user_id'])->increment('highly_rated_replies_count');
                    }
                }
            }

            // Update post reply_count
            $totalReplies = DB::table('forum_replies')->where('forum_post_id', $postId)->count();
            DB::table('forum_posts')->where('id', $postId)->update([
                'reply_count' => $totalReplies,
                'updated_at'  => $this->randTs(20),
            ]);
        }
    }

    // ════════════════════════════════════════════════════════════════════════
    //  4. CV PROFILES
    // ════════════════════════════════════════════════════════════════════════

    private function createCvProfiles(): void
    {
        $cvData = $this->cvProfileData();

        // Pick 35 random members to have a CV
        $candidates = $this->allMembers;
        shuffle($candidates);
        $candidates = array_slice($candidates, 0, 35);

        foreach (array_slice($cvData, 0, count($candidates)) as $i => $cv) {
            $userId = $candidates[$i];
            $now = $this->randTs(70);

            // Determine which hub this user is in to pick relevant skills
            $userHubs = DB::table('user_hubs')->where('user_id', $userId)->pluck('hub_id')->toArray();
            $primaryHub = DB::table('user_hubs')->where('user_id', $userId)->where('is_primary', 1)->value('hub_id');

            $skills = $this->skillsForHub($primaryHub ?? $this->financeHubId);
            $hubIds = $userHubs;

            DB::table('cv_profiles')->insert([
                'user_id'            => $userId,
                'job_title'          => $cv['job_title'],
                'current_industry'   => $cv['current_industry'],
                'years_experience'   => $cv['years_experience'],
                'experience_level'   => $cv['experience_level'],
                'skills'             => json_encode($skills),
                'hub_ids'            => json_encode($hubIds),
                'education_level'    => $cv['education_level'],
                'education_field'    => $cv['education_field'],
                'location_country'   => 'Egypt',
                'location_city'      => $cv['location_city'],
                'summary'            => $cv['summary'],
                'preferred_sectors'  => json_encode($cv['preferred_sectors']),
                'job_type_preference'=> $cv['job_type_preference'],
                'open_to_relocation' => rand(0, 1),
                'is_visible'         => rand(0, 10) > 2 ? 1 : 0, // 70% visible
                'created_at'         => $now,
                'updated_at'         => $now,
            ]);
        }
    }

    // ════════════════════════════════════════════════════════════════════════
    //  5. JOB LISTINGS & NOTIFICATIONS
    // ════════════════════════════════════════════════════════════════════════

    private function createJobListings(): void
    {
        $listings = $this->jobListingData();

        // Pick 6 members to be employers (post jobs)
        $employers = array_slice($this->allMembers, 0, 6);
        shuffle($employers);

        $listingIds = [];

        foreach ($listings as $i => $job) {
            $employerId = $employers[$i % count($employers)];
            $hubId = match($job['hub']) {
                'finance'   => $this->financeHubId,
                'marketing' => $this->marketingHubId,
                'sales'     => $this->salesHubId,
                default     => $this->financeHubId,
            };
            $now = $this->randTs(55);

            $listingId = DB::table('job_listings')->insertGetId([
                'posted_by'           => $employerId,
                'hub_id'              => $hubId,
                'job_title'           => $job['job_title'],
                'company_name'        => $job['company_name'],
                'industry'            => $job['industry'],
                'location_city'       => $job['location_city'],
                'job_type'            => $job['job_type'],
                'description'         => $job['description'],
                'required_skills'     => json_encode($job['required_skills']),
                'min_experience_years'=> $job['min_experience_years'],
                'salary_range'        => $job['salary_range'],
                'status'              => $job['status'],
                'created_at'          => $now,
                'updated_at'          => $now,
            ]);

            $listingIds[] = [
                'id'          => $listingId,
                'employer_id' => $employerId,
                'hub_id'      => $hubId,
            ];
        }

        // Create job notifications — employers reaching out to CV holders
        $cvProfiles = DB::table('cv_profiles')->where('is_visible', 1)->get()->toArray();
        if (empty($cvProfiles)) return;

        $notificationStatuses = ['pending', 'pending', 'accepted', 'accepted', 'declined', 'connected', 'connected', 'accepted', 'pending', 'connected', 'declined', 'accepted', 'connected', 'pending', 'accepted'];

        foreach (array_slice($listingIds, 0, 15) as $i => $listing) {
            $cvProfile = $cvProfiles[array_rand($cvProfiles)];
            if ($cvProfile->user_id === $listing['employer_id']) continue;

            $status = $notificationStatuses[$i % count($notificationStatuses)];
            $connectedAt = $status === 'connected' ? $this->randTs(20) : null;
            $now = $this->randTs(40);

            DB::table('job_notifications')->insert([
                'job_listing_id'       => $listing['id'],
                'cv_profile_id'        => $cvProfile->id,
                'professional_user_id' => $cvProfile->user_id,
                'employer_user_id'     => $listing['employer_id'],
                'message'              => $this->randomJobOutreachMessage(),
                'status'               => $status,
                'professional_consented'=> in_array($status, ['accepted', 'connected']) ? 1 : 0,
                'employer_consented'   => $status === 'connected' ? 1 : 0,
                'connected_at'         => $connectedAt,
                'created_at'           => $now,
                'updated_at'           => $now,
            ]);
        }
    }

    // ════════════════════════════════════════════════════════════════════════
    //  6. FREELANCE DATA
    // ════════════════════════════════════════════════════════════════════════

    private function createFreelanceData(): void
    {
        $freelanceProfileData = $this->freelanceProfileData();

        // 25 members become freelancers
        $freelancers = $this->allMembers;
        shuffle($freelancers);
        $freelancers = array_slice($freelancers, 0, 25);

        $profileIds = [];

        foreach ($freelancers as $i => $userId) {
            $pd = $freelanceProfileData[$i % count($freelanceProfileData)];
            $primaryHub = DB::table('user_hubs')->where('user_id', $userId)->where('is_primary', 1)->value('hub_id') ?? $this->financeHubId;
            $now = $this->randTs(65);

            $profileId = DB::table('freelance_profiles')->insertGetId([
                'user_id'          => $userId,
                'hub_id'           => $primaryHub,
                'headline'         => $pd['headline'],
                'description'      => $pd['description'],
                'services'         => json_encode($this->servicesForHub($primaryHub)),
                'sector_expertise' => json_encode($this->randomSectors(2)),
                'experience_level' => $pd['experience_level'],
                'availability'     => $pd['availability'],
                'rate_min_egp'     => $pd['rate_min'],
                'rate_max_egp'     => $pd['rate_max'],
                'rate_is_visible'  => rand(0, 1),
                'review_count'     => 0,
                'rating_average'   => 0.00,
                'is_active'        => rand(0, 10) > 1 ? 1 : 0, // 80% active
                'linkedin_url'     => 'https://linkedin.com/in/' . Str::slug($pd['headline'] . '-' . rand(1000, 9999)),
                'created_at'       => $now,
                'updated_at'       => $now,
            ]);

            $profileIds[] = ['id' => $profileId, 'user_id' => $userId, 'hub_id' => $primaryHub];
        }

        // 15 briefs posted by non-freelancer members
        $briefPosters = array_diff($this->allMembers, $freelancers);
        shuffle($briefPosters);
        $briefPosters = array_slice($briefPosters, 0, 15);

        $briefData = $this->freelanceBriefData();
        $briefIds = [];

        foreach ($briefPosters as $i => $userId) {
            $bd = $briefData[$i % count($briefData)];
            $primaryHub = DB::table('user_hubs')->where('user_id', $userId)->where('is_primary', 1)->value('hub_id') ?? $this->financeHubId;
            $now = $this->randTs(50);

            $briefId = DB::table('freelance_briefs')->insertGetId([
                'user_id'           => $userId,
                'hub_id'            => $primaryHub,
                'title'             => $bd['title'],
                'description'       => $bd['description'],
                'required_skills'   => json_encode($bd['required_skills']),
                'preferred_sector'  => $bd['preferred_sector'],
                'duration_estimate' => $bd['duration_estimate'],
                'timeline'          => $bd['timeline'],
                'budget_min_egp'    => $bd['budget_min'],
                'budget_max_egp'    => $bd['budget_max'],
                'budget_is_visible' => rand(0, 1),
                'status'            => $bd['status'],
                'created_at'        => $now,
                'updated_at'        => $now,
            ]);

            $briefIds[] = ['id' => $briefId, 'user_id' => $userId];
        }

        // 20 freelance matches in various states
        $matchStatuses = ['pending', 'pending', 'interested', 'interested', 'declined', 'connected', 'connected', 'connected', 'interested', 'pending', 'connected', 'interested', 'declined', 'connected', 'pending', 'connected', 'interested', 'pending', 'connected', 'interested'];

        $matchIds = [];
        foreach (array_slice($profileIds, 0, 20) as $i => $profile) {
            // Find a seeker who is NOT the profile owner
            $seekerPool = array_filter($briefPosters, fn($id) => $id !== $profile['user_id']);
            if (empty($seekerPool)) continue;
            $seekerPool = array_values($seekerPool);
            $seekerId = $seekerPool[array_rand($seekerPool)];

            $briefId = isset($briefIds[$i]) ? $briefIds[$i]['id'] : null;
            $status = $matchStatuses[$i % count($matchStatuses)];
            $connectedAt = $status === 'connected' ? $this->randTs(25) : null;
            $now = $this->randTs(40);

            $matchId = DB::table('freelance_matches')->insertGetId([
                'freelance_brief_id'   => $briefId,
                'freelance_profile_id' => $profile['id'],
                'seeker_user_id'       => $seekerId,
                'provider_user_id'     => $profile['user_id'],
                'status'               => $status,
                'seeker_consented'     => $status === 'connected' ? 1 : 0,
                'provider_consented'   => in_array($status, ['interested', 'connected']) ? 1 : 0,
                'connected_at'         => $connectedAt,
                'seeker_message'       => $this->randomSeekerMessage(),
                'created_at'           => $now,
                'updated_at'           => $now,
            ]);

            if ($status === 'connected') {
                $matchIds[] = [
                    'id'         => $matchId,
                    'seeker_id'  => $seekerId,
                    'profile_id' => $profile['id'],
                    'provider_id'=> $profile['user_id'],
                ];
            }
        }

        // 8 reviews on connected matches
        $reviewMessages = $this->reviewMessages();
        foreach (array_slice($matchIds, 0, 8) as $i => $match) {
            $rating = rand(3, 5);
            $reviewMsg = $reviewMessages[$i % count($reviewMessages)];
            $now = $this->randTs(20);

            DB::table('reviews')->insert([
                'freelance_match_id'   => $match['id'],
                'reviewer_user_id'     => $match['seeker_id'],
                'freelance_profile_id' => $match['profile_id'],
                'rating'               => $rating,
                'comment'              => $reviewMsg,
                'posted_as_nickname'   => rand(0, 1),
                'created_at'           => $now,
                'updated_at'           => $now,
            ]);

            // Update profile review stats
            $allRatings = DB::table('reviews')->where('freelance_profile_id', $match['profile_id'])->pluck('rating');
            $avg = round($allRatings->avg(), 2);
            DB::table('freelance_profiles')->where('id', $match['profile_id'])->update([
                'review_count'   => $allRatings->count(),
                'rating_average' => $avg,
            ]);
        }
    }

    // ════════════════════════════════════════════════════════════════════════
    //  7. DOCUMENTS
    // ════════════════════════════════════════════════════════════════════════

    private function createDocuments(): void
    {
        $docs = $this->documentData();

        $uploaders = $this->allMembers;
        shuffle($uploaders);

        $documentIds = [];

        foreach ($docs as $i => $doc) {
            $userId = $uploaders[$i % count($uploaders)];
            $hubId = match($doc['hub']) {
                'finance'   => $this->financeHubId,
                'marketing' => $this->marketingHubId,
                'sales'     => $this->salesHubId,
                default     => $this->financeHubId,
            };
            $uuid = Str::uuid()->toString();
            $now = $this->randTs(60);

            $docId = DB::table('documents')->insertGetId([
                'user_id'           => $userId,
                'hub_id'            => $hubId,
                'original_filename' => Str::slug($doc['title_en']) . '.pdf',
                'stored_filename'   => $uuid . '.pdf',
                'file_path'         => 'documents/' . $uuid . '.pdf',
                'file_type'         => 'pdf',
                'file_size'         => rand(500000, 5000000),
                'title_en'          => $doc['title_en'],
                'title_ar'          => $doc['title_ar'] ?? null,
                'description_en'    => $doc['description_en'],
                'description_ar'    => $doc['description_ar'] ?? null,
                'language'          => 'en',
                'document_category' => $doc['category'],
                'tags'              => json_encode($doc['tags']),
                'sector_id'         => !empty($this->sectorIds) ? $this->sectorIds[array_rand($this->sectorIds)] : null,
                'visibility'        => rand(0, 10) > 2 ? 'all' : 'hub',
                'status'            => $doc['status'],
                'download_count'    => rand(5, 150),
                'rating_count'      => 0,
                'rating_average'    => 0.00,
                'created_at'        => $now,
                'updated_at'        => $now,
            ]);

            $documentIds[] = ['id' => $docId, 'user_id' => $userId];
        }

        // Rate documents — each approved document gets 2–4 ratings
        foreach ($documentIds as $doc) {
            if (rand(0, 10) < 3) continue; // skip 30%

            $raters = array_filter($this->allMembers, fn($id) => $id !== $doc['user_id']);
            $raters = array_values($raters);
            shuffle($raters);
            $raterCount = rand(2, 4);
            $ratings = [];
            $totalRating = 0;

            foreach (array_slice($raters, 0, $raterCount) as $raterId) {
                $rating = rand(3, 5);
                $totalRating += $rating;
                $ratings[] = $rating;
                $now = $this->randTs(40);

                DB::table('document_ratings')->insert([
                    'user_id'     => $raterId,
                    'document_id' => $doc['id'],
                    'rating'      => $rating,
                    'comment'     => rand(0, 1) ? $this->randomDocumentComment() : null,
                    'created_at'  => $now,
                    'updated_at'  => $now,
                ]);
            }

            if (!empty($ratings)) {
                $avg = round($totalRating / count($ratings), 2);
                DB::table('documents')->where('id', $doc['id'])->update([
                    'rating_count'   => count($ratings),
                    'rating_average' => $avg,
                ]);
            }
        }
    }

    // ════════════════════════════════════════════════════════════════════════
    //  DATA: MEMBERS — FINANCE (34)
    // ════════════════════════════════════════════════════════════════════════

    private function financeProfileData(): array
    {
        return [
            ['name' => 'Ahmed Mahmoud',     'nickname' => 'ahmed_fin',       'email' => 'ahmed.mahmoud@demo.ip',    'profession' => 'Financial Analyst',       'level' => 'mid',      'sector' => 'Banking',        'bio' => 'FP&A specialist with 5 years in Egyptian banking sector.',               'theme' => 'navy', 'language' => 'en'],
            ['name' => 'Sara Hassan',       'nickname' => 'sara_h',          'email' => 'sara.hassan@demo.ip',      'profession' => 'Senior Accountant',       'level' => 'senior',   'sector' => 'Manufacturing',  'bio' => 'Certified accountant specializing in cost control and IFRS.',            'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Omar Khalil',       'nickname' => 'okhalil',         'email' => 'omar.khalil@demo.ip',      'profession' => 'CFO',                     'level' => 'senior_10','sector' => 'Real Estate',    'bio' => 'CFO at a mid-size real estate developer in New Cairo.',                  'theme' => 'navy', 'language' => 'en'],
            ['name' => 'Nour ElSayed',      'nickname' => 'nour_finance',    'email' => 'nour.elsayed@demo.ip',     'profession' => 'Treasury Manager',        'level' => 'mid',      'sector' => 'FMCG',           'bio' => 'Managing cash flow and hedging for a listed FMCG company.',              'theme' => 'dark', 'language' => 'ar'],
            ['name' => 'Karim Adel',        'nickname' => 'karimadel',       'email' => 'karim.adel@demo.ip',       'profession' => 'Financial Controller',    'level' => 'senior',   'sector' => 'Manufacturing',  'bio' => 'Financial controller overseeing 3 manufacturing plants.',                'theme' => 'navy', 'language' => 'en'],
            ['name' => 'Mona Fathy',        'nickname' => 'mona_cpa',        'email' => 'mona.fathy@demo.ip',       'profession' => 'Tax Consultant',          'level' => 'mid',      'sector' => 'Services',       'bio' => 'Tax advisor for SMEs navigating Egyptian tax law.',                      'theme' => 'navy', 'language' => 'ar'],
            ['name' => 'Youssef Ibrahim',   'nickname' => 'youssef_i',       'email' => 'youssef.ibrahim@demo.ip',  'profession' => 'Budget Analyst',          'level' => 'junior',   'sector' => 'Healthcare',     'bio' => 'Fresh finance graduate working in hospital budgeting.',                  'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Rania Mostafa',     'nickname' => 'rania_m',         'email' => 'rania.mostafa@demo.ip',    'profession' => 'Investment Analyst',      'level' => 'mid',      'sector' => 'Startups',       'bio' => 'Evaluating startup deals for a Cairo-based VC fund.',                    'theme' => 'navy', 'language' => 'en'],
            ['name' => 'Hossam Nabil',      'nickname' => 'hossam_n',        'email' => 'hossam.nabil@demo.ip',     'profession' => 'Credit Analyst',          'level' => 'junior',   'sector' => 'Banking',        'bio' => 'Commercial credit analyst at a private Egyptian bank.',                  'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Dina Ramadan',      'nickname' => 'dina_r',          'email' => 'dina.ramadan@demo.ip',     'profession' => 'Finance Manager',         'level' => 'senior',   'sector' => 'Logistics',      'bio' => 'Finance manager at a logistics company operating across Egypt.',         'theme' => 'navy', 'language' => 'ar'],
            ['name' => 'Tarek Saad',        'nickname' => 'tarek_s',         'email' => 'tarek.saad@demo.ip',       'profession' => 'Cost Accountant',         'level' => 'mid',      'sector' => 'Manufacturing',  'bio' => 'Standard costing and variance analysis specialist.',                    'theme' => 'navy', 'language' => 'en'],
            ['name' => 'Yasmin Osman',      'nickname' => 'yasmin_o',        'email' => 'yasmin.osman@demo.ip',     'profession' => 'FP&A Manager',            'level' => 'senior',   'sector' => 'FMCG',           'bio' => 'Leading FP&A for a top FMCG company in Egypt.',                          'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Sherif Farouk',     'nickname' => 'sherif_f',        'email' => 'sherif.farouk@demo.ip',    'profession' => 'Chief Accountant',        'level' => 'senior',   'sector' => 'Hospitality',    'bio' => 'Chief accountant for a hotel chain across Red Sea resorts.',            'theme' => 'navy', 'language' => 'ar'],
            ['name' => 'Amira Zaki',        'nickname' => 'amira_z',         'email' => 'amira.zaki@demo.ip',       'profession' => 'Financial Analyst',       'level' => 'fresh',    'sector' => 'Startups',       'bio' => 'Just joined a fintech startup fresh out of AUC.',                        'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Wael Hamdi',        'nickname' => 'wael_h',          'email' => 'wael.hamdi@demo.ip',       'profession' => 'Head of Finance',         'level' => 'senior_15','sector' => 'Real Estate',    'bio' => 'Heading finance for one of Egypt largest real estate groups.',           'theme' => 'navy', 'language' => 'en'],
            ['name' => 'Eman Shawky',       'nickname' => 'eman_sh',         'email' => 'eman.shawky@demo.ip',      'profession' => 'Accounts Payable Lead',   'level' => 'mid',      'sector' => 'Trading',        'bio' => 'Managing AP operations for a trading group with 200+ vendors.',          'theme' => 'navy', 'language' => 'ar'],
            ['name' => 'Basem Fouad',       'nickname' => 'basem_f',         'email' => 'basem.fouad@demo.ip',      'profession' => 'Corporate Finance Mgr',   'level' => 'senior',   'sector' => 'Banking',        'bio' => 'Corporate finance professional with M&A experience.',                    'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Heba Sami',         'nickname' => 'heba_s',          'email' => 'heba.sami@demo.ip',        'profession' => 'Internal Auditor',        'level' => 'mid',      'sector' => 'Healthcare',     'bio' => 'Internal audit at a healthcare group — risk and controls focus.',        'theme' => 'navy', 'language' => 'en'],
            ['name' => 'Khaled Mansour',    'nickname' => 'khaledm',         'email' => 'khaled.mansour@demo.ip',   'profession' => 'Finance Director',        'level' => 'senior_20','sector' => 'Manufacturing',  'bio' => '20 years in manufacturing finance. Now consulting.',                    'theme' => 'navy', 'language' => 'ar'],
            ['name' => 'Nadia Fouad',       'nickname' => 'nadia_f',         'email' => 'nadia.fouad@demo.ip',      'profession' => 'AR Specialist',           'level' => 'junior',   'sector' => 'Services',       'bio' => 'Accounts receivable and collections at a B2B services company.',         'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Mohamed Atef',      'nickname' => 'moatef',          'email' => 'mohamed.atef@demo.ip',     'profession' => 'Payroll Manager',         'level' => 'mid',      'sector' => 'FMCG',           'bio' => 'Payroll and compensation for 1,200 employees across Egypt.',             'theme' => 'navy', 'language' => 'ar'],
            ['name' => 'Rana Tawfik',       'nickname' => 'rana_t',          'email' => 'rana.tawfik@demo.ip',      'profession' => 'Risk Analyst',            'level' => 'junior',   'sector' => 'Banking',        'bio' => 'Credit and market risk analysis trainee at a foreign bank.',             'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Hazem Gouda',       'nickname' => 'hazem_g',         'email' => 'hazem.gouda@demo.ip',      'profession' => 'Treasury Analyst',        'level' => 'junior',   'sector' => 'Logistics',      'bio' => 'Cash management and FX at a logistics firm.',                            'theme' => 'navy', 'language' => 'en'],
            ['name' => 'Salma Abbas',       'nickname' => 'salma_a',         'email' => 'salma.abbas@demo.ip',      'profession' => 'Senior Financial Analyst','level' => 'senior',   'sector' => 'Education',      'bio' => 'Financial modelling for an education group expanding to GCC.',           'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Ibrahim Wahba',     'nickname' => 'ibrahimw',        'email' => 'ibrahim.wahba@demo.ip',    'profession' => 'Statutory Reporting Mgr', 'level' => 'senior',   'sector' => 'Manufacturing',  'bio' => 'IFRS statutory reporting and board packs.',                              'theme' => 'navy', 'language' => 'ar'],
            ['name' => 'Marwa Helal',       'nickname' => 'marwa_h',         'email' => 'marwa.helal@demo.ip',      'profession' => 'Finance Business Partner', 'level' => 'mid',     'sector' => 'FMCG',           'bio' => 'Finance business partner supporting commercial and supply chain.',        'theme' => 'navy', 'language' => 'en'],
            ['name' => 'Sameh Barakat',     'nickname' => 'sameh_b',         'email' => 'sameh.barakat@demo.ip',    'profession' => 'Leasing Analyst',         'level' => 'junior',   'sector' => 'Real Estate',    'bio' => 'Financial analysis for a real estate leasing portfolio.',                'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Ghada Salah',       'nickname' => 'ghada_s',         'email' => 'ghada.salah@demo.ip',      'profession' => 'Group CFO',               'level' => 'senior_20','sector' => 'Hospitality',    'bio' => 'Group CFO for a hospitality and entertainment conglomerate.',            'theme' => 'navy', 'language' => 'ar'],
            ['name' => 'Fady Mikhail',      'nickname' => 'fady_m',          'email' => 'fady.mikhail@demo.ip',     'profession' => 'Receivables Manager',     'level' => 'mid',      'sector' => 'Trading',        'bio' => 'Managing a 50M EGP receivables book for a trading group.',              'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Abeer Mohsen',      'nickname' => 'abeer_mo',        'email' => 'abeer.mohsen@demo.ip',     'profession' => 'Financial Planning Mgr',  'level' => 'senior',   'sector' => 'Healthcare',     'bio' => 'Annual planning and quarterly forecasting for a hospital network.',       'theme' => 'navy', 'language' => 'en'],
            ['name' => 'Ayman Radwan',      'nickname' => 'ayman_r',         'email' => 'ayman.radwan@demo.ip',     'profession' => 'Tax Manager',             'level' => 'senior',   'sector' => 'Manufacturing',  'bio' => 'Tax planning and CIT compliance for a manufacturing group.',             'theme' => 'dark', 'language' => 'ar'],
            ['name' => 'Nesma Ragab',       'nickname' => 'nesma_r',         'email' => 'nesma.ragab@demo.ip',      'profession' => 'Junior Accountant',       'level' => 'fresh',    'sector' => 'Startups',       'bio' => 'First job in accounting at a Cairo tech startup.',                       'theme' => 'navy', 'language' => 'en'],
            ['name' => 'Ehab Lotfy',        'nickname' => 'ehab_l',          'email' => 'ehab.lotfy@demo.ip',       'profession' => 'Business Controller',     'level' => 'senior',   'sector' => 'FMCG',           'bio' => 'Business controller driving commercial finance across FMCG portfolio.',  'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Mervat Soliman',    'nickname' => 'mervat_s',        'email' => 'mervat.soliman@demo.ip',   'profession' => 'Finance Student',         'level' => 'student',  'sector' => 'Banking',        'bio' => 'Finance student at Cairo University, doing internship in banking.',       'theme' => 'navy', 'language' => 'ar'],
        ];
    }

    // ════════════════════════════════════════════════════════════════════════
    //  DATA: MEMBERS — MARKETING (33)
    // ════════════════════════════════════════════════════════════════════════

    private function marketingProfileData(): array
    {
        return [
            ['name' => 'Layla Nasser',      'nickname' => 'layla_mkt',       'email' => 'layla.nasser@demo.ip',     'profession' => 'Brand Manager',           'level' => 'mid',      'sector' => 'FMCG',           'bio' => 'Brand manager for a top personal care brand in Egypt.',                  'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Tamer Gaber',       'nickname' => 'tamerg',          'email' => 'tamer.gaber@demo.ip',      'profession' => 'Digital Marketing Mgr',   'level' => 'senior',   'sector' => 'Startups',       'bio' => 'Performance marketing and growth hacking for funded startups.',          'theme' => 'navy', 'language' => 'en'],
            ['name' => 'Ines Wahid',        'nickname' => 'ines_w',          'email' => 'ines.wahid@demo.ip',       'profession' => 'CMO',                     'level' => 'senior_10','sector' => 'Real Estate',    'bio' => 'CMO at a real estate developer launching projects in Dubai.',             'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Sherif Samir',      'nickname' => 'sherifsam',       'email' => 'sherif.samir@demo.ip',     'profession' => 'Content Strategist',      'level' => 'mid',      'sector' => 'Education',      'bio' => 'Content strategy and SEO for an EdTech platform.',                       'theme' => 'navy', 'language' => 'ar'],
            ['name' => 'Noha Elsheikh',     'nickname' => 'noha_e',          'email' => 'noha.elsheikh@demo.ip',    'profession' => 'Social Media Manager',    'level' => 'junior',   'sector' => 'Hospitality',    'bio' => 'Social media and influencer marketing for hotel brands.',                'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Hassan Moustafa',   'nickname' => 'hassan_mkt',      'email' => 'hassan.moustafa@demo.ip',  'profession' => 'Marketing Analyst',       'level' => 'junior',   'sector' => 'FMCG',           'bio' => 'Market research and consumer insights at a multinational.',              'theme' => 'navy', 'language' => 'en'],
            ['name' => 'Soha Abdelaziz',    'nickname' => 'soha_a',          'email' => 'soha.abdelaziz@demo.ip',   'profession' => 'Trade Marketing Mgr',     'level' => 'senior',   'sector' => 'FMCG',           'bio' => 'Trade marketing and shopper activation for a leading food brand.',        'theme' => 'dark', 'language' => 'ar'],
            ['name' => 'Amr Elnaggar',      'nickname' => 'amr_el',          'email' => 'amr.elnaggar@demo.ip',     'profession' => 'E-Commerce Manager',      'level' => 'mid',      'sector' => 'Trading',        'bio' => 'Running marketplaces and D2C channels for a fashion brand.',             'theme' => 'navy', 'language' => 'en'],
            ['name' => 'Reem Ezzat',        'nickname' => 'reem_e',          'email' => 'reem.ezzat@demo.ip',       'profession' => 'PR Manager',              'level' => 'mid',      'sector' => 'Hospitality',    'bio' => 'PR and media relations for a luxury hotel group.',                       'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Walid Emam',        'nickname' => 'walid_em',        'email' => 'walid.emam@demo.ip',       'profession' => 'Marketing Director',      'level' => 'senior_15','sector' => 'Real Estate',    'bio' => 'Marketing director with 15 years in real estate launches.',              'theme' => 'navy', 'language' => 'ar'],
            ['name' => 'Nadia Kamal',       'nickname' => 'nadia_k',         'email' => 'nadia.kamal@demo.ip',      'profession' => 'CRM Manager',             'level' => 'mid',      'sector' => 'Banking',        'bio' => 'Customer retention and lifecycle marketing at a retail bank.',           'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Bishoy Rizk',       'nickname' => 'bishoy_r',        'email' => 'bishoy.rizk@demo.ip',      'profession' => 'Paid Media Specialist',   'level' => 'junior',   'sector' => 'Startups',       'bio' => 'Google and Meta ads for e-commerce brands.',                             'theme' => 'navy', 'language' => 'en'],
            ['name' => 'Doaa Fawzy',        'nickname' => 'doaa_f',          'email' => 'doaa.fawzy@demo.ip',       'profession' => 'Category Manager',        'level' => 'senior',   'sector' => 'FMCG',           'bio' => 'Category management for a supermarket chain across Egypt.',              'theme' => 'dark', 'language' => 'ar'],
            ['name' => 'Fares Badawi',      'nickname' => 'fares_b',         'email' => 'fares.badawi@demo.ip',     'profession' => 'Marketing Manager',       'level' => 'senior',   'sector' => 'Healthcare',     'bio' => 'Marketing for a pharma company targeting HCP and consumer.',             'theme' => 'navy', 'language' => 'en'],
            ['name' => 'Hana Khalaf',       'nickname' => 'hana_k',          'email' => 'hana.khalaf@demo.ip',      'profession' => 'Brand Strategist',        'level' => 'mid',      'sector' => 'Services',       'bio' => 'Brand architecture and repositioning consultant.',                       'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Mostafa Zidan',     'nickname' => 'mostafa_z',       'email' => 'mostafa.zidan@demo.ip',    'profession' => 'Growth Marketer',         'level' => 'junior',   'sector' => 'Startups',       'bio' => 'Funnel optimization and conversion rate for a SaaS product.',            'theme' => 'navy', 'language' => 'ar'],
            ['name' => 'Shaimaa Hany',      'nickname' => 'shaimaa_h',       'email' => 'shaimaa.hany@demo.ip',     'profession' => 'Influencer Mktg Mgr',     'level' => 'mid',      'sector' => 'FMCG',           'bio' => 'Managing influencer campaigns at 10M+ reach for FMCG brands.',           'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Adel Borhan',       'nickname' => 'adel_b',          'email' => 'adel.borhan@demo.ip',      'profession' => 'VP Marketing',            'level' => 'senior_20','sector' => 'Banking',        'bio' => 'VP of Marketing at a leading Egyptian bank.',                            'theme' => 'navy', 'language' => 'ar'],
            ['name' => 'Manar Hamed',       'nickname' => 'manar_hm',        'email' => 'manar.hamed@demo.ip',      'profession' => 'Marketing Coordinator',   'level' => 'fresh',    'sector' => 'Education',      'bio' => 'Supporting marketing operations at an education company.',               'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Kareem Soliman',    'nickname' => 'kareem_sol',      'email' => 'kareem.soliman@demo.ip',   'profession' => 'SEO Specialist',          'level' => 'junior',   'sector' => 'Services',       'bio' => 'Organic search and content SEO for a digital agency.',                   'theme' => 'navy', 'language' => 'en'],
            ['name' => 'Rasha Galal',       'nickname' => 'rasha_g',         'email' => 'rasha.galal@demo.ip',      'profession' => 'Event Marketing Mgr',     'level' => 'mid',      'sector' => 'Hospitality',    'bio' => 'MICE marketing and B2B events for a 5-star hotel.',                      'theme' => 'dark', 'language' => 'ar'],
            ['name' => 'Tarek Habib',       'nickname' => 'tarek_hab',       'email' => 'tarek.habib@demo.ip',      'profession' => 'Retail Marketing Mgr',    'level' => 'senior',   'sector' => 'Trading',        'bio' => 'In-store activation and shopper journey across 300 stores.',             'theme' => 'navy', 'language' => 'en'],
            ['name' => 'Zeinab Morsi',      'nickname' => 'zeinab_m',        'email' => 'zeinab.morsi@demo.ip',     'profession' => 'Customer Insights Mgr',   'level' => 'mid',      'sector' => 'FMCG',           'bio' => 'Qual and quant consumer research feeding brand strategy.',                'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Gamal Abdelnabi',   'nickname' => 'gamal_a',         'email' => 'gamal.abdelnabi@demo.ip',  'profession' => 'Marketing Student',       'level' => 'student',  'sector' => 'Education',      'bio' => 'Final year marketing student at GUC.',                                   'theme' => 'navy', 'language' => 'ar'],
            ['name' => 'Lobna Ismail',      'nickname' => 'lobna_i',         'email' => 'lobna.ismail@demo.ip',     'profession' => 'Product Marketing Mgr',   'level' => 'senior',   'sector' => 'Startups',       'bio' => 'Launching tech products into Egyptian and GCC markets.',                 'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Samer Ashraf',      'nickname' => 'samer_ash',       'email' => 'samer.ashraf@demo.ip',     'profession' => 'Media Planning Mgr',      'level' => 'mid',      'sector' => 'FMCG',           'bio' => 'TV, digital, and OOH media buying for national campaigns.',              'theme' => 'navy', 'language' => 'en'],
            ['name' => 'Yasmine Wahba',     'nickname' => 'yasmine_wb',      'email' => 'yasmine.wahba@demo.ip',    'profession' => 'Marketing Analyst',       'level' => 'junior',   'sector' => 'Logistics',      'bio' => 'Data analytics and dashboards for marketing performance.',               'theme' => 'dark', 'language' => 'ar'],
            ['name' => 'Ramez Fathi',       'nickname' => 'ramez_f',         'email' => 'ramez.fathi@demo.ip',      'profession' => 'Digital Director',        'level' => 'senior_10','sector' => 'Hospitality',    'bio' => 'Leading digital transformation for a hospitality group.',                'theme' => 'navy', 'language' => 'en'],
            ['name' => 'Maha Saeed',        'nickname' => 'maha_sa',         'email' => 'maha.saeed@demo.ip',       'profession' => 'Brand Executive',         'level' => 'fresh',    'sector' => 'FMCG',           'bio' => 'Brand execution across GT and MT channels.',                             'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Khaled Dahab',      'nickname' => 'khaled_d',        'email' => 'khaled.dahab@demo.ip',     'profession' => 'CSR & Comms Manager',     'level' => 'mid',      'sector' => 'Manufacturing',  'bio' => 'Corporate communications and sustainability reporting.',                 'theme' => 'navy', 'language' => 'ar'],
            ['name' => 'Engy Abdou',        'nickname' => 'engy_a',          'email' => 'engy.abdou@demo.ip',       'profession' => 'Marketing VP',            'level' => 'senior_20','sector' => 'Banking',        'bio' => 'Two decades in financial services marketing across MENA.',               'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Tarek Nour',        'nickname' => 'tarek_n',         'email' => 'tarek.nour@demo.ip',       'profession' => 'Performance Mktg Lead',   'level' => 'mid',      'sector' => 'Startups',       'bio' => 'ROAS-obsessed performance marketer for a Series B startup.',             'theme' => 'navy', 'language' => 'en'],
            ['name' => 'Salwa Hossam',      'nickname' => 'salwa_ho',        'email' => 'salwa.hossam@demo.ip',     'profession' => 'Creative Director',       'level' => 'senior',   'sector' => 'Services',       'bio' => 'Creative direction for integrated campaigns across MENA.',               'theme' => 'dark', 'language' => 'ar'],
        ];
    }

    // ════════════════════════════════════════════════════════════════════════
    //  DATA: MEMBERS — SALES (33)
    // ════════════════════════════════════════════════════════════════════════

    private function salesProfileData(): array
    {
        return [
            ['name' => 'Mahmoud Ismail',    'nickname' => 'mahmoud_sales',   'email' => 'mahmoud.ismail@demo.ip',   'profession' => 'Sales Director',          'level' => 'senior_10','sector' => 'Manufacturing',  'bio' => 'Sales director managing a 200-person field force.',                      'theme' => 'navy', 'language' => 'en'],
            ['name' => 'Dalia Farid',       'nickname' => 'dalia_f',         'email' => 'dalia.farid@demo.ip',      'profession' => 'Key Account Manager',     'level' => 'senior',   'sector' => 'FMCG',           'bio' => 'Managing key modern trade accounts worth 50M EGP annually.',            'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Hany Elmasry',      'nickname' => 'hany_el',         'email' => 'hany.elmasry@demo.ip',     'profession' => 'VP of Sales',             'level' => 'senior_20','sector' => 'Real Estate',    'bio' => 'VP Sales overseeing off-plan and resale portfolios.',                    'theme' => 'navy', 'language' => 'ar'],
            ['name' => 'Nermeen Saber',     'nickname' => 'nermeen_s',       'email' => 'nermeen.saber@demo.ip',    'profession' => 'Regional Sales Manager',  'level' => 'senior',   'sector' => 'Healthcare',     'bio' => 'Pharma sales manager covering Delta and Alexandria regions.',            'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Essam Helmy',       'nickname' => 'essam_h',         'email' => 'essam.helmy@demo.ip',      'profession' => 'BDM',                     'level' => 'mid',      'sector' => 'Startups',       'bio' => 'B2B business development for a SaaS company expanding regionally.',      'theme' => 'navy', 'language' => 'en'],
            ['name' => 'Sohair Kamel',      'nickname' => 'sohair_k',        'email' => 'sohair.kamel@demo.ip',     'profession' => 'Sales Manager',           'level' => 'senior',   'sector' => 'Logistics',      'bio' => 'Freight sales and fleet management for a logistics company.',            'theme' => 'dark', 'language' => 'ar'],
            ['name' => 'Wael Kassem',       'nickname' => 'wael_k',          'email' => 'wael.kassem@demo.ip',      'profession' => 'Channel Sales Manager',   'level' => 'mid',      'sector' => 'Manufacturing',  'bio' => 'Distributor management across Upper Egypt and Delta.',                   'theme' => 'navy', 'language' => 'en'],
            ['name' => 'Menna Yousry',      'nickname' => 'menna_y',         'email' => 'menna.yousry@demo.ip',     'profession' => 'Inside Sales Rep',        'level' => 'junior',   'sector' => 'Services',       'bio' => 'Inbound and outbound sales for a B2B services platform.',                'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Amir Farag',        'nickname' => 'amir_f',          'email' => 'amir.farag@demo.ip',       'profession' => 'Sales Operations Mgr',    'level' => 'mid',      'sector' => 'FMCG',           'bio' => 'Sales ops, forecasting, and incentives for a 400-person sales team.',   'theme' => 'navy', 'language' => 'ar'],
            ['name' => 'Nada Sherif',       'nickname' => 'nada_sh',         'email' => 'nada.sherif@demo.ip',      'profession' => 'Enterprise Sales Exec',   'level' => 'senior',   'sector' => 'Banking',        'bio' => 'Enterprise banking solutions for top-100 corporate clients.',            'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Hisham Nasr',       'nickname' => 'hisham_n',        'email' => 'hisham.nasr@demo.ip',      'profession' => 'Account Executive',       'level' => 'junior',   'sector' => 'Startups',       'bio' => 'Closing SME deals for a cloud software company.',                        'theme' => 'navy', 'language' => 'en'],
            ['name' => 'Fatma Zaghloul',    'nickname' => 'fatma_z',         'email' => 'fatma.zaghloul@demo.ip',   'profession' => 'Retail Sales Manager',    'level' => 'senior',   'sector' => 'Trading',        'bio' => 'Retail sales and in-store performance for 150 outlets.',                 'theme' => 'dark', 'language' => 'ar'],
            ['name' => 'Omar Sadek',        'nickname' => 'omar_sad',        'email' => 'omar.sadek@demo.ip',       'profession' => 'Export Sales Manager',    'level' => 'senior',   'sector' => 'Manufacturing',  'bio' => 'Export sales across Africa and GCC for a food manufacturer.',            'theme' => 'navy', 'language' => 'en'],
            ['name' => 'Sherine Ghaly',     'nickname' => 'sherine_g',       'email' => 'sherine.ghaly@demo.ip',    'profession' => 'Sales Trainer',           'level' => 'mid',      'sector' => 'Services',       'bio' => 'Sales training and capability building for field forces.',               'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Mohamed Bekhit',    'nickname' => 'mo_bekhit',       'email' => 'mo.bekhit@demo.ip',        'profession' => 'Territory Sales Mgr',     'level' => 'mid',      'sector' => 'Healthcare',     'bio' => 'Territory management for a medical devices company.',                    'theme' => 'navy', 'language' => 'ar'],
            ['name' => 'Dena Hafez',        'nickname' => 'dena_h',          'email' => 'dena.hafez@demo.ip',       'profession' => 'Sales Analyst',           'level' => 'junior',   'sector' => 'FMCG',           'bio' => 'Sales data analysis and sell-through reporting.',                        'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Khaled Saleh',      'nickname' => 'khaled_sal',      'email' => 'khaled.saleh@demo.ip',     'profession' => 'Head of Sales',           'level' => 'senior_15','sector' => 'Real Estate',    'bio' => 'Heading a sales team of 60 for a luxury real estate developer.',         'theme' => 'navy', 'language' => 'en'],
            ['name' => 'Noura Talat',       'nickname' => 'noura_t',         'email' => 'noura.talat@demo.ip',      'profession' => 'B2B Sales Manager',       'level' => 'senior',   'sector' => 'Logistics',      'bio' => 'Corporate accounts and fleet sales for a transport company.',            'theme' => 'dark', 'language' => 'ar'],
            ['name' => 'Magdy Salama',      'nickname' => 'magdy_s',         'email' => 'magdy.salama@demo.ip',     'profession' => 'Sales Fresh Graduate',    'level' => 'fresh',    'sector' => 'Manufacturing',  'bio' => 'Starting my sales career at a consumer goods company.',                  'theme' => 'navy', 'language' => 'en'],
            ['name' => 'Ola Gamal',         'nickname' => 'ola_g',           'email' => 'ola.gamal@demo.ip',        'profession' => 'Customer Success Mgr',    'level' => 'mid',      'sector' => 'Startups',       'bio' => 'Post-sales success and upsell for a B2B SaaS.',                          'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Hossein Aly',       'nickname' => 'hossein_a',       'email' => 'hossein.aly@demo.ip',      'profession' => 'Sales Director',          'level' => 'senior_10','sector' => 'FMCG',           'bio' => 'Nationwide sales for a beverage brand with 500M EGP revenue.',           'theme' => 'navy', 'language' => 'ar'],
            ['name' => 'Yara Badran',       'nickname' => 'yara_b',          'email' => 'yara.badran@demo.ip',      'profession' => 'Pre-Sales Consultant',    'level' => 'mid',      'sector' => 'Banking',        'bio' => 'Solution design and RFP responses for enterprise banking tech.',         'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Samy Fouad',        'nickname' => 'samy_f',          'email' => 'samy.fouad@demo.ip',       'profession' => 'National Sales Manager',  'level' => 'senior_15','sector' => 'Healthcare',     'bio' => 'National sales manager for an OTC pharma brand.',                        'theme' => 'navy', 'language' => 'en'],
            ['name' => 'Rehab Gomaa',       'nickname' => 'rehab_g',         'email' => 'rehab.gomaa@demo.ip',      'profession' => 'Sales Student',           'level' => 'student',  'sector' => 'Services',       'bio' => 'Business student looking to break into sales.',                          'theme' => 'dark', 'language' => 'ar'],
            ['name' => 'Diaa Mansour',      'nickname' => 'diaa_m',          'email' => 'diaa.mansour@demo.ip',     'profession' => 'Franchise Sales Mgr',     'level' => 'senior',   'sector' => 'FMCG',           'bio' => 'Franchise and sub-distributor expansion across Egypt.',                  'theme' => 'navy', 'language' => 'en'],
            ['name' => 'Samira Naguib',     'nickname' => 'samira_n',        'email' => 'samira.naguib@demo.ip',    'profession' => 'Telesales Manager',       'level' => 'mid',      'sector' => 'Banking',        'bio' => 'Leading a 30-agent telesales team for retail banking.',                  'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Gamal Nour',        'nickname' => 'gamal_n',         'email' => 'gamal.nour@demo.ip',       'profession' => 'Sales Engineer',          'level' => 'mid',      'sector' => 'Manufacturing',  'bio' => 'Technical sales for industrial equipment and machinery.',                'theme' => 'navy', 'language' => 'ar'],
            ['name' => 'Dalia Nasser',      'nickname' => 'dalia_na',        'email' => 'dalia.nasser@demo.ip',     'profession' => 'Key Account Executive',   'level' => 'junior',   'sector' => 'FMCG',           'bio' => 'Managing smaller retail chains as part of a key accounts team.',         'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Ramadan Shehata',   'nickname' => 'ramadan_sh',      'email' => 'ramadan.shehata@demo.ip',  'profession' => 'Outdoor Sales Rep',       'level' => 'junior',   'sector' => 'Manufacturing',  'bio' => 'Field sales visiting 20 outlets per day across Greater Cairo.',          'theme' => 'navy', 'language' => 'ar'],
            ['name' => 'Hind Selim',        'nickname' => 'hind_s',          'email' => 'hind.selim@demo.ip',       'profession' => 'Sales Coach',             'level' => 'senior',   'sector' => 'Services',       'bio' => 'Sales coaching and pipeline management consulting for SMEs.',            'theme' => 'dark', 'language' => 'en'],
            ['name' => 'Emad Nofal',        'nickname' => 'emad_no',         'email' => 'emad.nofal@demo.ip',       'profession' => 'Modern Trade Manager',    'level' => 'senior',   'sector' => 'FMCG',           'bio' => 'Modern trade execution and space management for a food brand.',          'theme' => 'navy', 'language' => 'en'],
            ['name' => 'Amal Amin',         'nickname' => 'amal_am',         'email' => 'amal.amin@demo.ip',        'profession' => 'Sales Operations Analyst','level' => 'fresh',    'sector' => 'FMCG',           'bio' => 'Supporting sales ops with data, tools, and reporting.',                  'theme' => 'dark', 'language' => 'ar'],
            ['name' => 'Ziad Masri',        'nickname' => 'ziad_ma',         'email' => 'ziad.masri@demo.ip',       'profession' => 'Partnerships Manager',    'level' => 'mid',      'sector' => 'Startups',       'bio' => 'Strategic partnerships and channel development for a growth-stage startup.', 'theme' => 'navy', 'language' => 'en'],
        ];
    }

    // ════════════════════════════════════════════════════════════════════════
    //  DATA: FORUM POSTS (25)
    // ════════════════════════════════════════════════════════════════════════

    private function forumPostData(): array
    {
        return [
            // FINANCE
            [
                'hub_id' => $this->financeHubId, 'post_type' => 'question', 'visibility' => 'all',
                'title' => 'My boss rejected my budget without explanation — what do I do?',
                'body' => "I spent three weeks building a detailed bottom-up budget for next year. My CFO rejected the whole thing in a 10-minute meeting and just said \"redo it with 15% less\". No explanation of which lines to cut or why.\n\nHas anyone dealt with this? Do I just apply the cut uniformly or push back and ask for more context? I don't want to seem difficult but I also don't want to submit a budget that doesn't make operational sense.",
                'tags' => ['budgeting', 'CFO', 'communication'],
                'language' => 'en',
            ],
            [
                'hub_id' => $this->financeHubId, 'post_type' => 'question', 'visibility' => 'all',
                'title' => 'How do you handle a client who delays payment for 6+ months?',
                'body' => "We have a government client who owes us 2.3M EGP. The project was delivered 7 months ago, invoices submitted, all paperwork done. Payments keep getting \"approved next month\" and never come.\n\nOur cash flow is being strangled. We can't afford legal action (they are connected). Has anyone navigated this? Any strategies that actually worked?",
                'tags' => ['receivables', 'cash-flow', 'government'],
                'language' => 'en',
            ],
            [
                'hub_id' => $this->financeHubId, 'post_type' => 'question', 'visibility' => 'hub',
                'title' => 'Best way to present financial results to a non-finance board?',
                'body' => "Our board has one finance person (the CFO) and five others from engineering and operations backgrounds. Every quarter I present the P&L and their eyes glaze over by slide 2.\n\nI want to make the numbers tell a story they actually care about. What visuals, structures, or frameworks have worked for you when presenting to a non-finance audience?",
                'tags' => ['presentation', 'board', 'storytelling'],
                'language' => 'en',
            ],
            [
                'hub_id' => $this->financeHubId, 'post_type' => 'knowledge_share', 'visibility' => 'all',
                'source_url' => 'https://www.linkedin.com/pulse/cash-conversion-cycle-explained',
                'source_label' => 'LinkedIn',
                'title' => 'Great breakdown of Cash Conversion Cycle — worth reading',
                'body' => "Found this explanation of CCC very practical — uses a manufacturing example which is rare. It breaks down DSO, DIO, and DPO in a way that actually shows the levers you can pull.\n\nFor anyone managing working capital in manufacturing or trading, this is worth 10 minutes.",
                'tags' => ['cash-conversion', 'working-capital', 'manufacturing'],
                'language' => 'en',
            ],
            [
                'hub_id' => $this->financeHubId, 'post_type' => 'question', 'visibility' => 'all',
                'title' => 'When does it make sense to hedge currency exposure vs just absorb it?',
                'body' => "We are a trading company importing from Europe. With EGP volatility, the FX risk on each shipment can wipe out the margin entirely.\n\nOur bank has offered forward contracts but the cost is eating into already thin margins. How do you think about the break-even point for hedging? Is there a rule of thumb for when to hedge and when to just price the risk in?",
                'tags' => ['FX', 'hedging', 'treasury'],
                'language' => 'en',
            ],
            [
                'hub_id' => $this->financeHubId, 'post_type' => 'question', 'visibility' => 'all',
                'title' => 'IFRS 16 lease accounting — how are you handling short-term renewals?',
                'body' => "We have about 40 store leases, most of them 2-year contracts that we keep renewing. Under IFRS 16 this creates a lot of ROU asset and lease liability movement every cycle.\n\nAre other companies treating these as short-term leases and exempting them? Or recognizing the renewal option and extending the lease term? Our auditors have two different views and I want to know what the market practice is.",
                'tags' => ['IFRS16', 'leases', 'audit'],
                'language' => 'en',
            ],
            [
                'hub_id' => $this->financeHubId, 'post_type' => 'knowledge_share', 'visibility' => 'all',
                'source_url' => 'https://www.mckinsey.com/capabilities/strategy-and-corporate-finance/our-insights',
                'source_label' => 'Article',
                'title' => 'McKinsey piece on zero-based budgeting — practical or just theory?',
                'body' => "Sharing this McKinsey article on ZBB. Have read it twice and my reaction is: sounds great on paper, brutal to implement without a 6-month runway and full management buy-in.\n\nHas anyone actually implemented ZBB in an Egyptian company? What was the reaction from department heads when you asked them to justify every single line from zero?",
                'tags' => ['ZBB', 'budgeting', 'cost-cutting'],
                'language' => 'en',
            ],
            [
                'hub_id' => $this->financeHubId, 'post_type' => 'question', 'visibility' => 'all',
                'title' => 'How do you handle inflation in a 3-year financial model?',
                'body' => "Building a 3-year plan for management. Egypt inflation has been wild — 35% last year, now coming down. If I use a flat inflation assumption I will be wrong either way.\n\nDo you build separate scenarios? Use a declining rate? How are you handling this in your planning models right now?",
                'tags' => ['modelling', 'inflation', 'forecasting'],
                'language' => 'en',
            ],
            // MARKETING
            [
                'hub_id' => $this->marketingHubId, 'post_type' => 'question', 'visibility' => 'all',
                'title' => 'How do you prove marketing ROI to a CEO who only cares about sales?',
                'body' => "Our CEO keeps asking \"what did marketing actually contribute to sales this quarter?\" We run brand campaigns, social, some performance, and events — but attribution is a mess.\n\nThe sales team takes credit for every deal. How are you building the case for marketing contribution when you don't have clean multi-touch attribution data?",
                'tags' => ['ROI', 'attribution', 'CEO'],
                'language' => 'en',
            ],
            [
                'hub_id' => $this->marketingHubId, 'post_type' => 'question', 'visibility' => 'all',
                'title' => 'Meta ads CPM in Egypt has doubled — is everyone experiencing this?',
                'body' => "Our Meta CPM went from 18 EGP to 38 EGP in 6 months. Same targeting, similar creative quality. We are getting half the reach for the same budget.\n\nIs this Egypt-wide or something specific to our account? Has anyone found ways to fight rising CPMs — different audience structures, creative approaches, or just shifted budget to another channel?",
                'tags' => ['Meta', 'paid-social', 'CPM'],
                'language' => 'en',
            ],
            [
                'hub_id' => $this->marketingHubId, 'post_type' => 'knowledge_share', 'visibility' => 'all',
                'source_url' => 'https://www.linkedin.com/pulse/brand-building-performance-marketing-egypt',
                'source_label' => 'LinkedIn',
                'title' => 'The brand vs performance debate — where do you land for Egyptian market?',
                'body' => "Sharing an article that argues for a 60/40 brand/performance split. The Egyptian context is interesting — brand equity matters a lot in FMCG but performance delivers the short-term numbers leadership wants.\n\nFor those managing significant budgets in Egypt — what split are you running and is it working?",
                'tags' => ['brand', 'performance', 'budgeting'],
                'language' => 'en',
            ],
            [
                'hub_id' => $this->marketingHubId, 'post_type' => 'question', 'visibility' => 'all',
                'title' => 'Influencer contracts in Egypt — what clauses actually matter?',
                'body' => "We are scaling up influencer marketing but our contracts are basically just a scope of work and payment terms. We got burned recently when an influencer posted for a competitor one week after our campaign.\n\nWhat clauses are you including? Exclusivity periods, content approval, performance guarantees, usage rights? Any templates or experiences to share?",
                'tags' => ['influencer', 'contracts', 'legal'],
                'language' => 'en',
            ],
            [
                'hub_id' => $this->marketingHubId, 'post_type' => 'question', 'visibility' => 'hub',
                'title' => 'How to handle a product launch when the product was delayed by 3 months?',
                'body' => "We pre-built all the buzz, teaser campaigns, influencer seeding — and now the product launch got pushed 3 months due to supply issues.\n\nWe have audience attention now and cannot sustain it for 3 more months without a product. How do you keep the community engaged and convert that pre-launch energy into actual sales when the product finally arrives?",
                'tags' => ['launch', 'product', 'timing'],
                'language' => 'en',
            ],
            [
                'hub_id' => $this->marketingHubId, 'post_type' => 'knowledge_share', 'visibility' => 'all',
                'source_url' => 'https://hbr.org/2023/marketing-egypt-consumer-behavior',
                'source_label' => 'Article',
                'title' => 'How Egyptian consumer behavior shifted post-devaluation — interesting data',
                'body' => "This HBR piece has data points that match what we are seeing on the ground. Price sensitivity shifted dramatically in categories that used to be fairly inelastic — even premium consumers are trading down.\n\nFor brand managers in FMCG — are you seeing the same premiumization story unravel or holding in your category?",
                'tags' => ['consumer-behavior', 'FMCG', 'economy'],
                'language' => 'en',
            ],
            [
                'hub_id' => $this->marketingHubId, 'post_type' => 'question', 'visibility' => 'all',
                'title' => 'CRM vs loyalty programme — which one first for an FMCG brand?',
                'body' => "We are a mid-size FMCG brand thinking about building a direct relationship with our end consumer. Right now we sell through GT and MT and have zero first-party data.\n\nWould you build the CRM infrastructure first or launch a loyalty programme to get the data? Both require significant budget and we can only do one this year.",
                'tags' => ['CRM', 'loyalty', 'first-party-data'],
                'language' => 'en',
            ],
            // SALES
            [
                'hub_id' => $this->salesHubId, 'post_type' => 'question', 'visibility' => 'all',
                'title' => 'How do you motivate a sales team when the product is genuinely overpriced?',
                'body' => "Our competitors have cut prices aggressively. Our product is good but we are now 20-25% more expensive with no meaningful differentiation story the field team believes in.\n\nMorale is suffering. Targets are the same. How do you keep the team selling hard when they feel like they are fighting with one hand tied behind their back?",
                'tags' => ['motivation', 'pricing', 'team-management'],
                'language' => 'en',
            ],
            [
                'hub_id' => $this->salesHubId, 'post_type' => 'question', 'visibility' => 'all',
                'title' => 'Distributor conflict — GT distributor undercutting MT prices',
                'body' => "Our GT distributor is selling our product to small retailers at a price that undercuts our MT pricing. The hypermarkets are furious and threatening to delist us.\n\nThis is a channel conflict that management has been ignoring for 2 years. I am the sales manager in the middle. What is the right move here — and how do you document and escalate this without getting blamed for the mess?",
                'tags' => ['distribution', 'channel-conflict', 'pricing'],
                'language' => 'en',
            ],
            [
                'hub_id' => $this->salesHubId, 'post_type' => 'question', 'visibility' => 'all',
                'title' => 'What is a realistic commission structure for a B2B SaaS sales team in Egypt?',
                'body' => "We are setting up our first proper sales team for a B2B SaaS product. Average deal size is 30-80K EGP annually, sales cycle 2-3 months.\n\nWhat base/variable split makes sense in this market? Is 70/30 still the standard or has it moved? What accelerators work? I don't want to design something that kills retention after the first ramp-up period.",
                'tags' => ['commission', 'SaaS', 'compensation'],
                'language' => 'en',
            ],
            [
                'hub_id' => $this->salesHubId, 'post_type' => 'knowledge_share', 'visibility' => 'all',
                'source_url' => 'https://www.linkedin.com/pulse/challenger-sale-egypt-b2b',
                'source_label' => 'LinkedIn',
                'title' => 'Does the Challenger Sale model actually work in Egypt?',
                'body' => "Read this piece arguing that the Challenger Sale model does not translate to relationship-driven markets like Egypt where trust and connections are paramount.\n\nI have mixed feelings — some of the reframe techniques are gold, but cold challenging a senior Egyptian buyer you have just met is social suicide. What is your experience? Can you adapt it or is it fundamentally a Western model?",
                'tags' => ['challenger-sale', 'B2B', 'methodology'],
                'language' => 'en',
            ],
            [
                'hub_id' => $this->salesHubId, 'post_type' => 'question', 'visibility' => 'all',
                'title' => 'How to handle a key account that wants a 30% discount to renew?',
                'body' => "Our biggest customer (35% of revenue) just came to renewal and their procurement team is demanding a 30% discount. They know our dependency and are using it.\n\nI cannot lose this account. I also cannot give 30% — it would be below cost. What negotiation moves are available when the power balance is this lopsided?",
                'tags' => ['negotiation', 'key-accounts', 'renewal'],
                'language' => 'en',
            ],
            [
                'hub_id' => $this->salesHubId, 'post_type' => 'question', 'visibility' => 'hub',
                'title' => 'CRM adoption — how do you get the sales team to actually use it?',
                'body' => "We bought Salesforce 8 months ago. Our sales team logs in to pull their reports and then manages everything on WhatsApp and Excel.\n\nI have tried mandate, training, and showing them the reports they are missing. Nothing sticks. The senior reps especially see it as admin work. What finally broke through the resistance in your organization?",
                'tags' => ['CRM', 'Salesforce', 'adoption'],
                'language' => 'en',
            ],
            [
                'hub_id' => $this->salesHubId, 'post_type' => 'knowledge_share', 'visibility' => 'all',
                'source_url' => 'https://www.linkedin.com/pulse/negotiation-egyptian-business-culture',
                'source_label' => 'LinkedIn',
                'title' => 'Shared: Negotiation in Egyptian business culture — cultural nuances worth reading',
                'body' => "This piece resonated with me — especially the part about how Egyptians separate the relationship from the negotiation in a way that confuses Western counterparts. The relationship comes first, always.\n\nFor those selling to large Egyptian corporates and family businesses — what cultural nuances have you learned the hard way?",
                'tags' => ['negotiation', 'culture', 'B2B'],
                'language' => 'en',
            ],
            [
                'hub_id' => $this->salesHubId, 'post_type' => 'question', 'visibility' => 'all',
                'title' => 'Building a sales pipeline from zero in a new territory',
                'body' => "I have just been asked to open the Alexandria region for us. No existing accounts, no database, no team yet — just a territory and a target.\n\nHow do you approach building a pipeline completely from scratch? What sequence worked for you — networking first, cold outreach, partnerships? How long until you expected any real pipeline to form?",
                'tags' => ['pipeline', 'new-territory', 'prospecting'],
                'language' => 'en',
            ],
        ];
    }

    // ════════════════════════════════════════════════════════════════════════
    //  DATA: CV PROFILES (35 templates)
    // ════════════════════════════════════════════════════════════════════════

    private function cvProfileData(): array
    {
        $cities = ['Cairo', 'Alexandria', 'Giza', 'New Cairo', '6th of October', 'Maadi', 'Heliopolis', 'Nasr City'];
        return [
            ['job_title' => 'Financial Analyst', 'current_industry' => 'Banking', 'years_experience' => 5, 'experience_level' => 'mid', 'education_level' => 'Bachelor', 'education_field' => 'Accounting', 'location_city' => 'Cairo', 'summary' => 'FP&A analyst with 5 years in Egyptian banking, strong Excel and PowerBI skills.', 'preferred_sectors' => ['Banking', 'FMCG'], 'job_type_preference' => 'full_time'],
            ['job_title' => 'Senior Accountant', 'current_industry' => 'Manufacturing', 'years_experience' => 8, 'experience_level' => 'senior', 'education_level' => 'Bachelor', 'education_field' => 'Accounting', 'location_city' => 'Cairo', 'summary' => 'IFRS-certified accountant with experience in cost control and financial reporting.', 'preferred_sectors' => ['Manufacturing', 'FMCG'], 'job_type_preference' => 'full_time'],
            ['job_title' => 'Digital Marketing Manager', 'current_industry' => 'Startups', 'years_experience' => 6, 'experience_level' => 'senior', 'education_level' => 'Bachelor', 'education_field' => 'Marketing', 'location_city' => 'New Cairo', 'summary' => 'Performance marketing leader with expertise in Meta, Google, and growth hacking.', 'preferred_sectors' => ['Startups', 'FMCG'], 'job_type_preference' => 'full_time'],
            ['job_title' => 'Brand Manager', 'current_industry' => 'FMCG', 'years_experience' => 7, 'experience_level' => 'senior', 'education_level' => 'Master', 'education_field' => 'Business Administration', 'location_city' => 'Cairo', 'summary' => 'Brand manager with track record launching FMCG products across Egypt and GCC.', 'preferred_sectors' => ['FMCG', 'Healthcare'], 'job_type_preference' => 'full_time'],
            ['job_title' => 'Sales Director', 'current_industry' => 'Manufacturing', 'years_experience' => 12, 'experience_level' => 'senior', 'education_level' => 'Bachelor', 'education_field' => 'Business Administration', 'location_city' => 'Giza', 'summary' => 'Sales director with 12 years managing large field forces across FMCG and manufacturing.', 'preferred_sectors' => ['Manufacturing', 'FMCG'], 'job_type_preference' => 'full_time'],
            ['job_title' => 'Treasury Manager', 'current_industry' => 'FMCG', 'years_experience' => 9, 'experience_level' => 'senior', 'education_level' => 'Bachelor', 'education_field' => 'Finance', 'location_city' => 'Cairo', 'summary' => 'Treasury and cash management expert, experienced in FX hedging and bank relations.', 'preferred_sectors' => ['FMCG', 'Banking'], 'job_type_preference' => 'full_time'],
            ['job_title' => 'Key Account Manager', 'current_industry' => 'FMCG', 'years_experience' => 6, 'experience_level' => 'senior', 'education_level' => 'Bachelor', 'education_field' => 'Marketing', 'location_city' => 'Alexandria', 'summary' => 'KAM for modern trade with strong Carrefour, Spinneys, and B.TECH relationships.', 'preferred_sectors' => ['FMCG', 'Trading'], 'job_type_preference' => 'full_time'],
            ['job_title' => 'Content Strategist', 'current_industry' => 'Education', 'years_experience' => 4, 'experience_level' => 'mid', 'education_level' => 'Bachelor', 'education_field' => 'Communications', 'location_city' => 'New Cairo', 'summary' => 'Content and SEO strategist for EdTech platforms, Arabic and English content creator.', 'preferred_sectors' => ['Education', 'Startups'], 'job_type_preference' => 'full_time'],
            ['job_title' => 'Financial Controller', 'current_industry' => 'Real Estate', 'years_experience' => 10, 'experience_level' => 'senior', 'education_level' => 'Master', 'education_field' => 'Accounting', 'location_city' => 'New Cairo', 'summary' => 'Financial controller for real estate developers, strong in project accounting and cash flows.', 'preferred_sectors' => ['Real Estate', 'Construction'], 'job_type_preference' => 'full_time'],
            ['job_title' => 'Regional Sales Manager', 'current_industry' => 'Healthcare', 'years_experience' => 8, 'experience_level' => 'senior', 'education_level' => 'Bachelor', 'education_field' => 'Pharmacy', 'location_city' => 'Cairo', 'summary' => 'Pharma sales manager covering Cairo and Delta with a track record of exceeding targets.', 'preferred_sectors' => ['Healthcare', 'FMCG'], 'job_type_preference' => 'full_time'],
            ['job_title' => 'Media Planner', 'current_industry' => 'FMCG', 'years_experience' => 5, 'experience_level' => 'mid', 'education_level' => 'Bachelor', 'education_field' => 'Marketing', 'location_city' => 'Cairo', 'summary' => 'TV, digital, and OOH media planner managing multi-million EGP media budgets.', 'preferred_sectors' => ['FMCG', 'Services'], 'job_type_preference' => 'full_time'],
            ['job_title' => 'Business Development Manager', 'current_industry' => 'Startups', 'years_experience' => 5, 'experience_level' => 'mid', 'education_level' => 'Bachelor', 'education_field' => 'Business', 'location_city' => 'Cairo', 'summary' => 'BDM specializing in B2B SaaS and tech partnerships across Egypt and GCC.', 'preferred_sectors' => ['Startups', 'Banking'], 'job_type_preference' => 'full_time'],
            ['job_title' => 'Internal Auditor', 'current_industry' => 'Healthcare', 'years_experience' => 6, 'experience_level' => 'mid', 'education_level' => 'Bachelor', 'education_field' => 'Accounting', 'location_city' => 'Heliopolis', 'summary' => 'CIA-certified internal auditor with risk-based audit experience in regulated industries.', 'preferred_sectors' => ['Healthcare', 'Banking'], 'job_type_preference' => 'full_time'],
            ['job_title' => 'E-Commerce Manager', 'current_industry' => 'Trading', 'years_experience' => 4, 'experience_level' => 'mid', 'education_level' => 'Bachelor', 'education_field' => 'Marketing', 'location_city' => 'Cairo', 'summary' => 'Managing marketplace and D2C channels with strong Noon, Amazon, and Jumia experience.', 'preferred_sectors' => ['Trading', 'FMCG'], 'job_type_preference' => 'full_time'],
            ['job_title' => 'Sales Trainer', 'current_industry' => 'Services', 'years_experience' => 9, 'experience_level' => 'senior', 'education_level' => 'Bachelor', 'education_field' => 'Business', 'location_city' => '6th of October', 'summary' => 'Sales training and coaching specialist, certified trainer with 500+ trainees developed.', 'preferred_sectors' => ['Services', 'FMCG'], 'job_type_preference' => 'contract'],
            ['job_title' => 'Cost Accountant', 'current_industry' => 'Manufacturing', 'years_experience' => 4, 'experience_level' => 'mid', 'education_level' => 'Bachelor', 'education_field' => 'Accounting', 'location_city' => '6th of October', 'summary' => 'Standard costing and variance analysis in manufacturing, strong SAP CO module.', 'preferred_sectors' => ['Manufacturing', 'FMCG'], 'job_type_preference' => 'full_time'],
            ['job_title' => 'Social Media Manager', 'current_industry' => 'Hospitality', 'years_experience' => 3, 'experience_level' => 'junior', 'education_level' => 'Bachelor', 'education_field' => 'Communications', 'location_city' => 'Maadi', 'summary' => 'Social media and community management for hotel and hospitality brands.', 'preferred_sectors' => ['Hospitality', 'FMCG'], 'job_type_preference' => 'full_time'],
            ['job_title' => 'FP&A Manager', 'current_industry' => 'FMCG', 'years_experience' => 8, 'experience_level' => 'senior', 'education_level' => 'Master', 'education_field' => 'Finance', 'location_city' => 'Cairo', 'summary' => 'FP&A leader with strong financial modelling, scenario planning, and business partnering skills.', 'preferred_sectors' => ['FMCG', 'Manufacturing'], 'job_type_preference' => 'full_time'],
            ['job_title' => 'Channel Sales Manager', 'current_industry' => 'Manufacturing', 'years_experience' => 7, 'experience_level' => 'senior', 'education_level' => 'Bachelor', 'education_field' => 'Business', 'location_city' => 'Nasr City', 'summary' => 'Distributor and channel management across GT networks, Upper Egypt specialist.', 'preferred_sectors' => ['Manufacturing', 'FMCG'], 'job_type_preference' => 'full_time'],
            ['job_title' => 'CRM Manager', 'current_industry' => 'Banking', 'years_experience' => 6, 'experience_level' => 'mid', 'education_level' => 'Bachelor', 'education_field' => 'Marketing', 'location_city' => 'Cairo', 'summary' => 'CRM and loyalty programme specialist in retail banking, Salesforce certified.', 'preferred_sectors' => ['Banking', 'Startups'], 'job_type_preference' => 'full_time'],
            ['job_title' => 'Risk Analyst', 'current_industry' => 'Banking', 'years_experience' => 3, 'experience_level' => 'junior', 'education_level' => 'Bachelor', 'education_field' => 'Finance', 'location_city' => 'Cairo', 'summary' => 'Credit and market risk analysis at a private bank, FRM Part 1 candidate.', 'preferred_sectors' => ['Banking', 'Insurance'], 'job_type_preference' => 'full_time'],
            ['job_title' => 'Trade Marketing Manager', 'current_industry' => 'FMCG', 'years_experience' => 8, 'experience_level' => 'senior', 'education_level' => 'Bachelor', 'education_field' => 'Marketing', 'location_city' => 'Cairo', 'summary' => 'Trade marketing, visibility, and shopper activation for FMCG brands in GT and MT.', 'preferred_sectors' => ['FMCG', 'Retail'], 'job_type_preference' => 'full_time'],
            ['job_title' => 'Enterprise Sales Executive', 'current_industry' => 'Banking', 'years_experience' => 9, 'experience_level' => 'senior', 'education_level' => 'Master', 'education_field' => 'Business', 'location_city' => 'New Cairo', 'summary' => 'Enterprise sales for financial services solutions, strong in complex B2B deals.', 'preferred_sectors' => ['Banking', 'Startups'], 'job_type_preference' => 'full_time'],
            ['job_title' => 'Marketing Analyst', 'current_industry' => 'FMCG', 'years_experience' => 2, 'experience_level' => 'junior', 'education_level' => 'Bachelor', 'education_field' => 'Statistics', 'location_city' => 'Cairo', 'summary' => 'Consumer research and data analysis, Nielsen and Kantar panels experience.', 'preferred_sectors' => ['FMCG', 'Consulting'], 'job_type_preference' => 'full_time'],
            ['job_title' => 'Export Sales Manager', 'current_industry' => 'Manufacturing', 'years_experience' => 10, 'experience_level' => 'senior', 'education_level' => 'Bachelor', 'education_field' => 'International Business', 'location_city' => 'Alexandria', 'summary' => 'Export sales across Africa and MENA, fluent in Arabic, English, and French.', 'preferred_sectors' => ['Manufacturing', 'Trading'], 'job_type_preference' => 'full_time'],
            ['job_title' => 'Junior Accountant', 'current_industry' => 'Startups', 'years_experience' => 1, 'experience_level' => 'fresh', 'education_level' => 'Bachelor', 'education_field' => 'Accounting', 'location_city' => 'Maadi', 'summary' => 'Recent accounting graduate eager to grow in a dynamic startup environment.', 'preferred_sectors' => ['Startups', 'Services'], 'job_type_preference' => 'full_time'],
            ['job_title' => 'Investment Analyst', 'current_industry' => 'Startups', 'years_experience' => 4, 'experience_level' => 'mid', 'education_level' => 'Master', 'education_field' => 'Finance', 'location_city' => 'Cairo', 'summary' => 'VC analyst evaluating early-stage deals in Egypt, strong financial modelling background.', 'preferred_sectors' => ['Startups', 'Banking'], 'job_type_preference' => 'full_time'],
            ['job_title' => 'SEO Specialist', 'current_industry' => 'Services', 'years_experience' => 3, 'experience_level' => 'junior', 'education_level' => 'Bachelor', 'education_field' => 'Computer Science', 'location_city' => 'Cairo', 'summary' => 'Technical and on-page SEO for Arabic and English content, strong in local SEO.', 'preferred_sectors' => ['Services', 'Education'], 'job_type_preference' => 'full_time'],
            ['job_title' => 'Sales Operations Manager', 'current_industry' => 'FMCG', 'years_experience' => 7, 'experience_level' => 'senior', 'education_level' => 'Bachelor', 'education_field' => 'Business', 'location_city' => 'Cairo', 'summary' => 'Sales ops, incentive design, and CRM management for large FMCG sales organizations.', 'preferred_sectors' => ['FMCG', 'Logistics'], 'job_type_preference' => 'full_time'],
            ['job_title' => 'Payroll Manager', 'current_industry' => 'FMCG', 'years_experience' => 8, 'experience_level' => 'mid', 'education_level' => 'Bachelor', 'education_field' => 'Accounting', 'location_city' => '6th of October', 'summary' => 'Payroll, benefits, and compensation specialist managing 1000+ employee payrolls.', 'preferred_sectors' => ['FMCG', 'Manufacturing'], 'job_type_preference' => 'full_time'],
            ['job_title' => 'Customer Success Manager', 'current_industry' => 'Startups', 'years_experience' => 4, 'experience_level' => 'mid', 'education_level' => 'Bachelor', 'education_field' => 'Business', 'location_city' => 'Maadi', 'summary' => 'Post-sales success, onboarding, and upsell for B2B SaaS products targeting SMEs.', 'preferred_sectors' => ['Startups', 'Services'], 'job_type_preference' => 'full_time'],
            ['job_title' => 'Brand Strategist', 'current_industry' => 'Services', 'years_experience' => 8, 'experience_level' => 'senior', 'education_level' => 'Master', 'education_field' => 'Marketing', 'location_city' => 'Cairo', 'summary' => 'Brand architecture and repositioning consultant for Egyptian and GCC companies.', 'preferred_sectors' => ['Services', 'FMCG'], 'job_type_preference' => 'contract'],
            ['job_title' => 'Tax Manager', 'current_industry' => 'Manufacturing', 'years_experience' => 9, 'experience_level' => 'senior', 'education_level' => 'Bachelor', 'education_field' => 'Accounting', 'location_city' => 'Cairo', 'summary' => 'CIT and VAT specialist with deep experience in tax inspections and disputes.', 'preferred_sectors' => ['Manufacturing', 'Services'], 'job_type_preference' => 'full_time'],
            ['job_title' => 'Paid Media Specialist', 'current_industry' => 'Startups', 'years_experience' => 3, 'experience_level' => 'junior', 'education_level' => 'Bachelor', 'education_field' => 'Marketing', 'location_city' => 'New Cairo', 'summary' => 'Google and Meta ads specialist with strong ROAS focus for e-commerce brands.', 'preferred_sectors' => ['Startups', 'Trading'], 'job_type_preference' => 'full_time'],
            ['job_title' => 'Pre-Sales Consultant', 'current_industry' => 'Banking', 'years_experience' => 5, 'experience_level' => 'mid', 'education_level' => 'Bachelor', 'education_field' => 'Computer Science', 'location_city' => 'Cairo', 'summary' => 'Solution design and RFP responses for enterprise fintech and banking software.', 'preferred_sectors' => ['Banking', 'Startups'], 'job_type_preference' => 'full_time'],
        ];
    }

    // ════════════════════════════════════════════════════════════════════════
    //  DATA: JOB LISTINGS (18)
    // ════════════════════════════════════════════════════════════════════════

    private function jobListingData(): array
    {
        return [
            ['hub' => 'finance', 'job_title' => 'Senior Financial Analyst', 'company_name' => 'Horizon Foods Egypt', 'industry' => 'FMCG', 'location_city' => 'Cairo', 'job_type' => 'full_time', 'description' => 'We are looking for a senior financial analyst to join our FP&A team. You will own the monthly P&L review, annual budgeting process, and drive business partnering with commercial teams. The ideal candidate has 5+ years in FMCG finance.', 'required_skills' => ['Excel', 'Financial Modelling', 'PowerBI', 'FMCG'], 'min_experience_years' => 5, 'salary_range' => '25,000 – 35,000 EGP', 'status' => 'active'],
            ['hub' => 'finance', 'job_title' => 'Treasury Manager', 'company_name' => 'AlNile Trading Group', 'industry' => 'Trading', 'location_city' => 'Cairo', 'job_type' => 'full_time', 'description' => 'AlNile Trading Group is hiring a Treasury Manager to manage daily cash operations, banking relationships, and FX exposure. You will report to the CFO and manage a small team. Import/export experience is a plus.', 'required_skills' => ['Treasury', 'FX Hedging', 'Cash Management', 'Banking'], 'min_experience_years' => 7, 'salary_range' => '30,000 – 40,000 EGP', 'status' => 'active'],
            ['hub' => 'finance', 'job_title' => 'Cost Accountant', 'company_name' => 'Delta Steel Manufacturing', 'industry' => 'Manufacturing', 'location_city' => '6th of October', 'job_type' => 'full_time', 'description' => 'Delta Steel is looking for a cost accountant to maintain the standard cost system, perform monthly variance analysis, and support the annual inventory count. SAP experience required.', 'required_skills' => ['SAP', 'Cost Accounting', 'Variance Analysis'], 'min_experience_years' => 3, 'salary_range' => '12,000 – 18,000 EGP', 'status' => 'active'],
            ['hub' => 'finance', 'job_title' => 'Finance Business Partner', 'company_name' => 'Oasis Pharma', 'industry' => 'Healthcare', 'location_city' => 'New Cairo', 'job_type' => 'full_time', 'description' => 'Finance business partner to support the commercial and supply chain teams at Oasis Pharma. You will translate financial data into business insights and influence strategic decisions. Strong communication skills required.', 'required_skills' => ['FP&A', 'Business Partnering', 'Excel', 'PowerPoint'], 'min_experience_years' => 6, 'salary_range' => '28,000 – 38,000 EGP', 'status' => 'active'],
            ['hub' => 'finance', 'job_title' => 'Internal Auditor', 'company_name' => 'Pyramid Hotels Group', 'industry' => 'Hospitality', 'location_city' => 'Cairo', 'job_type' => 'full_time', 'description' => 'Pyramid Hotels Group is expanding its internal audit team. You will plan and execute risk-based audits across our hotel properties in Egypt. CIA certification preferred.', 'required_skills' => ['Internal Audit', 'Risk Assessment', 'COSO', 'CIA'], 'min_experience_years' => 4, 'salary_range' => '18,000 – 25,000 EGP', 'status' => 'filled'],
            ['hub' => 'finance', 'job_title' => 'Finance Internship', 'company_name' => 'Sanabil Ventures', 'industry' => 'Startups', 'location_city' => 'Maadi', 'job_type' => 'internship', 'description' => 'A 3-month paid internship for finance students. You will support the finance team with modelling, reporting, and analysis. Great exposure to startup finance and VC-backed company operations.', 'required_skills' => ['Excel', 'Financial Analysis'], 'min_experience_years' => 0, 'salary_range' => '3,000 – 4,000 EGP', 'status' => 'active'],
            ['hub' => 'marketing', 'job_title' => 'Brand Manager', 'company_name' => 'Baraka Consumer Goods', 'industry' => 'FMCG', 'location_city' => 'Cairo', 'job_type' => 'full_time', 'description' => 'Baraka Consumer Goods is hiring a Brand Manager for our personal care portfolio. You will own the brand P&L, develop the annual brand plan, and lead cross-functional teams to execute it. 5+ years FMCG brand management required.', 'required_skills' => ['Brand Management', 'P&L', 'ATL/BTL', 'FMCG'], 'min_experience_years' => 5, 'salary_range' => '28,000 – 40,000 EGP', 'status' => 'active'],
            ['hub' => 'marketing', 'job_title' => 'Digital Marketing Manager', 'company_name' => 'ElSawy Digital', 'industry' => 'Startups', 'location_city' => 'New Cairo', 'job_type' => 'full_time', 'description' => 'ElSawy Digital is a fast-growing digital agency looking for a Digital Marketing Manager to lead client accounts across performance and brand. Meta Blueprint and Google Ads certifications required.', 'required_skills' => ['Meta Ads', 'Google Ads', 'SEO', 'Analytics'], 'min_experience_years' => 4, 'salary_range' => '20,000 – 30,000 EGP', 'status' => 'active'],
            ['hub' => 'marketing', 'job_title' => 'CRM Manager', 'company_name' => 'Mashreq Egypt Bank', 'industry' => 'Banking', 'location_city' => 'Cairo', 'job_type' => 'full_time', 'description' => 'We are looking for a CRM Manager to own the retail banking customer lifecycle — from onboarding journeys to retention campaigns. Salesforce or similar CRM platform experience required.', 'required_skills' => ['CRM', 'Salesforce', 'Email Marketing', 'Segmentation'], 'min_experience_years' => 5, 'salary_range' => '25,000 – 35,000 EGP', 'status' => 'active'],
            ['hub' => 'marketing', 'job_title' => 'Social Media Specialist', 'company_name' => 'Ras El Bar Resorts', 'industry' => 'Hospitality', 'location_city' => 'Cairo', 'job_type' => 'full_time', 'description' => 'We are looking for a creative social media specialist to manage our resort accounts on Instagram, TikTok, and Facebook. Content creation, community management, and influencer coordination required.', 'required_skills' => ['Instagram', 'TikTok', 'Content Creation', 'Community Management'], 'min_experience_years' => 2, 'salary_range' => '8,000 – 14,000 EGP', 'status' => 'active'],
            ['hub' => 'marketing', 'job_title' => 'Trade Marketing Manager', 'company_name' => 'Pharaoh Foods', 'industry' => 'FMCG', 'location_city' => 'Giza', 'job_type' => 'full_time', 'description' => 'Pharaoh Foods is seeking a Trade Marketing Manager to drive in-store visibility, shopper activation, and sell-through across GT and MT channels. 6+ years trade marketing experience in FMCG required.', 'required_skills' => ['Trade Marketing', 'Shopper Marketing', 'GT/MT', 'Planogram'], 'min_experience_years' => 6, 'salary_range' => '30,000 – 42,000 EGP', 'status' => 'closed'],
            ['hub' => 'marketing', 'job_title' => 'Marketing Coordinator', 'company_name' => 'Rowad EdTech', 'industry' => 'Education', 'location_city' => 'Cairo', 'job_type' => 'part_time', 'description' => 'Part-time marketing coordinator for an EdTech startup. You will support campaign execution, social content calendar, and event logistics. Ideal for a recent graduate or student.', 'required_skills' => ['Social Media', 'Canva', 'Content Writing'], 'min_experience_years' => 0, 'salary_range' => '5,000 – 7,000 EGP', 'status' => 'active'],
            ['hub' => 'sales', 'job_title' => 'Sales Manager — Modern Trade', 'company_name' => 'Horizon Foods Egypt', 'industry' => 'FMCG', 'location_city' => 'Cairo', 'job_type' => 'full_time', 'description' => 'Horizon Foods is seeking a Modern Trade Sales Manager to manage key accounts across all major hypermarket and supermarket chains. You will lead a team of 6 KAMs and be accountable for a 120M EGP revenue target.', 'required_skills' => ['Key Account Management', 'MT', 'Negotiation', 'P&L'], 'min_experience_years' => 8, 'salary_range' => '40,000 – 55,000 EGP', 'status' => 'active'],
            ['hub' => 'sales', 'job_title' => 'B2B Sales Executive', 'company_name' => 'CloudNile Software', 'industry' => 'Startups', 'location_city' => 'New Cairo', 'job_type' => 'full_time', 'description' => 'CloudNile Software is growing its enterprise sales team. You will prospect, qualify, and close deals for our cloud ERP solution targeting mid-market companies. Quota: 8 new logos per quarter.', 'required_skills' => ['B2B Sales', 'SaaS', 'CRM', 'Cold Outreach'], 'min_experience_years' => 3, 'salary_range' => '15,000 – 22,000 EGP + commission', 'status' => 'active'],
            ['hub' => 'sales', 'job_title' => 'Regional Sales Manager', 'company_name' => 'MedCare Devices', 'industry' => 'Healthcare', 'location_city' => 'Alexandria', 'job_type' => 'full_time', 'description' => 'MedCare Devices is hiring a Regional Sales Manager for Alexandria and the Delta region. You will manage a team of 8 medical reps covering hospitals, clinics, and pharmacies.', 'required_skills' => ['Medical Sales', 'Team Management', 'Healthcare', 'Negotiation'], 'min_experience_years' => 6, 'salary_range' => '25,000 – 35,000 EGP', 'status' => 'active'],
            ['hub' => 'sales', 'job_title' => 'Sales Operations Analyst', 'company_name' => 'AlNile Trading Group', 'industry' => 'Trading', 'location_city' => 'Cairo', 'job_type' => 'full_time', 'description' => 'Sales operations analyst to support our national sales force with data, dashboards, and process improvement. Power BI and Salesforce experience required.', 'required_skills' => ['PowerBI', 'Salesforce', 'Excel', 'Data Analysis'], 'min_experience_years' => 2, 'salary_range' => '10,000 – 15,000 EGP', 'status' => 'active'],
            ['hub' => 'sales', 'job_title' => 'Head of Sales', 'company_name' => 'Palm Hills Properties', 'industry' => 'Real Estate', 'location_city' => 'Cairo', 'job_type' => 'full_time', 'description' => 'Palm Hills is looking for a Head of Sales to lead a 50-person sales team selling off-plan residential units. You will own the annual sales target of 800M EGP and report to the CEO.', 'required_skills' => ['Real Estate Sales', 'Team Leadership', 'Off-plan', 'CRM'], 'min_experience_years' => 12, 'salary_range' => '60,000 – 80,000 EGP + commission', 'status' => 'active'],
            ['hub' => 'sales', 'job_title' => 'Telesales Representative', 'company_name' => 'Mashreq Egypt Bank', 'industry' => 'Banking', 'location_city' => 'Cairo', 'job_type' => 'full_time', 'description' => 'Inbound and outbound telesales for retail banking products — personal loans, credit cards, and savings accounts. Call center experience required.', 'required_skills' => ['Telesales', 'Banking Products', 'Communication', 'CRM'], 'min_experience_years' => 1, 'salary_range' => '6,000 – 9,000 EGP + commission', 'status' => 'active'],
        ];
    }

    // ════════════════════════════════════════════════════════════════════════
    //  DATA: FREELANCE PROFILES (templates)
    // ════════════════════════════════════════════════════════════════════════

    private function freelanceProfileData(): array
    {
        return [
            ['headline' => 'Financial Modelling & Valuation Specialist', 'description' => 'I build 3-statement models, DCF valuations, and investor-ready financial models for startups and SMEs. I have built 40+ models for Egyptian and GCC clients. Turnaround typically 3-7 days.', 'experience_level' => 'senior', 'availability' => 'evenings', 'rate_min' => 3000, 'rate_max' => 8000],
            ['headline' => 'Performance Marketing — Meta & Google Ads', 'description' => 'I run profitable paid campaigns for e-commerce and lead gen businesses in Egypt. I specialize in reducing CPL and improving ROAS. I work with budgets from 10K to 500K EGP/month.', 'experience_level' => 'senior', 'availability' => 'weekends', 'rate_min' => 2500, 'rate_max' => 6000],
            ['headline' => 'B2B Sales Consultant & Training', 'description' => 'I help companies build and fix their sales processes — from pipeline management to closing techniques. I run workshops and 1-on-1 coaching for sales teams of 5-50 reps.', 'experience_level' => 'senior', 'availability' => 'weekends', 'rate_min' => 4000, 'rate_max' => 10000],
            ['headline' => 'Tax & Accounting Advisory for SMEs', 'description' => 'CPA with 10 years experience in Egyptian tax law. I help SMEs with CIT returns, VAT compliance, and navigating tax inspections. Arabic and English.', 'experience_level' => 'senior', 'availability' => 'evenings', 'rate_min' => 2000, 'rate_max' => 5000],
            ['headline' => 'Brand Strategy & Positioning Consultant', 'description' => 'I work with FMCG and services brands on repositioning, brand architecture, and launch strategy. Clients include listed companies and private equity-backed businesses.', 'experience_level' => 'senior', 'availability' => 'weekends', 'rate_min' => 5000, 'rate_max' => 15000],
            ['headline' => 'Sales Compensation & Incentive Design', 'description' => 'I design commission structures and incentive programmes that motivate the right behaviors. Worked with field forces from 20 to 2,000 reps across Egypt and GCC.', 'experience_level' => 'senior', 'availability' => 'evenings', 'rate_min' => 3500, 'rate_max' => 9000],
            ['headline' => 'Content Strategy & SEO (Arabic + English)', 'description' => 'I develop content strategies and SEO plans for EdTech, SaaS, and service businesses. Arabic content is a specialty. Measurable organic growth in 90 days.', 'experience_level' => 'mid', 'availability' => 'full', 'rate_min' => 1500, 'rate_max' => 4000],
            ['headline' => 'Digital Marketing Consultant — FMCG & Retail', 'description' => 'I help FMCG and retail brands build digital marketing capabilities — from strategy to execution. Media planning, influencer selection, and performance tracking.', 'experience_level' => 'senior', 'availability' => 'weekends', 'rate_min' => 3000, 'rate_max' => 7500],
            ['headline' => 'FP&A & Business Planning Freelancer', 'description' => 'I produce annual budgets, quarterly forecasts, and board-ready management packs. Available for 6-12 month engagements or one-off projects. Remote-friendly.', 'experience_level' => 'senior', 'availability' => 'evenings', 'rate_min' => 3500, 'rate_max' => 8000],
            ['headline' => 'KAM & Distributor Management Consultant', 'description' => 'I help FMCG companies fix their distributor relationships and KAM structures. I have restructured distribution networks for 3 listed companies in the past 5 years.', 'experience_level' => 'senior', 'availability' => 'weekends', 'rate_min' => 4000, 'rate_max' => 10000],
            ['headline' => 'Internal Audit & Risk Assessment', 'description' => 'CIA-certified auditor available for project-based internal audit engagements. I specialize in process audits, fraud investigations, and setting up audit functions from scratch.', 'experience_level' => 'senior', 'availability' => 'evenings', 'rate_min' => 2500, 'rate_max' => 7000],
            ['headline' => 'E-Commerce & Marketplace Strategy', 'description' => 'I help brands launch and scale on Noon, Amazon, Jumia, and D2C channels. From listing optimization to pricing strategy and fulfilment setup.', 'experience_level' => 'mid', 'availability' => 'weekends', 'rate_min' => 2000, 'rate_max' => 5000],
            ['headline' => 'CRM Implementation & Marketing Automation', 'description' => 'Salesforce and HubSpot implementation specialist. I have set up CRM systems for 15+ companies in Egypt — from configuration to adoption training.', 'experience_level' => 'mid', 'availability' => 'full', 'rate_min' => 2500, 'rate_max' => 6000],
            ['headline' => 'Trade Marketing & In-Store Execution Audits', 'description' => 'I audit in-store execution quality, planogram compliance, and activation ROI for FMCG brands. Mystery shopping, outlet visits, and gap analysis included.', 'experience_level' => 'senior', 'availability' => 'weekends', 'rate_min' => 3000, 'rate_max' => 7000],
            ['headline' => 'Financial Model Review & Stress Testing', 'description' => 'I review and stress-test existing financial models — catching errors, testing assumptions, and adding scenario analysis. I have reviewed 60+ models for banks and PE funds.', 'experience_level' => 'senior', 'availability' => 'evenings', 'rate_min' => 2000, 'rate_max' => 5000],
            ['headline' => 'Sales Training — Field Force & Telesales', 'description' => 'I design and deliver sales training programmes for field forces and call centers. Topics: objection handling, consultative selling, pipeline management, negotiation.', 'experience_level' => 'senior', 'availability' => 'weekends', 'rate_min' => 3000, 'rate_max' => 8000],
            ['headline' => 'Influencer Marketing Strategy & Management', 'description' => 'I manage end-to-end influencer campaigns for FMCG, beauty, and lifestyle brands. Influencer identification, briefing, contracting, and post-campaign reporting.', 'experience_level' => 'mid', 'availability' => 'evenings', 'rate_min' => 1500, 'rate_max' => 4000],
            ['headline' => 'Working Capital & Cash Flow Optimisation', 'description' => 'I help trading and manufacturing companies free up cash trapped in working capital — through DPO extension, DSO reduction, and inventory optimisation projects.', 'experience_level' => 'senior', 'availability' => 'weekends', 'rate_min' => 4000, 'rate_max' => 12000],
            ['headline' => 'Market Research & Consumer Insights', 'description' => 'I design and execute qual and quant research projects — focus groups, online surveys, NPS studies, and dipstick tracking. Arabic and English fieldwork.', 'experience_level' => 'mid', 'availability' => 'full', 'rate_min' => 2000, 'rate_max' => 6000],
            ['headline' => 'Business Turnaround & Operational Finance', 'description' => 'I work with distressed businesses to stabilize cash flow, restructure costs, and communicate with lenders. 20 years of experience, handled 8 turnaround assignments.', 'experience_level' => 'senior', 'availability' => 'weekends', 'rate_min' => 8000, 'rate_max' => 25000],
            ['headline' => 'Social Media Management — B2B Brands', 'description' => 'I manage LinkedIn and Twitter presence for B2B companies — thought leadership content, employer branding, and lead generation through organic social.', 'experience_level' => 'mid', 'availability' => 'evenings', 'rate_min' => 1500, 'rate_max' => 3500],
            ['headline' => 'Real Estate Sales Strategy & Team Setup', 'description' => 'I help real estate developers build their sales teams from scratch — commission design, hiring profiles, sales scripts, and launch event planning.', 'experience_level' => 'senior', 'availability' => 'weekends', 'rate_min' => 5000, 'rate_max' => 15000],
            ['headline' => 'IFRS Implementation & Technical Accounting', 'description' => 'I advise on IFRS adoption and complex technical accounting matters — IFRS 15 revenue recognition, IFRS 16 leases, IFRS 9 financial instruments.', 'experience_level' => 'senior', 'availability' => 'evenings', 'rate_min' => 4000, 'rate_max' => 12000],
            ['headline' => 'Data Analytics & Sales Dashboard Design', 'description' => 'I build sales and marketing dashboards in PowerBI and Tableau — from raw data to boardroom-ready visuals. Connected to CRM and ERP data sources.', 'experience_level' => 'mid', 'availability' => 'full', 'rate_min' => 2000, 'rate_max' => 5000],
            ['headline' => 'Pharma & Healthcare Sales Strategy', 'description' => 'I help pharmaceutical and medical device companies design their go-to-market strategy, territory structure, and targeting models for the Egyptian market.', 'experience_level' => 'senior', 'availability' => 'weekends', 'rate_min' => 4000, 'rate_max' => 10000],
        ];
    }

    // ════════════════════════════════════════════════════════════════════════
    //  DATA: FREELANCE BRIEFS (15)
    // ════════════════════════════════════════════════════════════════════════

    private function freelanceBriefData(): array
    {
        return [
            ['title' => 'Need a financial model for a Series A pitch deck', 'description' => 'We are a B2B SaaS startup raising Series A. We need a 3-year financial model with three scenarios (base, bull, bear), unit economics section, and an investor-ready output. Must be dynamic and well-documented.', 'required_skills' => ['Financial Modelling', 'Startup Finance', 'Excel'], 'preferred_sector' => 'Startups', 'duration_estimate' => '1-2 weeks', 'timeline' => 'Within 2 weeks', 'budget_min' => 5000, 'budget_max' => 10000, 'status' => 'open'],
            ['title' => 'Meta Ads audit and restructure — e-commerce brand', 'description' => 'Our Meta ads account has 8 campaigns running with no clear structure. ROAS has dropped from 4x to 2x in 3 months. Need an expert to audit the account, identify the issues, and restructure campaigns. Budget 80K EGP/month.', 'required_skills' => ['Meta Ads', 'E-Commerce', 'Performance Marketing'], 'preferred_sector' => 'Trading', 'duration_estimate' => '2-4 weeks', 'timeline' => 'ASAP', 'budget_min' => 3000, 'budget_max' => 7000, 'status' => 'open'],
            ['title' => 'Sales commission redesign for 80-person field team', 'description' => 'Our current commission scheme is rewarding the wrong behaviors — reps chase volume, ignore margin, and new SKUs never get pushed. Need a consultant to redesign the full incentive structure with clear KPIs.', 'required_skills' => ['Sales Compensation', 'Incentive Design', 'FMCG'], 'preferred_sector' => 'FMCG', 'duration_estimate' => '3-6 weeks', 'timeline' => 'Next month', 'budget_min' => 8000, 'budget_max' => 18000, 'status' => 'open'],
            ['title' => 'VAT and CIT compliance review — manufacturing company', 'description' => 'We have a tax inspection coming in 3 months. Need a tax consultant to review our last 3 years of filings, identify exposure, and help us prepare our defense file. Delta region manufacturing company.', 'required_skills' => ['Egyptian Tax Law', 'CIT', 'VAT'], 'preferred_sector' => 'Manufacturing', 'duration_estimate' => '4-8 weeks', 'timeline' => 'This quarter', 'budget_min' => 10000, 'budget_max' => 20000, 'status' => 'open'],
            ['title' => 'Brand repositioning for mid-market FMCG personal care brand', 'description' => 'Our brand has been losing share to both premium and economy. We need a brand strategy consultant to help us reposition, sharpen the target consumer, and develop a new communication platform.', 'required_skills' => ['Brand Strategy', 'Consumer Insights', 'FMCG'], 'preferred_sector' => 'FMCG', 'duration_estimate' => '6-10 weeks', 'timeline' => 'Flexible', 'budget_min' => 15000, 'budget_max' => 35000, 'status' => 'open'],
            ['title' => 'Distributorship review and restructuring — food company', 'description' => 'We have 12 distributors covering Greater Cairo and we think the territories are badly drawn and some distributors are underperforming. Need a sales consultant to audit the network and recommend restructuring.', 'required_skills' => ['Distribution Management', 'FMCG', 'Route to Market'], 'preferred_sector' => 'FMCG', 'duration_estimate' => '4-6 weeks', 'timeline' => 'Q3', 'budget_min' => 12000, 'budget_max' => 22000, 'status' => 'open'],
            ['title' => 'CRM implementation — HubSpot for 20-person sales team', 'description' => 'We have purchased HubSpot but have been struggling with implementation for 4 months. Need someone to set up the full pipeline, integrate with our email, build dashboards, and train the team.', 'required_skills' => ['HubSpot', 'CRM Implementation', 'Sales Training'], 'preferred_sector' => 'Services', 'duration_estimate' => '2-4 weeks', 'timeline' => 'ASAP', 'budget_min' => 6000, 'budget_max' => 12000, 'status' => 'in_progress'],
            ['title' => 'Content strategy and SEO plan for fintech startup', 'description' => 'We are a fintech startup with a content team but no strategy. We need a content strategist to develop a 12-month content plan, keyword map, and editorial calendar targeting Arabic-speaking financial professionals.', 'required_skills' => ['Content Strategy', 'SEO', 'Arabic Content', 'Fintech'], 'preferred_sector' => 'Startups', 'duration_estimate' => '2-3 weeks', 'timeline' => 'This month', 'budget_min' => 4000, 'budget_max' => 8000, 'status' => 'open'],
            ['title' => 'Board pack redesign — quarterly financial reporting', 'description' => 'Our board pack is currently a 60-page Excel printout. We want to redesign it into a concise, visual 15-page PowerPoint that tells the story clearly. Need someone with both finance and presentation skills.', 'required_skills' => ['Financial Reporting', 'PowerPoint', 'Data Visualization'], 'preferred_sector' => 'Manufacturing', 'duration_estimate' => '1-2 weeks', 'timeline' => 'Before next board meeting', 'budget_min' => 3000, 'budget_max' => 6000, 'status' => 'open'],
            ['title' => 'Market research — consumer attitudes to insurance in Egypt', 'description' => 'We are launching a digital insurance product and need consumer research on attitudes, awareness, and willingness to pay for life insurance among 25-45 year old Egyptian professionals.', 'required_skills' => ['Market Research', 'Consumer Insights', 'Survey Design'], 'preferred_sector' => 'Services', 'duration_estimate' => '3-5 weeks', 'timeline' => 'Flexible', 'budget_min' => 8000, 'budget_max' => 18000, 'status' => 'open'],
            ['title' => 'Influencer strategy for new beverage launch', 'description' => 'Launching a premium Egyptian herbal drink targeting health-conscious 20-35 year olds. Need an influencer strategy — platform mix, tier recommendation, selection criteria, and a launch calendar.', 'required_skills' => ['Influencer Marketing', 'Social Media', 'FMCG', 'Launch Strategy'], 'preferred_sector' => 'FMCG', 'duration_estimate' => '2-3 weeks', 'timeline' => '6 weeks from now', 'budget_min' => 4000, 'budget_max' => 9000, 'status' => 'open'],
            ['title' => 'Working capital analysis — reducing cash conversion cycle', 'description' => 'We are a trading company with CCC of 90 days. Management wants to reduce it to 60 days this year. Need a finance consultant to model the levers — DSO, DPO, DIO — and build a roadmap.', 'required_skills' => ['Working Capital', 'Cash Flow Analysis', 'Finance'], 'preferred_sector' => 'Trading', 'duration_estimate' => '2-3 weeks', 'timeline' => 'This quarter', 'budget_min' => 5000, 'budget_max' => 12000, 'status' => 'open'],
            ['title' => 'Sales training programme — new hire onboarding', 'description' => 'We hire 15 new sales reps every quarter and our onboarding is ad hoc. Need to build a structured 4-week onboarding programme — product training, sales skills, and territory management.', 'required_skills' => ['Sales Training', 'Curriculum Design', 'Onboarding'], 'preferred_sector' => 'FMCG', 'duration_estimate' => '4-6 weeks', 'timeline' => 'Next quarter', 'budget_min' => 10000, 'budget_max' => 20000, 'status' => 'open'],
            ['title' => 'E-commerce launch on Noon and Amazon.eg', 'description' => 'We sell offline only and want to launch on Noon and Amazon.eg. Need someone to set up the accounts, create the listings, plan the initial inventory, and manage the first 3 months of performance.', 'required_skills' => ['Noon', 'Amazon.eg', 'E-Commerce', 'Marketplace Management'], 'preferred_sector' => 'Trading', 'duration_estimate' => '4-8 weeks', 'timeline' => 'Next 2 months', 'budget_min' => 5000, 'budget_max' => 10000, 'status' => 'open'],
            ['title' => 'PowerBI dashboard for sales and finance KPIs', 'description' => 'We have data in Odoo and Excel. We want a PowerBI dashboard covering: sales by region/rep/SKU, P&L by product line, and cash flow. Connected live to sources. Need documentation and training included.', 'required_skills' => ['PowerBI', 'Data Analytics', 'Odoo', 'Dashboard Design'], 'preferred_sector' => 'Manufacturing', 'duration_estimate' => '2-4 weeks', 'timeline' => 'ASAP', 'budget_min' => 6000, 'budget_max' => 12000, 'status' => 'open'],
        ];
    }

    // ════════════════════════════════════════════════════════════════════════
    //  DATA: DOCUMENTS (20)
    // ════════════════════════════════════════════════════════════════════════

    private function documentData(): array
    {
        return [
            ['hub' => 'finance', 'title_en' => 'Egypt FMCG Financial Benchmarks 2024', 'title_ar' => 'معايير الأداء المالي للسلع الاستهلاكية في مصر 2024', 'description_en' => 'A benchmarking report covering key financial ratios for FMCG companies in Egypt — gross margin, EBITDA, DSO, DPO, and cash conversion cycles across 40 companies.', 'category' => 'Reports', 'tags' => ['FMCG', 'benchmarks', 'finance', 'Egypt'], 'status' => 'approved'],
            ['hub' => 'finance', 'title_en' => 'Working Capital Optimisation Playbook', 'title_ar' => 'دليل تحسين رأس المال العامل', 'description_en' => 'A practical guide to reducing cash conversion cycle in trading and manufacturing companies — covering DSO reduction tactics, DPO negotiation, and inventory management frameworks.', 'category' => 'Guides', 'tags' => ['working-capital', 'cash-flow', 'manufacturing'], 'status' => 'approved'],
            ['hub' => 'finance', 'title_en' => '3-Statement Financial Model Template', 'title_ar' => 'قالب النموذج المالي ثلاثي القوائم', 'description_en' => 'A ready-to-use Excel template for building an integrated P&L, Balance Sheet, and Cash Flow model. Includes automated checks, scenario toggles, and a waterfall chart.', 'category' => 'Templates', 'tags' => ['financial-model', 'Excel', 'template'], 'status' => 'approved'],
            ['hub' => 'finance', 'title_en' => 'EGP Volatility Impact on Corporate Finance Decisions', 'description_en' => 'An analysis of how Egyptian pound devaluation cycles affect corporate capital structure, hedging decisions, and investment hurdle rates for listed companies.', 'category' => 'Research', 'tags' => ['FX', 'EGP', 'corporate-finance', 'devaluation'], 'status' => 'approved'],
            ['hub' => 'finance', 'title_en' => 'IFRS 16 Lease Accounting — Egypt Implementation Guide', 'description_en' => 'A step-by-step guide to implementing IFRS 16 in Egyptian companies — covering identification of leases, measurement of ROU assets, and disclosure requirements.', 'category' => 'Guides', 'tags' => ['IFRS16', 'leases', 'accounting'], 'status' => 'approved'],
            ['hub' => 'finance', 'title_en' => 'Egyptian Tax Calendar & Compliance Checklist 2024', 'title_ar' => 'التقويم الضريبي المصري وقائمة الامتثال 2024', 'description_en' => 'Month-by-month tax obligations for Egyptian companies — CIT installments, VAT filings, payroll tax, withholding tax, and stamp duty deadlines.', 'category' => 'Templates', 'tags' => ['tax', 'compliance', 'Egypt'], 'status' => 'approved'],
            ['hub' => 'finance', 'title_en' => 'Board Pack Design — Best Practice Guide', 'description_en' => 'A guide to designing board-ready management packs — structure, visualizations, narrative flow, and how to present financial results to non-finance board members.', 'category' => 'Guides', 'tags' => ['board-pack', 'reporting', 'communication'], 'status' => 'pending'],
            ['hub' => 'marketing', 'title_en' => 'Egypt Digital Marketing Landscape Report 2024', 'description_en' => 'A comprehensive overview of the Egyptian digital marketing ecosystem — social media penetration, ad spend by platform, top verticals, and consumer online behavior.', 'category' => 'Reports', 'tags' => ['digital-marketing', 'Egypt', 'social-media', '2024'], 'status' => 'approved'],
            ['hub' => 'marketing', 'title_en' => 'FMCG Brand Health Tracking Methodology', 'description_en' => 'A framework for setting up and running brand health trackers — awareness, consideration, purchase, and NPS metrics. Includes survey template and analysis guide.', 'category' => 'Guides', 'tags' => ['brand', 'research', 'FMCG', 'tracking'], 'status' => 'approved'],
            ['hub' => 'marketing', 'title_en' => 'Influencer Marketing Rate Card — Egypt 2024', 'description_en' => 'A benchmarking document for influencer rates across Egyptian Instagram, TikTok, and YouTube — broken down by follower tier, niche, and engagement rate.', 'category' => 'Reports', 'tags' => ['influencer', 'rates', 'Egypt', 'benchmarks'], 'status' => 'approved'],
            ['hub' => 'marketing', 'title_en' => 'Meta Ads Campaign Structure Best Practices', 'description_en' => 'A guide to structuring Meta ad campaigns for Egyptian market — audience setup, campaign objectives, creative best practices, and optimization routines for FMCG and e-commerce.', 'category' => 'Guides', 'tags' => ['Meta', 'Facebook', 'Instagram', 'ads'], 'status' => 'approved'],
            ['hub' => 'marketing', 'title_en' => 'Trade Marketing Execution Audit Checklist', 'title_ar' => 'قائمة مراجعة تنفيذ التسويق التجاري', 'description_en' => 'A detailed checklist for auditing in-store execution quality — planogram compliance, visibility scores, pricing accuracy, and promotion execution across GT and MT.', 'category' => 'Templates', 'tags' => ['trade-marketing', 'audit', 'in-store'], 'status' => 'approved'],
            ['hub' => 'marketing', 'title_en' => 'Egyptian Consumer Behavior Post-Devaluation Study', 'description_en' => 'Primary research conducted in 2024 on how Egyptian consumers have changed their purchasing decisions — trading down, category exit, and private label adoption.', 'category' => 'Research', 'tags' => ['consumer-behavior', 'devaluation', 'Egypt', 'research'], 'status' => 'pending'],
            ['hub' => 'marketing', 'title_en' => 'Marketing ROI Attribution Framework', 'description_en' => 'A practical framework for attributing revenue to marketing activities in a multi-channel environment — from last-click to data-driven attribution models.', 'category' => 'Guides', 'tags' => ['ROI', 'attribution', 'analytics'], 'status' => 'approved'],
            ['hub' => 'sales', 'title_en' => 'Egypt Sales Compensation Benchmarks 2024', 'description_en' => 'A benchmarking report on sales compensation structures across Egyptian industries — base/variable splits, commission rates, accelerators, and total on-target earnings by level and sector.', 'category' => 'Reports', 'tags' => ['compensation', 'commissions', 'benchmarks', 'Egypt'], 'status' => 'approved'],
            ['hub' => 'sales', 'title_en' => 'Key Account Management — Negotiation Playbook', 'description_en' => 'A practical playbook for negotiating with major Egyptian retailers — preparation, BATNA setting, concession strategies, and handling procurement teams.', 'category' => 'Guides', 'tags' => ['KAM', 'negotiation', 'retail', 'FMCG'], 'status' => 'approved'],
            ['hub' => 'sales', 'title_en' => 'CRM Adoption Playbook — Getting Your Team to Use It', 'description_en' => 'A guide to driving CRM adoption in resistant sales teams — change management, gamification, manager routines, and dashboard design that makes CRM useful rather than administrative.', 'category' => 'Guides', 'tags' => ['CRM', 'Salesforce', 'adoption', 'change-management'], 'status' => 'approved'],
            ['hub' => 'sales', 'title_en' => 'Distribution Network Audit Methodology', 'title_ar' => 'منهجية تدقيق شبكة التوزيع', 'description_en' => 'A step-by-step methodology for auditing and restructuring distributor networks in Egypt — coverage analysis, territory design, performance scorecards, and transition planning.', 'category' => 'Guides', 'tags' => ['distribution', 'GT', 'channel', 'audit'], 'status' => 'approved'],
            ['hub' => 'sales', 'title_en' => 'Sales Pipeline Management — Excel Template', 'description_en' => 'A practical Excel sales pipeline template for B2B companies — deal stages, probability weighting, weighted pipeline, and monthly forecast view. No CRM required.', 'category' => 'Templates', 'tags' => ['pipeline', 'B2B', 'Excel', 'forecasting'], 'status' => 'approved'],
            ['hub' => 'sales', 'title_en' => 'Territory Planning & Route to Market Framework', 'description_en' => 'A framework for designing and optimizing sales territories — workload analysis, coverage models, productivity targets, and a phased implementation approach.', 'category' => 'Guides', 'tags' => ['territory', 'route-to-market', 'field-force'], 'status' => 'pending'],
        ];
    }

    // ════════════════════════════════════════════════════════════════════════
    //  HELPERS
    // ════════════════════════════════════════════════════════════════════════

    private function skillsForHub(int $hubId): array
    {
        if ($hubId === $this->financeHubId) {
            return array_slice(array_merge(
                ['Excel', 'Financial Modelling', 'PowerBI', 'SAP', 'IFRS', 'FP&A', 'Budgeting', 'Cash Flow Management', 'Tax Compliance', 'Financial Reporting'],
                []
            ), 0, rand(4, 7));
        }
        if ($hubId === $this->marketingHubId) {
            return array_slice(array_merge(
                ['Meta Ads', 'Google Ads', 'SEO', 'Brand Management', 'Content Strategy', 'CRM', 'Market Research', 'Trade Marketing', 'Media Planning', 'Digital Analytics'],
                []
            ), 0, rand(4, 7));
        }
        return array_slice(array_merge(
            ['B2B Sales', 'Key Account Management', 'Salesforce', 'Negotiation', 'Pipeline Management', 'Sales Training', 'CRM', 'Channel Management', 'Cold Calling', 'Territory Management'],
            []
        ), 0, rand(4, 7));
    }

    private function servicesForHub(int $hubId): array
    {
        if ($hubId === $this->financeHubId) {
            $all = ['Financial Modelling', 'Budgeting & Forecasting', 'Tax Advisory', 'Internal Audit', 'Working Capital Optimisation', 'Board Reporting', 'IFRS Consulting', 'Cash Flow Management'];
        } elseif ($hubId === $this->marketingHubId) {
            $all = ['Brand Strategy', 'Performance Marketing', 'Content Strategy', 'SEO', 'Market Research', 'Influencer Marketing', 'CRM Setup', 'Trade Marketing'];
        } else {
            $all = ['Sales Training', 'CRM Implementation', 'Distribution Setup', 'Incentive Design', 'Sales Strategy', 'KAM Coaching', 'Territory Planning', 'Pipeline Management'];
        }
        shuffle($all);
        return array_slice($all, 0, rand(2, 4));
    }

    private function randomSectors(int $count): array
    {
        $sectors = ['FMCG', 'Manufacturing', 'Banking', 'Real Estate', 'Healthcare', 'Startups', 'Trading', 'Logistics', 'Hospitality', 'Education'];
        shuffle($sectors);
        return array_slice($sectors, 0, $count);
    }

    private function randomSolutionContent(): string
    {
        $solutions = [
            "The core issue here is a mismatch between accrual accounting profit and actual cash timing. The first step is to build a 13-week cash flow forecast to understand exactly when the cash gap hits. From there, you have three levers: accelerate collections by offering early payment discounts (2/10 net 30 is a good start), negotiate extended payment terms with key suppliers (60-90 days is achievable with a good relationship), and look at whether the inventory build-up can be reduced. I would prioritize the collection side first because that is where the fastest impact is.",

            "This is a classic seasonal business problem. The answer is not to grow your way out of it — that just makes the seasonal swing bigger. What you need is a revolving credit facility sized to cover the off-season working capital gap. Get this in place before you need it, because banks will not lend to a company that is already in distress. On the operational side, consider whether you can shift some demand — promotions in the off-season, subscription models, or B2B contracts with different payment timing.",

            "The forecast rejection without explanation is a management communication problem, not a finance problem. Before you reapply any cuts, request a 30-minute meeting with your CFO and come with specific questions: Which departments are targets? What is the strategic context — cost pressure from investors, lower revenue outlook, or pure efficiency drive? Applying 15% uniformly is the lazy answer and will break some departments while leaving room in others. You want to be the person who asks the right questions, not just the one who complies.",

            "From experience, the best way to present to a non-finance board is to lead with the business question, not the financial result. Instead of opening with 'Revenue was 45.2M this quarter,' open with 'We gained 2 points of market share but our cash conversion slowed — here is what that means for us.' Use one page per business question. Visuals should be simple — bar charts and single numbers, not pivot tables. I always end every pack with 'Three decisions needed from this board.'",

            "For a B2B SaaS with 30-80K EGP ACV and 2-3 month cycle, 70/30 base/variable is reasonable. The variable should kick in at 75% of quota (not 100%) to keep reps motivated even in tough months. Accelerators above 100% quota should be meaningful — I recommend 1.5x commission rate above quota. For a new team, add a ramp period of 90 days at 50% of full variable expectation. The worst thing you can do is have reps hit quota once and then leave because the plan does not reward overperformance.",

            "The distributor conflict is real and it is costing you. Document every incident with dates, quantities, and prices. Build the business case in EGP terms — how much revenue are you losing from MT delisting risk versus the volume the GT distributor is moving? Take this to commercial leadership with a specific proposal: either enforce the price corridor (put it in the distributor contract) or restructure territories so GT and MT don't overlap. You need management to make this call, but you need to make the cost of inaction visible.",
        ];
        return $solutions[array_rand($solutions)];
    }

    private function randomReplyBody(string $postTitle): string
    {
        $replies = [
            "I have dealt with almost exactly this situation. The key is to separate the business problem from the relationship dynamic — your boss may have external pressure you are not seeing. My approach was to ask for a 20-minute meeting, bring the budget printout, and ask three specific questions: What is the strategic goal behind the 15% reduction? Are there specific lines that are more flexible than others? What would a good outcome look like for the business? That meeting changed the whole conversation.",
            "This is a very common situation in Egyptian corporates. In my experience, the rejection without explanation usually means one of two things: either there is a top-down directive you have not been told about, or the budget number made someone uncomfortable and they do not want to justify the pushback. Either way, you need more information before you cut anything. Push for a conversation before you touch the numbers.",
            "Completely agree with what others have said. I would add: before that meeting, do a quick sensitivity analysis showing what happens to key business metrics if you apply the 15% uniformly versus targeted cuts. Walking in with data makes you the expert in the room, not just someone asking for permission.",
            "We had this exact problem two years ago with a government client owing us 1.8M EGP. What finally worked was escalating to a political level above the finance department — we went through a mutual contact to the undersecretary's office. Not ideal, but sometimes that is the reality in Egypt. The other thing that helped was submitting everything digitally through their official procurement portal, which creates a paper trail that is harder to ignore.",
            "Have you considered factoring the receivable? Some banks and specialized factoring companies will advance 70-80% of the invoice value, even for government receivables, at a cost. For a 2.3M invoice it might be worth the discount just to stabilize your cash flow while you pursue collection in parallel.",
            "The Meta CPM increase is real and affecting everyone I speak to. What has worked for us is three things: first, move more budget to Reels — CPM on Reels is still 30-40% lower than feed. Second, broaden your audience targeting — the algorithm works better when it has more room to find the right people. Third, creative refresh matters more than anything — stale creatives are penalized heavily. We refresh every 2-3 weeks now.",
            "On the commission structure question: the mistake most companies make is designing the commission for the reps they want, not the reps they have. If your current team is predominantly hunters, a pure new business commission works. If they are farmers, you need a renewal and expansion component. I would run a quick diagnostic on your top 5 reps and understand what behavior you actually want to incentivize before designing anything.",
            "The CRM adoption problem is fundamentally a manager behavior problem, not a rep behavior problem. If the manager does not use the CRM in every 1:1 and pipeline review, reps will never use it. The first intervention is always at the manager level — build their dashboards, make their performance reviews CRM-dependent, and then the reps follow.",
        ];
        return $replies[array_rand($replies)];
    }

    private function randomNestedReply(): string
    {
        $nested = [
            "That is a great point. I would add that the timing of when you have this conversation matters a lot — early in the planning cycle you have more leverage than at the end.",
            "Completely agree. The factoring option is underused in Egypt — most finance people do not know it exists for government receivables.",
            "This matches my experience exactly. Reels CPM has been significantly better for us too, especially for product awareness campaigns.",
            "The manager behavior point is spot on. We changed our pipeline review format to require CRM screenshots and adoption went from 40% to 85% in one quarter.",
            "One thing I would add: document everything in writing after the verbal conversation. Send a meeting summary email. It protects you and creates accountability.",
            "Have you looked at your audience overlap? Sometimes when CPM spikes it is because multiple campaigns are competing for the same audience. Use the audience overlap tool.",
        ];
        return $nested[array_rand($nested)];
    }

    private function randomJobOutreachMessage(): string
    {
        $messages = [
            "Hello, I came across your profile on InPractice and I think your background aligns very well with a position we currently have open. I would love to share more details if you are open to a conversation.",
            "Your experience in financial modelling and FP&A is exactly what we are looking for. We have an exciting opportunity that could be a great fit. Would you be open to a brief call this week?",
            "I noticed your profile and was impressed by your track record. We are building a strong team and I believe you could make a real impact. Interested in learning more?",
            "We are looking for someone with your exact background and I do not want this opportunity to pass you by. The role comes with strong compensation and a clear growth path.",
        ];
        return $messages[array_rand($messages)];
    }

    private function randomSeekerMessage(): string
    {
        $messages = [
            "I saw your profile and your experience looks like exactly what we need. We have a project starting in 3 weeks. Happy to share a detailed brief if you are interested.",
            "Your background in this area is very relevant to a project we have. We have budget approved and are ready to move quickly. Would you be open to a 30-minute intro call?",
            "We have been looking for someone with your specific expertise for a while. Our timeline is flexible — more interested in finding the right person than rushing.",
            "Your profile stood out because of your sector expertise. This project needs someone who understands the Egyptian market context deeply. Happy to discuss.",
        ];
        return $messages[array_rand($messages)];
    }

    private function reviewMessages(): array
    {
        return [
            "Excellent work — delivered exactly what was promised, on time, and with a level of detail that exceeded our expectations. The financial model was clean, well-documented, and the CFO loved it. Will definitely work together again.",
            "Very professional and responsive throughout the project. Knew the Egyptian market context well which saved a lot of back-and-forth. The final deliverable was practical and actionable, not just theoretical.",
            "Good quality work overall. There was one round of revisions needed because the initial scope was interpreted slightly differently, but once we aligned it came together well. Recommended.",
            "Exceptional consultant. Ran our team through the sales training workshop and the feedback from the reps was the best we have ever had. The content was tailored to our specific products and competitive situation, not generic.",
            "Solid work. Met the timeline, addressed all our feedback, and was easy to work with. The tax review caught an exposure we had missed for 2 years — paid for itself many times over.",
            "Outstanding. The brand strategy work completely changed how we think about our positioning. The consumer insight workshop alone was worth the full project fee.",
            "Very responsive, understood the brief quickly, and delivered a campaign structure that immediately improved our ROAS. Saved us from continuing to waste budget on a broken account structure.",
            "Professional, experienced, and direct — which is exactly what we needed. The distribution audit identified issues we had been debating internally for years. The restructuring plan is now being implemented.",
        ];
    }

    private function randomDocumentComment(): string
    {
        $comments = [
            "Very practical and well-structured. I have been looking for something like this for months.",
            "Excellent resource. Shared it with my whole team.",
            "The benchmarks section is particularly useful — hard to find this data in the Egyptian context.",
            "Well-written and relevant. A few things specific to our industry but 80% directly applicable.",
            "Exactly what I needed for my board presentation next week. Thank you for sharing.",
            "The template is clean and well-documented. Saved me at least 3 days of work.",
        ];
        return $comments[array_rand($comments)];
    }
}
