<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\Models\RCampaign;
use App\Models\RHealthStory;
use App\Models\RPoll;
use App\Models\RPollOption;
use App\Models\RPollResponse;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;

/**
 * Seeder: RAdvocacyDataSeeder
 * 
 * Seeds comprehensive advocacy data for SSHIA.
 * Includes campaigns, health stories, and community polls.
 * 
 * @author SSHIA Development Team
 * @version 1.0.0
 */
class RAdvocacyDataSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        $this->command->info('Seeding Digital Health Advocacy data...');

        // Get first user for author
        $authorId = DB::table('users')->first()->id ?? 1;
        $now = now();

        // Create Campaigns
        $campaigns = $this->createCampaigns($authorId, $now);

        // Create Health Stories
        $this->createHealthStories($campaigns, $authorId, $now);

        // Create Polls
        $this->createPolls($campaigns, $authorId, $now);

        $this->command->info('Digital Health Advocacy data seeded successfully!');
    }

    /**
     * Create health advocacy campaigns.
     */
    protected function createCampaigns(int $authorId, $now): array
    {
        $campaigns = [];
        $campaignData = [
            [
                'title' => 'Maternal Health Awareness Initiative',
                'slug' => 'maternal-health-awareness-initiative',
                'description' => 'A comprehensive campaign focused on improving maternal health outcomes across South Sudan. This initiative combines community education, digital health tools, and healthcare worker training to reduce maternal mortality and improve antenatal care attendance. The campaign targets both urban and rural communities, with special focus on hard-to-reach areas.',
                'objectives' => '1. Increase antenatal care attendance by 40% in target communities. 2. Train 500 community health workers on maternal health messaging. 3. Distribute 10,000 educational materials. 4. Establish 20 community support groups for pregnant women. 5. Reduce maternal mortality rate by 15% in intervention areas.',
                'target_audience' => 'Pregnant women, women of reproductive age (15-49 years), community health workers, traditional birth attendants, male partners, community leaders',
                'regions' => ['Jonglei', 'Unity', 'Upper Nile', 'Central Equatoria'],
                'status' => 'active',
                'is_featured' => true,
                'start_date' => $now->copy()->subMonths(6)->format('Y-m-d'),
                'end_date' => $now->copy()->addMonths(6)->format('Y-m-d'),
                'meta_title' => 'Maternal Health Awareness Initiative | SSHIA',
                'meta_description' => 'Join SSHIA\'s campaign to improve maternal health outcomes in South Sudan through education, digital tools, and community support.',
                'meta_keywords' => ['maternal health', 'antenatal care', 'South Sudan', 'pregnancy', 'health awareness'],
            ],
            [
                'title' => 'Digital Health Literacy for Youth',
                'slug' => 'digital-health-literacy-youth',
                'description' => 'An innovative campaign designed to improve digital health literacy among young people in South Sudan. Through social media engagement, interactive workshops, and peer education programs, this campaign empowers youth to make informed health decisions and combat health misinformation online. The program leverages popular platforms to reach its target audience effectively.',
                'objectives' => '1. Train 2,000 youth as digital health ambassadors. 2. Reach 100,000 young people with health information via social media. 3. Develop a digital health literacy curriculum for secondary schools. 4. Create 50 youth-friendly health education videos. 5. Establish peer support networks in 50 schools.',
                'target_audience' => 'Youth aged 15-30, secondary school students, university students, young professionals, youth leaders',
                'regions' => ['Juba', 'Wau', 'Malakal', 'Yei', 'Rumbek'],
                'status' => 'active',
                'is_featured' => true,
                'start_date' => $now->copy()->subMonths(4)->format('Y-m-d'),
                'end_date' => $now->copy()->addMonths(8)->format('Y-m-d'),
                'meta_title' => 'Digital Health Literacy for Youth | SSHIA',
                'meta_description' => 'Empowering South Sudanese youth with digital health literacy skills to make informed decisions and fight misinformation.',
                'meta_keywords' => ['digital health', 'youth', 'health literacy', 'South Sudan', 'health education'],
            ],
            [
                'title' => 'Malaria Prevention and Control',
                'slug' => 'malaria-prevention-control',
                'description' => 'A nationwide campaign to reduce malaria incidence through community education, distribution of preventive tools, and promotion of early treatment-seeking behavior. This campaign combines traditional outreach methods with innovative digital approaches to maximize reach and impact across all 10 states of South Sudan.',
                'objectives' => '1. Distribute 50,000 insecticide-treated bed nets. 2. Train 1,000 community health workers on malaria prevention messaging. 3. Reach 500,000 people with educational content. 4. Increase early treatment-seeking behavior by 35%. 5. Reduce malaria-related deaths by 20% in target communities.',
                'target_audience' => 'General population, pregnant women, children under 5, mothers and caregivers, community health workers',
                'regions' => ['Northern Bahr el Ghazal', 'Western Bahr el Ghazal', 'Eastern Equatoria', 'Western Equatoria', 'Lakes', 'Warrap'],
                'status' => 'active',
                'is_featured' => false,
                'start_date' => $now->copy()->subMonths(8)->format('Y-m-d'),
                'end_date' => $now->copy()->addMonths(4)->format('Y-m-d'),
                'meta_title' => 'Malaria Prevention Campaign | SSHIA',
                'meta_description' => 'Join the fight against malaria in South Sudan. Learn prevention methods and early treatment options.',
                'meta_keywords' => ['malaria', 'prevention', 'South Sudan', 'bed nets', 'health campaign'],
            ],
            [
                'title' => 'Immunization Awareness Drive',
                'slug' => 'immunization-awareness-drive',
                'description' => 'This campaign aims to increase childhood immunization coverage across South Sudan by addressing vaccine hesitancy, improving access to immunization services, and strengthening community trust in the healthcare system. Through partnership with religious and community leaders, we work to ensure every child receives life-saving vaccines.',
                'objectives' => '1. Increase routine immunization coverage from 45% to 70%. 2. Train 300 healthcare workers on vaccine communication. 3. Engage 100 religious leaders as immunization advocates. 4. Reduce zero-dose children by 40%. 5. Establish 50 new outreach immunization sites.',
                'target_audience' => 'Parents and caregivers of children under 5, pregnant women, community leaders, religious leaders, healthcare workers',
                'regions' => ['Central Equatoria', 'Eastern Equatoria', 'Western Equatoria', 'Jonglei', 'Lakes'],
                'status' => 'active',
                'is_featured' => false,
                'start_date' => $now->copy()->subMonths(3)->format('Y-m-d'),
                'end_date' => $now->copy()->addMonths(9)->format('Y-m-d'),
                'meta_title' => 'Immunization Awareness Drive | SSHIA',
                'meta_description' => 'Protecting South Sudan\'s children through immunization awareness and improved vaccine access.',
                'meta_keywords' => ['immunization', 'vaccines', 'children', 'South Sudan', 'health protection'],
            ],
            [
                'title' => 'Mental Health Support Initiative',
                'slug' => 'mental-health-support-initiative',
                'description' => 'Breaking the silence on mental health in South Sudan. This campaign raises awareness about mental health issues, reduces stigma, and connects people with support services. We address the psychological impact of conflict, displacement, and daily stressors while building community resilience and support networks.',
                'objectives' => '1. Train 200 community mental health facilitators. 2. Establish 30 community support groups. 3. Develop culturally-appropriate mental health resources. 4. Reach 100,000 people with awareness messages. 5. Integrate mental health into 50 primary healthcare facilities.',
                'target_audience' => 'General population, conflict-affected communities, displaced persons, healthcare workers, youth, community leaders',
                'regions' => ['Juba', 'Bentiu', 'Malakal', 'Wau', 'Yei', 'Torit'],
                'status' => 'active',
                'is_featured' => true,
                'start_date' => $now->copy()->subMonths(5)->format('Y-m-d'),
                'end_date' => $now->copy()->addMonths(7)->format('Y-m-d'),
                'meta_title' => 'Mental Health Support Initiative | SSHIA',
                'meta_description' => 'Supporting mental health and building resilience in South Sudan communities affected by conflict and displacement.',
                'meta_keywords' => ['mental health', 'psychological support', 'South Sudan', 'resilience', 'wellness'],
            ],
            [
                'title' => 'Clean Water and Hygiene Promotion',
                'slug' => 'clean-water-hygiene-promotion',
                'description' => 'A comprehensive WASH campaign promoting access to clean water, proper sanitation, and hygiene practices to prevent waterborne diseases. The campaign combines infrastructure support with behavioral change communication to create lasting improvements in community health outcomes.',
                'objectives' => '1. Rehabilitate 20 boreholes in underserved communities. 2. Distribute 5,000 household water treatment kits. 3. Train 150 WASH committee members. 4. Reach 200,000 people with hygiene messaging. 5. Reduce diarrheal disease incidence by 25% in target communities.',
                'target_audience' => 'Rural communities, schools, health facilities, households, women and children, community leaders',
                'regions' => ['Jonglei', 'Unity', 'Upper Nile', 'Warrap', 'Lakes'],
                'status' => 'active',
                'is_featured' => false,
                'start_date' => $now->copy()->subMonths(7)->format('Y-m-d'),
                'end_date' => $now->copy()->addMonths(5)->format('Y-m-d'),
                'meta_title' => 'Clean Water and Hygiene Promotion | SSHIA',
                'meta_description' => 'Improving water, sanitation, and hygiene in South Sudan to prevent disease and save lives.',
                'meta_keywords' => ['clean water', 'sanitation', 'hygiene', 'WASH', 'South Sudan'],
            ],
            [
                'title' => 'Nutrition Security for Mothers and Children',
                'slug' => 'nutrition-security-mothers-children',
                'description' => 'Addressing malnutrition among the most vulnerable populations in South Sudan. This campaign promotes optimal infant and young child feeding practices, supports breastfeeding mothers, and provides nutrition education to families. We work to reduce stunting, wasting, and micronutrient deficiencies through community-based interventions.',
                'objectives' => '1. Reduce childhood stunting by 10% in target areas. 2. Support 5,000 breastfeeding mothers through peer counseling. 3. Establish 50 community nutrition gardens. 4. Train 200 nutrition volunteers. 5. Increase exclusive breastfeeding rates to 70%.',
                'target_audience' => 'Pregnant and lactating women, mothers of children under 5, caregivers, community health workers, traditional leaders',
                'regions' => ['Northern Bahr el Ghazal', 'Warrap', 'Unity', 'Jonglei'],
                'status' => 'active',
                'is_featured' => false,
                'start_date' => $now->copy()->subMonths(6)->format('Y-m-d'),
                'end_date' => $now->copy()->addMonths(6)->format('Y-m-d'),
                'meta_title' => 'Nutrition Security for Mothers and Children | SSHIA',
                'meta_description' => 'Fighting malnutrition in South Sudan through nutrition education and support for mothers and children.',
                'meta_keywords' => ['nutrition', 'malnutrition', 'breastfeeding', 'children', 'South Sudan'],
            ],
            [
                'title' => 'GBV Prevention and Response',
                'slug' => 'gbv-prevention-response',
                'description' => 'A multi-faceted campaign addressing gender-based violence through prevention, survivor support, and community mobilization. We work to change harmful social norms, strengthen support services, and empower women and girls. The campaign engages men and boys as allies in preventing violence and promoting gender equality.',
                'objectives' => '1. Train 100 GBV response counselors. 2. Establish 15 safe spaces for women and girls. 3. Engage 500 men and boys as GBV prevention advocates. 4. Provide support services to 2,000 survivors. 5. Increase reporting of GBV cases by 30% through awareness.',
                'target_audience' => 'Women and girls, survivors of GBV, men and boys, community leaders, healthcare workers, police and legal professionals',
                'regions' => ['Juba', 'Bentiu', 'Malakal', 'Wau', 'Yambio', 'Rumbek'],
                'status' => 'active',
                'is_featured' => false,
                'start_date' => $now->copy()->subMonths(4)->format('Y-m-d'),
                'end_date' => $now->copy()->addMonths(8)->format('Y-m-d'),
                'meta_title' => 'GBV Prevention and Response | SSHIA',
                'meta_description' => 'Working to prevent gender-based violence and support survivors in South Sudan communities.',
                'meta_keywords' => ['GBV', 'gender-based violence', 'women', 'prevention', 'South Sudan'],
            ],
            [
                'title' => 'HIV/AIDS Awareness and Testing',
                'slug' => 'hiv-aids-awareness-testing',
                'description' => 'Promoting HIV awareness, testing, and treatment in South Sudan. This campaign works to reduce new infections, combat stigma and discrimination, and ensure people living with HIV have access to treatment and support services. We emphasize youth-friendly approaches and community-based testing.',
                'objectives' => '1. Test 50,000 people for HIV. 2. Increase ART enrollment by 25%. 3. Train 200 peer educators. 4. Reduce HIV-related stigma by 30%. 5. Achieve 90-90-90 targets in pilot communities.',
                'target_audience' => 'Youth aged 15-35, pregnant women, key populations, general population, healthcare workers',
                'regions' => ['Central Equatoria', 'Western Equatoria', 'Eastern Equatoria', 'Jonglei', 'Lakes'],
                'status' => 'active',
                'is_featured' => false,
                'start_date' => $now->copy()->subMonths(5)->format('Y-m-d'),
                'end_date' => $now->copy()->addMonths(7)->format('Y-m-d'),
                'meta_title' => 'HIV/AIDS Awareness Campaign | SSHIA',
                'meta_description' => 'Know your status. Get tested. Support available. Join SSHIA\'s HIV awareness and testing campaign.',
                'meta_keywords' => ['HIV', 'AIDS', 'testing', 'awareness', 'South Sudan'],
            ],
            [
                'title' => 'Non-Communicable Disease Prevention',
                'slug' => 'ncd-prevention-campaign',
                'description' => 'Addressing the growing burden of non-communicable diseases in South Sudan through prevention, early detection, and management. This campaign focuses on lifestyle modifications, screening programs, and health system strengthening for NCD care. We target diabetes, hypertension, and cardiovascular diseases.',
                'objectives' => '1. Screen 20,000 people for diabetes and hypertension. 2. Train 100 healthcare workers on NCD management. 3. Develop national NCD guidelines. 4. Establish 10 NCD clinics in primary healthcare centers. 5. Reduce NCD risk factors through community education.',
                'target_audience' => 'Adults over 30 years, healthcare workers, urban populations, government employees, teachers',
                'regions' => ['Juba', 'Wau', 'Malakal', 'Yei', 'Rumbek'],
                'status' => 'active',
                'is_featured' => false,
                'start_date' => $now->copy()->subMonths(2)->format('Y-m-d'),
                'end_date' => $now->copy()->addMonths(10)->format('Y-m-d'),
                'meta_title' => 'NCD Prevention Campaign | SSHIA',
                'meta_description' => 'Preventing diabetes, hypertension, and heart disease in South Sudan through lifestyle changes and early detection.',
                'meta_keywords' => ['NCD', 'diabetes', 'hypertension', 'prevention', 'South Sudan'],
            ],
            [
                'title' => 'School Health Program',
                'slug' => 'school-health-program',
                'description' => 'Promoting health in schools across South Sudan. This comprehensive program addresses school-based health services, health education, and creating healthy school environments. We partner with the Ministry of Education to integrate health into the school curriculum and establish school health clubs.',
                'objectives' => '1. Establish health clubs in 200 schools. 2. Train 500 teachers as health educators. 3. Provide health screenings for 50,000 students. 4. Install handwashing stations in 150 schools. 5. Integrate health education into the national curriculum.',
                'target_audience' => 'Primary and secondary school students, teachers, school administrators, parents, education officials',
                'regions' => ['Central Equatoria', 'Eastern Equatoria', 'Western Equatoria', 'Northern Bahr el Ghazal', 'Western Bahr el Ghazal'],
                'status' => 'active',
                'is_featured' => false,
                'start_date' => $now->copy()->subMonth()->format('Y-m-d'),
                'end_date' => $now->copy()->addYear()->format('Y-m-d'),
                'meta_title' => 'School Health Program | SSHIA',
                'meta_description' => 'Building healthy schools and healthy futures for South Sudan\'s children through comprehensive school health programs.',
                'meta_keywords' => ['school health', 'children', 'education', 'health promotion', 'South Sudan'],
            ],
            [
                'title' => 'Community Health Worker Recognition',
                'slug' => 'chw-recognition-campaign',
                'description' => 'Celebrating and supporting Community Health Workers who serve as the backbone of healthcare delivery in South Sudan. This campaign highlights CHW contributions, advocates for improved working conditions, and provides ongoing professional development opportunities. We work to strengthen the CHW program nationally.',
                'objectives' => '1. Recognize 500 outstanding CHWs with awards. 2. Advocate for CHW salary integration into government payroll. 3. Provide refresher training for 2,000 CHWs. 4. Develop career pathway framework for CHWs. 5. Establish CHW support networks in all states.',
                'target_audience' => 'Community health workers, health administrators, policymakers, community members, donor organizations',
                'regions' => ['All 10 States', 'Administrative Areas'],
                'status' => 'active',
                'is_featured' => false,
                'start_date' => $now->copy()->subMonths(3)->format('Y-m-d'),
                'end_date' => $now->copy()->addMonths(9)->format('Y-m-d'),
                'meta_title' => 'CHW Recognition Campaign | SSHIA',
                'meta_description' => 'Honoring the heroes of community health in South Sudan - our dedicated Community Health Workers.',
                'meta_keywords' => ['community health workers', 'CHW', 'healthcare heroes', 'South Sudan', 'recognition'],
            ],
        ];

        foreach ($campaignData as $data) {
            $campaign = RCampaign::firstOrCreate(
                ['slug' => $data['slug']],
                array_merge($data, [
                    'user_id' => $authorId,
                    'views_count' => rand(100, 5000),
                    'stories_count' => rand(5, 20),
                    'created_at' => $now->copy()->subDays(rand(10, 180)),
                    'updated_at' => $now,
                ])
            );
            $campaigns[] = $campaign;
        }

        return $campaigns;
    }

    /**
     * Create health stories.
     */
    protected function createHealthStories(array $campaigns, int $authorId, $now): void
    {
        $stories = [
            [
                'title' => 'How Mobile Health Alerts Saved My Pregnancy',
                'slug' => 'mobile-health-alerts-saved-pregnancy',
                'excerpt' => 'Mary\'s story of how digital health notifications helped her identify warning signs and seek timely medical care during her pregnancy in rural Jonglei.',
                'content' => '<p>Mary Akol, a 28-year-old mother from Bor, Jonglei State, never imagined that a simple mobile phone could save her life and that of her unborn child. Living in a remote village where the nearest health facility is a three-hour walk, Mary had experienced complications in her previous pregnancy that resulted in a stillbirth.</p><p>When she became pregnant again, a community health worker enrolled her in SSHIA\'s maternal health messaging program. "Every week, I received messages about what to expect during my pregnancy," Mary recalls. "One message talked about warning signs like severe headache and blurred vision."</p><p>In her seventh month, Mary began experiencing exactly those symptoms. Remembering the message, she immediately contacted the community health worker, who arranged emergency transport to Bor State Hospital. Mary was diagnosed with preeclampsia, a condition that could have been fatal without timely intervention.</p><p>"The doctors said if I had come even one day later, both my baby and I could have died," Mary shares. Her daughter, named Amal meaning "hope," was born healthy after Mary received emergency treatment.</p><p>Today, Mary is a vocal advocate for the mobile health program in her community. She shares her story with other pregnant women, encouraging them to enroll in the messaging service. "Knowledge saved my life," she says. "I want every woman to have access to this information."</p>',
                'location' => 'Bor, Jonglei State',
                'campaign_id' => 1, // Maternal Health
                'status' => 'published',
                'is_featured' => true,
                'author_name' => 'Mary Akol',
                'published_at' => $now->copy()->subMonth(),
            ],
            [
                'title' => 'Youth Digital Health Ambassadors Making a Difference',
                'slug' => 'youth-digital-health-ambassadors',
                'excerpt' => 'A group of university students in Juba are using social media to combat health misinformation and promote accurate health information among their peers.',
                'content' => '<p>In a small office at the University of Juba, a group of energetic young people gather around smartphones and laptops, crafting health messages that will reach thousands of their peers across South Sudan. They are the Digital Health Ambassadors, trained through SSHIA\'s youth health literacy program.</p><p>"Before the training, I used to share health information without verifying it," admits 22-year-old James Deng, a third-year student. "I didn\'t realize how dangerous misinformation can be. Now, I always fact-check before sharing anything about health."</p><p>The ambassadors have created a popular WhatsApp group with over 2,000 members where they share verified health tips, debunk myths, and answer questions from peers. They also run a Facebook page that reaches an estimated 50,000 young people monthly with engaging health content.</p><p>One of their most successful campaigns addressed COVID-19 vaccine hesitancy. "We created short videos featuring young people explaining why they chose to get vaccinated," explains Grace Loki, another ambassador. "The videos were shared widely, and many young people told us they decided to get vaccinated after watching."</p><p>The group has also addressed sensitive topics like mental health and reproductive health, breaking taboos through open, youth-friendly discussions. Their approach has earned recognition from the Ministry of Health, which now partners with them to disseminate health information to young people.</p><p>"We are not just consumers of health information anymore," says James. "We are creators and fact-checkers. That\'s empowering."</p>',
                'location' => 'Juba, Central Equatoria',
                'campaign_id' => 2, // Digital Health Literacy
                'status' => 'published',
                'is_featured' => true,
                'author_name' => 'James Deng',
                'published_at' => $now->copy()->subWeeks(3),
            ],
            [
                'title' => 'From Skeptic to Advocate: A Mother\'s Immunization Journey',
                'slug' => 'mother-immunization-journey-skeptic-advocate',
                'excerpt' => 'Rebecca\'s transformation from vaccine-hesitant mother to community immunization champion shows the power of education and trust-building.',
                'content' => '<p>When community health workers first approached Rebecca William about vaccinating her children, she firmly refused. Like many mothers in her community in Yei, Rebecca had heard stories about vaccines causing harm. "People said vaccines were a way to control our population," she recalls. "I was scared for my children."</p><p>It took months of patient conversations with Sister Anna, a trusted local health worker, to change Rebecca\'s mind. "Sister Anna didn\'t judge me or force me," Rebecca says. "She answered all my questions, and she brought another mother whose children were vaccinated to talk to me."</p><p>What finally convinced Rebecca was seeing her neighbor\'s children - all vaccinated - growing up healthy while unvaccinated children in the community were frequently sick with preventable diseases. "I realized the stories I heard were not true," she admits. "The evidence was right in front of me."</p><p>Rebecca took all four of her children for vaccination. When her youngest daughter nearly died from measles during an outbreak, the child recovered quickly because she had been vaccinated. "The doctor said if she hadn\'t been vaccinated, she wouldn\'t have made it," Rebecca says with emotion.</p><p>Today, Rebecca is one of the most vocal immunization advocates in Yei. She accompanies health workers on community visits, sharing her story with hesitant mothers. "I tell them, I was like you. I understand your fears. But look at my children - they are healthy because of vaccines."</p><p>Her efforts have contributed to a significant increase in immunization coverage in her community. Health workers estimate that Rebecca has personally convinced over 50 mothers to vaccinate their children.</p>',
                'location' => 'Yei, Central Equatoria',
                'campaign_id' => 4, // Immunization
                'status' => 'published',
                'is_featured' => true,
                'author_name' => 'Rebecca William',
                'published_at' => $now->copy()->subWeeks(2),
            ],
            [
                'title' => 'Community Radio Saves Lives During Malaria Season',
                'slug' => 'community-radio-saves-lives-malaria',
                'excerpt' => 'A local radio station in Aweil partnered with SSHIA to broadcast malaria prevention messages, resulting in dramatic improvements in health outcomes.',
                'content' => '<p>Every Saturday evening, families across Northern Bahr el Ghazal tune their radios to Aweil Community Radio for "Health Hour," a popular program that has become essential listening during malaria season. The program, supported by SSHIA\'s malaria prevention campaign, has transformed how communities in the region prevent and respond to malaria.</p><p>Presenter Santino Arop starts each show with a catchy jingle about sleeping under mosquito nets. Then he takes calls from listeners, answering their questions about malaria symptoms, treatment, and prevention. "When we started, most callers didn\'t know that malaria is spread by mosquitoes," Santino says. "Now they ask specific questions about net maintenance and early treatment."</p><p>The program\'s impact is visible in local health facilities. Dr. Nyibol Akol at Aweil Hospital notes, "Since the radio program started, we\'ve seen a 40% reduction in severe malaria cases. Patients are coming earlier, and more families are using bed nets correctly."</p><p>One memorable segment featured a mother who saved her child\'s life by recognizing danger signs she learned from the radio program. "The child had high fever and was convulsing," the mother testified on air. "Because of what I heard on the radio, I rushed him to the health center immediately instead of waiting for traditional treatment."</p><p>The program also conducts weekly quizzes with prizes of insecticide-treated bed nets and malaria treatment vouchers. These incentives have increased listenership and knowledge retention. A recent survey showed that 78% of regular listeners could correctly identify at least three malaria prevention methods.</p>',
                'location' => 'Aweil, Northern Bahr el Ghazal',
                'campaign_id' => 3, // Malaria
                'status' => 'published',
                'is_featured' => false,
                'author_name' => 'Santino Arop',
                'published_at' => $now->copy()->subWeeks(4),
            ],
            [
                'title' => 'Finding Hope: A Survivor\'s Mental Health Journey',
                'slug' => 'finding-hope-survivor-mental-health-journey',
                'excerpt' => 'After years of struggling with trauma from conflict, Martha found healing through SSHIA\'s community mental health support program.',
                'content' => '<p>Martha Nyandeng, 35, spent years silently suffering from the psychological wounds of conflict. Displaced multiple times from her home in Unity State, she lost family members, witnessed violence, and lived in constant fear. When she finally settled in a displacement camp in Bentiu, the nightmares were unrelenting.</p><p>"I couldn\'t sleep. I couldn\'t eat. I was always afraid," Martha recalls. "People told me to be strong, to forget the past. But I couldn\'t. I thought I was losing my mind."</p><p>A community mental health facilitator trained by SSHIA noticed Martha\'s distress and gently approached her. Through regular home visits and participation in a women\'s support group, Martha began her journey to recovery.</p><p>"The first time I shared my story with other women, I cried for hours," Martha says. "But they understood. They had similar experiences. I didn\'t feel alone anymore."</p><p>Martha learned coping techniques including breathing exercises, grounding techniques for panic attacks, and ways to manage her anxiety. She also found purpose in supporting other women in the camp who were struggling.</p><p>"I realized my pain could become my strength," she reflects. "When I help another woman who is suffering, I heal a little more too."</p><p>Today, Martha is a trained peer counselor herself. She facilitates support groups and makes home visits to women in crisis. Her own transformation - from isolated sufferer to community healer - inspires others to seek help.</p><p>"Mental health problems are not a weakness," Martha emphasizes. "They are wounds that need care, just like physical wounds. I want every woman to know that healing is possible."</p>',
                'location' => 'Bentiu, Unity State',
                'campaign_id' => 5, // Mental Health
                'status' => 'published',
                'is_featured' => true,
                'author_name' => 'Martha Nyandeng',
                'published_at' => $now->copy()->subWeeks(2),
            ],
            [
                'title' => 'A Village Transformed: Clean Water Brings Health',
                'slug' => 'village-transformed-clean-water-health',
                'excerpt' => 'The rehabilitation of a borehole in Warrap State dramatically reduced waterborne diseases and transformed community health practices.',
                'content' => '<p>For years, the community of Mayen Abun in Warrap State relied on a stagnant pond for their water needs. Children suffered constant diarrhea, and cholera outbreaks were common during the rainy season. When SSHIA\'s WASH team arrived to rehabilitate the village\'s broken borehole, everything changed.</p><p>"Before the borehole was fixed, we had no choice but to drink dirty water," says village chief Deng Akok. "Our children were always sick. We spent all our money on medicine."</p><p>The project went beyond just repairing the borehole. SSHIA established a water management committee, trained community members on maintenance, and conducted hygiene education sessions. Each household received a water treatment kit and training on proper water storage.</p><p>The results were immediate and dramatic. Within three months, diarrhea cases among children under five dropped by 75%. School attendance improved as children were no longer frequently sick. Women, who previously spent hours walking to the pond, now had more time for income-generating activities and family care.</p><p>"My children used to be sick almost every week," says mother of five Adut Ngor. "Now they are healthy. They go to school regularly. I never knew clean water could make such a difference."</p><p>The community has embraced new hygiene practices. Handwashing stations have been installed near the borehole, and families have constructed pit latrines with guidance from SSHIA trainers. The village has become a model for neighboring communities, who visit to learn about their transformation.</p>',
                'location' => 'Mayen Abun, Warrap State',
                'campaign_id' => 6, // WASH
                'status' => 'published',
                'is_featured' => false,
                'author_name' => 'Deng Akok',
                'published_at' => $now->copy()->subWeeks(3),
            ],
            [
                'title' => 'Breastfeeding Support Group Changes Lives',
                'slug' => 'breastfeeding-support-group-changes-lives',
                'excerpt' => 'A peer support group in Unity State is helping mothers overcome breastfeeding challenges and improve their babies\' nutrition.',
                'content' => '<p>When Nyanut Kuol gave birth to her first child, she struggled to breastfeed. Like many new mothers, she faced challenges with latching and worried her baby wasn\'t getting enough milk. In her community, traditional advice often discouraged exclusive breastfeeding, and many women introduced other foods within the first few weeks.</p><p>"My mother-in-law told me to give the baby water and animal milk," Nyanut recalls. "She said my milk wasn\'t enough. I was confused and worried."</p><p>A community nutrition volunteer visited Nyanut and invited her to the newly formed breastfeeding support group. There, Nyanut met other mothers facing similar challenges and learned about the benefits of exclusive breastfeeding for the first six months.</p><p>"The volunteer showed me how to help my baby latch properly," Nyanut says. "She explained that babies don\'t need water - breast milk has everything they need. I learned to tell when my baby was getting enough milk."</p><p>The support group meets weekly, providing a space for mothers to share experiences, ask questions, and receive encouragement. Peer counselors who have successfully breastfed provide guidance and support to new mothers.</p><p>Nyanut\'s daughter, now eight months old, is thriving. "She has never been sick, not even once," Nyanut says proudly. "She is growing well, and the health workers say she is very healthy."</p><p>Nyanut has become a peer counselor herself, helping other mothers navigate breastfeeding challenges. She visits pregnant women to prepare them for breastfeeding before their babies arrive. "I want every mother to know that she can breastfeed successfully with the right support," she says.</p>',
                'location' => 'Unity State',
                'campaign_id' => 7, // Nutrition
                'status' => 'published',
                'is_featured' => false,
                'author_name' => 'Nyanut Kuol',
                'published_at' => $now->copy()->subWeeks(5),
            ],
            [
                'title' => 'Breaking the Silence on Gender-Based Violence',
                'slug' => 'breaking-silence-gender-based-violence',
                'excerpt' => 'A women\'s safe space in Juba provides survivors with counseling, legal support, and a path to healing and empowerment.',
                'content' => '<p>At a modest building in Juba, women gather daily for counseling sessions, vocational training, and mutual support. This is one of SSHIA\'s safe spaces for survivors of gender-based violence, providing a refuge where women can heal and rebuild their lives.</p><p>Anna, 28, came to the safe space six months ago after escaping an abusive marriage. "I was married at 16," she shares. "For years, I endured beatings and humiliation. I thought it was normal. I had nowhere to go."</p><p>A neighbor who had received training from SSHIA recognized the signs of abuse and connected Anna with the safe space. There, Anna received counseling, medical care, and temporary accommodation. She also joined a support group with other survivors.</p><p>"The first time I shared my story, I felt a weight lift off me," Anna says. "The counselors helped me understand that the abuse was not my fault. They gave me back my dignity."</p><p>Anna is now learning tailoring skills and plans to start her own business. She has also become an advocate, speaking out against gender-based violence in her community and helping other women access support services.</p><p>"Many women suffer in silence," Anna observes. "They don\'t know there is help available. I want to reach them, to tell them they are not alone."</p><p>The safe space has supported over 500 women since it opened, providing services including legal aid, vocational training, and help with safe housing. Staff work with community leaders to prevent violence and engage men and boys as allies in promoting gender equality.</p>',
                'location' => 'Juba, Central Equatoria',
                'campaign_id' => 8, // GBV
                'status' => 'published',
                'is_featured' => false,
                'author_name' => 'Anna',
                'published_at' => $now->copy()->subWeeks(4),
            ],
            [
                'title' => 'Youth Peer Educators Lead HIV Awareness',
                'slug' => 'youth-peer-educators-hiv-awareness',
                'excerpt' => 'Young people trained as peer educators are changing attitudes about HIV testing and reducing stigma in their communities.',
                'content' => '<p>In Torit, Eastern Equatoria, a group of dynamic young people are transforming how their peers think about HIV. Trained as peer educators through SSHIA\'s HIV awareness campaign, they conduct outreach in schools, markets, and community gathering places, providing accurate information and encouraging testing.</p><p>"Young people don\'t want to listen to older people talk about HIV," says 24-year-old facilitator Omoro James. "But they will listen to their friends. We speak their language, we understand their concerns."</p><p>The peer educators use music, drama, and social media to spread their message. They organize testing events where young people can get tested in a friendly, non-judgmental environment. Since the program began, HIV testing among youth in Torit has increased by 60%.</p><p>One of their most successful initiatives is "Know Your Status" events at secondary schools. These events combine entertainment with education, featuring local musicians and testimonials from young people living with HIV who are thriving on treatment.</p><p>"Before, people thought HIV was a death sentence," Omoro explains. "When they see young people living positively, healthy and happy, it changes everything. They realize HIV is manageable."</p><p>The peer educators also work to combat stigma. "We teach that you can\'t get HIV from sharing food, from hugging, from casual contact," Omoro says. "This simple information helps people support their friends and family members living with HIV instead of rejecting them."</p>',
                'location' => 'Torit, Eastern Equatoria',
                'campaign_id' => 9, // HIV
                'status' => 'published',
                'is_featured' => false,
                'author_name' => 'Omoro James',
                'published_at' => $now->copy()->subWeeks(6),
            ],
            [
                'title' => 'School Health Clubs Promote Wellness',
                'slug' => 'school-health-clubs-promote-wellness',
                'excerpt' => 'Students at Juba Day Secondary School are leading health initiatives through their active health club, creating lasting change in their school community.',
                'content' => '<p>Every Wednesday afternoon, the classroom transforms into a buzzing center of health activity. Students from Juba Day Secondary School\'s health club gather to plan their latest initiatives - from handwashing campaigns to mental health awareness weeks.</p><p>The club, established with support from SSHIA\'s school health program, has become a model for student-led health promotion. Its 45 active members are trained peer educators who lead activities throughout the school year.</p><p>"We used to have a big problem with students not washing hands after using the toilet," says club president Sarah Kiden, 17. "We created a campaign with posters and demonstrations. Now, almost everyone washes their hands."</p><p>The club has installed tippy-taps (simple handwashing stations) throughout the school and monitors their use. They have also addressed issues like substance abuse, teenage pregnancy, and mental health through school-wide assemblies and classroom presentations.</p><p>One of their most impactful initiatives was a mental health awareness week. "We invited counselors to talk about stress and depression," Sarah explains. "Many students came forward to ask for help. The school now has a referral system for students who need support."</p><p>The club\'s efforts have improved overall school attendance and created a more supportive environment. Teachers report fewer discipline problems and improved student wellbeing.</p><p>"Being in the health club has changed me," Sarah reflects. "I think about health in everything I do. I want to become a doctor and continue serving my community."</p>',
                'location' => 'Juba, Central Equatoria',
                'campaign_id' => 11, // School Health
                'status' => 'published',
                'is_featured' => false,
                'author_name' => 'Sarah Kiden',
                'published_at' => $now->copy()->subWeeks(3),
            ],
            [
                'title' => 'CHW Hero: Bringing Healthcare to Remote Villages',
                'slug' => 'chw-hero-bringing-healthcare-remote-villages',
                'excerpt' => 'Community Health Worker Taban Peter walks hours each day to bring essential health services to families in remote areas of Eastern Equatoria.',
                'content' => '<p>Before dawn, Taban Peter straps on his backpack filled with medical supplies and begins his daily journey. The 32-year-old community health worker (CHW) serves five remote villages in Eastern Equatoria, providing basic healthcare services to families who would otherwise have no access to medical care.</p><p>"The nearest health facility is four hours away by foot," Taban explains. "For pregnant women, elderly people, and young children, that distance can be deadly. I bring healthcare to them."</p><p>Trained through SSHIA\'s CHW program, Taban provides services including treatment of common illnesses like malaria and diarrhea, antenatal care visits, immunization referrals, and health education. He maintains detailed records of every family in his catchment area, tracking pregnancies, vaccinations, and health conditions.</p><p>His impact is visible in the health outcomes of his communities. In the two years since he began serving these villages, no woman has died in childbirth. Immunization coverage has increased from 20% to 75%. Malaria deaths among children have dropped dramatically.</p><p>"Taban saved my daughter\'s life," says mother Abuko Lojo. "She had high fever and was convulsing. Taban came immediately, gave her treatment, and stayed with us through the night. He carried her to the road when we needed to go to the hospital."</p><p>Despite the challenges - long walks in scorching heat, encounters with wildlife, nights away from his own family - Taban remains dedicated. "This is my calling," he says simply. "My community depends on me."</p><p>Taban was recently recognized as an outstanding CHW by SSHIA, receiving a certificate and equipment to support his work. He hopes his recognition will inspire other young people to become community health workers.</p>',
                'location' => 'Eastern Equatoria',
                'campaign_id' => 12, // CHW Recognition
                'status' => 'published',
                'is_featured' => true,
                'author_name' => 'Taban Peter',
                'published_at' => $now->copy()->subWeek(),
            ],
            [
                'title' => 'Traditional Birth Attendant Transforms into Skilled Birth Companion',
                'slug' => 'traditional-birth-attendant-skilled-companion',
                'excerpt' => 'Mama Angelina, a traditional birth attendant for 30 years, embraced new training to improve maternal outcomes in her community.',
                'content' => '<p>For three decades, Mama Angelina has helped women give birth in her village on the outskirts of Wau. Like many traditional birth attendants (TBAs), she learned her skills from her mother and grandmother, passing down knowledge through generations.</p><p>When SSHIA began training TBAs to become skilled birth companions, some resisted, seeing it as an challenge to their traditional role. Mama Angelina, however, embraced the opportunity to learn.</p><p>"I have always wanted to help women have safe deliveries," she says. "When I learned there were new techniques that could save more lives, I wanted to know them."</p><p>The training taught Mama Angelina to recognize danger signs during pregnancy and labor, when to refer women to health facilities, and how to support facility births while maintaining her cultural role. She learned about hygiene practices that prevent infection and how to help women birth in health facilities while providing the emotional support TBAs traditionally offer.</p><p>"Before the training, I attended all births at home," Mama Angelina explains. "Now, I encourage women to deliver at the health center. I go with them, stay by their side, help them through labor. They have a skilled birth attendant and me - together, we keep them safe."</p><p>Since completing the training, Mama Angelina has supported over 100 facility births. Not a single mother or baby has been lost under her care. She continues to provide prenatal massages, traditional comfort measures, and postpartum support while ensuring women receive skilled medical care during delivery.</p><p>"My grandmother would be proud," Mama Angelina smiles. "I am keeping our traditions while adding new knowledge. This is how we save our women."</p>',
                'location' => 'Wau, Western Bahr el Ghazal',
                'campaign_id' => 1, // Maternal Health
                'status' => 'published',
                'is_featured' => false,
                'author_name' => 'Mama Angelina',
                'published_at' => $now->copy()->subWeeks(2),
            ],
        ];

        foreach ($stories as $story) {
            RHealthStory::firstOrCreate(
                ['slug' => $story['slug']],
                array_merge($story, [
                    'user_id' => $authorId,
                    'views_count' => rand(50, 2000),
                    'shares_count' => rand(10, 200),
                    'moderated_by' => $authorId,
                    'moderated_at' => $story['published_at'],
                    'created_at' => $story['published_at']->copy()->subDays(rand(1, 7)),
                    'updated_at' => $story['published_at'],
                ])
            );
        }
    }

    /**
     * Create polls with options and responses.
     */
    protected function createPolls(array $campaigns, int $authorId, $now): void
    {
        $pollsData = [
            [
                'question' => 'What health topic would you like to learn more about?',
                'description' => 'Help us prioritize our health education content by selecting the topics most important to you and your family.',
                'campaign_id' => null,
                'poll_type' => 'single_choice',
                'options' => [
                    ['text' => 'Maternal and child health', 'color' => '#3B82F6'],
                    ['text' => 'Malaria prevention', 'color' => '#10B981'],
                    ['text' => 'Nutrition and healthy eating', 'color' => '#F59E0B'],
                    ['text' => 'Mental health and wellbeing', 'color' => '#8B5CF6'],
                    ['text' => 'HIV/AIDS awareness', 'color' => '#EF4444'],
                    ['text' => 'Water and hygiene practices', 'color' => '#06B6D4'],
                ],
                'status' => 'active',
                'display_position' => 'sidebar',
            ],
            [
                'question' => 'How do you prefer to receive health information?',
                'description' => 'We want to make health information accessible to everyone. Tell us your preferred channels for receiving health education.',
                'campaign_id' => 2, // Digital Health Literacy
                'poll_type' => 'multiple_choice',
                'max_selections' => 3,
                'options' => [
                    ['text' => 'WhatsApp messages', 'color' => '#25D366'],
                    ['text' => 'Radio programs', 'color' => '#8B5CF6'],
                    ['text' => 'Community health workers', 'color' => '#3B82F6'],
                    ['text' => 'Social media (Facebook, Twitter)', 'color' => '#1877F2'],
                    ['text' => 'Community gatherings', 'color' => '#F59E0B'],
                    ['text' => 'Health facility visits', 'color' => '#10B981'],
                ],
                'status' => 'active',
                'display_position' => 'inline',
            ],
            [
                'question' => 'What barriers prevent you from seeking healthcare?',
                'description' => 'Understanding the challenges you face helps us advocate for better health services. Select all that apply.',
                'campaign_id' => null,
                'poll_type' => 'multiple_choice',
                'max_selections' => 4,
                'options' => [
                    ['text' => 'Distance to health facility', 'color' => '#EF4444'],
                    ['text' => 'Cost of services', 'color' => '#F59E0B'],
                    ['text' => 'Long waiting times', 'color' => '#8B5CF6'],
                    ['text' => 'Lack of medicines', 'color' => '#10B981'],
                    ['text' => 'Cultural barriers', 'color' => '#3B82F6'],
                    ['text' => 'Fear or stigma', 'color' => '#EC4899'],
                    ['text' => 'Poor quality of care', 'color' => '#6B7280'],
                ],
                'status' => 'active',
                'display_position' => 'sidebar',
            ],
            [
                'question' => 'Have you or someone you know experienced mental health challenges?',
                'description' => 'This anonymous poll helps us understand the prevalence of mental health concerns in our communities. Your response is confidential.',
                'campaign_id' => 5, // Mental Health
                'poll_type' => 'single_choice',
                'options' => [
                    ['text' => 'Yes, personally experienced', 'color' => '#3B82F6'],
                    ['text' => 'Yes, a family member', 'color' => '#10B981'],
                    ['text' => 'Yes, a friend or neighbor', 'color' => '#8B5CF6'],
                    ['text' => 'Not that I know of', 'color' => '#6B7280'],
                    ['text' => 'Prefer not to say', 'color' => '#9CA3AF'],
                ],
                'status' => 'active',
                'display_position' => 'modal',
            ],
            [
                'question' => 'How confident are you in identifying malaria symptoms?',
                'description' => 'Early detection of malaria saves lives. Let us know if you need more information about recognizing symptoms.',
                'campaign_id' => 3, // Malaria
                'poll_type' => 'single_choice',
                'options' => [
                    ['text' => 'Very confident', 'color' => '#10B981'],
                    ['text' => 'Somewhat confident', 'color' => '#3B82F6'],
                    ['text' => 'Not very confident', 'color' => '#F59E0B'],
                    ['text' => 'Not confident at all', 'color' => '#EF4444'],
                ],
                'status' => 'active',
                'display_position' => 'sidebar',
            ],
            [
                'question' => 'What services would you like to see at your local health facility?',
                'description' => 'Your input helps us advocate for better health services in your community. Choose up to 3 options.',
                'campaign_id' => null,
                'poll_type' => 'multiple_choice',
                'max_selections' => 3,
                'options' => [
                    ['text' => '24-hour emergency services', 'color' => '#EF4444'],
                    ['text' => 'Maternity services', 'color' => '#EC4899'],
                    ['text' => 'Laboratory services', 'color' => '#3B82F6'],
                    ['text' => 'Pharmacy/medicines', 'color' => '#10B981'],
                    ['text' => 'Mental health support', 'color' => '#8B5CF6'],
                    ['text' => 'Vaccination services', 'color' => '#F59E0B'],
                    ['text' => 'Nutrition counseling', 'color' => '#06B6D4'],
                ],
                'status' => 'active',
                'display_position' => 'inline',
            ],
            [
                'question' => 'Do you sleep under a mosquito net every night?',
                'description' => 'Sleeping under an insecticide-treated net is one of the most effective ways to prevent malaria. Be honest - we want to understand real practices.',
                'campaign_id' => 3, // Malaria
                'poll_type' => 'single_choice',
                'options' => [
                    ['text' => 'Yes, every night', 'color' => '#10B981'],
                    ['text' => 'Most nights', 'color' => '#3B82F6'],
                    ['text' => 'Sometimes', 'color' => '#F59E0B'],
                    ['text' => 'Rarely', 'color' => '#EF4444'],
                    ['text' => 'Never (I don\'t have a net)', 'color' => '#6B7280'],
                ],
                'status' => 'active',
                'display_position' => 'sidebar',
            ],
            [
                'question' => 'How has digital health information helped you?',
                'description' => 'Share your experience with receiving health information through mobile phones and digital platforms.',
                'campaign_id' => 2, // Digital Health Literacy
                'poll_type' => 'multiple_choice',
                'max_selections' => 3,
                'options' => [
                    ['text' => 'Learned to prevent diseases', 'color' => '#10B981'],
                    ['text' => 'Knew when to seek medical help', 'color' => '#3B82F6'],
                    ['text' => 'Shared information with family', 'color' => '#8B5CF6'],
                    ['text' => 'Improved my health practices', 'color' => '#F59E0B'],
                    ['text' => 'Debunked health myths', 'color' => '#EC4899'],
                    ['text' => 'Found nearby health services', 'color' => '#06B6D4'],
                ],
                'status' => 'active',
                'display_position' => 'inline',
            ],
        ];

        foreach ($pollsData as $pollData) {
            $poll = RPoll::create([
                'user_id' => $authorId,
                'campaign_id' => $pollData['campaign_id'],
                'question' => $pollData['question'],
                'description' => $pollData['description'],
                'poll_type' => $pollData['poll_type'],
                'max_selections' => $pollData['max_selections'] ?? 1,
                'allow_other' => false,
                'show_results' => true,
                'results_public' => true,
                'status' => $pollData['status'],
                'display_position' => $pollData['display_position'],
                'total_responses' => 0,
                'starts_at' => $now->copy()->subWeeks(2),
                'ends_at' => $now->copy()->addMonths(3),
                'created_at' => $now->copy()->subWeeks(2),
            ]);

            // Create options
            foreach ($pollData['options'] as $index => $optionData) {
                RPollOption::create([
                    'poll_id' => $poll->id,
                    'option_text' => $optionData['text'],
                    'color' => $optionData['color'],
                    'sort_order' => $index,
                    'votes_count' => 0,
                ]);
            }

            // Add some responses
            $this->addPollResponses($poll);
        }
    }

    /**
     * Add sample poll responses.
     */
    protected function addPollResponses(RPoll $poll): void
    {
        $options = $poll->options;
        $totalResponses = rand(50, 200);
        
        for ($i = 0; $i < $totalResponses; $i++) {
            $selectedOption = $options->random();
            
            RPollResponse::create([
                'poll_id' => $poll->id,
                'option_id' => $selectedOption->id,
                'user_id' => null,
                'respondent_hash' => md5(uniqid() . $i),
                'ip_address' => '192.168.' . rand(0, 255) . '.' . rand(0, 255),
            ]);

            $selectedOption->increment('votes_count');
        }

        $poll->update(['total_responses' => $totalResponses]);
    }
}
