<?php

namespace Database\Seeders;

use App\Models\Course;
use Illuminate\Database\Seeder;
use Illuminate\Support\Str;

/**
 * Money-Wise Academy mini-courses, from the client's course write-ups.
 * Seeded published & free for now; set pricing/visibility in admin, and
 * attach the session videos to each intro lesson once IDs are available.
 */
class MiniCoursesSeeder extends Seeder
{
    public function run(): void
    {
        $courses = [
            [
                'slug' => 'retirement-benefits-options',
                'title' => 'Retirement Benefits Options',
                'subtitle' => 'with Joseph Njuguna, architect financial dignity with pensions, annuities and drawdowns.',
                'emoji' => 'landmark',
                'cover_path' => 'images/stock/retired-couple.jpg',
                'level' => 'all',
                'sort' => 10,
                'description' => "Welcome to Architecting Financial Dignity: The Essential Retirement Planning Blueprint. This course is for anyone at any stage of working life, just starting out, self-employed, or nearing retirement, who wants to replace uncertainty with intentional choices.\n\nWe go beyond simply \"saving money\" to set realistic goals based on your lifestyle, health and housing needs, and build income using pensions, annuities and drawdowns, while avoiding costly mistakes around taxation and cash withdrawals.\n\nIncluded: guided video lessons in clear, practical language; simple tools to estimate retirement income and targets; and frameworks for choosing between cash, annuities and income drawdown.",
                'outcomes' => [
                    'What retirement benefits really involve, beyond simply "saving money"',
                    'How to set realistic goals based on lifestyle, health and income needs',
                    'Build and grow retirement income using pensions, annuities and drawdowns',
                    'Reduce costly mistakes around taxation, cash withdrawals and retirement decisions',
                ],
            ],
            [
                'slug' => 'planning-for-retirement',
                'title' => 'Planning for Retirement',
                'subtitle' => 'with Dr. Edward Odundo, retire with dignity, health and financial stability.',
                'emoji' => 'shield-check',
                'cover_path' => 'images/stock/hero-family.jpg',
                'level' => 'all',
                'sort' => 11,
                'description' => "The Blueprint for a Dignified Retirement is a practical guide for anyone, whether in your 20s or rapidly approaching retirement, who feels overwhelmed or unsure about the future.\n\nIt moves beyond \"saving money\" to a holistic approach: medical cover, steady monthly income, and strong personal relationships. You'll understand how pensions, annuities, drawdowns and provident funds work in practice, why post-retirement medical cover must be planned early, and how to secure reliable income rather than just a lump sum.\n\nIncluded: guided video lessons based on real Kenyan retirement experiences, simple planning frameworks, and reflection prompts to fit decisions to your life.",
                'outcomes' => [
                    'Think about retirement from a real-life view: health, liquidity, lifestyle and family',
                    'Why post-retirement medical cover is essential and how to plan for it early',
                    'How pensions, annuities, drawdowns and provident funds work in practice',
                    'Plan for steady monthly income, not just lump sums, and avoid common mistakes',
                ],
            ],
            [
                'slug' => 'analyzing-financial-statements',
                'title' => 'Analyzing Financial Statements (Stocks) 101',
                'subtitle' => 'with Eleanor, CFA, evaluate companies and invest with confidence, not guesswork.',
                'emoji' => 'trending-up',
                'cover_path' => 'images/stock/phone-chart.jpg',
                'level' => 'intermediate',
                'sort' => 12,
                'description' => "An introduction to strategic financial statement analysis for stock investing, for anyone who wants to invest in equities with clarity, moving beyond tips, hype and headlines.\n\nWe demystify what financial statements actually reveal about a company's health: how to connect the income statement, balance sheet and cash flow statement, spot red flags like rising debt or shrinking margins, and read key ratios like profitability and return on equity. The goal is to shift stocks from \"quick-money\" tools to components of a diversified portfolio.\n\nIncluded: guided video lessons led by experienced professionals, real Kenyan market examples, and simple step-by-step frameworks for analysing companies.",
                'outcomes' => [
                    'Read and connect the income statement, balance sheet and cash flow statement',
                    'Compare companies in an industry and spot meaningful trends over time',
                    'Understand key ratios: profitability, return on equity, debt levels and valuation',
                    'Identify red flags and reduce fear, hype and emotional decision-making',
                ],
            ],
            [
                'slug' => 'crypto-basics',
                'title' => 'Crypto Basics',
                'subtitle' => 'with Timothy Mruttu, understand blockchain and crypto without the hype.',
                'emoji' => 'coins',
                'cover_path' => 'images/stock/man-laptop.jpg',
                'level' => 'beginner',
                'sort' => 13,
                'description' => "An introduction to cryptocurrency and blockchain essentials, for anyone curious but unsure, intimidated or cautious about where to start.\n\nWe give plain-language explanations of how Bitcoin, Ethereum and smart contracts work, the difference between store-of-value assets and speculative tokens, real-world uses of blockchain beyond trading, and the key risks: volatility, regulation, security and scams. The aim is decisions driven by understanding, not fear of missing out.\n\nIncluded: guided video lessons led by experienced practitioners, beginner-friendly explanations, and simple frameworks to assess risk, purpose and suitability.",
                'outcomes' => [
                    'What blockchain and cryptocurrency actually are, beyond the headlines',
                    'How crypto works in simple terms, Bitcoin, Ethereum and smart contracts',
                    'Where crypto fits (or doesn\'t) in a broader financial plan',
                    'Key risks to understand: volatility, regulation, security and scams',
                ],
            ],
            [
                'slug' => 'core-values-and-your-money',
                'title' => 'Core Values & Your Money',
                'subtitle' => 'with Frank Kitonga, align your money decisions with what you truly value.',
                'emoji' => 'compass',
                'cover_path' => 'images/stock/woman-smile.jpg',
                'level' => 'all',
                'sort' => 14,
                'description' => "The Financial Integrity Blueprint: Aligning Money with Core Values, for anyone who struggles with financial discipline or feels stuck in repeating patterns like debt cycles and overspending.\n\nWe look beyond budgeting tips to the \"why\" behind your money behaviour, and why financial success is 80% behaviour and values rather than technical knowledge. You'll identify your core values, see how they silently drive spending, debt and lifestyle choices, and learn practical tests to validate what you truly value, so your money serves a bigger purpose: family, faith, integrity, impact and legacy.\n\nIncluded: the full live-session recording, real-life case stories, a values identification exercise, and a values hierarchy framework you can reuse to test future decisions.",
                'outcomes' => [
                    'Why money behaviour is 80% values and behaviour, not knowledge',
                    'Identify your core personal values and how they were formed',
                    'Recognise how values silently drive spending, debt and lifestyle choices',
                    'Apply practical tests so money decisions get easier, faster and more consistent',
                ],
            ],
        ];

        // Prices for the paid single-session masterclasses [KES, USD].
        // Derived from the Academy's relative pricing; confirm/adjust in admin.
        $prices = [
            'retirement-benefits-options' => [1500, 12],
            'planning-for-retirement' => [2500, 20],
            'analyzing-financial-statements' => [2500, 20],
            'crypto-basics' => [2000, 15],
            'core-values-and-your-money' => [1500, 12],
        ];

        foreach ($courses as $data) {
            $intro = $data['description'];
            [$kes, $usd] = $prices[$data['slug']] ?? [0, 0];

            // Course-level fields only. AcademyImportSeeder builds the real
            // lessons (video + materials) afterwards, replacing this placeholder.
            $course = Course::updateOrCreate(
                ['slug' => $data['slug']],
                [...$data, 'price_kes' => $kes, 'price_usd' => $usd, 'is_published' => true]
            );

            $course->modules()->delete();
            $module = $course->modules()->create(['title' => 'Course', 'summary' => null, 'sort' => 0]);
            $module->lessons()->create([
                'title' => 'Course introduction',
                'slug' => 'introduction',
                'summary' => Str::of($intro)->before("\n")->limit(200),
                'video_url' => null,
                'duration_minutes' => 0,
                'is_free_preview' => false,
                'sort' => 0,
            ]);
        }
    }
}
