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 } from "@/components/ui/card";
import { ARCHETYPES } from "@/data/archetypes";

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

const QUESTIONNAIRE_OVERVIEW = [
  { section: "1", title: "Demographics & Goals", description: "Age, height, weight, primary goals, and struggle duration to establish your baseline." },
  { section: "2", title: "Lifestyle & Stress", description: "Occupation type, working hours, stress levels, and coping mechanisms." },
  { section: "3", title: "Eating Patterns", description: "Meal frequency, eating speed, cravings, and patterns that reveal metabolic drivers." },
  { section: "4", title: "Food Relationships", description: "Emotional eating patterns, food guilt, restriction-binge cycles." },
  { section: "5", title: "Sleep & Energy", description: "Sleep quality, energy levels, caffeine dependence, and circadian rhythm patterns." },
  { section: "6", title: "Physical Activity", description: "Exercise frequency, type, barriers, and daily movement patterns." },
  { section: "7", title: "Medical & Health History", description: "Diagnosed conditions, medications, family history, and hormonal changes." },
  { section: "8", title: "GLP-1 Eligibility Branch", description: "Conditional section for eligible individuals assessing medication candidacy." },
  { section: "9", title: "Lab Data (Optional)", description: "Blood test values for more precise metabolic insight." },
  { section: "10", title: "Mindset & Motivation", description: "Readiness to change, barriers to success, and preferred support style." },
];

