"use client";

import { useState } from "react";
import Image from "next/image";
import Link from "next/link";
import { CheckCircle, TrendingUp, Shield } from "lucide-react";

interface HeroContent {
  id: number;
  badge: string;
  headline: string;
  subheadline: string;
  ctaPrimary: string;
  ctaSecondary: string;
  treatmentMatchScore: number;
  estimatedSavings: string;
  badges: string[];
  coordinatorName: string | null;
  coordinatorOnline: boolean | null;
  doctorImageUrl: string | null;
}

const TREATMENT_TYPES = [
  "Kidney Transplant",
  "Liver Transplant",
  "Cardiac Surgery",
  "Cancer Care",
  "Orthopedics",
  "IVF & Fertility",
];

const DESTINATIONS = ["India", "Thailand", "Singapore", "Turkey", "Germany"];
const MONTHS = ["January 2026","February 2026","March 2026","April 2026","May 2026","June 2026","July 2026","August 2026","September 2026","October 2026","November 2026","December 2026"];
const BUDGETS = ["৳ 1L - ৳ 3L", "৳ 3L - ৳ 5L", "৳ 5L - ৳ 12L", "৳ 12L - ৳ 25L", "৳ 25L+"];

export default function HeroSection({ hero }: { hero: HeroContent }) {
  const [treatment, setTreatment] = useState("Kidney Transplant");
  const [destination, setDestination] = useState("India");
  const [month, setMonth] = useState("August 2026");
  const [budget, setBudget] = useState("৳ 5L - ৳ 12L");

  return (
    <section className="relative pt-16 overflow-hidden bg-white">
      <div className="max-w-7xl mx-auto px-4 sm:px-6 py-10 lg:py-14">
        <div className="grid lg:grid-cols-2 gap-8 lg:gap-12 items-center">
          {/* Left Content */}
          <div className="animate-fade-in-up">
            {/* Badge */}
            <div className="inline-flex items-center gap-2 bg-green-50 border border-green-200 text-green-700 text-xs font-semibold px-3 py-1.5 rounded-full mb-5">
              <span className="text-base">🇧🇩</span>
              <span>{hero.badge.replace("🇧🇩 ", "")}</span>
            </div>

            {/* Headline */}
            <h1 className="text-3xl sm:text-4xl lg:text-5xl font-bold text-slate-900 leading-tight mb-4">
              {hero.headline.split("\n").map((line, i) => (
                <span key={i}>
                  {line}
                  {i < hero.headline.split("\n").length - 1 && <br />}
                </span>
              ))}
            </h1>

            {/* Subheadline */}
            <p className="text-slate-500 text-base lg:text-lg mb-6 max-w-lg">
              {hero.subheadline}
            </p>

            {/* Trust Badges */}
            <div className="flex flex-wrap gap-3 mb-7">
              {hero.badges.map((badge) => (
                <span
                  key={badge}
                  className="flex items-center gap-1.5 text-xs text-slate-600 bg-slate-100 px-3 py-1.5 rounded-full font-medium"
                >
                  <Shield className="w-3 h-3 text-green-500" />
                  {badge}
                </span>
              ))}
            </div>

            {/* CTAs */}
            <div className="flex flex-wrap gap-3">
              <Link
                href="#find-treatment"
                className="bg-green-600 hover:bg-green-700 text-white font-semibold px-6 py-3 rounded-lg transition-all hover:shadow-lg hover:-translate-y-0.5 text-sm"
              >
                {hero.ctaPrimary}
              </Link>
              <Link
                href="#packages"
                className="border border-slate-300 text-slate-700 hover:border-green-500 hover:text-green-600 font-semibold px-6 py-3 rounded-lg transition-all text-sm"
              >
                {hero.ctaSecondary}
              </Link>
            </div>
          </div>

          {/* Right – Doctor Image + Floating Cards */}
          <div className="relative hidden sm:block animate-slide-right">
            <div className="relative w-full max-w-md mx-auto lg:ml-auto">
              {/* Doctor Image */}
              <div className="relative rounded-2xl overflow-hidden bg-gradient-to-br from-green-50 to-blue-50 shadow-2xl" style={{ height: 380 }}>
                <Image
                  src={
                    hero.doctorImageUrl ||
                    "https://images.pexels.com/photos/7195309/pexels-photo-7195309.jpeg?auto=compress&cs=tinysrgb&fit=crop&h=600&w=500"
                  }
                  alt="Medical Coordinator"
                  fill
                  className="object-cover object-center"
                  priority
                />
              </div>

              {/* Treatment Match Score Card */}
              <div className="absolute top-4 right-4 bg-white rounded-2xl shadow-xl p-4 min-w-[160px] animate-fade-in animation-delay-300">
                <p className="text-xs text-slate-500 font-medium mb-1">Treatment Match Score</p>
                <p className="text-4xl font-bold text-purple-600">{hero.treatmentMatchScore}%</p>
              </div>

              {/* Estimated Savings Card */}
              <div className="absolute bottom-4 left-4 bg-white rounded-2xl shadow-xl p-4 min-w-[180px] animate-fade-in animation-delay-400">
                <p className="text-xs text-slate-500 font-medium mb-1">Estimated Savings</p>
                <div className="flex items-center gap-1">
                  <TrendingUp className="w-4 h-4 text-green-500" />
                  <p className="text-2xl font-bold text-slate-900">{hero.estimatedSavings}</p>
                </div>
              </div>

              {/* Coordinator Online Badge */}
              {hero.coordinatorOnline && (
                <div className="absolute bottom-4 right-4 bg-white rounded-full shadow-lg px-3 py-1.5 flex items-center gap-1.5 animate-fade-in animation-delay-500">
                  <span className="w-2 h-2 bg-green-500 rounded-full animate-pulse" />
                  <span className="text-xs text-slate-600 font-medium">{hero.coordinatorName}</span>
                </div>
              )}
            </div>
          </div>
        </div>

        {/* Search / Find Treatment Bar */}
        <div id="find-treatment" className="mt-10 bg-white border border-slate-200 rounded-2xl shadow-lg p-5 scroll-mt-20">
          <h2 className="text-base font-bold text-slate-800 mb-4">Find Your Treatment</h2>
          <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3 mb-4">
            {/* Treatment Type */}
            <div>
              <label className="text-xs text-slate-500 font-medium mb-1 block">Treatment Type</label>
              <select
                value={treatment}
                onChange={(e) => setTreatment(e.target.value)}
                className="w-full border border-slate-200 rounded-lg px-3 py-2.5 text-sm text-slate-800 bg-slate-50 focus:outline-none focus:ring-2 focus:ring-green-400 focus:border-transparent"
              >
                {TREATMENT_TYPES.map((t) => (
                  <option key={t}>{t}</option>
                ))}
              </select>
            </div>
            {/* Destination */}
            <div>
              <label className="text-xs text-slate-500 font-medium mb-1 block">Destination</label>
              <select
                value={destination}
                onChange={(e) => setDestination(e.target.value)}
                className="w-full border border-slate-200 rounded-lg px-3 py-2.5 text-sm text-slate-800 bg-slate-50 focus:outline-none focus:ring-2 focus:ring-green-400 focus:border-transparent"
              >
                {DESTINATIONS.map((d) => (
                  <option key={d}>{d}</option>
                ))}
              </select>
            </div>
            {/* Preferred Month */}
            <div>
              <label className="text-xs text-slate-500 font-medium mb-1 block">Preferred Month</label>
              <select
                value={month}
                onChange={(e) => setMonth(e.target.value)}
                className="w-full border border-slate-200 rounded-lg px-3 py-2.5 text-sm text-slate-800 bg-slate-50 focus:outline-none focus:ring-2 focus:ring-green-400 focus:border-transparent"
              >
                {MONTHS.map((m) => (
                  <option key={m}>{m}</option>
                ))}
              </select>
            </div>
            {/* Budget Range */}
            <div>
              <label className="text-xs text-slate-500 font-medium mb-1 block">Budget Range</label>
              <select
                value={budget}
                onChange={(e) => setBudget(e.target.value)}
                className="w-full border border-slate-200 rounded-lg px-3 py-2.5 text-sm text-slate-800 bg-slate-50 focus:outline-none focus:ring-2 focus:ring-green-400 focus:border-transparent"
              >
                {BUDGETS.map((b) => (
                  <option key={b}>{b}</option>
                ))}
              </select>
            </div>
          </div>
          <button className="w-full sm:w-auto bg-green-600 hover:bg-green-700 text-white font-semibold px-8 py-3 rounded-xl transition-all hover:shadow-lg flex items-center justify-center gap-2 text-sm">
            <svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
              <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
            </svg>
            Compare Options
          </button>
        </div>
      </div>
    </section>
  );
}
