/**
 * DEMO-ONLY plan & credit balances (pricing strategy doc, 2026-09-07).
 * Real metering, resets, and rollover rules are BACKEND (§25 of the doc):
 * monthly credits reset each cycle and do not roll over; bonus AI credits
 * from route purchases last ~12 months; usage order = monthly → bonus →
 * purchased refills.
 *
 * CONSUMPTION SCOPE (§10-11 — binds the UI even now): AI Credits are consumed
 * ONLY by new AI reasoning (questions, comparisons, summaries, explanations).
 * NEVER by uploading/opening/viewing permits, trips, dashboards, route maps,
 * alerts, history, invites, settings, or RE-VIEWING an old answer — "the user
 * should not feel punished for navigating the platform." The demo balance
 * below is static and must never visually decrement on navigation.
 */

export interface Plan {
  name: string
  price: number
  routes: number
  credits: number
  bestFor: string
  /** Extra positioning line from the strategy doc (Pro §16). */
  positioning?: string
  /** One-line plan purpose (Pro Tools article §26–§29, 2026-09-12). */
  tagline: string
  /** "Includes" list shown on the plan card (same article). */
  includes: string[]
}

/**
 * The four plans — "every paid dollar gives one included Express Route credit."
 * Article §7 (2026-09-12): core operational tools are on every plan; business
 * management tools (invoicing, expenses, PDF, invoice email, financial summary)
 * are Pro and Pro Plus. See CORE_TOOLS / BUSINESS_TOOLS below.
 */
export const PLANS: Plan[] = [
  {
    name: 'Free',
    price: 0,
    routes: 1,
    credits: 1,
    bestFor: 'Testing the platform',
    tagline: 'For trying HeavyHaul Agent and receiving shared trip access.',
    includes: [
      'Basic account',
      'Shared trip access',
      'Limited AI Credits',
      'Limited Express Route access',
      'Basic profile',
      'Document upload when required',
      'View assigned permits and routes when shared',
      'Pilot paperwork on your trips - free for your first 90 days',
    ],
  },
  // Renamed from "Pilot" on 2026-09-12 (Pro Tools article §2–§3): the word now
  // means pilot cars, pilot drivers and pilot companies inside the product.
  {
    name: 'Starter',
    price: 9,
    routes: 9,
    credits: 5,
    bestFor: 'Drivers, owner-operators, occasional users',
    tagline: 'For light individual usage.',
    includes: [
      '9 Express Routes per month',
      'Monthly AI Credits',
      'Core trip tools',
      'Shared permit access',
      'Basic route tools',
      'Basic profile and history',
      'Pilot paperwork on your trips (COI, licenses, certifications) - for brokers, carrier dispatchers and drivers',
    ],
  },
  {
    name: 'Pro',
    price: 29,
    routes: 29,
    credits: 15,
    bestFor: 'Brokers, dispatchers, small carriers, regular users',
    positioning:
      'Best for brokers and dispatchers who want permit visibility, AI answers, and route credits in one workspace.',
    tagline: 'For working users who need business tools.',
    // Nash, 2026-09-13: "the Pro plan has specific things designed for the
    // broker, for the carrier and for the pilot" — each line names its role.
    includes: [
      '29 Express Routes per month',
      'Monthly AI Credits',
      'Everything included in Starter',
      'Pilot companies and pilot drivers: generate invoices for your trips',
      'Pilot drivers: track expenses for the trip',
      'Carrier truck drivers: track expenses for the trip',
      'PDF invoice export',
      'Send invoice by email',
      'Trip financial summary',
      'Custom invoice line items',
      'Receipt uploads',
    ],
  },
  // Nash, 2026-09-13: the Fleet plan ($99) is replaced by Pro Plus ($59) —
  // "simply the higher plan above Pro, not a fleet/team package". No shared
  // routes, shared AI Credits or multi-user logic. The GPS items are FUTURE
  // features listed on the plan only; nothing is built yet.
  {
    name: 'Pro Plus',
    price: 59,
    routes: 59,
    credits: 30,
    bestFor: 'Advanced users, higher usage, future GPS trip visibility',
    tagline:
      'Pro Plus is for advanced users who need more Express Routes, more AI Credits, and future active-trip GPS visibility tools. It includes everything in Pro, plus higher monthly usage and future location-based trip visibility features.',
    includes: [
      '59 Express Routes per month',
      '$30 AI Credits per month',
      'Everything included in Pro',
      'Future active trip GPS visibility',
      'Future truck/driver location view for active trips',
      'Future assigned pilot car location view during active pilot assignments',
    ],
  },
]

/** Pilot build: everyone is on Free until payments connect.
 *  Guardrail from the doc: "Do not give too much free usage" — Free stays at
 *  exactly 1 Express Route + $1 AI Credits; never enrich it without Nash. */
export const CURRENT_PLAN = PLANS[0]

/** Static demo balance shown in the chat + wallet. TODO(backend): real balance. */
export const DEMO_AI_CREDITS_REMAINING = '$1.00'

/** Pay-as-you-go pricing + the ~50% bonus rule (Express $1.99 → $1 bonus;
 *  Extended $10 → $5 bonus). Extended Routes are never covered by monthly
 *  Express Route credits. */
export const PAYG = {
  express: { price: '$1.99', bonus: '$1' },
  extended: { price: '$10', bonus: '$5' },
} as const

/** Article §7 — available across plans. */
export const CORE_TOOLS = [
  'Trip workspace',
  'Permit upload',
  'Shared permit viewing',
  'Basic route viewing if shared or purchased',
  'AI questions using available credits',
  'Basic dashboard',
  'Pilot assignment access',
  'Driver/pilot invite flow',
  'Basic profile',
  'Basic document upload',
  'Trip history',
  'Basic contact information',
] as const

/** Article §7 — Pro or Pro Plus. */
export const BUSINESS_TOOLS = [
  'Invoice generator',
  'Expense tracking',
  'PDF invoice download',
  'Invoice email sending',
  'Invoice history',
  'Trip financial summary',
  'Expense reports',
  'Driver invoice management',
  'Advanced dispatch tools',
  'Document expiration reminders',
  'Advanced reporting',
] as const

/** Article §6 — sell the tools, not the tokens. */
export const PRO_UPGRADE_PITCH =
  'Upgrade to Pro to create invoices, track expenses, generate PDF invoices, and send them directly from the trip.'
