/**
 * Services Catalog — centralized pricing and durations.
 * All service CTAs route to the contact form.
 */

export interface Service {
  category: "audit" | "build" | "migration" | "training" | "service";
  currency: "USD";
  deliverable: string;
  description: string;
  duration: string;
  featured?: boolean;
  price: number | string; // number for fixed price, string for ranges like "6000-15000"
  slug: string;
  title: string;
}

const servicesCatalog: Service[] = [
  // ============================================
  // AUDITS
  // ============================================
  {
    slug: "headless-performance-audit",
    category: "audit",
    title: "Headless Performance Audit (Light)",
    description:
      "A rapid diagnostic of your site's SEO, speed, and technical health. Perfect for getting a quick, expert overview.",
    deliverable: "PDF Report + HTML Lighthouse + Key Recommendations.",
    duration: "3 days",
    price: 199,
    currency: "USD",
    featured: true,
  },
  {
    slug: "headless-optimization-migration-audit",
    category: "audit",
    title: "Headless Optimization & Migration Audit (Pro)",
    description:
      "Our most comprehensive audit for teams serious about growth. Covers marketing tech, full SEO, API performance, and ROI analysis.",
    deliverable: "Detailed PDF Report + Data JSON + Technical Action Plan.",
    duration: "7-10 days",
    price: "1200-2000",
    currency: "USD",
    featured: true,
  },
  {
    slug: "shopify-posthog-experiments-audit",
    category: "audit",
    title: "Shopify Headless + Posthog Experiments Audit",
    description:
      "Analysis of Posthog tracking, Feature Flags, and impact on SEO/UX.",
    deliverable: "Event Flow + Posthog Performance Report.",
    duration: "5 days",
    price: 900,
    currency: "USD",
  },
  {
    slug: "feature-flags-seo-impact",
    category: "audit",
    title: "Feature Flags & SEO Impact Review",
    description:
      "Audit of SSR/ISR rendering variations related to Feature Flags.",
    deliverable: "SEO Impact Report + Implementation Checklist.",
    duration: "4 days",
    price: 800,
    currency: "USD",
  },
  {
    slug: "cms-api-latency-audit",
    category: "audit",
    title: "CMS API Latency & Data Pipeline Audit",
    description:
      "Detection of slowdowns in CMS → Frontend chain (Prismic, WP GraphQL, Contentful).",
    deliverable: "Request Heatmap + Caching/CDN Recommendations.",
    duration: "5 days",
    price: 900,
    currency: "USD",
  },
  {
    slug: "core-web-vitals-headless",
    category: "audit",
    title: "Core Web Vitals Headless Optimization",
    description: "Deep-dive analysis of LCP, INP, CLS for Headless stack.",
    deliverable: "Lighthouse Report + Prioritized Fix List.",
    duration: "3 days",
    price: 700,
    currency: "USD",
  },
  {
    slug: "shopify-storefront-api-performance",
    category: "audit",
    title: "Storefront API Performance Audit (Shopify Hydrogen)",
    description: "Optimization of Storefront API and ISR/Edge caching.",
    deliverable: "JSON Report + GraphQL Query Analysis.",
    duration: "5 days",
    price: 950,
    currency: "USD",
  },
  {
    slug: "headless-migration-seo-mapping",
    category: "audit",
    title: "Headless Migration SEO Mapping",
    description:
      "Verification of SEO mapping and structure during Headless migrations.",
    deliverable: "URL Mapping Table + JSON Schema + Sitemap.",
    duration: "5 days",
    price: 1000,
    currency: "USD",
  },
  {
    slug: "tracking-layer-consistency",
    category: "audit",
    title: "Tracking Layer Consistency Audit",
    description: "Audit of GA4 / Meta Pixel / Posthog in Headless environment.",
    deliverable: "Tracking Diagram + Event Table.",
    duration: "4 days",
    price: 850,
    currency: "USD",
  },
  {
    slug: "marketing-experiment-readiness",
    category: "audit",
    title: "Marketing Experiment Readiness Audit",
    description: "Verifies ability to run A/B tests without performance loss.",
    deliverable: "Experimentation Plan + Readiness Score.",
    duration: "4 days",
    price: 850,
    currency: "USD",
  },
  {
    slug: "international-seo-geo-headless",
    category: "audit",
    title: "International SEO & GEO-Headless Configuration",
    description:
      "Audit of multilingual and multi-country Headless configuration.",
    deliverable: "Hreflang JSON Report + Indexation Strategy.",
    duration: "5 days",
    price: 900,
    currency: "USD",
  },
  {
    slug: "headless-security-api-check",
    category: "audit",
    title: "Headless Security & API Exposure Check",
    description:
      "Security audit of Headless APIs, tokens and marketing webhooks.",
    deliverable: "OWASP-style Report + Security Checklist.",
    duration: "3 days",
    price: 700,
    currency: "USD",
  },

  // ============================================
  // BUILDS
  // ============================================
  {
    slug: "shopify-headless-creation",
    category: "build",
    title: "Shopify Headless Creation",
    description:
      "A complete, custom Headless storefront built with Shopify Hydrogen or Next.js, fully integrated with the CMS of your choice.",
    deliverable: "Deployed Headless Site + Documentation + SEO Setup.",
    duration: "3-6 weeks",
    price: "6000-15000",
    currency: "USD",
    featured: true,
  },
  {
    slug: "wordpress-headless-setup",
    category: "build",
    title: "WordPress Headless Setup (WooCommerce)",
    description:
      "Conversion of WordPress or WooCommerce to Headless Next.js with preserved SEO structure.",
    deliverable:
      "Next.js Front + Content Migration + Redirects + Lighthouse Report.",
    duration: "3-5 weeks",
    price: "5000-12000",
    currency: "USD",
  },

  // ============================================
  // MIGRATION
  // ============================================
  {
    slug: "wordpress-to-shopify-migration",
    category: "migration",
    title: "Migration WordPress → Shopify Headless",
    description:
      "Our signature zero-loss migration service. We handle everything: data, content, SEO, tracking, and performance.",
    deliverable: "New Shopify Headless Site + Tracking + Final Audit.",
    duration: "5-8 weeks",
    price: "8000-20000",
    currency: "USD",
    featured: true,
  },

  // ============================================
  // TRAINING
  // ============================================
  {
    slug: "seo-technical-data-workshop",
    category: "training",
    title: "SEO Technique & Data Workshop (2h)",
    description: "Private coaching for marketers on technical SEO audits.",
    deliverable: "Live Session + Practical Guide + Optional Replay.",
    duration: "2 hours",
    price: 400,
    currency: "USD",
  },
  {
    slug: "ai-for-seo-teams",
    category: "training",
    title: "AI for SEO Teams Workshop (2h)",
    description: "Training on AI applied to SEO (prompting, automation, APIs).",
    deliverable: "Group Session + Post-Training Support.",
    duration: "2 hours",
    price: 400,
    currency: "USD",
  },

  // ============================================
  // SERVICES
  // ============================================
  {
    slug: "cro-optimization",
    category: "service",
    title: "Conversion Rate Optimization (CRO)",
    description:
      "Data-driven CRO service combining A/B testing, heatmap analysis, and UX optimization to maximize conversions on your existing traffic.",
    deliverable:
      "CRO Audit Report + A/B Test Roadmap + Implementation Support.",
    duration: "Ongoing",
    price: "2000-5000",
    currency: "USD",
  },
  {
    slug: "wordpress-maintenance",
    category: "service",
    title: "WordPress Managed Maintenance",
    description:
      "Proactive WordPress maintenance including core/plugin updates, security monitoring, performance optimization, and uptime guarantees.",
    deliverable: "Monthly Report + Priority Support + Security Monitoring.",
    duration: "Monthly",
    price: "200-500",
    currency: "USD",
  },
  {
    slug: "wordpress-security",
    category: "service",
    title: "WordPress Security Hardening",
    description:
      "Application-level WordPress security: WAF deployment, malware scanning, file integrity monitoring, and incident response.",
    deliverable: "Security Audit Report + WAF Setup + Monitoring Dashboard.",
    duration: "One-time + Monthly",
    price: "500-1500",
    currency: "USD",
  },
  {
    slug: "wordpress-malware-removal",
    category: "service",
    title: "WordPress Malware Removal",
    description:
      "Emergency WordPress malware removal: deep scan, forensic analysis, complete cleanup, database sanitization, and post-cleanup hardening with 90-day guarantee.",
    deliverable:
      "Clean Site + Forensic Report + Hardening Checklist + 90-Day Guarantee.",
    duration: "24-48 hours",
    price: "499-899",
    currency: "USD",
  },
];

