"use client";

import { motion, useInView } from "framer-motion";
import { useRef } from "react";
import Image from "next/image";
import { Button } from "@/components/shared/Button";

export function FinalCTA() {
  const ref = useRef(null);
  const isInView = useInView(ref, { once: true, margin: "-100px" });

  return (
    <section className="relative py-24 md:py-36 overflow-hidden" ref={ref}>
      <div className="absolute inset-0">
        <Image
          src="/images/manifesto_coastline.jpg"
          alt="Locals enjoying the sun on Istanbul's Asian side waterfront with the sea and islands beyond"
          fill
          className="object-cover"
          sizes="100vw"
        />
        <div className="absolute inset-0 bg-gradient-to-t from-deep-nazar/80 via-deep-nazar/50 to-deep-nazar/30" />
      </div>

      <div className="relative z-10 max-w-3xl mx-auto text-center px-5 sm:px-8">
        <motion.div
          initial={{ opacity: 0, y: 30 }}
          animate={isInView ? { opacity: 1, y: 0 } : {}}
          transition={{ duration: 0.8 }}
        >
          <h2 className="font-display text-3xl sm:text-4xl md:text-5xl font-bold text-white leading-tight mb-6">
            Your Istanbul Trip Already Has a Hagia Sophia Day.{" "}
            <span className="text-sun-yolk italic">
              Now Give It an Anatolian Edit.
            </span>
          </h2>

          <p className="text-white/80 text-lg md:text-xl mb-4">
            Small groups. Limited dates. The kind of day you&apos;ll talk about for
            years.
          </p>

          <div className="inline-flex items-center gap-2 bg-coral-spritz/20 backdrop-blur-sm rounded-full px-5 py-2 mb-8">
            <span className="w-2 h-2 rounded-full bg-coral-spritz animate-pulse" />
            <span className="text-white text-sm font-medium">
              Only 3 spots remaining for this week
            </span>
          </div>

          <div className="flex flex-col items-center gap-4">
            <Button href="/experiences/the-other-side" variant="coral" size="lg">
              Book Your Experience
            </Button>

            <p className="text-white/50 text-sm">
              Free cancellation up to 48 hours before &middot; Instant
              confirmation &middot; Pay securely online
            </p>
          </div>
        </motion.div>
      </div>
    </section>
  );
}
