<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;

/**
 * InPractice — Marketing Generic Cases [04/10]
 * Market Research: MG-MR-02 to MG-MR-06
 *
 * Run: php artisan db:seed --class=MarketingGenericCaseSeeder_04
 */
class MarketingGenericCaseSeeder_04 extends Seeder
{
    public function run(): void
    {
        $this->command->info('📢 [04/10] Market Research (2-6) ...');

        $hub   = DB::table('hubs')->where('slug', 'marketing')->first();
        $admin = DB::table('users')->where('role', 'admin')->first();

        if (! $hub || ! $admin) {
            $this->command->error('Hub or admin not found. Run HubSeeder and AdminSeeder first.');
            return;
        }

        $hubId   = $hub->id;
        $adminId = $admin->id;
        $now     = now();


        $cases = [
        
            // ── MG-MR-02 ──────────────────────────────────────────────────
            [
                'topic_slug'    => 'market_research',
                'topic_name_en' => 'Market Research',
                'topic_name_ar' => 'أبحاث السوق',
                'difficulty'    => 'beginner',
                'sort_order'    => 302,
                'read_time_minutes' => 10,
        
                'title_en'    => 'The Competitor You Did Not See Coming',
                'subtitle_en' => 'How to build a competitive intelligence system before you need it',
                'situation_en' => "You are a marketing manager at **Prism Optical**, a chain of 12 optometry clinics across Cairo offering eye exams, prescription glasses, and contact lenses. The business has grown steadily for 8 years on quality service and word-of-mouth.\n\nSix months ago, a new competitor called **LensWorld** opened 4 locations simultaneously in your highest-revenue areas — Maadi, Heliopolis, Zamalek, and New Cairo. LensWorld offers:\n- Same-day glasses (Prism takes 3–5 days)\n- Prices 25% lower across all frames\n- Online booking with 30-minute appointment slots\n- A branded mobile app for prescription management\n\nPrism's revenue is down 19% in the four affected areas. You had no early warning.\n\nThe CEO asks: *'How did we not see this coming — and how do we make sure it never happens again?'*",
                'challenge_questions_en' => json_encode([
                    "What is competitive intelligence and how is it different from market research?",
                    "Looking back, what signals were available 6–12 months before LensWorld opened that Prism could have detected with a basic monitoring system?",
                    "Design a competitive intelligence system for Prism Optical that would give 90-day early warning of any new significant entrant.",
                    "Now that LensWorld is established, design a competitive response strategy — what does Prism do in the next 90 days?",
                ]),
                'solution_en' => "## Competitive Intelligence: Seeing the Market Before It Moves\n\n### What Is Competitive Intelligence?\n\nCompetitive intelligence (CI) is the systematic collection and analysis of publicly available information about competitors, market trends, and industry developments — to inform strategic decisions before situations become crises.\n\nIt is different from market research, which typically studies customers. CI studies competitors and the environment.\n\n### The Signals That Were Available\n\nBefore any new retail chain opens 4 locations simultaneously, there is a trail of signals — all publicly available:\n\n| Signal | Where to Find It | Timeline Before Opening |\n|---|---|---|\n| Commercial lease registrations | Real estate agents, property listing sites | 6–9 months |\n| Trade licence applications | Commercial registry (public record) | 4–6 months |\n| Job listings | LinkedIn, Wuzzuf, Bayt | 3–5 months |\n| Interior fit-out activity | Physical walk-bys of commercial spaces | 1–3 months |\n| Social media account creation | Instagram, Facebook page creation dates | 1–3 months |\n| Google Maps listing registration | Google search | 4–8 weeks |\n\nLensWorld opening 4 locations simultaneously means they signed 4 leases months before opening. A basic monitoring system would have caught this.\n\n### A Competitive Intelligence System for Prism Optical\n\n**Layer 1 — Digital monitoring (automated, weekly)**\n- Google Alerts for: 'optometry Cairo', 'glasses chain Egypt', competitor brand names\n- Monitor job boards (LinkedIn, Wuzzuf) for 'optometrist' and 'optical' job listings in Cairo\n- Monitor Instagram and TikTok for new optical brands gaining followers\n\n**Layer 2 — Physical monitoring (monthly)**\n- Assign one person per district to walk commercial areas and note any fit-out activity in retail spaces suitable for clinics\n- Report any observed optical or healthcare clinic openings\n\n**Layer 3 — Intelligence network (ongoing)**\n- Frame opticians and lens suppliers talk to everyone — they will know before the public does. Build a relationship with 2–3 wholesale suppliers and ask: 'Any new players coming in?'\n- Staff who come from competitor clinics bring valuable intelligence about what competitors are planning\n\n**Layer 4 — Quarterly competitive review**\n- Every 90 days, formally review: competitor pricing, new services, location expansions, social media performance, customer reviews\n- Red flag triggers: any competitor opening 2+ new locations in a quarter\n\n### 90-Day Competitive Response to LensWorld\n\n**Weeks 1–4: Match the most defensible gap**\nSame-day glasses. This is a service gap that directly addresses the most actionable competitive advantage. Identify which lab processes prevent same-day delivery and solve them. Even 'same-day for selected frames' changes the conversation.\n\n**Weeks 5–8: Win on relationship, not price**\nPrism cannot match 25% lower prices without destroying its business model. But Prism has 8 years of patient records, trusted relationships, and deep community presence. Launch a loyalty programme: *'Prism Patients First — free annual eye test for returning patients.'*\n\n**Weeks 9–12: Online booking**\nIf Prism does not have online booking, this is a non-negotiable fix. No customer in 2025 should have to call to book an eye exam. WhatsApp booking is a minimum; a booking link in Google Business Profile is essential.",
        
                'bigger_lesson_en' => "**Competitive intelligence is not a research project — it is an ongoing business habit.**\n\nMarkets move faster than strategic planning cycles. The companies that are never surprised by competitors have built watching the market into their weekly operations — not just their annual strategy reviews. A competitor entering your market should never be a surprise. It should be a confirmation of something you already suspected.",
        
                'skills_taught_en' => json_encode([
                    'Competitive intelligence framework',
                    'Early warning signal monitoring',
                    'Competitive response strategy',
                    'Market monitoring system design',
                    'Competitive gap analysis',
                ]),
        
                'title_ar'    => 'المنافس الذي لم تره قادماً',
                'subtitle_ar' => 'كيف تبني نظام استخبارات تنافسية قبل أن تحتاجه',
                'situation_ar' => "أنت مدير تسويق في **بريزم أوبتيكال**، سلسلة 12 عيادة بصريات في القاهرة. قبل ستة أشهر، فتح منافس جديد اسمه **لينز وورلد** 4 فروع في مناطق إيراداتك الأعلى — المعادي والمطرية والزمالك والقاهرة الجديدة. يقدم:\n- نظارات في نفس اليوم (بريزم تأخذ 3-5 أيام)\n- أسعار أقل 25%\n- حجز أونلاين\n- تطبيق جوال لإدارة الوصفة\n\nإيرادات بريزم انخفضت 19% في المناطق الأربع. لم يكن لديك إنذار مبكر.\n\nيسأل الرئيس: *'كيف لم نرَ هذا قادماً — وكيف نضمن عدم تكراره؟'*",
                'challenge_questions_ar' => json_encode([
                    "ما الاستخبارات التنافسية وكيف تختلف عن أبحاث السوق؟",
                    "بأثر رجعي، ما الإشارات المتاحة قبل 6-12 شهراً من افتتاح لينز وورلد التي كان بإمكان بريزم اكتشافها؟",
                    "صمم نظام استخبارات تنافسية لبريزم أوبتيكال يعطي إنذاراً مبكراً بـ90 يوماً.",
                    "الآن بعد أن استقر لينز وورلد، صمم استراتيجية رد تنافسي — ماذا تفعل بريزم في الـ90 يوماً القادمة؟",
                ]),
                'solution_ar' => "## الاستخبارات التنافسية: رؤية السوق قبل تحركه\n\n### الإشارات التي كانت متاحة\n\n| الإشارة | أين تجدها | الجدول الزمني قبل الافتتاح |\n|---|---|---|\n| تسجيلات الإيجارات التجارية | وكلاء عقارات | 6-9 أشهر |\n| إعلانات التوظيف | LinkedIn، وظف | 3-5 أشهر |\n| نشاط التجهيز الداخلي | جولات ميدانية | 1-3 أشهر |\n| إنشاء حسابات التواصل | إنستغرام، فيسبوك | 1-3 أشهر |\n\n### نظام استخبارات تنافسية لبريزم\n\n**الطبقة 1:** مراقبة رقمية أوتوماتيكية أسبوعية (تنبيهات جوجل، إعلانات وظائف)\n**الطبقة 2:** مراقبة ميدانية شهرية (جولات في المناطق التجارية)\n**الطبقة 3:** شبكة معلومات (علاقات مع موردي العدسات والإطارات)\n**الطبقة 4:** مراجعة تنافسية ربع سنوية رسمية\n\n### رد تنافسي في 90 يوماً\n\nالأسابيع 1-4: نظارات في نفس اليوم للإطارات المختارة\nالأسابيع 5-8: برنامج ولاء (فحص سنوي مجاني للعملاء العائدين)\nالأسابيع 9-12: حجز أونلاين كحد أدنى",
        
                'bigger_lesson_ar' => "**الاستخبارات التنافسية ليست مشروع بحث — بل عادة عمل مستمرة.**\n\nالشركات التي لا يفاجئها المنافسون دمجت مراقبة السوق في عملياتها الأسبوعية لا مجرد مراجعاتها الاستراتيجية السنوية.",
        
                'skills_taught_ar' => json_encode([
                    'إطار الاستخبارات التنافسية',
                    'مراقبة إشارات الإنذار المبكر',
                    'استراتيجية الرد التنافسي',
                    'تصميم نظام مراقبة السوق',
                    'تحليل الفجوة التنافسية',
                ]),
                'created_at' => $now,
                'updated_at' => $now,
            ],
        
            // ── MG-MR-03 ──────────────────────────────────────────────────
            [
                'topic_slug'    => 'market_research',
                'topic_name_en' => 'Market Research',
                'topic_name_ar' => 'أبحاث السوق',
                'difficulty'    => 'intermediate',
                'sort_order'    => 303,
                'read_time_minutes' => 12,
        
                'title_en'    => 'The Market Size That Was Wrong',
                'subtitle_en' => 'How to size a market properly — and why most estimates are dangerously optimistic',
                'situation_en' => "You are a marketing consultant helping **EduTech Nile**, an Egyptian startup preparing to pitch investors for Series A funding. The startup has built an online professional development platform targeting Egyptian white-collar workers.\n\nThe founding team's pitch deck includes this market size claim:\n\n*'Egypt has 6.2 million white-collar workers. If we charge EGP 99/month and capture just 5% of the market, our annual revenue potential is EGP 370 million.'*\n\nThe investor they are pitching — a Cairo-based VC — pushes back immediately:\n\n*'Your market sizing is wrong. 5% of 6.2 million is not your addressable market. Come back when you understand TAM, SAM, and SOM.'*\n\nYou have 48 hours to fix the pitch.",
                'challenge_questions_en' => json_encode([
                    "What is wrong with EduTech Nile's market sizing approach — specifically, why is '5% of all white-collar workers' not a realistic SOM?",
                    "Define TAM, SAM, and SOM and apply each to EduTech Nile's business — with realistic estimates and the logic behind each number.",
                    "The investor said the sizing is 'dangerously optimistic.' What is the risk to a startup of overestimating its addressable market?",
                    "Rebuild the market sizing slide for the pitch deck — with realistic numbers, clear methodology, and the assumptions stated explicitly.",
                ]),
                'solution_en' => "## Market Sizing: TAM, SAM, SOM — The Investor Standard\n\n### What's Wrong with the Original Approach\n\nThe '5% of everyone' approach is called **top-down market sizing with an optimism multiplier** — and experienced investors see through it immediately. The problems:\n\n1. Not all 6.2 million white-collar workers can access or afford a digital subscription\n2. Not all sectors have the same propensity to pay for professional development\n3. The platform cannot simultaneously serve all geographies, sectors, and experience levels in Year 1\n4. 5% sounds conservative but is enormous for an early-stage startup — equivalent to 310,000 paying subscribers\n\n### TAM, SAM, SOM Applied to EduTech Nile\n\n**TAM — Total Addressable Market**\n*'The total market if we had 100% share of everything we could theoretically serve'*\n\nEgypt white-collar workers: 6.2 million\nWith internet access and smartphone: ~4.1 million (66%)\nWith disposable income for subscriptions (EGP 99+/month): ~2.3 million (based on income band data)\n**TAM: 2.3 million people × EGP 1,188/year = EGP 2.73 billion/year**\n\n**SAM — Serviceable Addressable Market**\n*'The segment of TAM we can actually reach with our current product and model'*\n\nEduTech Nile currently offers: Finance and Business courses in Arabic\nTarget profile: Finance/Business professionals, Cairo and Alexandria-based, aged 25–40\nEstimated population matching profile: ~320,000\nWillingness to pay for online professional development (estimated 35%): ~112,000\n**SAM: 112,000 people × EGP 1,188/year = EGP 133 million/year**\n\n**SOM — Serviceable Obtainable Market**\n*'The realistic share we can capture in the next 3 years given our resources and competition'*\n\nYear 1 target: 2,000 subscribers (launch, word-of-mouth, first marketing push)\nYear 2 target: 8,000 subscribers (product-market fit confirmed, growth investment)\nYear 3 target: 22,000 subscribers (15–20% market penetration of engaged SAM)\n**SOM Year 3: 22,000 × EGP 1,188 = EGP 26 million ARR**\n\n### Why Overestimating Market Size Is Dangerous\n\n1. **Investor credibility** — Sophisticated investors know the real market. If the sizing is wrong, they question everything else in the deck.\n2. **Internal planning** — Overestimated TAM leads to overinvestment in supply (too many courses, too many markets) before demand is proven\n3. **Hiring ahead of revenue** — Companies that believe they are in a EGP 370M market hire and spend accordingly — and run out of cash before reaching it\n\n### The Rebuilt Market Sizing Slide\n\n| Metric | Number | Methodology |\n|---|---|---|\n| Egypt white-collar workers | 6.2M | CAPMAS data |\n| Internet + smartphone access | 4.1M | MCIT penetration data |\n| Disposable income for subscriptions | 2.3M | Income band estimates |\n| **TAM** | **EGP 2.73B/year** | Full digitally-accessible market |\n| Finance/Business professionals, urban | 320,000 | Sector employment data |\n| Willing to pay for online development | 112,000 | 35% propensity estimate |\n| **SAM** | **EGP 133M/year** | Current product-addressable segment |\n| Year 3 paying subscribers (target) | 22,000 | 20% of engaged SAM |\n| **SOM Year 3** | **EGP 26M ARR** | Conservative 3-year target |\n\nAssumptions stated explicitly: 35% willingness-to-pay is based on comparable regional markets (Coursera Egypt data, LinkedIn Learning penetration). This will be validated with a 500-person pricing survey before Series A closes.",
        
                'bigger_lesson_en' => "**TAM is where you dream. SAM is where you plan. SOM is where you actually operate.**\n\nEvery founder believes they are in a massive market. Investors have heard this a thousand times. The founders who earn investment are those who can draw a credible line from 'this is how big the world is' to 'this is the specific, reachable slice we are going after first — and here is exactly how we will get there.'",
        
                'skills_taught_en' => json_encode([
                    'TAM/SAM/SOM market sizing framework',
                    'Bottom-up vs. top-down market sizing',
                    'Investor-grade market analysis',
                    'Market sizing assumptions and transparency',
                    'Realistic growth target setting',
                ]),

                'skills_taught_ar' => json_encode([
                    'إطار تحجيم السوق TAM/SAM/SOM',
                    'التحجيم من أعلى لأسفل مقابل من أسفل لأعلى',
                    'تحليل السوق بمستوى المستثمر',
                    'افتراضات تحجيم السوق والشفافية',
                    'تحديد أهداف النمو الواقعية',
                ]),

                'title_ar' => 'حجم السوق الخاطئ',
                'subtitle_ar' => 'كيف تقيس السوق بشكل صحيح — ولماذا معظم التقديرات متفائلة بشكل خطر',
                'situation_ar' => "أنت مستشار تسويق تساعد **إيدوتك نايل**، ناشئة مصرية تُعدّ لعرض المستثمرين للجولة A. بنت المنصة منصة تطوير مهني أونلاين تستهدف الموظفين ذوي الياقات البيضاء.\n\nادعاء حجم السوق في العرض:\n*'مصر لديها 6.2 مليون موظف ياقة بيضاء. إذا فرضنا 99 جنيه/شهر واستحوذنا على 5% فقط، العائد السنوي المحتمل 370 مليون جنيه.'*\n\nالمستثمر يرفض فوراً:\n*'تحجيم سوقكم خاطئ. 5% من 6.2 مليون ليس سوقكم القابل للخدمة. عودوا حين تفهمون TAM وSAM وSOM.'*",
                'challenge_questions_ar' => json_encode([
                    "ما الخطأ في نهج إيدوتك نايل في تحجيم السوق — لماذا '5% من جميع ياقات البيضاء' ليس SOM واقعياً؟",
                    "عرّف TAM وSAM وSOM وطبق كل منها على إيدوتك نايل — بتقديرات واقعية والمنطق وراء كل رقم.",
                    "قال المستثمر إن التحجيم 'متفائل بشكل خطر'. ما خطر المبالغة في تقدير السوق القابل للاستهداف على ناشئة؟",
                    "أعد بناء شريحة تحجيم السوق للعرض — بأرقام واقعية ومنهجية واضحة وافتراضات مُصرَّح بها.",
                ]),
                'solution_ar' => "## تحجيم السوق: TAM وSAM وSOM — المعيار الاستثماري\n\n| المقياس | الرقم | المنهجية |\n|---|---|---|\n| **TAM** | **2.73 مليار جنيه/سنة** | السوق الرقمي الكامل |\n| **SAM** | **133 مليون جنيه/سنة** | متخصصو المال والأعمال الحضريون |\n| **SOM السنة 3** | **26 مليون جنيه ARR** | 22,000 مشترك (20% من SAM المتفاعل) |\n\n### لماذا المبالغة في تقدير حجم السوق خطيرة\n\n1. **مصداقية المستثمر** — المستثمرون المتمرسون يعرفون السوق الحقيقي\n2. **التخطيط الداخلي** — يؤدي للاستثمار الزائد في العرض قبل إثبات الطلب\n3. **التوظيف قبل الإيرادات** — الشركات المؤمنة بسوق ضخم تنفق وفقاً لذلك وتنفد السيولة",
        
                'bigger_lesson_ar' => "**TAM حيث تحلم. SAM حيث تخطط. SOM حيث تعمل فعلاً.**\n\nكل مؤسس يؤمن بأنه في سوق ضخم. المؤسسون الذين يكسبون الاستثمار هم من يستطيعون رسم خط موثوق من 'هذا حجم العالم' إلى 'هذه الشريحة المحددة القابلة للوصول التي نستهدفها أولاً — وهذه تحديداً طريقة وصولنا.'",
        
                'skills_taught_ar' => json_encode([
                    'إطار تحجيم السوق TAM/SAM/SOM',
                    'التحجيم من أعلى لأسفل مقابل من أسفل لأعلى',
                    'تحليل السوق بمستوى المستثمر',
                    'افتراضات تحجيم السوق والشفافية',
                    'تحديد أهداف النمو الواقعية',
                ]),
                'created_at' => $now,
                'updated_at' => $now,
            ],
        
            // ── MG-MR-04 ──────────────────────────────────────────────────
            [
                'topic_slug'    => 'market_research',
                'topic_name_en' => 'Market Research',
                'topic_name_ar' => 'أبحاث السوق',
                'difficulty'    => 'intermediate',
                'sort_order'    => 304,
                'read_time_minutes' => 11,
        
                'title_en'    => 'The Focus Group That Killed the Right Product',
                'subtitle_en' => 'Why qualitative research must be interpreted — not just believed',
                'situation_en' => "You are a brand manager at **Sunrise Beverages**, an Egyptian drinks company. You have developed a sparkling water product with a subtle hibiscus flavour — a first for the Egyptian market. Before launch, your team ran 3 focus groups in Cairo (n=24 total participants).\n\nFocus group findings:\n- Participants described the concept as 'nice but unusual'\n- 14 of 24 said they 'probably would not buy it regularly'\n- Several said: 'Egyptians don't drink sparkling water'\n- The moderator's report concluded: 'Weak concept. Low purchase intent. Not recommended for launch.'\n\nBased on this, your manager wants to kill the product.\n\nYou are not sure. You have seen hibiscus sparkling water sell well in Beirut and Dubai. You suspect the focus groups measured unfamiliarity, not rejection.\n\nYou have 2 weeks and EGP 40,000 to either confirm the kill decision or make the case for a test launch.",
                'challenge_questions_en' => json_encode([
                    "What are the known limitations of focus groups — and which of those limitations are most likely affecting these results?",
                    "What is the difference between 'I don't like this' and 'I am unfamiliar with this' — and how can research tell the difference?",
                    "Design a 2-week, EGP 40,000 research plan that would give you a more commercially reliable answer about this product's potential.",
                    "If the quantitative test shows 28% purchase intent among young urban consumers, should you recommend a test launch? What conditions would you attach to the recommendation?",
                ]),
                'solution_en' => "## Focus Groups: A Powerful Tool With Serious Limitations\n\n### The Known Limitations Affecting These Results\n\n**Limitation 1 — Social conformity in groups**\nFocus groups are social environments. When one strong personality says 'Egyptians don't drink sparkling water,' others moderate their own positive responses to conform. Research consistently shows that group dynamics suppress positive sentiment for unfamiliar innovations.\n\n**Limitation 2 — Unfamiliarity ≠ rejection**\nWhen consumers encounter a product they have never seen before, their initial response is often cautious or negative — not because they don't like it, but because they have no mental reference for it. The same consumers may become enthusiastic adopters after trial.\n\n**Limitation 3 — Small sample, wrong sample**\nN=24 across 3 groups is too small to be statistically meaningful for a launch decision. More critically: who were these 24 people? If they skewed older or outside the urban-young demographic, they are not the right respondents for a product targeting young, cosmopolitan Egyptians.\n\n**Limitation 4 — Concept testing without trial**\nPeople respond to descriptions of new products very differently from how they respond to the actual product. Sparkling water is a sensory experience — assessing it from a concept description is like assessing a perfume from its name.\n\n### 'I Don't Like This' vs. 'I Am Unfamiliar With This'\n\nThe tell-tale signs of unfamiliarity (not rejection):\n- Comments about 'Egyptians don't do this' (cultural generalisation, not personal preference)\n- No specific negative attribute mentioned (taste, price, packaging) — just vague discomfort\n- Comparisons to products they are familiar with that are adjacent\n\nThe tell-tale signs of genuine rejection:\n- Specific negative attributes: 'the flavour is too strong,' 'the carbonation is too harsh'\n- Strong emotional response: disgust, not just confusion\n- Consistent across all segments and demographics\n\n### A 2-Week EGP 40,000 Research Plan\n\n**Week 1 — In-store tasting trial (EGP 20,000)**\nSet up sampling stations in 5 locations: a Carrefour, a premium café, a pharmacy in Zamalek, a gym, and a university campus. Target: 400 taste tests.\n- After each taste: 5-question survey (taste rating, purchase intent, price acceptance, frequency intention)\n- This is revealed preference, not stated preference — they have tasted the real product\n\n**Week 2 — Online quantitative survey (EGP 12,000)**\nTarget: 300 urban Egyptians aged 22–38, smartphone users, ABC+ socioeconomic group\n- Show product concept (with hibiscus flavour and packaging)\n- Measure: purchase intent, price sensitivity, consumption occasion fit\n- Include photos of the product — not just a description\n\n**Remaining EGP 8,000 — Competitor benchmarking**\nAnalyse how imported sparkling waters (Perrier, San Pellegrino) perform in premium Egyptian retail. If they sell, there is a market for sparkling water — the question is whether a local hibiscus variant can claim a share.\n\n### The Test Launch Recommendation Framework\n\nIf results show 28% purchase intent among target segment:\n- 28% purchase intent = strong for a new-to-market product category (category innovation benchmarks 20–35%)\n- **Recommended: limited test launch with these conditions:**\n  1. Test in 3 premium modern trade accounts (Carrefour, Spinneys, Gourmet) for 90 days\n  2. Supported by sampling at launch (taste is the primary conversion trigger)\n  3. Clear success metrics: 40%+ repeat rate after trial, 80+ units/store/week by week 8\n  4. If metrics are not met by Day 90, roll back without national commitment",
        
                'bigger_lesson_en' => "**Focus groups are a compass, not a verdict.**\n\nThey tell you what questions to ask next — they do not tell you what to do. For new-to-market innovations especially, qualitative research measures the first impression of the unfamiliar. The only research that measures actual market potential is research that puts the real product in front of real consumers in a real purchase situation.",
        
                'skills_taught_en' => json_encode([
                    'Focus group limitations and interpretation',
                    'Qualitative vs. quantitative research roles',
                    'In-home and in-store product testing',
                    'Unfamiliarity vs. rejection signal differentiation',
                    'Test launch design and success metrics',
                ]),
        
                'title_ar'    => 'مجموعة التركيز التي قتلت المنتج الصحيح',
                'subtitle_ar' => 'لماذا يجب تفسير البحث النوعي لا مجرد تصديقه',
                'situation_ar' => "أنت مدير علامة في **صنرايز للمشروبات**. طورت منتج مياه غازية بنكهة الكركديه الخفيفة — الأول من نوعه في السوق المصرية. قبل الإطلاق، أجرى فريقك 3 مجموعات تركيز في القاهرة (24 مشاركاً إجمالاً).\n\nنتائج مجموعات التركيز:\n- وصف المشاركون المفهوم بـ'لطيف لكن غير مألوف'\n- 14 من 24 قالوا إنهم 'على الأرجح لن يشتروه بانتظام'\n- البعض قال: 'المصريون لا يشربون المياه الغازية'\n- خلاصة المشرف: 'مفهوم ضعيف. يُنصح بعدم الإطلاق.'\n\nلديك 2 أسبوع و40,000 جنيه إما لتأكيد قرار الإلغاء أو صنع الحجة للإطلاق التجريبي.",
                'challenge_questions_ar' => json_encode([
                    "ما القيود المعروفة لمجموعات التركيز — وأيها يؤثر على النتائج الحالية على الأرجح؟",
                    "ما الفرق بين 'لا أحب هذا' و'لست مألوفاً بهذا' — وكيف يمكن للبحث التمييز بينهما؟",
                    "صمم خطة بحثية مدتها أسبوعان بـ40,000 جنيه تعطيك إجابة أكثر موثوقية تجارياً عن إمكانية هذا المنتج.",
                    "إذا أظهر الاختبار الكمي نية شراء 28% لدى المستهلكين الشباب الحضريين، هل توصي بإطلاق تجريبي؟",
                ]),
                'solution_ar' => "## مجموعات التركيز: أداة قوية بقيود جدية\n\n### القيود المؤثرة على هذه النتائج\n\n1. **التوافق الاجتماعي في المجموعات** — حين يقول شخصية قوية 'المصريون لا يشربون مياهاً غازية'، يعدّل الآخرون ردود فعلهم الإيجابية\n2. **عدم الألفة ≠ الرفض** — الاستجابة الأولية للمنتج الجديد غالباً حذرة، لا لأنهم لا يحبونه بل لعدم وجود مرجع ذهني\n3. **اختبار المفهوم بلا تجربة** — المياه الغازية تجربة حسية، تقييمها من وصف مثل تقييم عطر من اسمه\n\n### خطة بحث أسبوعان بـ40,000 جنيه\n\n**الأسبوع 1 (20,000 جنيه):** محطات تذوق في 5 مواقع (كارفور، كافيه راقٍ، صيدلية الزمالك، نادي رياضي، حرم جامعي) — 400 اختبار تذوق\n**الأسبوع 2 (12,000 جنيه):** استطلاع كمي أونلاين — 300 مصري حضري 22-38 سنة\n**المتبقي (8,000 جنيه):** تحليل أداء المياه الغازية المستوردة في التجزئة المصرية الراقية",
        
                'bigger_lesson_ar' => "**مجموعات التركيز بوصلة لا حكم.**\n\nتخبرك بما تسأل عنه لاحقاً — لا بما يجب فعله. للابتكارات الجديدة على السوق خاصةً، البحث النوعي يقيس الانطباع الأول عن غير المألوف. البحث الوحيد الذي يقيس الإمكانية الحقيقية هو البحث الذي يضع المنتج الحقيقي أمام مستهلكين حقيقيين في موقف شراء حقيقي.",
        
                'skills_taught_ar' => json_encode([
                    'قيود مجموعات التركيز وتفسيرها',
                    'دور البحث النوعي مقابل الكمي',
                    'اختبار المنتج في المنزل وفي المتجر',
                    'التمييز بين إشارات عدم الألفة والرفض',
                    'تصميم الإطلاق التجريبي ومقاييس النجاح',
                ]),
                'created_at' => $now,
                'updated_at' => $now,
            ],
        
            // ── MG-MR-05 ──────────────────────────────────────────────────
            [
                'topic_slug'    => 'market_research',
                'topic_name_en' => 'Market Research',
                'topic_name_ar' => 'أبحاث السوق',
                'difficulty'    => 'advanced',
                'sort_order'    => 305,
                'read_time_minutes' => 14,
        
                'title_en'    => 'The Segmentation That Changed Everything',
                'subtitle_en' => 'Moving from demographic segments to behavioural segments that actually predict purchase',
                'situation_en' => "You are the head of consumer insights at **Atlas Insurance Egypt**, one of the largest private insurance companies in the country. The company has been marketing car insurance using broad demographic segments:\n\n- Segment A: Males 25–45, high income\n- Segment B: Females 25–40, professional\n- Segment C: Males 45–60, business owners\n\nThis segmentation has driven all creative, media, and pricing strategy for 4 years. But the marketing director is frustrated: *'We're targeting the same people as everyone else and getting the same results as everyone else. Conversion is 2.1% on digital and we cannot improve it.'*\n\nYou propose a behavioural segmentation study. The board approves EGP 280,000 for the research. You have 90 days.",
                'challenge_questions_en' => json_encode([
                    "What is the fundamental limitation of demographic segmentation for a product like car insurance — and why does it fail to predict actual purchase behaviour?",
                    "What is behavioural segmentation and what types of behavioural data would be most predictive for car insurance purchase?",
                    "Design the 90-day research process: what data sources, what methods, and what output do you need to deliver to the marketing director?",
                    "The research identifies 4 behavioural segments with distinct motivations. How do you translate segments into actionable marketing strategies — media, message, and offer — for each?",
                ]),
                'solution_en' => "## Behavioural Segmentation: Moving from Who They Are to Why They Buy\n\n### The Limitation of Demographic Segmentation\n\nDemographics tell you who someone is — age, income, gender. They do not tell you why they buy insurance or what would make them switch providers.\n\nTwo men, both aged 35, both high-income:\n- Man A: Anxious about risks, has children, just bought his first new car — insurance is a priority, he compares carefully and chooses the best coverage\n- Man B: Forced to buy insurance by law, minimally engaged, buys the cheapest option and auto-renews without thinking\n\nIdentical demographic profile. Completely different buyer behaviours. Demographic segmentation cannot tell the difference. It serves them the same ad and wonders why only 2.1% convert.\n\n### Behavioural Segmentation for Insurance\n\nBehavioural segmentation groups people by *what they do* and *why they do it* — not who they are. Key behavioural variables for insurance:\n\n- **Risk attitude** — how concerned are they about financial risk?\n- **Decision-making style** — price-driven vs. coverage-driven vs. brand-driven?\n- **Engagement with insurance** — proactive (researches options) vs. passive (auto-renews)\n- **Life trigger** — what event prompted them to consider insurance? (new car, accident, policy renewal)\n- **Channel preference** — digital-native buyer vs. agent-relationship buyer vs. bank-bundled buyer\n\n### The 90-Day Research Process\n\n**Days 1–30: Data mining + qualitative**\n- Mine existing customer database: claim history, renewal behaviour, policy type chosen, premium paid, acquisition channel — cluster into behavioural patterns\n- 6 depth interviews with recent buyers and 6 with non-converters: understand the actual purchase journey\n\n**Days 31–60: Quantitative validation**\n- Online survey: 800 Egyptian car owners who have purchased insurance in the last 2 years\n- Measure all behavioural variables: risk attitude scale, decision-making style, trigger event, channel preference, coverage priorities\n- Run cluster analysis to identify distinct behavioural segments\n\n**Days 61–90: Segment profiling and strategy translation**\n- Profile each segment: size, current penetration, revenue potential, acquisition cost\n- Map segments to media channels and message frameworks\n- Deliver actionable playbook to marketing team\n\n### The Four Behavioural Segments (Illustrative Output)\n\n**Segment 1 — The Protectors (28% of market)**\nBehaviour: Risk-averse, coverage-focused, research-intensive, willing to pay premium\nTrigger: Life events (new baby, new car, accident)\nMessage: 'When it matters most, Atlas is there' — coverage story, claims testimonials\nChannel: Long-form content, YouTube, agent referral\nConversion rate potential: 8–12%\n\n**Segment 2 — The Minimisers (34% of market)**\nBehaviour: Price-driven, low engagement, auto-renews, legally compliant only\nTrigger: Renewal notice\nMessage: 'Egypt's lowest third-party rate — officially' — price proof, speed, no hassle\nChannel: SMS, price comparison sites, Google Search\nConversion rate potential: 4–6%\n\n**Segment 3 — The Convenience Seekers (22% of market)**\nBehaviour: Values speed and digital ease over price or coverage depth\nTrigger: Time pressure, car purchase\nMessage: 'Insurance in 4 minutes, from your phone' — process simplicity, digital UX\nChannel: Instagram, mobile ads, car dealership partnerships\nConversion rate potential: 6–9%\n\n**Segment 4 — The Trust-Dependents (16% of market)**\nBehaviour: Relationship-driven, buys through a trusted agent or bank\nTrigger: Agent recommendation\nMessage: Delivered by agents, not mass media — invest in agent quality and tools\nChannel: Agent network, bank branch integration\nConversion rate potential: 15–22% (but requires agent investment)",
        
                'bigger_lesson_en' => "**Targeting a demographic is targeting a census category. Targeting a behaviour is targeting a buyer.**\n\nThe most powerful segmentation system is the one that predicts what someone will do next — not who they are today. Behavioural segments are harder to build than demographic ones, but they are the difference between a 2.1% conversion rate and an 8% one.",
        
                'skills_taught_en' => json_encode([
                    'Demographic vs. behavioural segmentation',
                    'Insurance consumer behaviour research',
                    'Cluster analysis and segment identification',
                    'Segment-to-strategy translation',
                    'Conversion rate improvement through targeting',
                ]),
        
                'title_ar'    => 'التقسيم الذي غيّر كل شيء',
                'subtitle_ar' => 'الانتقال من الشرائح الديموغرافية إلى الشرائح السلوكية التي تتنبأ فعلاً بالشراء',
                'situation_ar' => "أنت رئيس رؤى المستهلك في **أطلس للتأمين مصر**. تسوّق الشركة تأمين السيارات باستخدام شرائح ديموغرافية واسعة:\n- الشريحة أ: ذكور 25-45، دخل مرتفع\n- الشريحة ب: إناث 25-40، مهنيات\n- الشريحة ج: ذكور 45-60، أصحاب أعمال\n\nهذا التقسيم يقود الاستراتيجية الإبداعية والإعلامية والتسعيرية منذ 4 سنوات. لكن مدير التسويق محبط: *'نستهدف نفس الناس كالجميع ونحصل على نفس النتائج. معدل التحويل 2.1% ولا نستطيع تحسينه.'*\n\nتقترح دراسة تقسيم سلوكي. المجلس يوافق بـ280,000 جنيه. لديك 90 يوماً.",
                'challenge_questions_ar' => json_encode([
                    "ما القيود الجوهرية للتقسيم الديموغرافي لمنتج كتأمين السيارات — ولماذا يفشل في التنبؤ بسلوك الشراء الفعلي؟",
                    "ما التقسيم السلوكي وأي أنواع البيانات السلوكية ستكون الأكثر تنبؤاً لشراء تأمين السيارات؟",
                    "صمم عملية البحث لـ90 يوماً: ما مصادر البيانات والأساليب والمخرجات؟",
                    "البحث يحدد 4 شرائح سلوكية بدوافع مميزة. كيف تترجم الشرائح لاستراتيجيات تسويقية قابلة للتنفيذ؟",
                ]),
                'solution_ar' => "## التقسيم السلوكي: من هم للسبب وراء شرائهم\n\n### الشرائح السلوكية الأربع (مخرجات توضيحية)\n\n**الشريحة 1 — الحامون (28%):** خائفون من المخاطر، تغطية أولاً، بحث مكثف — رسالة: 'عندما يهم الأمر، أطلس موجود'\n\n**الشريحة 2 — المقلّلون (34%):** يبحثون عن السعر فقط، تجديد تلقائي — رسالة: 'أقل سعر طرف ثالث في مصر'\n\n**الشريحة 3 — باحثو الراحة (22%):** يقدّرون السرعة والرقمية — رسالة: 'تأمين في 4 دقائق من هاتفك'\n\n**الشريحة 4 — المعتمدون على الثقة (16%):** يشترون عبر وكيل موثوق — الاستثمار في جودة الوكلاء وأدواتهم\n\n**إمكانية معدل التحويل: 4-22% حسب الشريحة مقارنة بـ2.1% الحالية**",
        
                'bigger_lesson_ar' => "**استهداف ديموغرافي هو استهداف فئة إحصائية. استهداف سلوكي هو استهداف مشترٍ.**\n\nأقوى نظام تقسيم هو الذي يتنبأ بما سيفعله الشخص لاحقاً — لا من هو اليوم. الشرائح السلوكية أصعب بناءً من الديموغرافية، لكنها الفرق بين معدل تحويل 2.1% ومعدل 8%.",
        
                'skills_taught_ar' => json_encode([
                    'التقسيم الديموغرافي مقابل السلوكي',
                    'بحث سلوك المستهلك في التأمين',
                    'تحليل التجميع وتحديد الشرائح',
                    'ترجمة الشرائح إلى استراتيجيات',
                    'تحسين معدل التحويل عبر الاستهداف',
                ]),
                'created_at' => $now,
                'updated_at' => $now,
            ],
        
            // ── MG-MR-06 ──────────────────────────────────────────────────
            [
                'topic_slug'    => 'market_research',
                'topic_name_en' => 'Market Research',
                'topic_name_ar' => 'أبحاث السوق',
                'difficulty'    => 'advanced',
                'sort_order'    => 306,
                'read_time_minutes' => 14,
        
                'title_en'    => 'The Price That Nobody Would Pay',
                'subtitle_en' => 'How to find the optimal price point using research — not guesswork',
                'situation_en' => "You are the marketing director at **MedAssist**, an Egyptian health-tech startup offering a telemedicine subscription service — unlimited doctor consultations via video call for a flat monthly fee. The founding team is debating the launch price.\n\nFounder A wants EGP 149/month: *'We need to be premium to signal quality.'*\nFounder B wants EGP 59/month: *'We need to be accessible to grow fast.'*\nFounder C wants EGP 99/month: *'Let's split the difference.'*\n\nNone of them has talked to a potential customer. You have EGP 35,000 and 3 weeks to run pricing research before the board meeting.",
                'challenge_questions_en' => json_encode([
                    "Why is 'splitting the difference' between founder opinions not a pricing strategy — and what does pricing research actually measure?",
                    "Explain the Van Westendorp Price Sensitivity Meter methodology — the four questions it asks and what each answer reveals about price tolerance.",
                    "Design a 3-week, EGP 35,000 pricing research plan for MedAssist that would give the board a defensible pricing recommendation.",
                    "The research shows: optimal price point EGP 89, acceptable range EGP 69–119, above EGP 129 = significant rejection. What pricing strategy do you recommend for launch — and what does the research NOT tell you that you still need to find out?",
                ]),
                'solution_en' => "## Pricing Research: Finding What the Market Will Actually Pay\n\n### Why Founder Intuition Is Not Pricing Strategy\n\nFounder A's 'premium signals quality' assumption works if consumers already believe the product is worth premium — but for a new, unproven telemedicine service in Egypt, quality must first be demonstrated, not assumed.\n\nFounder B's 'low price grows fast' logic ignores margin sustainability and the risk of anchoring the brand at a price that makes later increases psychologically painful.\n\nFounder C's 'split the difference' is not pricing research — it is negotiation. The right price is determined by the market, not by the average of three opinions.\n\n### The Van Westendorp Price Sensitivity Meter\n\nThis is the most widely used consumer pricing research methodology. It asks four questions about a specific product:\n\n**Question 1:** 'At what price would this product be so cheap that you would doubt its quality?' → **Too Cheap** threshold\n\n**Question 2:** 'At what price would this product be a bargain — great value for money?' → **Acceptable Low** threshold\n\n**Question 3:** 'At what price would this product start to feel expensive, but you would still consider buying it?' → **Acceptable High** threshold\n\n**Question 4:** 'At what price would this product be too expensive for you to consider buying?' → **Too Expensive** threshold\n\nWhen these four curves are plotted on a graph, they reveal:\n- **Optimal Price Point (OPP):** Where 'too cheap' and 'too expensive' intersect — the price with maximum acceptability\n- **Acceptable Price Range (APR):** The range between 'bargain' and 'expensive but acceptable'\n- **Point of Marginal Cheapness:** Below this, buyers question quality\n- **Point of Marginal Expensiveness:** Above this, most buyers exit\n\n### 3-Week EGP 35,000 Research Plan\n\n**Week 1 — Qualitative framing (EGP 8,000)**\n6 depth interviews with target users (working professionals, families in Cairo, aged 28–45 with health concerns). Goal: understand how they currently access healthcare, what they pay, and how they value convenience vs. cost.\n\n**Week 2 — Van Westendorp quantitative survey (EGP 18,000)**\nOnline panel: 400 respondents matching target demographic.\n- Section 1: Concept explanation and comprehension check\n- Section 2: Four VW price questions\n- Section 3: Purchase intent at three price points (EGP 69, EGP 99, EGP 129)\n- Section 4: Feature prioritisation (what features justify higher price?)\n\n**Week 3 — Analysis and recommendation (EGP 9,000)**\nPlot VW curves. Identify OPP and APR. Run purchase intent analysis by segment. Deliver pricing recommendation with 3 scenarios.\n\n### Interpreting the Research Output\n\nIf research shows: OPP = EGP 89, APR = EGP 69–119, rejection above EGP 129:\n\n**Launch recommendation: EGP 99/month**\n\nRationale:\n- EGP 99 is above the OPP (EGP 89) but within the acceptable range\n- The EGP 10 premium over OPP signals quality without triggering rejection\n- It is below the rejection threshold (EGP 129) with a comfortable EGP 30 buffer\n- It creates room for promotional pricing (EGP 79 introductory) without destroying the anchor\n\n**What the research does NOT tell you:**\n1. **Will the product retain subscribers?** Price research measures willingness to try — not willingness to continue paying after the first month.\n2. **How does price interact with channel?** A price that works direct-to-consumer may not work when sold through insurance companies or employers.\n3. **What is the competitor response?** Competitors may reprice in response to your launch price.\n4. **Does the price need to differ by segment?** Corporate/family plans may have different price elasticity than individual plans.\n\n**Recommended additional research:** A 90-day trial at EGP 99 with 500 subscribers, measuring Month 2 and Month 3 renewal rates. Only this will tell you if the price is sustainable, not just acceptable.",
        
                'bigger_lesson_en' => "**Price is the only element of the marketing mix that generates revenue — everything else creates cost.**\n\nUnder-pricing is as dangerous as over-pricing — it signals low quality, attracts the wrong customers, and creates a margin trap that is almost impossible to exit. The right price is discovered through research, not debated in a boardroom.",
        
                'skills_taught_en' => json_encode([
                    'Van Westendorp Price Sensitivity Meter',
                    'Pricing research methodology',
                    'Optimal price point identification',
                    'Launch pricing strategy',
                    'Price research limitations and follow-up',
                ]),
        
                'title_ar'    => 'السعر الذي لن يدفعه أحد',
                'subtitle_ar' => 'كيف تجد نقطة السعر المثالية بالبحث لا التخمين',
                'situation_ar' => "أنت مدير التسويق في **ميد أسيست**، ناشئة صحية مصرية تقدم خدمة اشتراك تطبيب عن بُعد. يتجادل فريق التأسيس حول سعر الإطلاق:\n\nالمؤسس أ يريد 149 جنيه/شهر: *'نحتاج أن نكون راقين لنُشير للجودة.'*\nالمؤسس ب يريد 59 جنيه/شهر: *'نحتاج أن نكون في متناول الجميع للنمو السريع.'*\nالمؤسس ج يريد 99 جنيه/شهر: *'لنقسم الفرق.'*\n\nلم يتحدث أحد منهم مع عميل محتمل. لديك 35,000 جنيه و3 أسابيع لإجراء أبحاث تسعير قبل اجتماع المجلس.",
                'challenge_questions_ar' => json_encode([
                    "لماذا 'تقسيم الفرق' بين آراء المؤسسين ليس استراتيجية تسعير — وماذا يقيس بحث التسعير فعلاً؟",
                    "اشرح منهجية Van Westendorp لحساسية السعر — الأسئلة الأربعة التي تطرحها وما تكشفه كل إجابة.",
                    "صمم خطة بحث تسعير لـ3 أسابيع بـ35,000 جنيه تعطي المجلس توصية تسعير قابلة للدفاع عنها.",
                    "البحث يُظهر: نقطة السعر المثالية 89 جنيه، النطاق المقبول 69-119 جنيه، فوق 129 جنيه رفض كبير. ما استراتيجية التسعير التي توصي بها للإطلاق؟",
                ]),
                'solution_ar' => "## بحث التسعير: إيجاد ما سيدفعه السوق فعلاً\n\n### مقياس حساسية السعر لـVan Westendorp\n\nأربعة أسئلة:\n1. 'بأي سعر يكون المنتج رخيصاً جداً لدرجة الشك في جودته؟' ← حد رخيص جداً\n2. 'بأي سعر يكون صفقة جيدة؟' ← حد مقبول منخفض\n3. 'بأي سعر يبدأ بالشعور بالغلاء لكنك لا تزال تفكر في الشراء؟' ← حد مقبول مرتفع\n4. 'بأي سعر يكون غالياً جداً للشراء؟' ← حد غالٍ جداً\n\n### توصية التسعير\n\n**الإطلاق بـ99 جنيه/شهر:**\n- أعلى من نقطة السعر المثالية (89 جنيه) بما يكفي لإشارة الجودة\n- ضمن النطاق المقبول مع هامش 30 جنيه قبل الرفض\n- يتيح التسعير الترويجي (79 جنيه تمهيدي) دون تدمير المرساة\n\n**ما لا يُخبرك به البحث:**\nالاحتفاظ بالمشتركين، التفاعل مع القنوات، الاستجابة التنافسية، الحاجة لتسعير مختلف حسب الشريحة",
        
                'bigger_lesson_ar' => "**السعر العنصر الوحيد في المزيج التسويقي الذي يولّد إيرادات — كل شيء آخر يُنشئ تكاليف.**\n\nالتسعير المنخفض بالغ الخطورة كالمرتفع — يُشير لجودة متدنية ويجذب العملاء الخاطئين. السعر الصحيح يُكتشف بالبحث لا يُناقَش في غرفة الاجتماعات.",
        
                'skills_taught_ar' => json_encode([
                    'مقياس حساسية السعر لـVan Westendorp',
                    'منهجية بحث التسعير',
                    'تحديد نقطة السعر المثالية',
                    'استراتيجية التسعير للإطلاق',
                    'قيود بحث التسعير والمتابعة',
                ]),
                'created_at' => $now,
                'updated_at' => $now,
            ],
        
            // ══════════════════════════════════════════════════════════════
            //  TOPIC 4 — CAMPAIGN PLANNING (6 cases: MG-CP-01 to MG-CP-06)
            // ══════════════════════════════════════════════════════════════
        
                ];

       $cases = array_map(function ($case) use ($hubId, $adminId, $now) {
            return array_merge($case, [
                'hub_id'       => $hubId,
                'created_by'   => $adminId,
                'status'       => 'published',
                'published_at' => $now,
            ]);
        }, $cases);

        DB::table('cases')->insert($cases);
        $this->command->info('  ✅ 5 cases inserted (MG-MR-02 to MG-MR-06)');
    }
}
