/**
 * WelcomePageData — static data and builder functions extracted from Welcome.tsx (DEBT-005).
 *
 * Contains features list, steps, FAQ copy reference, and `buildPricingTiers`.
 * Move, not rewrite — verbatim from Welcome.tsx.
 */
import {
  Activity,
  BarChart3,
  Bell,
  FileSearch,
  FileText,
  Search,
  Target,
  TrendingUp,
  Zap,
} from 'lucide-react';

import { CTA_LABELS } from '@/config/cta-labels';

export interface WelcomePricing {
  free_name: string;
  free_price: number;
  free_drafts: number;
  pro_name: string;
  pro_price: number;
  pro_drafts: number;
  team_name: string;
  team_price: number;
  team_drafts: number;
}

export interface SocialProofMetrics {
  analyses_run: number;
  recommendations_generated: number;
  sites_connected: number;
}

export const features = [
  {
    icon: Search,
    title: 'Live GSC Data',
    description: 'Real-time Google Search Console integration with traffic analysis.',
  },
  {
    icon: Target,
    title: '12 Recommendation Types',
    description: 'From noindex fixes to full rewrites, ranked by impact.',
  },
  {
    icon: TrendingUp,
    title: 'Keyword Opportunities',
    description: 'Striking distance keywords, CTR gaps, and rising queries.',
  },
  {
    icon: FileSearch,
    title: 'SERP Content Scoring',
    description: 'Optimize word count, headings, and term coverage in real time.',
  },
  {
    icon: Zap,
    title: 'One-Click WordPress Publish',
    description: 'Publish AI drafts directly to WordPress. Batch operations included.',
  },
  {
    icon: BarChart3,
    title: 'ROI Tracking',
    description:
      'Measure clicks, CTR, and position changes at 7, 14, 30, and 90 days. Impact scores adapt to what actually works on your site.',
  },
  {
    icon: Bell,
    title: 'Traffic Anomaly Alerts',
    description: 'Automatic detection of sudden drops, sustained declines, and spikes.',
  },
  {
    icon: FileText,
    title: 'Shareable Report Links',
    description:
      'Generate password-protected, expiring report links — no login required for recipients.',
  },
  {
    icon: Activity,
    title: 'Algorithm-Update Correlation',
    description:
      'Automatically correlates traffic drops to named Google update windows — so you know if it was your content or the algorithm.',
  },
];

export const steps = [
  {
    number: '1',
    title: 'Connect',
    time: '~3 min',
    description:
      'Authorize Google Search Console and install the WordPress plugin. No server configuration needed.',
  },
  {
    number: '2',
    title: 'Analyze',
    time: '~2 min',
    description:
      'Pick a before-after time window. RankWizAI identifies traffic changes and generates prioritized recommendations.',
  },
  {
    number: '3',
    title: 'Fix & Track',
    time: 'Ongoing',
    description:
      'Approve AI drafts, publish to WordPress, and watch ROI tracking confirm which changes drove results.',
  },
];

export function buildPricingTiers(p?: WelcomePricing, activeTrialCount?: number) {
  const freePrice = p?.free_price ?? 0;
  const freeDrafts = p?.free_drafts ?? 5;
  const proPrice = p?.pro_price ?? 49;
  const proDrafts = p?.pro_drafts ?? 100;
  const teamPrice = p?.team_price ?? 99;

  const teamSubtext =
    activeTrialCount && activeTrialCount > 0
      ? `${activeTrialCount} teams starting free this month`
      : 'No credit card. Cancel anytime.';

  return [
    {
      key: 'free',
      name: p?.free_name ?? 'Starter',
      price: freePrice === 0 ? '$0' : `$${freePrice}`,
      period: '/month',
      cta: CTA_LABELS.FREE_NO_CARD,
      cta_subtext: undefined as string | undefined,
      features: [
        '1 WordPress site',
        'Up to 25 pages analyzed',
        `${freeDrafts} AI drafts/month`,
        'All 8 recommendation types',
      ],
    },
    {
      key: 'pro',
      name: p?.pro_name ?? 'Professional',
      price: `$${proPrice}`,
      period: '/month',
      highlight: true,
      cta: CTA_LABELS.PRO_TRIAL,
      cta_subtext: 'No credit card. Cancel anytime.' as string | undefined,
      features: [
        'Up to 5 sites',
        `${proDrafts} AI drafts/month`,
        'Batch AI & SERP scoring',
        'Traffic anomaly alerts',
      ],
    },
    {
      key: 'team',
      name: p?.team_name ?? 'Power',
      price: `$${teamPrice}`,
      period: '/month',
      cta: CTA_LABELS.TEAM_TRIAL,
      cta_subtext: teamSubtext as string | undefined,
      features: [
        'Unlimited sites, pages & AI drafts',
        'Shareable report links & custom domain',
        'Team roles with full audit trail',
        'Multi-site cohort refresh & client-ready ROI reports',
      ],
    },
  ];
}