export default function MethodologyPage() {
  return (
    <div className="flex flex-col">
      {/* ── Hero ──────────────────────────────────────────────────────────────── */}
      <section className="bg-gradient-to-br from-teal-950 to-teal-800 px-4 py-20">
        <div className="mx-auto max-w-3xl text-center">
          <Badge className="mb-5 border-teal-500/40 bg-teal-500/20 text-teal-300">
            The Science Behind Novalife
          </Badge>
          <h1 className="text-4xl font-extrabold tracking-tight text-white md:text-5xl">
            The 6-Archetype Methodology
          </h1>
          <p className="mt-5 text-lg text-teal-100/80 leading-relaxed">
            Precision weight management based on identifying and addressing the root cause of your metabolic
            challenges — not symptoms.
          </p>
        </div>
      </section>

      {/* ── Why Archetypes ────────────────────────────────────────────────────── */}
      <section className="bg-white px-4 py-20">
        <div className="mx-auto max-w-3xl">
          <h2 className="text-2xl font-bold text-gray-900 md:text-3xl">Why One-Size-Fits-All Fails</h2>
          <div className="mt-5 space-y-4 text-gray-600 leading-relaxed">
            <p>
              The conventional weight management model treats all bodies as identical metabolic machines responding
              predictably to calorie deficits and exercise. Decades of research — and the lived experience of
              millions of people — show this model is fundamentally flawed.
            </p>
            <p>
              A person whose weight gain is driven by chronic cortisol from work stress requires a completely
              different intervention than someone whose PCOS-related insulin resistance is the primary driver. The
              Stress Eater who is told to simply "eat less and move more" will fail — not because of willpower,
              but because their cortisol-appetite feedback loop isn't addressed.
            </p>
            <p>
              The Novalife archetype system codifies six distinct metabolic profiles, each representing a
              different underlying driver of weight gain. By identifying your archetype first, we can build a
              protocol that addresses the root cause rather than symptoms.
            </p>
          </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 mb-12">
            <h2 className="text-3xl font-bold text-gray-900 md:text-4xl">The 6 Metabolic Archetypes</h2>
            <p className="mt-4 text-gray-500">Each archetype has a distinct biological profile and requires a tailored approach.</p>
          </div>
          <div className="space-y-6">
            {ARCHETYPES.map((archetype, i) => {
              const Icon = ARCHETYPE_ICONS[archetype.icon] || Brain;
              return (
                <Card key={archetype.id} className="border-gray-100 overflow-hidden">
                  <div className="flex flex-col md:flex-row">
                    <div
                      className="flex items-center justify-center p-8 md:w-48 md:shrink-0"
                      style={{ backgroundColor: archetype.bgColor }}
                    >
                      <div className="flex flex-col items-center gap-3">
                        <div
                          className="flex h-14 w-14 items-center justify-center rounded-2xl shadow-sm"
                          style={{ backgroundColor: archetype.color }}
                        >
                          <Icon className="h-7 w-7 text-white" />
                        </div>
                        <span
                          className="rounded-full px-2.5 py-1 text-xs font-bold"
                          style={{ backgroundColor: archetype.color, color: "white" }}
                        >
                          #{i + 1}
                        </span>
                      </div>
                    </div>
                    <CardContent className="flex-1 p-6">
                      <div className="flex flex-wrap items-start justify-between gap-3 mb-3">
                        <div>
                          <h3 className="text-lg font-bold text-gray-900">{archetype.name}</h3>
                          <p className="text-sm font-medium" style={{ color: archetype.color }}>{archetype.tagline}</p>
                        </div>
                        <Badge
                          variant="outline"
                          className={`text-xs ${archetype.glp1Relevance === "high" ? "border-red-200 text-red-600 bg-red-50" : archetype.glp1Relevance === "medium" ? "border-amber-200 text-amber-600 bg-amber-50" : "border-green-200 text-green-600 bg-green-50"}`}
                        >
                          GLP-1 relevance: {archetype.glp1Relevance}
                        </Badge>
                      </div>
                      <p className="text-gray-600 leading-relaxed text-sm mb-4">{archetype.longDescription}</p>
                      <div>
                        <p className="text-xs font-semibold text-gray-700 uppercase tracking-wide mb-2">Key traits</p>
                        <div className="flex flex-wrap gap-1.5">
                          {archetype.traits.slice(0, 3).map((trait) => (
                            <span
                              key={trait}
                              className="rounded-full px-2.5 py-0.5 text-xs"
                              style={{ backgroundColor: archetype.bgColor, color: archetype.color }}
                            >
                              {trait}
                            </span>
                          ))}
                        </div>
                      </div>
                    </CardContent>
                  </div>
                </Card>
              );
            })}
          </div>
        </div>
      </section>

      {/* ── Questionnaire Overview ────────────────────────────────────────────── */}
      <section className="bg-white px-4 py-20">
        <div className="mx-auto max-w-4xl">
          <div className="text-center mb-12">
            <h2 className="text-3xl font-bold text-gray-900 md:text-4xl">The 10-Section Assessment</h2>
            <p className="mt-4 text-gray-500">Each section contributes unique data to your metabolic profile.</p>
          </div>
          <div className="grid gap-3 sm:grid-cols-2">
            {QUESTIONNAIRE_OVERVIEW.map((s) => (
              <div key={s.section} className="flex gap-4 rounded-xl border border-gray-100 bg-gray-50 p-4">
                <div className="flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-teal-600 text-white text-sm font-bold">
                  {s.section}
                </div>
                <div>
                  <p className="font-semibold text-gray-900 text-sm">{s.title}</p>
                  <p className="text-xs text-gray-500 mt-0.5 leading-relaxed">{s.description}</p>
                </div>
              </div>
            ))}
          </div>
        </div>
      </section>

      {/* ── GLP-1 Section ─────────────────────────────────────────────────────── */}
      <section className="bg-teal-50 px-4 py-20">
        <div className="mx-auto max-w-3xl">
          <div className="flex items-start gap-5">
            <div className="flex h-12 w-12 shrink-0 items-center justify-center rounded-xl bg-teal-600 text-white">
              <Activity className="h-6 w-6" />
            </div>
            <div>
              <h2 className="text-2xl font-bold text-gray-900 mb-3">GLP-1 Eligibility Assessment</h2>
              <p className="text-gray-600 leading-relaxed mb-4">
                GLP-1 receptor agonists represent one of the most significant advances in metabolic medicine in
                decades. Medications like semaglutide (Ozempic, Wegovy) and tirzepatide (Mounjaro) are showing
                15–22% body weight reductions in clinical trials — particularly effective for individuals with
                insulin resistance, PCOS, and other metabolic conditions.
              </p>
              <p className="text-gray-600 leading-relaxed mb-4">
                Our assessment includes a validated GLP-1 eligibility screening based on BMI thresholds, medical
                history, and metabolic markers. This does not constitute medical advice — it provides a preliminary
                assessment and recommended next steps for discussion with your GP or endocrinologist.
              </p>
              <div className="flex flex-col gap-2">
                {[
                  "Included in Advanced and Professional reports",
                  "Based on clinical prescribing criteria (BMI ≥ 30, or BMI ≥ 27 with co-morbidities)",
                  "Includes specific discussion points for your medical appointment",
                  "Identifies which archetype profiles have highest GLP-1 benefit potential",
                ].map((point) => (
                  <div key={point} 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">{point}</span>
                  </div>
                ))}
              </div>
            </div>
          </div>
        </div>
      </section>

      {/* ── CTA ───────────────────────────────────────────────────────────────── */}
      <section className="bg-teal-950 px-4 py-20 text-center">
        <h2 className="text-3xl font-bold text-white md:text-4xl">Ready to discover your archetype?</h2>
        <p className="mt-4 text-teal-300/70 text-lg">Take the 10-minute assessment — free, no credit card required.</p>
        <Button asChild size="lg" className="mt-8 bg-amber-500 hover:bg-amber-400 text-white font-bold px-10">
          <Link href="/quiz">
            Start Free Assessment
            <ArrowRight className="ml-2 h-4 w-4" />
          </Link>
        </Button>
      </section>
    </div>
  );
}