/**
 * Helper Functions
 */

// Get service by slug
export const getServiceBySlug = (slug: string): Service | undefined =>
  servicesCatalog.find((service) => service.slug === slug);

// Get services by category
const _getServicesByCategory = (category: Service["category"]): Service[] =>
  servicesCatalog.filter((service) => service.category === category);

// Get featured services
export const getFeaturedServices = (): Service[] =>
  servicesCatalog.filter((service) => service.featured);

// Format price for display
export const formatPrice = (
  price: number | string,
  currency = "USD"
): string => {
  if (typeof price === "number") {
    return new Intl.NumberFormat("en-US", {
      style: "currency",
      currency,
      minimumFractionDigits: 0,
    }).format(price);
  }
  // Handle ranges like "6000-15000"
  const [min, max] = price.split("-").map(Number);
  return `${formatPrice(min, currency)} - ${formatPrice(max, currency)}`;
};

/**
 * Service Categories Configuration
 */
const _serviceCategories = {
  audits: {
    title: "Performance Audits",
    description: "Deep-dive technical analysis and optimization.",
    icon: "IconChartBar",
    slug: "audits",
    href: "/services/audits",
    subcategories: [
      {
        slug: "performance",
        title: "Performance & Core Web Vitals",
        description:
          "Optimize LCP, INP, CLS and API latency for lightning-fast experiences.",
        href: "/services/audits/performance",
        serviceCount: 4,
      },
    ],
  },
  builds: {
    title: "Headless Builds",
    description: "Custom e-commerce solutions built for scale.",
    icon: "IconCode",
    slug: "builds",
    href: "/services/builds/shopify-headless",
  },
  migration: {
    title: "Platform Migration",
    description: "Seamless transitions to modern architectures.",
    icon: "IconDatabase",
    slug: "migration",
    href: "/services/builds/shopify-headless",
  },
  training: {
    title: "Expert Training",
    description: "Upskill your team with cutting-edge knowledge.",
    icon: "IconUsers",
    slug: "training",
    href: "/services/training/seo-technical",
  },
} as const;
