import type { BusinessModel } from "@/content/types";

export type OpportunityArea = "measurement" | "conversion" | "demand" | "creative" | "retention";

export interface DiagnosticOption {
  value: string;
  label: string;
}

export interface DiagnosticQuestion {
  id: "model" | "objective" | "spend" | "constraint" | "platform";
  label: string;
  options: DiagnosticOption[];
}

export const diagnosticQuestions: DiagnosticQuestion[] = [
  {
    id: "model",
    label: "Business model",
    options: [
      { value: "saas", label: "SaaS" },
      { value: "ecommerce", label: "E-commerce" },
    ],
  },
  {
    id: "objective",
    label: "Primary objective",
    options: [
      { value: "scale", label: "Scale acquisition" },
      { value: "efficiency", label: "Improve efficiency" },
      { value: "conversion", label: "Improve conversion" },
      { value: "measurement", label: "Improve measurement" },
    ],
  },
  {
    id: "spend",
    label: "Monthly paid-media spend (USD)",
    options: [
      { value: "none", label: "Not running paid media" },
      { value: "under-10k", label: "Under $10k" },
      { value: "10k-50k", label: "$10k–$50k" },
      { value: "50k-150k", label: "$50k–$150k" },
      { value: "150k-plus", label: "$150k+" },
    ],
  },
  {
    id: "constraint",
    label: "Biggest constraint",
    options: [
      { value: "traffic", label: "Traffic" },
      { value: "conversion", label: "Conversion" },
      { value: "tracking", label: "Tracking" },
      { value: "creative", label: "Creative" },
      { value: "retention", label: "Retention" },
    ],
  },
  {
    id: "platform",
    label: "Primary platform",
    options: [
      { value: "google", label: "Google Ads" },
      { value: "meta", label: "Meta" },
      { value: "linkedin", label: "LinkedIn" },
      { value: "microsoft", label: "Microsoft Ads" },
      { value: "organic", label: "SEO + organic" },
      { value: "none", label: "No clear primary" },
    ],
  },
];

export const areaCopy: Record<OpportunityArea, { label: string; summary: string; checks: Record<BusinessModel, string[]> }> = {
  measurement: {
    label: "Measurement",
    summary:
      "Decisions are only as good as the data behind them. If conversions, pipeline, or revenue aren't tracked cleanly, budget drifts toward what's easy to count instead of what makes money.",
    checks: {
      saas: [
        "Whether CRM stages (SQL, opportunity, closed-won) flow back to ad platforms",
        "Source capture on every form, demo booking, and trial signup",
        "Where platform-reported conversions disagree with CRM pipeline",
      ],
      ecommerce: [
        "Match between server-side and browser purchase events",
        "Platform-reported revenue against store revenue, week by week",
        "Whether MER, new-customer CAC, and contribution margin are reported together",
      ],
    },
  },
  conversion: {
    label: "Conversion",
    summary:
      "Traffic is reaching you, but too little of it becomes demos, trials, or orders. Conversion gains compound across every channel you pay for.",
    checks: {
      saas: [
        "Message match between top campaigns and their landing pages",
        "Friction in demo booking and trial signup flows",
        "Drop-off between form submission and a booked meeting",
      ],
      ecommerce: [
        "Product page clarity: delivery, returns, and product detail",
        "Mobile checkout friction and payment options",
        "Free-shipping thresholds and offers relative to AOV",
      ],
    },
  },
  demand: {
    label: "Demand capture",
    summary:
      "The funnel may convert, but not enough qualified demand is entering it. The work is finding the channels, queries, and audiences that can scale at your target CAC.",
    checks: {
      saas: [
        "Search coverage of high-intent, category, and competitor terms",
        "Audience and account targeting on LinkedIn and Meta",
        "Organic and AI search visibility for buying-stage questions",
      ],
      ecommerce: [
        "Shopping feed quality and product coverage",
        "The balance of prospecting and retargeting on Meta",
        "Non-brand search and category page visibility",
      ],
    },
  },
  creative: {
    label: "Creative testing",
    summary:
      "Paid social performance usually depends more on creative than on targeting. Without a steady testing rhythm, results fade as audiences tire of the same ads.",
    checks: {
      saas: [
        "Whether creative speaks to specific roles, pains, and use cases",
        "Offer strength: demo, trial, tool, or content",
        "Test cadence, and how learnings are recorded",
      ],
      ecommerce: [
        "Creative volume and angle variety by product",
        "Fatigue signals: rising frequency with falling click-through",
        "Hooks, formats, and offers tested in a structured way",
      ],
    },
  },
  retention: {
    label: "Retention",
    summary:
      "Acquisition gets more expensive when customers don't return or expand. Better retention raises lifetime value, and with it the CAC you can afford.",
    checks: {
      saas: [
        "Trial activation and onboarding emails",
        "Nurture for prospects who aren't ready to buy yet",
        "Expansion and churn-risk signals in product and CRM data",
      ],
      ecommerce: [
        "Core flows: welcome, browse and cart abandonment, post-purchase",
        "Repeat purchase timing by product",
        "Segmentation by value, recency, and category",
      ],
    },
  },
};

/** Canonical names for every pair of areas, independent of order. */
export const pairNames: Record<string, string> = {
  "conversion+measurement": "Measurement + conversion infrastructure",
  "demand+measurement": "Measurement + demand capture",
  "creative+measurement": "Measurement + creative testing",
  "measurement+retention": "Measurement + lifecycle retention",
  "conversion+demand": "Demand capture + conversion",
  "conversion+creative": "Creative + conversion message match",
  "conversion+retention": "Conversion + customer retention",
  "creative+demand": "Demand capture + creative testing",
  "demand+retention": "Acquisition + retention economics",
  "creative+retention": "Creative testing + lifecycle retention",
};
