import Reveal from "./Reveal";
import {
  PhoneIcon,
  WhatsAppIcon,
  ShieldIcon,
  CarIcon,
  QrIcon,
  ChevronLeftIcon,
} from "./icons";

export default function AppShowcase() {
  return (
    <section id="app" className="relative overflow-hidden py-24 sm:py-28">
      <div className="pointer-events-none absolute inset-0 bg-glow-radial opacity-70" />
      {/* Floating ambient QR codes / silhouettes */}
      <QrIcon
        width={64}
        height={64}
        className="pointer-events-none absolute left-[8%] top-24 text-white/5 animate-float-slow"
      />
      <CarIcon
        width={88}
        height={88}
        className="pointer-events-none absolute right-[10%] top-40 text-white/5 animate-float"
      />
      <QrIcon
        width={44}
        height={44}
        className="pointer-events-none absolute bottom-24 left-[16%] text-white/5 animate-float"
      />

      <div className="relative mx-auto grid max-w-7xl grid-cols-1 items-center gap-14 px-5 sm:px-8 lg:grid-cols-2">
        {/* Copy */}
        <Reveal className="order-2 lg:order-1">
          <span className="eyebrow">Mobile App</span>
          <h2 className="mt-4 text-3xl font-bold leading-tight sm:text-4xl">
            Your whole vehicle inbox,{" "}
            <span className="text-gradient">in one tap</span>
          </h2>
          <p className="mt-4 max-w-lg text-lg leading-relaxed text-white/65">
            Scan the QR, see the vehicle, and choose how to reach the owner —
            an anonymous call or a quick WhatsApp message. Their number is never
            shared.
          </p>

          <ul className="mt-8 space-y-4">
            {[
              {
                icon: PhoneIcon,
                tone: "bg-brand/12 text-brand ring-brand/25",
                t: "Anonymous voice call",
                d: "Talk to the owner without either side seeing a number.",
              },
              {
                icon: WhatsAppIcon,
                tone: "bg-success/12 text-success ring-success/25",
                t: "Message on WhatsApp",
                d: "Send a quick, predefined message in a couple of taps.",
              },
              {
                icon: ShieldIcon,
                tone: "bg-electric/12 text-electric ring-electric/25",
                t: "Number never shared",
                d: "VehCall relays every contact through a secure layer.",
              },
            ].map((item) => (
              <li key={item.t} className="flex items-start gap-4">
                <span
                  className={`flex h-11 w-11 shrink-0 items-center justify-center rounded-xl ring-1 ${item.tone}`}
                >
                  <item.icon width={22} height={22} />
                </span>
                <div>
                  <p className="font-semibold text-white">{item.t}</p>
                  <p className="text-[15px] text-white/60">{item.d}</p>
                </div>
              </li>
            ))}
          </ul>
        </Reveal>

        {/* Phone mockup — recreation of the "Contact Owner" screen */}
        <Reveal delay={150} className="order-1 flex justify-center lg:order-2">
          <PhoneMockup />
        </Reveal>
      </div>
    </section>
  );
}

function PhoneMockup() {
  return (
    <div className="relative">
      <div className="pointer-events-none absolute -inset-8 rounded-[3rem] bg-electric/20 blur-3xl" />
      <div className="relative h-[648px] w-[300px] rounded-[2.75rem] border border-white/10 bg-gradient-to-b from-surface to-bg p-3 shadow-2xl shadow-electric/25">
        {/* Notch */}
        <div className="absolute left-1/2 top-3 z-10 h-6 w-28 -translate-x-1/2 rounded-full bg-bg" />
        {/* Screen */}
        <div className="relative h-full w-full overflow-hidden rounded-[2.25rem] bg-[#0a0e1a]">
          <div className="relative flex h-full flex-col px-5 pb-5 pt-8">
            {/* Header */}
            <div className="flex items-center justify-between">
              <span className="flex h-9 w-9 items-center justify-center rounded-full border border-white/10 text-white/80">
                <ChevronLeftIcon width={18} height={18} />
              </span>
              <span className="text-[15px] font-bold text-white">
                Contact Owner
              </span>
              <span className="h-9 w-9" />
            </div>

            {/* Vehicle card */}
            <div className="mt-4 rounded-3xl border border-white/8 bg-[#141a2e] px-5 py-5 text-center">
              <div className="relative mx-auto flex h-16 w-16 items-center justify-center rounded-full bg-gradient-to-br from-brand to-electric text-white shadow-[0_0_30px_4px_rgba(123,108,253,0.45)]">
                <CarIcon width={32} height={32} />
              </div>
              <p className="mt-3 text-lg font-bold text-white">Tata Punch</p>
              <p className="mt-1 text-sm tracking-[0.15em] text-white/45">
                KA-01-AB-1234
              </p>
              <span className="mt-2.5 inline-flex rounded-full bg-brand/15 px-4 py-1 text-xs font-bold tracking-wide text-brand">
                CAR
              </span>
            </div>

            {/* Privacy banner */}
            <div className="mt-3.5 flex items-center justify-center gap-2 rounded-2xl border border-success/30 bg-success/8 px-3 py-2.5">
              <ShieldIcon width={16} height={16} className="text-success" />
              <span className="text-[13px] font-medium text-success">
                Your number is never shared with the owner
              </span>
            </div>

            {/* Section label */}
            <p className="mt-4 text-[10px] font-semibold uppercase tracking-[0.14em] text-white/40">
              How would you like to reach them
            </p>

            {/* Action rows */}
            <div className="mt-3 space-y-2.5">
              <ContactRow
                icon={<PhoneIcon width={20} height={20} />}
                iconClass="bg-brand/15 text-brand"
                title="Call the owner"
                subtitle="Anonymous voice call through VehCall"
              />
              <ContactRow
                icon={<WhatsAppIcon width={20} height={20} />}
                iconClass="bg-success/15 text-success"
                title="Message on WhatsApp"
                subtitle="Send a quick message to the owner"
              />
            </div>

            {/* Disclaimer */}
            <p className="mt-auto px-2 text-center text-[10px] leading-relaxed text-white/35">
              By contacting the owner, you agree to VehCall&apos;s anonymous
              communication terms.
            </p>
          </div>
        </div>
      </div>
    </div>
  );
}

function ContactRow({
  icon,
  iconClass,
  title,
  subtitle,
}: {
  icon: React.ReactNode;
  iconClass: string;
  title: string;
  subtitle: string;
}) {
  return (
    <div className="flex items-center gap-3.5 rounded-2xl border border-white/6 bg-[#141a2e] px-4 py-3">
      <span
        className={`flex h-11 w-11 shrink-0 items-center justify-center rounded-full ${iconClass}`}
      >
        {icon}
      </span>
      <div className="min-w-0">
        <p className="text-[15px] font-bold text-white">{title}</p>
        <p className="text-[12px] leading-snug text-white/50">{subtitle}</p>
      </div>
    </div>
  );
}
