import Link from "next/link";

import {
  Activity,
  ArrowRight,
  Brain,
  Briefcase,
  CheckCircle2,
  Heart,
  Moon,
  TrendingDown,
} from "lucide-react";

import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardHeader } from "@/components/ui/card";
import { Separator } from "@/components/ui/separator";
import { ARCHETYPES } from "@/data/archetypes";
import { PACKAGES } from "@/data/packages";
import { LandingFaq } from "./_components/landing-faq";

const ARCHETYPE_ICONS: Record<string, React.ElementType> = {
  Brain,
  Activity,
  Moon,
  Briefcase,
  Heart,
  TrendingDown,
};

const HOW_IT_WORKS = [
  {
    step: "01",
    title: "Take the 10-Minute Assessment",
    description:
      "Answer questions across 10 sections covering lifestyle, eating patterns, sleep, hormones, and medical history.",
    color: "bg-teal-600",
  },
  {
    step: "02",
    title: "Discover Your Archetype",
    description:
      "Our scoring system classifies you into 1 of 6 metabolic archetypes — your personal blueprint for weight management.",
    color: "bg-violet-600",
  },
  {
    step: "03",
    title: "Unlock Your Personalised Report",
    description:
      "Choose a Starter, Advanced, or Professional package and receive a science-backed report tailored to your profile.",
    color: "bg-amber-500",
  },
  {
    step: "04",
    title: "Transform Your Health",
    description:
      "Follow your archetype-specific nutrition, lifestyle, and supplement protocol for lasting metabolic change.",
    color: "bg-emerald-600",
  },
];

const PAIN_POINTS = [
  {
    icon: "🔁",
    title: "The same diet fails again and again",
    description:
      "Calorie counting works for some people and completely fails for others — because your metabolic type determines how your body responds to food.",
  },
  {
    icon: "😓",
    title: "Willpower is never the problem",
    description:
      "Stress, hormones, sleep deprivation, and insulin resistance are biological forces that no amount of discipline can override alone.",
  },
  {
    icon: "🧬",
    title: "One-size-fits-all advice is ineffective",
    description:
      "Generic nutrition advice ignores the fact that 6 completely different metabolic profiles require 6 completely different approaches.",
  },
];

const TESTIMONIALS = [
  {
    quote:
      "After years of trying every diet, finally understanding I'm a Stress Eater changed everything. My cortisol-focused protocol has helped me lose 8kg in 3 months without counting a single calorie.",
    author: "K.M.",
    location: "Zurich, Switzerland",
    archetype: "The Stress Eater",
    archetypeColor: "bg-violet-100 text-violet-700",
  },
  {
    quote:
      "I had thyroid issues and PCOS and nothing was working. My Hormonal Imbalancer report finally explained WHY. The cycle-syncing approach has been life-changing.",
    author: "S.B.",
    location: "Geneva, Switzerland",
    archetype: "The Hormonal Imbalancer",
    archetypeColor: "bg-pink-100 text-pink-700",
  },
  {
    quote:
      "I work 60-hour weeks at a desk. Being identified as a Sedentary Professional gave me a protocol I could actually fit into my schedule. Down 6kg in 6 weeks.",
    author: "T.W.",
    location: "Basel, Switzerland",
    archetype: "The Sedentary Professional",
    archetypeColor: "bg-amber-100 text-amber-700",
  },
];

