import { onMount } from "solid-js";
import { A } from "@solidjs/router";
import { cn } from "~/lib/utils";
import { Button } from "~/components/ui";
import { Typewriter } from "~/components/ui/Typewriter";
import PageContainer from "~/components/layout/PageContainer";

function ShieldIcon() {
  return (
    <svg
      width="48"
      height="48"
      viewBox="0 0 48 48"
      fill="none"
      xmlns="http://www.w3.org/2000/svg"
      class="w-12 h-12 md:w-16 md:h-16"
    >
      <circle cx="24" cy="24" r="24" fill="var(--color-brand-primary)" />
      <path
        d="M24 10L16 14v6.5c0 5.1 3.4 9.9 8 11.5 4.6-1.6 8-6.4 8-11.5V14l-8-4z"
        fill="white"
        fill-opacity="0.9"
      />
      <path
        d="M20 24l3 2.5 5-5"
        stroke="var(--color-brand-primary)"
        stroke-width="1.5"
        stroke-linecap="round"
        stroke-linejoin="round"
      />
    </svg>
  );
}

interface HeroSectionProps {
  class?: string;
}

export default function HeroSection(props: HeroSectionProps) {
  let heroRef: HTMLDivElement | undefined;

  onMount(() => {
    if (heroRef) {
      heroRef.style.opacity = "1";
      heroRef.style.transform = "translateY(0)";
    }
  });

  return (
    <section class={cn("relative", props.class)}>
      <PageContainer>
        <div
          ref={heroRef}
          class="flex flex-col items-center text-center py-20 md:py-32 transition-all duration-700 ease-out"
          style="opacity: 0; transform: translateY(20px);"
        >
          <div class="mb-6 shadow-glow-primary rounded-full p-3">
            <ShieldIcon />
          </div>

          <h1 class="text-4xl md:text-6xl lg:text-7xl font-bold tracking-tight mb-6 max-w-4xl">
            <Typewriter speed={50} delay={400} keepAlive={false}>
              <span class="text-[var(--color-text-primary)]">AI-Powered </span>
              <span class="text-gradient-primary">Identity Protection</span>
              <br />
              <span class="text-[var(--color-text-primary)]">for Everyone</span>
            </Typewriter>
          </h1>

          <p class="text-xl md:text-2xl text-[var(--color-text-secondary)] max-w-2xl mb-10 leading-relaxed">
            ShieldAI uses advanced AI to monitor, detect, and prevent identity
            threats in real-time. Your digital identity, protected by
            intelligence.
          </p>

          <div class="flex flex-col sm:flex-row gap-4 mb-8">
            <A href="/signup">
              <Button variant="primary" size="lg">
                Get Started
              </Button>
            </A>
            <A href="#features">
              <Button variant="ghost" size="lg">
                Learn More
              </Button>
            </A>
          </div>

          <div class="flex flex-wrap items-center justify-center gap-x-6 gap-y-2 text-sm text-[var(--color-text-tertiary)]">
            <span class="flex items-center gap-1.5">
              <svg
                width="16"
                height="16"
                viewBox="0 0 16 16"
                fill="none"
                xmlns="http://www.w3.org/2000/svg"
              >
                <path
                  d="M6.5 11.5L3 8L4.1 6.9L6.5 9.3L12.4 3.4L13.5 4.5L6.5 11.5Z"
                  fill="var(--color-success)"
                />
              </svg>
              No credit card required
            </span>
            <span class="flex items-center gap-1.5">
              <svg
                width="16"
                height="16"
                viewBox="0 0 16 16"
                fill="none"
                xmlns="http://www.w3.org/2000/svg"
              >
                <path
                  d="M6.5 11.5L3 8L4.1 6.9L6.5 9.3L12.4 3.4L13.5 4.5L6.5 11.5Z"
                  fill="var(--color-success)"
                />
              </svg>
              Free tier available
            </span>
          </div>
        </div>
      </PageContainer>
    </section>
  );
}
