/* ============================================================
   P&L App (Lite) · "How it works" (the circle top right, and Admin → How it works)
   ------------------------------------------------------------
   The app in plain English, for the person using it. House rule (Ana, 5 Oct 2026):
   every change a user can see updates this guide in the same piece of work,
   and it only describes what is live.
   ============================================================ */
const GUIDE_US = [
  { title: 'What this app does', items: [
    'You type in the money that comes in and the money that goes out. The app turns it into your **Dashboard** and your **Profit & Loss**: what you earned, what it cost, and what you kept.',
    'The free plan has **one login per company**. Nobody outside your company can see your books. Logins for teammates (a bookkeeper, a partner) come with the paid plan.',
    'The **circle with your initial**, top right: which email you are logged in with, **How it works** (this guide) and **Sign out**.',
  ] },
  { title: 'Adding money in and money out', items: [
    '**Money In**: press **Add money in** for each invoice or payment from a customer. The amount is **before sales tax**; pick the sales tax rate and the tax and total are worked out for you.',
    '**Money Out**: press **Add expense** for each bill or receipt. One amount: the full amount you paid, sales tax included (in the US, sales tax on a bill is part of the cost).',
    'A new customer or vendor is added just by typing the name on a row. A name very like one you already have (HOME DEPOT #6512 and Home Depot) is matched to the one you have.',
    '**Status** is Paid or Unpaid. An unpaid row whose due date has passed shows **Overdue** by itself.',
    'Money In has **payment terms**: the due date is the invoice date plus the terms, and follows when you change either.',
  ] },
  { title: 'Changing and finding rows', items: [
    'Click a value in the table to change it straight away. **Open** (the arrow) shows the whole row; changes there are kept only when you press **Save**.',
    'Filter by any field, search, sort, and **Download** exactly the rows on screen as a spreadsheet.',
    'A red dot on a row means it is missing something (a category, or a due date on an unpaid row). The same rows are listed in Admin → **To review**.',
  ] },
  { title: 'Direct costs and overheads', items: [
    'Every expense category is a **direct cost** (the cost of doing the work: materials, subcontractors, labor) or an **overhead** (running the business: rent, insurance, software).',
    '**Gross profit** = revenue minus direct costs. **Net income** = gross profit minus overheads.',
    'You choose which is which in Admin → **Categories**, and can add, rename or delete categories there. A category some rows use cannot be deleted: rename it instead, or give those rows another category first.',
  ] },
  { title: 'Sales tax and income tax', items: [
    '**Sales tax** you charge customers is owed to the state. It is shown apart and never counted as income.',
    '**Set aside for income tax** in Profit & Loss is an estimate only: 25% of net income. It is not tax advice; ask your accountant what to set aside.',
  ] },
  { title: 'Dashboard, Profit & Loss and alerts', items: [
    'Click any card or figure to see exactly the rows that add up to it. The total at the bottom always matches.',
    'The **period button** (Dashboard, top bar; Profit & Loss, above the statement) picks what the figures cover: year to date, a month, a quarter, the last 12 months, a past year, or a custom range.',
    '**Accounts receivable**: what customers still owe you (sales tax included) and how late. **Accounts payable**: what you still owe on your bills and when it is due. Both are always as of today.',
    'The **bell** shows bills and invoices that are overdue or due in the next 7 days.',
    '**Accountant export** (Profit & Loss): every row in a period in one spreadsheet for your accountant.',
    'Dates: click one and a calendar opens. Type the date (MM/DD/YYYY) and press Enter, or pick a day.',
  ] },
  { title: 'Admin', items: [
    '**Vendors / Customers**: rename a name everywhere at once, or merge two that are really the same.',
    '**Categories**: income categories, and expense categories as direct cost or overhead.',
    '**To review**: every row missing something, with the reason.',
    '**Add a teammate** (locked): extra logins come with the paid plan.',
  ] },
  { title: 'The paid plan', items: [
    'Anything with a **lock** is part of the paid plan: automatic import (a PDF, a photo of a receipt or a bank CSV fills the rows in for you), Connect QuickBooks, logins for your team, the document kept with each row, part payments, splitting a bill, jobs and profit by job, vehicles, and more detail on every row.',
    'Click any lock to see what it does and book a 30-minute call. The paid plan is added to this same app: same login, same numbers.',
  ] },
];

/* **bold** inside a guide line */
function _guideLine(text) {
  return text.split('**').map((part, i) => i % 2 ? <b key={i} className="text-ink font-600">{part}</b> : <React.Fragment key={i}>{part}</React.Fragment>);
}

function HowItWorks() {
  return (
    <div className="flex flex-col gap-5">
      {GUIDE_US.map(s => (
        <div key={s.title}>
          <h4 className="text-[14px] font-700 text-ink font-display mb-1.5">{s.title}</h4>
          <ul className="flex flex-col gap-1.5 pl-4 list-disc marker:text-[#C9D9B8]">
            {s.items.map((t, i) => <li key={i} className="text-[13px] text-muted leading-relaxed">{_guideLine(t)}</li>)}
          </ul>
        </div>
      ))}
    </div>
  );
}

Object.assign(window, { HowItWorks, GUIDE_US });