export default function LandingPage() {
  return (
    <div className="flex flex-col">
      {/* ── Hero ──────────────────────────────────────────────────────────────── */}
      <section className="relative overflow-hidden bg-gradient-to-br from-teal-950 via-teal-900 to-emerald-900 px-4 py-20 md:py-32">
        {/* Decorative blobs */}
        <div className="pointer-events-none absolute inset-0 overflow-hidden">
          <div className="absolute -top-40 -right-40 h-96 w-96 rounded-full bg-teal-500/10 blur-3xl" />
          <div className="absolute -bottom-20 -left-20 h-80 w-80 rounded-full bg-emerald-400/10 blur-3xl" />
        </div>

        <div className="relative mx-auto max-w-6xl">
          <div className="mx-auto max-w-3xl text-center">
            <Badge className="mb-6 border-teal-500/40 bg-teal-500/20 text-teal-300 hover:bg-teal-500/20">
              AI-Assisted Precision Weight Management
            </Badge>
            <h1 className="mb-6 text-4xl font-extrabold leading-tight tracking-tight text-white md:text-5xl lg:text-6xl">
              Discover Why Your{" "}
              <span className="text-teal-300">Metabolism Works Against You</span>
            </h1>
            <p className="mb-10 text-lg text-teal-100/80 md:text-xl leading-relaxed">
              Take our 10-minute precision assessment and discover your metabolic archetype — your personalised
              blueprint for lasting weight management. Science-backed. Swiss precision.
            </p>
            <div className="flex flex-col items-center gap-4 sm:flex-row sm:justify-center">
              <Button
                asChild
                size="lg"
                className="bg-amber-500 hover:bg-amber-400 text-white font-bold shadow-lg shadow-amber-500/30 px-8"
              >
                <Link href="/quiz">
                  Find Your Metabolic Type — Free Assessment
                  <ArrowRight className="ml-2 h-4 w-4" />
                </Link>
              </Button>
              <Button
                asChild
                variant="outline"
                size="lg"
                className="border-teal-400/40 bg-transparent text-teal-200 hover:bg-teal-800/50 hover:text-white"
              >
                <Link href="#how-it-works">How It Works</Link>
              </Button>
            </div>
            <p className="mt-6 text-sm text-teal-300/60">No credit card required · Results in 10 minutes · 100% free to discover your type</p>
          </div>

          {/* Archetype teaser grid */}
          <div className="mt-16 grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-6">
            {ARCHETYPES.map((archetype) => {
              const Icon = ARCHETYPE_ICONS[archetype.icon] || Brain;
              return (
                <div
                  key={archetype.id}
                  className="flex flex-col items-center gap-2 rounded-xl border border-white/10 bg-white/5 p-3 text-center backdrop-blur-sm"
                >
                  <div
                    className="flex h-10 w-10 items-center justify-center rounded-lg"
                    style={{ backgroundColor: `${archetype.color}30` }}
                  >
                    <Icon className="h-5 w-5" style={{ color: archetype.color }} />
                  </div>
                  <p className="text-xs font-medium leading-tight text-white/80">{archetype.name}</p>
                </div>
              );
            })}
          </div>
        </div>
      </section>

      {/* ── Problem Statement ─────────────────────────────────────────────────── */}
      <section className="bg-gray-50 px-4 py-20">
        <div className="mx-auto max-w-6xl">
          <div className="mx-auto max-w-2xl text-center">
            <h2 className="text-3xl font-bold tracking-tight text-gray-900 md:text-4xl">
              95% of diets fail — because they ignore your metabolic type
            </h2>
            <p className="mt-4 text-gray-500">
              The reason isn't lack of effort. It's that you've been using the wrong approach for your unique biology.
            </p>
          </div>
          <div className="mt-12 grid gap-6 md:grid-cols-3">
            {PAIN_POINTS.map((point) => (
              <Card key={point.title} className="border-0 bg-white shadow-sm">
                <CardHeader className="pb-3">
                  <div className="mb-3 text-3xl">{point.icon}</div>
                  <h3 className="font-semibold text-gray-900">{point.title}</h3>
                </CardHeader>
                <CardContent>
                  <p className="text-sm text-gray-500 leading-relaxed">{point.description}</p>
                </CardContent>
              </Card>
            ))}
          </div>
        </div>
      </section>

      {/* ── How It Works ──────────────────────────────────────────────────────── */}
      <section id="how-it-works" className="bg-white px-4 py-20">
        <div className="mx-auto max-w-6xl">
          <div className="mx-auto max-w-2xl text-center">
            <h2 className="text-3xl font-bold tracking-tight text-gray-900 md:text-4xl">
              How Novalife Works
            </h2>
            <p className="mt-4 text-gray-500">Four steps to understanding and transforming your metabolism.</p>
          </div>
          <div className="mt-12 grid gap-8 md:grid-cols-2 lg:grid-cols-4">
            {HOW_IT_WORKS.map((step, i) => (
              <div key={step.step} className="relative flex flex-col items-start">
                {i < HOW_IT_WORKS.length - 1 && (
                  <div className="absolute top-6 left-14 hidden h-0.5 w-full bg-gray-100 lg:block" />
                )}
                <div
                  className={`mb-4 flex h-12 w-12 items-center justify-center rounded-xl text-white font-bold text-sm shadow-lg ${step.color}`}
                >
                  {step.step}
                </div>
                <h3 className="mb-2 font-semibold text-gray-900">{step.title}</h3>
                <p className="text-sm text-gray-500 leading-relaxed">{step.description}</p>
              </div>
            ))}
          </div>
        </div>
      </section>

      {/* ── The 6 Archetypes ──────────────────────────────────────────────────── */}
      <section className="bg-gray-50 px-4 py-20">
        <div className="mx-auto max-w-6xl">
          <div className="mx-auto max-w-2xl text-center">
            <h2 className="text-3xl font-bold tracking-tight text-gray-900 md:text-4xl">
              6 Metabolic Archetypes
            </h2>
            <p className="mt-4 text-gray-500">
              Every person falls into one of 6 distinct metabolic profiles. Each requires a completely different
              approach to diet, lifestyle, and supplementation.
            </p>
          </div>
          <div className="mt-12 grid gap-5 sm:grid-cols-2 lg:grid-cols-3">
            {ARCHETYPES.map((archetype) => {
              const Icon = ARCHETYPE_ICONS[archetype.icon] || Brain;
              return (
                <Card
                  key={archetype.id}
                  className="group cursor-pointer border-gray-100 transition-all hover:-translate-y-1 hover:shadow-md overflow-hidden"
                >
                  <div className="h-2 w-full" style={{ backgroundColor: archetype.color }} />
                  <CardContent className="p-5">
                    <div className="flex items-start gap-4">
                      <div
                        className="flex h-11 w-11 shrink-0 items-center justify-center rounded-xl"
                        style={{ backgroundColor: archetype.bgColor }}
                      >
                        <Icon className="h-5 w-5" style={{ color: archetype.color }} />
                      </div>
                      <div>
                        <h3 className="font-semibold text-gray-900 leading-tight">{archetype.name}</h3>
                        <p className="mt-1 text-xs text-gray-500 leading-relaxed">{archetype.tagline}</p>
                        <p className="mt-2 text-sm text-gray-600 leading-relaxed line-clamp-2">
                          {archetype.description}
                        </p>
                      </div>
                    </div>
                    <div className="mt-4 flex flex-wrap gap-1.5">
                      {archetype.traits.slice(0, 2).map((trait) => (
                        <span
                          key={trait}
                          className="rounded-full px-2.5 py-0.5 text-xs font-medium"
                          style={{ backgroundColor: archetype.bgColor, color: archetype.color }}
                        >
                          {trait.split(" ").slice(0, 3).join(" ")}…
                        </span>
                      ))}
                    </div>
                  </CardContent>
                </Card>
              );
            })}
          </div>
          <div className="mt-10 text-center">
            <Button asChild size="lg" className="bg-teal-600 hover:bg-teal-700 text-white font-semibold">
              <Link href="/quiz">
                Which one are you? Find out →
              </Link>
            </Button>
          </div>
        </div>
      </section>

      {/* ── What's In Your Report ─────────────────────────────────────────────── */}
      <section className="bg-white px-4 py-20">
        <div className="mx-auto max-w-6xl">
          <div className="mx-auto max-w-2xl text-center">
            <h2 className="text-3xl font-bold tracking-tight text-gray-900 md:text-4xl">
              What's in Your Report
            </h2>
            <p className="mt-4 text-gray-500">
              Three tiers of insight, from essential to comprehensive. All reports are CHF-priced.
            </p>
          </div>
          <div className="mt-12 grid gap-6 md:grid-cols-3">
            {PACKAGES.map((pkg) => (
              <Card
                key={pkg.id}
                className={`relative overflow-hidden border-2 ${pkg.isPopular ? "border-teal-600 shadow-lg shadow-teal-600/10" : "border-gray-100"}`}
              >
                {pkg.isPopular && (
                  <div className="absolute top-0 left-0 right-0 bg-teal-600 py-1.5 text-center text-xs font-bold text-white uppercase tracking-widest">
                    Most Popular
                  </div>
                )}
                <CardHeader className={`${pkg.isPopular ? "pt-10" : "pt-6"} pb-4`}>
                  <p className="text-sm font-medium text-gray-500">{pkg.name}</p>
                  <div className="flex items-baseline gap-1">
                    <span className="text-4xl font-bold text-gray-900">CHF {pkg.priceChf}</span>
                    <span className="text-sm text-gray-400">/{pkg.billingType === "monthly" ? "mo" : "one-time"}</span>
                  </div>
                  <p className="text-sm text-gray-500">{pkg.tagline}</p>
                </CardHeader>
                <CardContent className="space-y-3 pb-6">
                  {pkg.features.map((feature) => (
                    <div key={feature} className="flex items-start gap-2">
                      <CheckCircle2 className="mt-0.5 h-4 w-4 shrink-0 text-teal-600" />
                      <span className="text-sm text-gray-600">{feature}</span>
                    </div>
                  ))}
                  <Separator className="my-4" />
                  <Button
                    asChild
                    className={`w-full ${pkg.isPopular ? "bg-teal-600 hover:bg-teal-700 text-white" : "bg-gray-100 hover:bg-gray-200 text-gray-900"}`}
                  >
                    <Link href="/quiz">{pkg.ctaLabel}</Link>
                  </Button>
                </CardContent>
              </Card>
            ))}
          </div>
        </div>
      </section>

      {/* ── Testimonials ──────────────────────────────────────────────────────── */}
      <section className="bg-teal-950 px-4 py-20">
        <div className="mx-auto max-w-6xl">
          <div className="mx-auto max-w-2xl text-center">
            <h2 className="text-3xl font-bold tracking-tight text-white md:text-4xl">
              Real Results from Real People
            </h2>
            <p className="mt-4 text-teal-300/70">
              Anonymized testimonials from Novalife assessment participants.
            </p>
          </div>
          <div className="mt-12 grid gap-6 md:grid-cols-3">
            {TESTIMONIALS.map((t) => (
              <Card key={t.author} className="border-0 bg-white/5 text-white backdrop-blur-sm">
                <CardContent className="p-6">
                  <p className="mb-5 text-sm leading-relaxed text-teal-100/80 italic">"{t.quote}"</p>
                  <div className="flex items-center justify-between">
                    <div>
                      <p className="font-semibold text-sm text-white">{t.author}</p>
                      <p className="text-xs text-teal-300/60">{t.location}</p>
                    </div>
                    <span className={`rounded-full px-2.5 py-1 text-xs font-medium ${t.archetypeColor}`}>
                      {t.archetype}
                    </span>
                  </div>
                </CardContent>
              </Card>
            ))}
          </div>
        </div>
      </section>

      {/* ── FAQ ───────────────────────────────────────────────────────────────── */}
      <section className="bg-white px-4 py-20">
        <div className="mx-auto max-w-3xl">
          <div className="text-center">
            <h2 className="text-3xl font-bold tracking-tight text-gray-900 md:text-4xl">
              Frequently Asked Questions
            </h2>
          </div>
          <div className="mt-10">
            <LandingFaq />
          </div>
        </div>
      </section>

      {/* ── Final CTA ─────────────────────────────────────────────────────────── */}
      <section className="bg-gradient-to-r from-teal-600 to-emerald-600 px-4 py-20">
        <div className="mx-auto max-w-3xl text-center">
          <h2 className="text-3xl font-bold tracking-tight text-white md:text-4xl">
            Ready to understand your metabolism?
          </h2>
          <p className="mt-4 text-lg text-teal-100/80">
            10 minutes. 6 possible archetypes. 1 personalised protocol built for your unique biology.
          </p>
          <Button
            asChild
            size="lg"
            className="mt-8 bg-white text-teal-700 hover:bg-teal-50 font-bold px-10 shadow-lg"
          >
            <Link href="/quiz">
              Start Free Assessment
              <ArrowRight className="ml-2 h-4 w-4" />
            </Link>
          </Button>
          <p className="mt-4 text-sm text-teal-200/60">Free to discover your archetype · CHF 29 to unlock your full report</p>
        </div>
      </section>
    </div>
  );
}
