<?php

namespace Database\Seeders;

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

/**
 * InPractice — Marketing Generic Cases [02/10]
 * Brand Strategy: MG-BS-06, MG-BS-07
 * Digital Marketing: MG-DM-01, MG-DM-02, MG-DM-03
 *
 * Run: php artisan db:seed --class=MarketingGenericCaseSeeder_02
 */
class MarketingGenericCaseSeeder_02 extends Seeder
{
    public function run(): void
    {
        $this->command->info('📢 [02/10] Brand Strategy (6-7) + Digital Marketing (1-3) ...');

        $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 = [
        
            [
                'hub_id'        => $hubId,
                'created_by'    => $adminId,
                'topic_slug'    => 'brand_strategy',
                'topic_name_en' => 'Brand Strategy',
                'topic_name_ar' => 'استراتيجية العلامة التجارية',
                'layer'         => 'generic',
                'difficulty'    => 'advanced',
                'status'        => 'published',
                'published_at'  => $now,
                'sort_order'    => 106,
                'read_time_minutes' => 14,
        
                'title_en'    => 'The Purpose Trap',
                'subtitle_en' => 'When brand purpose becomes a liability instead of an asset',
                'situation_en' => "You are the CMO of **Nour Foods**, a large Egyptian food manufacturer. Three years ago, on the advice of a global agency, the company launched a purpose-driven brand platform: *'Nourishing Egyptian Families Since 1985.'*\n\nThe campaign was widely praised in marketing circles. The company invested EGP 22 million over two years in purpose-led advertising — films about Egyptian mothers, food security stories, farmer partnerships.\n\nNow a crisis has hit. A food safety report by an independent NGO found that two of Nour's product lines have higher-than-recommended sugar levels — flagged as a concern for childhood obesity. The report went viral on social media.\n\nThe company's response team is paralysed. The PR agency says: *'You can't defend this — you built a brand on 'nourishing families' and now you're accused of harming children.'*\n\nThe brand purpose has become the weapon being used against the brand.\n\nThe board asks you:\n1. How did brand purpose create this vulnerability?\n2. What is the correct crisis response?\n3. How do we rebuild after this?",
                'challenge_questions_en' => json_encode([
                    "What is the difference between a brand purpose that is earned and one that is aspirational — and which one did Nour Foods build?",
                    "Why does purpose-led branding create a higher standard of accountability than product-benefit branding?",
                    "Design a crisis communication response for the first 72 hours that does not abandon the purpose but does not defensively deny the issue.",
                    "What structural changes must Nour Foods make to re-earn the right to claim 'Nourishing Egyptian Families' going forward?",
                ]),
                'solution_en' => "## The Purpose Trap: When the Brand Promise Outpaces Reality\n\nBrand purpose is one of the most powerful tools in modern marketing — and one of the most dangerous when deployed dishonestly or prematurely.\n\n### Earned vs. Aspirational Purpose\n\n**Earned purpose** is built on what a company *already does* — embedded in its operations, supply chain, product standards, and culture. Consumers who investigate find that the purpose is real.\n\n**Aspirational purpose** is a marketing claim about what the company *wishes it stood for* — communicated through advertising before the operational reality catches up.\n\nNour Foods built aspirational purpose. The EGP 22 million was spent telling a story before ensuring the products fully lived that story. The result: a purpose platform that is a target, not a shield.\n\n### Why Purpose Raises the Accountability Bar\n\nA brand that says *'Our products taste great'* and is found to have high sugar is embarrassing. A brand that says *'We nourish Egyptian families'* and is found to have high sugar is a betrayal. The higher the moral claim, the higher the fall.\n\nThis is not an argument against brand purpose — it is an argument for *earning* it before *claiming* it.\n\n### 72-Hour Crisis Response\n\n**Hour 1–6: Internal fact-finding**\nBefore any public statement, the CMO must know: Is the report accurate? What are the actual sugar levels? What are the regulatory standards in Egypt vs. international recommendations? Do not communicate until you know the facts.\n\n**Hour 6–24: First public statement**\nPrinciples: acknowledge, do not minimise, do not attack the NGO.\n\n> *'We have seen the report from [NGO Name] and we take any question about our products' nutritional standards seriously. We are reviewing the findings carefully and will share our full response within 72 hours. As a company that has spent 40 years feeding Egyptian families, we hold ourselves to the highest standards — and if we have fallen short in any area, we will fix it.'*\n\n**Hour 24–72: Full response**\n- If the findings are accurate: announce a reformulation commitment with a specific timeline\n- If the findings are partially accurate: acknowledge what is true, clarify what is not, commit to the changes needed\n- If the findings are inaccurate: provide data, engage regulators, do not attack — propose a joint review\n\n### Rebuilding the Right to Claim the Purpose\n\n**Step 1 — Reform the products (12 months)**\nReduce sugar content in the flagged lines to meet the most stringent applicable standard. This is non-negotiable — the brand cannot claim nourishment while selling unhealthy products.\n\n**Step 2 — Third-party certification (Months 6–12)**\nSeek independent nutritional certification from a credible Egyptian or international body. Make this public. Let others validate the claim.\n\n**Step 3 — Transparent reporting (Year 2)**\nPublish an annual 'Nour Nutrition Report' — full disclosure of sugar, salt, and fat levels across the product range, benchmarked against international standards. This is radical transparency, and it rebuilds trust faster than advertising ever could.\n\n**Step 4 — Purpose earned, not claimed**\nOnly return to purpose-led advertising after Steps 1–3 are complete. The campaign becomes: *'Here is what we changed. Here is what we measured. Here is why we can say: Nourishing Egyptian Families.'*",
        
                'bigger_lesson_en' => "**Brand purpose is a contract, not a campaign.**\n\nWhen you claim a purpose, you invite the world to hold you accountable to it. Companies that live their purpose before claiming it emerge from crises stronger. Companies that claim it before living it become case studies in how not to do brand purpose.",
        
                'skills_taught_en' => json_encode([
                    'Purpose-led brand strategy',
                    'Crisis communication for brand crises',
                    'Earned vs. aspirational brand positioning',
                    'Reputational risk management',
                    'Rebuilding brand trust post-crisis',
                ]),
        
                'title_ar'    => 'فخ الغرض',
                'subtitle_ar' => 'حين يتحول غرض العلامة من أصل إلى مسؤولية',
                'situation_ar' => "أنت المدير التسويقي لـ**نور فودز**، شركة مصرية كبيرة لتصنيع الأغذية. قبل ثلاث سنوات، بنت الشركة منصة علامة ذات غرض: *'نغذي العائلات المصرية منذ 1985.'*\n\nاستثمرت الشركة 22 مليون جنيه على مدى عامين في إعلانات ذات غرض — أفلام عن الأمهات المصريات وقصص الأمن الغذائي.\n\nالآن أزمة ضربت. تقرير منظمة مستقلة وجد أن خطَّين من منتجات نور يحتويان على مستويات سكر أعلى من الموصى به — خطر على السمنة عند الأطفال. انتشر التقرير فيروسياً.\n\nغرض العلامة أصبح السلاح الذي يُستخدم ضدها.",
                'challenge_questions_ar' => json_encode([
                    "ما الفرق بين غرض العلامة المكتسَب والطموحي — وأيهما بنت نور فودز؟",
                    "لماذا تخلق العلامة ذات الغرض معياراً أعلى للمساءلة من علامة الفائدة؟",
                    "صمم استجابة أزمة اتصالية للـ72 ساعة الأولى لا تتخلى عن الغرض ولا تنكر المشكلة دفاعياً.",
                    "ما التغييرات الهيكلية التي يجب على نور فودز إجراؤها لاستعادة الحق في المطالبة بـ'نغذي العائلات'؟",
                ]),
                'solution_ar' => "## فخ الغرض: حين يسبق وعد العلامة الواقع\n\n### الغرض المكتسَب مقابل الطموحي\n\n**الغرض المكتسَب** يُبنى على ما تفعله الشركة *بالفعل* — مضمّن في عملياتها ومعايير منتجاتها.\n**الغرض الطموحي** ادعاء تسويقي عمّا *تتمنى* الشركة أن تمثله — قبل أن يلحق الواقع التشغيلي.\n\ننور فودز بنت غرضاً طموحياً. النتيجة: منصة غرض تمثّل هدفاً لا درعاً.\n\n### استجابة أزمة 72 ساعة\n\n**الساعة 1-6:** جمع الحقائق داخلياً قبل أي تصريح\n**الساعة 6-24:** بيان أول يعترف دون تقليل دون مهاجمة المنظمة\n**الساعة 24-72:** استجابة كاملة — إصلاح أو توضيح أو مراجعة مشتركة\n\n### إعادة بناء الحق في ادعاء الغرض\n\nإصلاح المنتجات ← شهادة طرف ثالث ← تقرير تغذية سنوي شفاف ← العودة للإعلان الغرضي بعد إثبات الإصلاح",
        
                'bigger_lesson_ar' => "**غرض العلامة عقد لا حملة.**\n\nحين تطالب بغرض، تدعو العالم لمحاسبتك عليه. الشركات التي تعيش غرضها قبل ادعائه تخرج من الأزمات أقوى. تلك التي تدّعيه قبل عيشه تصبح دراسات حالة في كيفية عدم استخدام غرض العلامة.",
        
                'skills_taught_ar' => json_encode([
                    'استراتيجية العلامة ذات الغرض',
                    'التواصل في أزمات العلامة',
                    'التموضع المكتسَب مقابل الطموحي',
                    'إدارة مخاطر السمعة',
                    'إعادة بناء ثقة العلامة بعد الأزمة',
                ]),
                'created_at' => $now,
                'updated_at' => $now,
            ],
        
            // ── MG-BS-07 ──────────────────────────────────────────────────
            [
                'hub_id'        => $hubId,
                'created_by'    => $adminId,
                'topic_slug'    => 'brand_strategy',
                'topic_name_en' => 'Brand Strategy',
                'topic_name_ar' => 'استراتيجية العلامة التجارية',
                'layer'         => 'generic',
                'difficulty'    => 'intermediate',
                'status'        => 'published',
                'published_at'  => $now,
                'sort_order'    => 107,
                'read_time_minutes' => 11,
        
                'title_en'    => 'The Visual Identity That Stopped Working',
                'subtitle_en' => 'When your logo and design system become a competitive disadvantage',
                'situation_en' => "You are a brand manager at **Delta Paper & Stationery**, a B2B Egyptian company supplying office paper, stationery, and printing materials to corporates and schools. The company's logo and visual identity have not changed since 2004 — a dark blue logo with a serif font and a paper icon.\n\nNew research shows that Delta is losing corporate tender bids to newer, smaller competitors. Exit interviews with three lost clients reveal a pattern: *'Your products are fine but you don't look like a company we want to be associated with. You look old.'*\n\nThe sales director wants to immediately update the logo. The CEO is resistant: *'We've had this logo for 20 years. Changing it will confuse our existing clients.'*\n\nYou have been asked to resolve this disagreement with a structured recommendation.",
                'challenge_questions_en' => json_encode([
                    "Is 'looking old' a legitimate brand problem — or is it a perception problem that can be solved without changing the logo?",
                    "What is the difference between a logo refresh and a full visual identity overhaul — and how do you decide which one Delta needs?",
                    "The CEO's concern about confusing existing clients is valid. How do you balance brand modernisation with continuity for an established B2B brand?",
                    "Design a visual identity update process that manages risk, maintains continuity, and gives the sales team something credible to present in the next tender cycle.",
                ]),
                'solution_en' => "## Visual Identity: When Design Becomes a Business Problem\n\nIn B2B markets, visual identity affects procurement decisions more than consumer marketers typically realise. Procurement teams and decision-makers use visual signals as proxies for company health, modernity, and reliability.\n\n### Is 'Looking Old' a Real Problem?\n\nYes — in B2B tender situations, it is. The reason: tender evaluators often know very little about the actual product quality of competing suppliers. They use visible signals to make inferences:\n\n- Modern logo + clean website = 'This company is organised and well-run'\n- Dated logo + old-format website = 'This company may be behind the times operationally'\n\nThis is unfair to Delta — whose products are genuinely good — but it is how human perception works. The visual identity is signalling incompetence it does not have.\n\n### Logo Refresh vs. Full Overhaul\n\n| Refresh (Evolution) | Overhaul (Revolution) |\n|---|---|\n| Same core logo, updated execution | New logo, new colours, new typography |\n| Existing clients recognise it | Existing clients need to be informed |\n| Lower cost and risk | Higher cost and risk |\n| Appropriate when equity exists in the mark | Appropriate when the mark has no positive equity |\n| Takes 3–6 months | Takes 6–18 months |\n\n**Delta should do a refresh, not an overhaul.** The company has 20 years of B2B relationships. There is equity in the Delta name. The problem is execution — the logo looks dated — not the logo's fundamental concept.\n\n### Managing the CEO's Continuity Concern\n\nThe CEO is right that sudden, dramatic changes confuse existing clients — but a well-managed refresh does not create this confusion. The principles:\n\n1. **Keep the core identifier** — the Delta name and the core colour (blue can be modernised, not replaced)\n2. **Phase the transition** — new materials roll out as old ones are consumed (business cards, letterheads, packaging reordered naturally)\n3. **Communicate proactively** — send existing key accounts a short note: *'Delta is updating its look. Same team, same quality, cleaner presentation.'\n4. **Update digital first** — website and email signatures are zero-cost to update and highest-visibility for tender evaluators\n\n### A Practical Update Process\n\n**Month 1:** Brief 2–3 local Egyptian design agencies. Require them to show how they would modernise Delta while preserving its blue heritage.\n\n**Month 2:** Review concepts internally and with 5 key clients — ask them: 'Does this still feel like Delta but more modern?' Their answer matters more than internal opinions.\n\n**Month 3:** Finalise the identity. Create a brand standards document covering logo usage, typography, colour codes.\n\n**Month 4:** Launch digitally. New website, LinkedIn, email signature.\n\n**Months 5–6:** Roll out to all physical materials as they are replaced naturally.\n\n**For the next tender:** Use the new identity on all tender documents and presentations. Brief the sales team on how to reference the update: *'We've refreshed our brand identity to better reflect the modern, responsive company we've become.'*",
        
                'bigger_lesson_en' => "**In B2B, your visual identity is your first sales pitch.**\n\nBefore a procurement manager reads a single line of your tender document, they have already formed an impression from your logo, your website, and the quality of your presentation materials. That impression either adds credibility to your proposal or subtracts from it. Design is not decoration — it is communication.",
        
                'skills_taught_en' => json_encode([
                    'B2B brand perception management',
                    'Visual identity refresh vs. overhaul',
                    'Design as business strategy',
                    'Managing brand change with existing clients',
                    'Tender and procurement brand signals',
                ]),
        
                'title_ar'    => 'الهوية البصرية التي توقفت عن العمل',
                'subtitle_ar' => 'حين يصبح شعارك ونظامك التصميمي عيباً تنافسياً',
                'situation_ar' => "أنت مدير علامة تجارية في **دلتا للورق والقرطاسية**، شركة مصرية B2B تورّد الورق والقرطاسية ومواد الطباعة للشركات والمدارس. شعار الشركة وهويتها البصرية لم يتغيرا منذ 2004.\n\nأبحاث جديدة تُظهر أن دلتا تخسر عطاءات الشركات لمنافسين أحدث وأصغر. مقابلات مع ثلاثة عملاء خسرتهم تكشف نمطاً: *'منتجاتكم جيدة لكنكم لا تبدون كشركة نريد الارتباط بها. تبدون قديمين.'*\n\nمدير المبيعات يريد تحديث الشعار فوراً. الرئيس مقاوم: *'هذا الشعار منذ 20 عاماً. تغييره سيربك عملاءنا الحاليين.'*",
                'challenge_questions_ar' => json_encode([
                    "هل 'المظهر القديم' مشكلة علامة تجارية حقيقية — أم مشكلة إدراك يمكن حلها دون تغيير الشعار؟",
                    "ما الفرق بين تجديد الشعار وإصلاح الهوية البصرية الكامل — وكيف تقرر أيهما تحتاجه دلتا؟",
                    "قلق الرئيس من إرباك العملاء الحاليين مبرر. كيف توازن بين التحديث والاستمرارية لعلامة B2B راسخة؟",
                    "صمم عملية تحديث هوية بصرية تدير المخاطر وتحافظ على الاستمرارية وتمنح فريق المبيعات شيئاً موثوقاً في دورة العطاءات القادمة.",
                ]),
                'solution_ar' => "## الهوية البصرية: حين يصبح التصميم مشكلة عمل\n\nفي أسواق B2B، تؤثر الهوية البصرية على قرارات الشراء أكثر مما يدرك مسوقو المستهلكين عادةً. فرق المشتريات تستخدم الإشارات البصرية كمؤشرات لصحة الشركة وحداثتها وموثوقيتها.\n\n### تجديد الشعار مقابل الإصلاح الكامل\n\n**دلتا تحتاج تجديداً لا إصلاحاً كاملاً.** للشركة 20 عاماً من العلاقات B2B. المشكلة في التنفيذ — الشعار يبدو قديماً — لا في المفهوم الأساسي.\n\n### عملية تحديث عملية\n\n**الشهر 1:** الاستعانة بـ2-3 وكالات تصميم محلية\n**الشهر 2:** مراجعة المفاهيم مع 5 عملاء رئيسيين\n**الشهر 3:** الانتهاء من الهوية وإنشاء دليل معايير العلامة\n**الشهر 4:** الإطلاق رقمياً أولاً\n**الشهور 5-6:** التطبيق على المواد المادية تدريجياً",
        
                'bigger_lesson_ar' => "**في B2B، هويتك البصرية هي أول عرض مبيعات لك.**\n\nقبل أن يقرأ مدير المشتريات سطراً واحداً من وثيقة عطائك، كوّن بالفعل انطباعاً من شعارك وموقعك ومواد عرضك. ذلك الانطباع إما يضيف مصداقية لاقتراحك أو ينتقص منها. التصميم ليس ديكوراً — إنه تواصل.",
        
                'skills_taught_ar' => json_encode([
                    'إدارة تصور العلامة في B2B',
                    'تجديد الهوية البصرية مقابل إصلاحها الكامل',
                    'التصميم كاستراتيجية عمل',
                    'إدارة تغيير العلامة مع العملاء الحاليين',
                    'الإشارات البصرية في العطاءات والمشتريات',
                ]),
                'created_at' => $now,
                'updated_at' => $now,
            ],
        
            // ══════════════════════════════════════════════════════════════
            //  TOPIC 2 — DIGITAL MARKETING (7 cases: MG-DM-01 to MG-DM-07)
            // ══════════════════════════════════════════════════════════════
        
            // ── MG-DM-01 ──────────────────────────────────────────────────
            [
                'hub_id'        => $hubId,
                'created_by'    => $adminId,
                'topic_slug'    => 'digital_marketing',
                'topic_name_en' => 'Digital Marketing',
                'topic_name_ar' => 'التسويق الرقمي',
                'layer'         => 'generic',
                'difficulty'    => 'beginner',
                'status'        => 'published',
                'published_at'  => $now,
                'sort_order'    => 201,
                'read_time_minutes' => 10,
        
                'title_en'    => 'The Facebook Budget That Disappeared',
                'subtitle_en' => 'Running ads without a strategy is just paying to be ignored',
                'situation_en' => "You are a marketing coordinator at **Sama Furniture**, a mid-sized Egyptian furniture retailer with 4 showrooms in Cairo. Your manager has been running Facebook ads for 8 months with a monthly budget of EGP 12,000. The company is getting clicks and some page likes — but almost no walk-ins or sales that can be traced to the ads.\n\nYour manager is frustrated: *\"We've spent EGP 96,000 on Facebook and I can't point to a single sofa that sold because of it. What are we doing wrong?\"*\n\nYou pull up the Facebook Ads Manager. Here is what you find:\n\n| Campaign | Monthly Budget | Objective | Result | Cost Per Result |\n|---|---|---|---|---|\n| Campaign 1 | EGP 5,000 | Page Likes | 847 likes | EGP 5.90/like |\n| Campaign 2 | EGP 4,000 | Post Engagement | 12,400 engagements | EGP 0.32/engagement |\n| Campaign 3 | EGP 3,000 | Website Clicks | 2,100 clicks | EGP 1.43/click |",
                'challenge_questions_en' => json_encode([
                    "Look at the three campaigns. What is fundamentally wrong with all three of them — regardless of their individual performance metrics?",
                    "Page likes cost EGP 5.90 each and there are 847 of them. Is this good or bad performance? What question must you answer before deciding?",
                    "The website click campaign delivered 2,100 clicks at EGP 1.43 each. If the website has no way to capture visitor information or convert them, what is the value of those clicks?",
                    "Redesign a 3-campaign structure for Sama Furniture with the correct objectives, targeting logic, and a way to measure actual business impact.",
                ]),
                'solution_en' => "## Diagnosis: Optimising for the Wrong Things\n\nSama Furniture's campaigns are technically running — Facebook is delivering results against the stated objectives. The problem is the objectives are wrong. The company is paying for metrics that do not lead to furniture sales.\n\n### The Fundamental Problem: Vanity Metrics\n\n| Metric | What It Measures | Does It Sell Furniture? |\n|---|---|---|\n| Page Likes | Who clicked 'Like' once | No |\n| Post Engagement | Who reacted, commented, shared | Rarely |\n| Website Clicks | Who visited the site | Only if site converts |\n| Showroom Visits | Who walked in to buy | Yes |\n| Purchase Conversions | Who bought online | Yes |\n\nNone of the three campaigns is optimised for what Sama Furniture actually needs: people visiting showrooms or buying online.\n\n### The Right Campaign Structure for a Furniture Retailer\n\nFacebook's advertising works in a funnel. Sama needs to build this funnel, not just run isolated campaigns.\n\n**Campaign 1 — AWARENESS (Top of Funnel)**\n- Objective: Video Views or Reach\n- Content: 15–30 second showcase videos of showrooms, best-selling collections\n- Target: Cairo residents aged 25–45, homeowners, engaged/newly married\n- Budget: EGP 3,000/month\n- Goal: Build a warm audience who has seen Sama's products\n\n**Campaign 2 — CONSIDERATION (Middle of Funnel)**\n- Objective: Traffic to website OR WhatsApp messages\n- Content: Specific product collections, 'New Arrival' posts, '3 Rooms Under EGP 25,000' type hooks\n- Target: Retarget people who watched 50%+ of Campaign 1 videos + lookalike audiences\n- Budget: EGP 5,000/month\n- Goal: Get interested people into a conversation or onto the website\n\n**Campaign 3 — CONVERSION (Bottom of Funnel)**\n- Objective: Store Traffic (if using Facebook's store traffic objective) OR WhatsApp lead generation\n- Content: Offers, showroom location, limited-time promotions\n- Target: Retarget people who clicked in Campaign 2 but did not convert\n- Budget: EGP 4,000/month\n- Goal: Drive showroom visits\n\n### Measuring Actual Business Impact\n\nThe missing piece: **attribution**. Sama needs to know which showroom visits came from Facebook.\n\nSimple solution:\n- Train showroom staff to ask every customer: *'How did you hear about us?'*\n- Add a WhatsApp chat button to all ads — every conversation is a lead that can be tracked\n- Create an ad-specific offer: *'Show this post in-store for 5% off'* — every redemption proves the ad drove the visit\n\n### Monthly Reporting That Matters\n\n| What to Report | Not What to Report |\n|---|---|\n| WhatsApp conversations started | Page likes |\n| Showroom visits attributed to ads | Post engagements |\n| Sales from tracked leads | Website clicks (without conversion) |\n| Cost per qualified lead | Cost per click |",
        
                'bigger_lesson_en' => "**Facebook will optimise for exactly what you ask it to optimise for. If you ask it for likes, it will get you likes. If you ask it for customers, you have to build the funnel that gets you customers.**\n\nThe most expensive mistake in digital marketing is not spending too much — it is spending on the wrong objective. Every EGP should be traceable to a business outcome, not a platform metric.",
        
                'skills_taught_en' => json_encode([
                    'Facebook Ads funnel structure',
                    'Vanity metrics vs. business metrics',
                    'Campaign objective selection',
                    'Retargeting strategy',
                    'Lead attribution for offline businesses',
                ]),
        
                'title_ar'    => 'ميزانية الفيسبوك التي اختفت',
                'subtitle_ar' => 'الإعلان بلا استراتيجية مجرد دفع مقابل أن يتجاهلك الناس',
                'situation_ar' => "أنت منسق تسويق في **سما للأثاث**، متجر أثاث مصري متوسط الحجم بـ4 صالات عرض في القاهرة. مديرك يدير إعلانات فيسبوك منذ 8 أشهر بميزانية شهرية 12,000 جنيه. الشركة تحصل على نقرات وإعجابات — لكن تقريباً لا زيارات للمعرض ولا مبيعات يمكن تتبعها.\n\nمديرك محبط: *\"أنفقنا 96,000 جنيه على فيسبوك ولا أستطيع الإشارة إلى أريكة واحدة بيعت بسببه. ما الخطأ الذي نفعله؟\"*\n\n| الحملة | الميزانية الشهرية | الهدف | النتيجة | تكلفة النتيجة |\n|---|---|---|---|---|\n| حملة 1 | 5,000 جنيه | إعجابات بالصفحة | 847 إعجاب | 5.90 جنيه |\n| حملة 2 | 4,000 جنيه | تفاعل مع المنشورات | 12,400 تفاعل | 0.32 جنيه |\n| حملة 3 | 3,000 جنيه | نقرات على الموقع | 2,100 نقرة | 1.43 جنيه |",
                'challenge_questions_ar' => json_encode([
                    "انظر للحملات الثلاث. ما الخطأ الجوهري في جميعها — بصرف النظر عن مؤشرات أدائها الفردية؟",
                    "الإعجابات بالصفحة تكلف 5.90 جنيه لكل إعجاب وهناك 847 إعجاباً. هل هذا أداء جيد أم سيئ؟",
                    "حملة نقرات الموقع حققت 2,100 نقرة بـ1.43 جنيه لكل نقرة. إذا كان الموقع لا يحول الزوار، ما قيمة تلك النقرات؟",
                    "أعد تصميم هيكل 3 حملات لسما للأثاث بالأهداف الصحيحة ومنطق الاستهداف وطريقة لقياس الأثر الفعلي.",
                ]),
                'solution_ar' => "## التشخيص: التحسين لأشياء خاطئة\n\nحملات سما للأثاث تعمل تقنياً — فيسبوك يحقق نتائج وفق الأهداف المحددة. المشكلة أن الأهداف خاطئة. الشركة تدفع مقابل مقاييس لا تؤدي إلى بيع الأثاث.\n\n### هيكل الحملة الصحيح لبائع الأثاث\n\n**حملة 1 — الوعي:** فيديوهات الصالات والمجموعات | 3,000 جنيه\n**حملة 2 — الاعتبار:** إعادة استهداف مشاهدي الفيديو | رسائل واتساب | 5,000 جنيه\n**حملة 3 — التحويل:** عروض وزيارات المعرض | 4,000 جنيه\n\n### قياس الأثر الفعلي\n\n- سؤال كل عميل في المعرض: كيف عرفت عنا؟\n- زر واتساب في كل إعلان — كل محادثة عميل محتمل يمكن تتبعه\n- عرض خاص: 'أظهر هذا المنشور في المعرض للحصول على 5% خصم'",
        
                'bigger_lesson_ar' => "**فيسبوك سيُحسّن تحديداً لما تطلبه منه. إذا طلبت إعجابات ستحصل على إعجابات. إذا أردت عملاء، يجب أن تبني القمع الذي يجلب عملاء.**\n\nأكثر الأخطاء كلفةً في التسويق الرقمي ليس الإنفاق الزائد — بل الإنفاق على الهدف الخاطئ.",
        
                'skills_taught_ar' => json_encode([
                    'هيكل قمع إعلانات فيسبوك',
                    'مقاييس الغرور مقابل مقاييس الأعمال',
                    'اختيار هدف الحملة',
                    'استراتيجية إعادة الاستهداف',
                    'نسب العملاء للإعلانات في الأعمال غير الرقمية',
                ]),
                'created_at' => $now,
                'updated_at' => $now,
            ],
        
            // ── MG-DM-02 ──────────────────────────────────────────────────
            [
                'hub_id'        => $hubId,
                'created_by'    => $adminId,
                'topic_slug'    => 'digital_marketing',
                'topic_name_en' => 'Digital Marketing',
                'topic_name_ar' => 'التسويق الرقمي',
                'layer'         => 'generic',
                'difficulty'    => 'beginner',
                'status'        => 'published',
                'published_at'  => $now,
                'sort_order'    => 202,
                'read_time_minutes' => 10,
        
                'title_en'    => 'The Influencer Deal That Delivered Nothing',
                'subtitle_en' => 'Why follower count is the least important thing about an influencer',
                'situation_en' => "You are a junior marketing executive at **Hana Cosmetics**, an Egyptian beauty brand. Your manager approved a paid influencer deal with a Cairo-based lifestyle influencer who has 380,000 Instagram followers. The deal cost EGP 18,000 for one Instagram Reel and two Stories promoting your new lip gloss collection.\n\nThe influencer posted as agreed. Here are the results:\n\n| Metric | Result |\n|---|---|\n| Reel views | 41,000 |\n| Story views | 28,000 / 19,000 |\n| Reel likes | 1,240 |\n| Reel comments | 47 |\n| Website visits from link in bio (3-day window) | 312 |\n| Units sold in 3 days post-campaign | 14 |\n| Revenue from tracked sales | EGP 2,940 |\n\nYour manager is furious: *\"We paid EGP 18,000 and made EGP 2,940 back. What went wrong and how do we fix our influencer strategy?\"*",
                'challenge_questions_en' => json_encode([
                    "Calculate the ROI of this campaign. What does the number tell you — and what does it not tell you?",
                    "The influencer has 380,000 followers but the Reel got 41,000 views. What does this engagement gap suggest?",
                    "List the five questions you should have asked before signing the influencer deal — and which ones would have prevented this outcome.",
                    "Design a better influencer marketing framework for Hana Cosmetics that goes beyond follower count to evaluate influencer fit, audience quality, and measurable outcomes.",
                ]),
                'solution_en' => "## The Influencer ROI Problem\n\n### Calculating the Return\n\n| Metric | Amount |\n|---|---|\n| Investment | EGP 18,000 |\n| Direct revenue (tracked) | EGP 2,940 |\n| Direct ROI | -83.7% |\n\nOn direct sales alone, this campaign lost money. But raw sales ROI is not the complete picture for influencer marketing — brand awareness and brand association have value that is harder to measure immediately. The problem here is that even the awareness metrics are disappointing.\n\n### Reading the Engagement Gap\n\n380,000 followers, 41,000 Reel views = **10.8% reach of followers**.\n\nIn 2024, a healthy Instagram Reel reach for an account this size is 15–30% of followers. 10.8% suggests:\n- Low organic engagement rate (the account may have bought followers or has an inactive audience)\n- The content was not resonating with the algorithm (likely posted at wrong time, weak hook)\n- The influencer's audience is not the right demographic for beauty products\n\n47 comments on a 41,000-view Reel = **0.11% comment rate**. Exceptionally low. Genuine, interested audiences comment. Passive or fake audiences scroll past.\n\n### Five Questions to Ask Before Signing\n\n**1. What is the engagement rate (not follower count)?**\nEngagement rate = (likes + comments) / followers × 100\nA 380K account should have at least 1.5–3% engagement. Calculate this from their last 12 posts before signing.\n\n**2. Who is the actual audience?**\nAsk the influencer for an audience insights screenshot: age breakdown, gender split, top cities, top countries. If the audience is not Egyptian women aged 20–35 for a beauty brand, the deal is wrong regardless of follower count.\n\n**3. Has this influencer promoted beauty products before — and what were the results?**\nAsk for case studies or results from previous brand deals in the same category. A lifestyle influencer who has never converted for a beauty brand is an untested vehicle.\n\n**4. What is the content plan, not just the deliverable?**\nOne Reel and two Stories is a media buy, not a content strategy. Did the influencer use the product? Did they show application? Was there a personal story? Was there a reason for followers to act?\n\n**5. What is the measurement mechanism?**\nBefore the deal, agree on: a unique discount code, a trackable link, or a specific CTA. Without measurement built in, you are flying blind.\n\n### A Better Influencer Framework for Hana Cosmetics\n\n**Tier 1 — Micro-influencers (10K–50K followers)**\n- Higher engagement rates (5–8% is achievable)\n- More authentic relationships with followers\n- Cost: EGP 1,500–4,000 per post\n- Strategy: Run 6–10 micro-influencers simultaneously for the EGP 18,000 budget\n- Expected: 5–8 genuine conversions each = 30–80 sales vs. 14 sales from one macro deal\n\n**Tier 2 — Category-specific influencers**\nOnly use beauty and skincare influencers for beauty products. A lifestyle influencer's audience follows them for travel, fashion, and food content — not product recommendations in a specific category.\n\n**Tier 3 — Performance-based deals**\nFor new influencer relationships, negotiate a lower base fee + commission per sale (tracked via unique code). This aligns incentives: the influencer earns more by driving real conversions, not just posting and collecting.",
        
                'bigger_lesson_en' => "**Followers are a distribution channel. Engagement is the proof that the channel works.**\n\nAn influencer with 50,000 genuinely engaged followers in your exact target demographic will outperform an influencer with 500,000 passive followers in a mixed, unfocused audience. In influencer marketing, reach without relevance is just expensive noise.",
        
                'skills_taught_en' => json_encode([
                    'Influencer ROI calculation',
                    'Engagement rate analysis',
                    'Influencer vetting framework',
                    'Micro vs. macro influencer strategy',
                    'Performance-based influencer deals',
                ]),
        
                'title_ar'    => 'صفقة المؤثر التي لم تُسفر عن شيء',
                'subtitle_ar' => 'لماذا عدد المتابعين أقل أهمية ما في المؤثر',
                'situation_ar' => "أنت منفذ تسويق مبتدئ في **هنا كوزماتيكس**، علامة تجميل مصرية. وافق مديرك على صفقة مع مؤثرة أسلوب حياة في القاهرة لديها 380,000 متابع على إنستغرام بتكلفة 18,000 جنيه لريل واحد وقصتين للترويج لمجموعة أحمر شفاه جديدة.\n\n| المقياس | النتيجة |\n|---|---|\n| مشاهدات الريل | 41,000 |\n| زيارات الموقع (3 أيام) | 312 |\n| وحدات مباعة في 3 أيام | 14 |\n| الإيرادات من المبيعات المتتبَّعة | 2,940 جنيه |\n\nمديرك غاضب: *\"دفعنا 18,000 جنيه وحصلنا على 2,940 جنيه. ما الخطأ وكيف نُصلح استراتيجية المؤثرين؟\"*",
                'challenge_questions_ar' => json_encode([
                    "احسب عائد الاستثمار في هذه الحملة. ماذا يخبرك الرقم — وما الذي لا يخبرك إياه؟",
                    "للمؤثرة 380,000 متابع لكن الريل حصل على 41,000 مشاهدة. ماذا يوحي هذا الفجوة في التفاعل؟",
                    "أدرج الأسئلة الخمسة التي كان يجب طرحها قبل التوقيع على الصفقة.",
                    "صمم إطاراً أفضل لتسويق المؤثرين في هنا كوزماتيكس يتجاوز عدد المتابعين.",
                ]),
                'solution_ar' => "## مشكلة عائد الاستثمار في المؤثرين\n\n### قراءة فجوة التفاعل\n\n380,000 متابع، 41,000 مشاهدة = **10.8% وصول من المتابعين**.\nنسبة تعليقات 0.11% على 41,000 مشاهدة — منخفضة استثنائياً. الجمهور الحقيقي المهتم يعلّق.\n\n### خمسة أسئلة قبل التوقيع\n\n1. ما معدل التفاعل (لا عدد المتابعين)؟\n2. من هو الجمهور الفعلي؟ (توزيع العمر والجنس والمدن)\n3. هل روّجت المؤثرة لمنتجات تجميل من قبل؟\n4. ما خطة المحتوى لا مجرد التسليمات؟\n5. ما آلية القياس؟ (كود خصم فريد، رابط قابل للتتبع)\n\n### إطار أفضل للمؤثرين\n\n**المستوى الأول — مؤثرون صغار (10-50 ألف متابع)**\nمعدل تفاعل أعلى (5-8%) وعلاقات أكثر أصالة\nتكلفة: 1,500-4,000 جنيه للمنشور\nبميزانية 18,000 جنيه: 6-10 مؤثرين صغار بدلاً من مؤثر واحد كبير",
        
                'bigger_lesson_ar' => "**المتابعون قناة توزيع. التفاعل هو الدليل على أن القناة تعمل.**\n\nمؤثر بـ50,000 متابع متفاعل حقيقي في جمهورك المستهدف سيتفوق على مؤثر بـ500,000 متابع سلبي في جمهور متنوع غير مركّز.",
        
                'skills_taught_ar' => json_encode([
                    'حساب عائد الاستثمار في المؤثرين',
                    'تحليل معدل التفاعل',
                    'إطار فرز المؤثرين',
                    'استراتيجية المؤثرين الصغار مقابل الكبار',
                    'صفقات المؤثرين القائمة على الأداء',
                ]),
                'created_at' => $now,
                'updated_at' => $now,
            ],
        
            // ── MG-DM-03 ──────────────────────────────────────────────────
            [
                'hub_id'        => $hubId,
                'created_by'    => $adminId,
                'topic_slug'    => 'digital_marketing',
                'topic_name_en' => 'Digital Marketing',
                'topic_name_ar' => 'التسويق الرقمي',
                'layer'         => 'generic',
                'difficulty'    => 'intermediate',
                'status'        => 'published',
                'published_at'  => $now,
                'sort_order'    => 203,
                'read_time_minutes' => 12,
        
                'title_en'    => 'The Website That Converts Nobody',
                'subtitle_en' => 'Traffic without conversion is just a vanity metric with a hosting bill',
                'situation_en' => "You are a digital marketing manager at **Cairo Print House**, an Egyptian commercial printing company offering business cards, banners, brochures, and packaging. The company runs Google Ads and gets approximately 3,400 website visitors per month at a cost of EGP 8,500 (EGP 2.50 per click).\n\nOf these 3,400 visitors, only 28 submit a quote request per month — a **conversion rate of 0.82%**. Industry benchmark for commercial printing is 3–5%.\n\nThe CEO wants to increase the Google Ads budget to get more traffic. You believe the problem is the website, not the traffic volume.\n\nYou conduct a quick review:\n- The website loads in 7.2 seconds on mobile\n- The quote request form has 14 fields\n- There is no pricing information anywhere on the site\n- The home page headline says: 'Cairo Print House — Quality Printing Services'\n- There is no live chat or WhatsApp button\n- The site has no customer reviews or logos of past clients",
                'challenge_questions_en' => json_encode([
                    "The CEO wants more traffic. Make the case — with numbers — for why fixing the website first is the higher-ROI decision.",
                    "Identify the top 5 conversion killers on Cairo Print House's website and explain what a potential customer is thinking when they encounter each one.",
                    "The quote form has 14 fields. What is the minimum number of fields needed to qualify a printing lead — and what happens to conversion rate when you reduce form length?",
                    "Design a website optimisation priority list — what do you fix first, second, and third — and why in that order?",
                ]),
                'solution_en' => "## The Conversion Rate Opportunity\n\n### The Numbers Case for Fixing the Website First\n\nCurrent state:\n- Monthly ad spend: EGP 8,500\n- Visitors: 3,400\n- Conversion rate: 0.82%\n- Leads: 28/month\n\n**Scenario A — Double the ad budget (CEO's suggestion):**\n- Monthly ad spend: EGP 17,000\n- Visitors: 6,800 (assuming same CPC)\n- Conversion rate: 0.82% (unchanged)\n- Leads: 55/month\n- Cost per lead: EGP 309\n\n**Scenario B — Fix the website, same ad budget:**\n- Monthly ad spend: EGP 8,500\n- Visitors: 3,400 (unchanged)\n- Conversion rate: 3.0% (industry benchmark)\n- Leads: 102/month\n- Cost per lead: EGP 83\n\nFix the website → **3.6× more leads at the same cost**. Doubling the budget gives 1.96× more leads at 2× the cost.\n\n**The ROI argument is decisive: fix the website first.**\n\n### The 5 Conversion Killers\n\n**Killer 1 — 7.2 second load time on mobile**\nA potential customer is thinking: *'This site is slow. Maybe the company is disorganised too. Let me try the next result.'*\nIndustry data: 53% of mobile users abandon a site that takes more than 3 seconds to load.\nFix: Image compression, remove heavy scripts, use a caching plugin. Target: under 3 seconds.\n\n**Killer 2 — No pricing information**\nA potential customer is thinking: *'I don't know if I can afford this. I'm not going to waste time getting a quote if the price is too high.'*\nPrinting customers always have a budget. Remove the mystery — show starting prices ('Business cards from EGP 150/500 units') or a pricing calculator.\n\n**Killer 3 — Generic headline**\n'Cairo Print House — Quality Printing Services' tells the visitor nothing they didn't already know from clicking the ad. A potential customer in 3 seconds needs to see: *'You are in the right place, this is specifically for you, here is why we are better.'*\nBetter headline: *'Fast, Professional Printing in Cairo — Orders Ready in 48 Hours'*\n\n**Killer 4 — 14-field quote form**\nA potential customer is thinking: *'I just want to know the price. This feels like a job application.'*\n5–6 fields maximum for a first contact form: Name, Phone/WhatsApp, Product type, Quantity, File ready (yes/no), Deadline. Everything else is collected after the lead is captured.\n\n**Killer 5 — No social proof**\nA potential customer choosing between two unknown printing companies defaults to the one that looks more established and trustworthy. Without client logos, reviews, or samples — Cairo Print House has no proof it can deliver.\n\n### Optimisation Priority Order\n\n**Priority 1 — Mobile speed (Week 1)**\nReason: Affects every visitor. If the site doesn't load, nothing else matters.\n\n**Priority 2 — Quote form reduction (Week 1)**\nReason: Highest-impact change, zero cost, immediate result on conversion rate.\n\n**Priority 3 — Add WhatsApp button (Week 1)**\nReason: Many Egyptian B2B buyers prefer WhatsApp to forms. A floating WhatsApp button captures leads who will never fill out a form.\n\n**Priority 4 — Add starting prices and pricing guide (Week 2)**\nReason: Removes the biggest objection before it becomes a reason to leave.\n\n**Priority 5 — Add social proof (Week 3)**\nReason: Collect 10 client testimonials and 5 client logos. This alone can improve conversion by 15–25%.",
        
                'bigger_lesson_en' => "**Pouring more traffic into a leaking bucket does not fill the bucket — it empties your budget.**\n\nConversion rate optimisation (CRO) is the highest-ROI activity in digital marketing because every improvement multiplies the value of all existing traffic. Fix the bucket before turning on the tap.",
        
                'skills_taught_en' => json_encode([
                    'Conversion rate optimisation (CRO)',
                    'Website audit methodology',
                    'Cost-per-lead analysis',
                    'Mobile UX for B2B websites',
                    'ROI case for CRO vs. traffic increase',
                ]),
        
                'title_ar'    => 'الموقع الذي لا يحوّل أحداً',
                'subtitle_ar' => 'الزيارات بلا تحويل مجرد مقياس غرور مع فاتورة استضافة',
                'situation_ar' => "أنت مدير تسويق رقمي في **كايرو برنت هاوس**، شركة طباعة تجارية مصرية. تدير الشركة إعلانات جوجل وتحصل على ~3,400 زيارة شهرية بتكلفة 8,500 جنيه (2.50 جنيه للنقرة).\n\nمن هؤلاء الـ3,400، يقدم فقط 28 شخصاً طلب عرض سعر شهرياً — **معدل تحويل 0.82%**. متوسط الصناعة 3-5%.\n\nالرئيس التنفيذي يريد رفع ميزانية إعلانات جوجل. أنت تعتقد المشكلة في الموقع لا في حجم الزيارات.\n\nمراجعتك السريعة:\n- الموقع يحمّل في 7.2 ثانية على الجوال\n- نموذج طلب العرض يحتوي 14 حقلاً\n- لا توجد معلومات أسعار في أي مكان\n- لا شات مباشر ولا زر واتساب\n- لا مراجعات عملاء ولا شعارات عملاء سابقين",
                'challenge_questions_ar' => json_encode([
                    "الرئيس يريد المزيد من الزيارات. اصنع الحجة — بالأرقام — على أن إصلاح الموقع أولاً هو القرار الأعلى عائداً.",
                    "حدد أهم 5 قاتلات تحويل في موقع كايرو برنت هاوس واشرح ما يفكر فيه العميل المحتمل عند مواجهة كل منها.",
                    "النموذج يحتوي 14 حقلاً. ما الحد الأدنى من الحقول لتأهيل عميل طباعة — وماذا يحدث لمعدل التحويل عند تقليل طول النموذج؟",
                    "صمم قائمة أولويات تحسين الموقع — ما الذي تُصلح أولاً وثانياً وثالثاً — ولماذا بهذا الترتيب؟",
                ]),
                'solution_ar' => "## فرصة معدل التحويل\n\n### الحجة بالأرقام لإصلاح الموقع أولاً\n\n**السيناريو أ — مضاعفة ميزانية الإعلانات:**\n- إنفاق 17,000 جنيه → 55 عميل محتمل/شهر → تكلفة لكل عميل: 309 جنيه\n\n**السيناريو ب — إصلاح الموقع بنفس الميزانية:**\n- إنفاق 8,500 جنيه → 102 عميل محتمل/شهر (عند 3%) → تكلفة لكل عميل: 83 جنيه\n\n**إصلاح الموقع → 3.6 ضعف عملاء محتملين بنفس التكلفة**\n\n### أهم 5 قاتلات التحويل\n\n1. **7.2 ثانية تحميل على الجوال** — 53% يغادرون بعد 3 ثوانٍ\n2. **لا معلومات أسعار** — العميل يغادر قبل طلب العرض\n3. **عنوان رئيسي عام** — لا يُقنع الزائر في 3 ثوانٍ\n4. **14 حقلاً في النموذج** — يشعر كطلب توظيف\n5. **لا إثبات اجتماعي** — لا تقييمات ولا شعارات عملاء\n\n### ترتيب الأولويات\n\nالأسبوع 1: سرعة الجوال + تقليل النموذج + زر واتساب\nالأسبوع 2: إضافة أسعار بداية\nالأسبوع 3: إضافة إثبات اجتماعي",
        
                'bigger_lesson_ar' => "**صبّ المزيد من الزيارات في دلو متسرب لا يملأ الدلو — بل يُفرغ ميزانيتك.**\n\nتحسين معدل التحويل (CRO) هو النشاط الأعلى عائداً في التسويق الرقمي لأن كل تحسين يُضاعف قيمة كل الزيارات الموجودة.",
        
                'skills_taught_ar' => json_encode([
                    'تحسين معدل التحويل (CRO)',
                    'منهجية تدقيق المواقع',
                    'تحليل تكلفة العميل المحتمل',
                    'تجربة المستخدم على الجوال لمواقع B2B',
                    'حجة العائد لـCRO مقابل زيادة الزيارات',
                ]),
                'created_at' => $now,
                'updated_at' => $now,
            ],
        
        ];

        DB::table('cases')->insert($cases);
        $this->command->info('  ✅ 5 cases inserted (MG-BS-06, MG-BS-07, MG-DM-01 to MG-DM-03)');
    }
}
