<?php

namespace Database\Seeders;

use App\Models\Guide;
use Illuminate\Database\Seeder;

class GuideSeeder extends Seeder
{
    public function run(): void
    {
        $guides = [
            [
                'slug' => 'debt-free-playbook',
                'title' => 'The Debt-Free Playbook',
                'category' => 'Debt',
                'cover_path' => 'images/stock/debt-free.jpg',
                'description' => 'The step-by-step system for clearing mobile loans, bank loans and family debts, for good.',
                'pages' => [
                    ['title' => 'Why debt wins (until today)', 'body' => "Debt doesn't win because you're weak. It wins because it's a system, automated, compounding and patient, while your repayment is usually a mood.\n\nThis playbook replaces mood with system. Five short chapters, one decision each. By the last page you'll have a written plan with a date on it."],
                    ['title' => 'Step 1, Face the number', 'body' => "List every single debt: mobile loans, bank, SACCO, employer, family. For each one write the balance, the interest rate, and the minimum payment.\n\nAdd it up. Look at it. Say it out loud.\n\nThat discomfort you feel? That's the debt losing its biggest weapon, vagueness. A named number can be killed."],
                    ['title' => 'Step 2, Stop the bleeding', 'body' => "No new debt from today. Not 'less debt', none.\n\nIf mobile loans are a monthly habit, the problem is a budget gap, not a borrowing gap. Find the leak: track 7 days of spending and one category will confess.\n\nDelete the loan apps. Seriously. The 30 seconds it takes to reinstall one is often enough for the urge to pass."],
                    ['title' => 'Step 3, Pick your weapon', 'body' => "Snowball: pay minimums on everything, throw every extra coin at the SMALLEST debt. Quick wins, unstoppable momentum.\n\nAvalanche: same, but target the HIGHEST INTEREST debt first. Mathematically cheapest.\n\nAcross Africa, mobile loans are usually both the smallest AND the most expensive, so both strategies agree: kill the app loans first."],
                    ['title' => 'Step 4, Protect the plan', 'body' => "Build a small emergency buffer at the same time, even one month of basic expenses.\n\nWithout it, the next emergency sends you straight back to borrowing and the plan dies. With it, emergencies become inconveniences.\n\nKeep it in a money market fund: close enough for real emergencies, far enough to survive impulses."],
                    ['title' => 'Step 5, Make it official', 'body' => "Open the Debt Payoff Planner at moneywise.co.ke/tools/debt-payoff. Enter your debts, choose your strategy, and meet your debt-free date.\n\nDownload the PDF. Stick it where you'll see it. Tell one person you trust.\n\nEvery cleared loan is a celebration. Mark each one, you're not just clearing debts, you're changing your family's story."],
                ],
            ],
            [
                'slug' => 'first-investment-guide',
                'title' => 'Your First Investment',
                'category' => 'Investing',
                'cover_path' => 'images/stock/investing.jpg',
                'description' => 'From "where do I even start?" to your first money market fund, in five honest pages.',
                'pages' => [
                    ['title' => 'The lie that keeps you waiting', 'body' => "\"I'll invest when I have real money.\"\n\nThat sentence has cost more African wealth than any scam. The truth: investing is a habit, not an amount. The person investing the smallest amount monthly is wealthier, in habit, knowledge and momentum, than the one waiting for a windfall.\n\nThis guide gets you started this week."],
                    ['title' => 'Before you invest one coin', 'body' => "Two prerequisites, no exceptions:\n\n1. No expensive debt. Mobile-loan interest beats any investment return. Clear it first, the Debt-Free Playbook is the companion to this guide.\n\n2. A starter emergency fund, one month of expenses. Without it, your first emergency becomes a forced withdrawal at the worst time."],
                    ['title' => 'Where first money belongs', 'body' => "The money market fund (MMF): the training ground of African investing.\n\nWhy it's first: low minimums, withdrawals in days not years, returns that beat every bank account, and regulated custody.\n\nIt won't make you rich, it makes you an investor. The habit, the statements, the watching it grow: that's the education."],
                    ['title' => 'How to choose your MMF', 'body' => "Compare three things:\n\n1. The effective annual yield (after fees), published monthly.\n2. The minimum investment and top-up amounts.\n3. Withdrawal speed and process.\n\nChoose a regulated, well-known manager in your market. Ask: is this fund licensed by my market's capital markets authority? If the seller gets cagey, walk."],
                    ['title' => 'The 90-day plan', 'body' => "Week 1: open the MMF account with the minimum.\nWeek 2: set an automatic monthly transfer, payday, before you can spend it.\nMonth 2: read your first statement; understand every line.\nMonth 3: increase the amount by any raise you can manage.\n\nThen come back to moneywise.co.ke/learn, goals, baskets and beyond. You're an investor now. Act accordingly."],
                ],
            ],
            [
                'slug' => 'emergency-fund-blueprint',
                'title' => 'The Emergency Fund Blueprint',
                'category' => 'Saving',
                'cover_path' => 'images/stock/savings.jpg',
                'description' => 'How much, where to keep it, and how to build it without feeling the pinch.',
                'pages' => [
                    ['title' => 'The fund that buys you sleep', 'body' => "An emergency fund isn't an investment. Its job isn't growth, it's peace.\n\nIt's the difference between an emergency being a bad week and a debt spiral. Between taking the first job and choosing the right one. Between panic and a plan.\n\nFour pages from now you'll know exactly how to build yours."],
                    ['title' => 'Your number', 'body' => "Essential monthly expenses × the right multiplier:\n\n• Stable salary: 3 months\n• Mixed income: 6 months\n• Hustle or freelance: 9 months\n\n'Essential' means survival mode: rent, food, transport, school fees, family support. Not lifestyle mode.\n\nCalculate yours precisely at moneywise.co.ke/tools/emergency-fund."],
                    ['title' => 'Where it lives', 'body' => "The fund needs to be close enough to reach in days, far enough to survive temptation:\n\n• 80-90% in a money market fund, earning real returns, withdrawable in 2-4 days.\n• 10-20% in a mobile-money savings vault, same-day access for true emergencies.\n• 0% in your everyday account, it will quietly become airtime and weekend plans.\n• 0% in shares or land, emergencies don't wait for the right price."],
                    ['title' => 'Building it painlessly', 'body' => "1. Automate a fixed amount the day money arrives, what you don't see, you don't spend.\n2. Bank every windfall: bonuses, refunds, side-hustle spikes. Pretend they never happened.\n3. Sell something. Most homes hold a month of expenses in unused things.\n4. Direct one expense you cut (one subscription, one habit) straight into the fund.\n\nSpeed matters less than direction."],
                    ['title' => 'The rules of use', 'body' => "Touch it only for true emergencies: medical, job loss, urgent family crisis, critical repairs.\n\nNot emergencies: sales, weddings, holidays, 'opportunities'. An opportunity that requires your safety net is a risk you can't afford yet.\n\nAfter every use: pause investing if needed and refill the fund first. The net goes back up before the acrobatics resume."],
                ],
            ],
            [
                'slug' => 'group-investing-starter-kit',
                'title' => 'The Group Investing Starter Kit',
                'category' => 'Chama & Groups',
                'cover_path' => 'images/stock/community.jpg',
                'description' => 'Chama, stokvel, susu or esusu, the governance kit that keeps friendship and money alive together.',
                'pages' => [
                    ['title' => 'Why groups beat individuals', 'body' => "Across Africa, group saving is a superpower: discipline through community, scale through pooling, and access to deals no individual could touch.\n\nIt's also where friendships go to die, when structure is missing.\n\nThis kit is the structure. Five pages, five fixes, zero drama."],
                    ['title' => 'The constitution', 'body' => "One page, written, signed by every member:\n\n• Purpose: saving? investing? both?\n• Leadership: roles, terms, how leaders change.\n• Money rules: contribution amount, due date, penalties, applied to EVERYONE equally.\n• Exit: how a member leaves, how their share is valued, how fast they're paid.\n\nDo this while everyone is still friends. That's the whole trick."],
                    ['title' => 'The money rules', 'body' => "• Group bank account with 3+ signatories. The treasurer's personal wallet is not infrastructure.\n• Monthly statement to every member: money in, money out, balance. Transparency kills suspicion before it grows.\n• Penalties applied automatically, the moment 'special cases' appear, the group has started dying.\n• Records in writing. The treasurer's memory is not a ledger."],
                    ['title' => 'Going legal', 'body' => "Register the group, self-help group, cooperative or company, whatever fits your market.\n\nWhy it matters: the group can own assets in its OWN name. Land bought in a 'trusted member's' name is a heartbreak with a title deed.\n\nRegistration also unlocks: group bank accounts, formal investments, loans against group assets, and continuity when members change."],
                    ['title' => 'From saving to investing', 'body' => "Once governance is solid, graduate the money:\n\n1. Park contributions in a money market fund, not a dormant account.\n2. Write a one-page investment policy: what you invest in, what you never touch, how you vote.\n3. Research before the meeting, decide at the meeting, document after the meeting.\n\nScore your group honestly at moneywise.co.ke/assessments/chama-health, then fix what the score flags."],
                ],
            ],
        ];

        foreach ($guides as $i => $guide) {
            Guide::updateOrCreate(['slug' => $guide['slug']], [...$guide, 'sort' => $i, 'is_published' => true]);
        }
    }
}
