import type { Metadata } from "next";
import Link from "next/link";
import { Film, Music, Shield, Palette, Sparkles, ArrowRight, RefreshCw } from "lucide-react";
import { SITE_NAME } from "@/lib/constants";
import { COMPETITORS, MASTER_FAQS } from "@/lib/alternatives-data";
import { createClient } from "@/lib/supabase/server";
import SiteHeader from "@/components/SiteHeader";
import MasterComparisonTable from "@/components/MasterComparisonTable";
import styles from "./compare.module.css";
import "@/app/landing.css";

export const metadata: Metadata = {
  title: "Bio Link Comparisons (2026) · sinss.lol vs guns.lol, Vaults.lol, feds.lol",
  description:
    "Compare the best bio link sites of 2026: sinss.lol vs guns.lol, Vaults.lol, feds.lol, and e-z.bio. Free video backgrounds, synced karaoke lyrics, 1-click profile importing, and flat lifetime pricing.",
  alternates: {
    canonical: "/compare",
  },
  openGraph: {
    title: "Bio Link Comparisons (2026) · sinss.lol vs guns.lol & Competitors",
    description:
      "Detailed side-by-side comparison of top bio link sites: sinss.lol vs guns.lol vs Vaults.lol vs feds.lol vs e-z.bio. Free video backgrounds, synced lyrics, and 1-click profile importing.",
    url: "https://www.sinss.lol/compare",
    siteName: SITE_NAME,
    type: "website",
  },
};

export default async function CompareIndexPage() {
  const supabase = await createClient();
  const {
    data: { user },
  } = await supabase.auth.getUser();

  let username: string | undefined;
  if (user) {
    const { data: prof } = await supabase
      .from("profiles")
      .select("username")
      .eq("id", user.id)
      .maybeSingle();
    if (prof?.username) username = prof.username;
  }

  const faqSchema = {
    "@context": "https://schema.org",
    "@type": "FAQPage",
    mainEntity: MASTER_FAQS.map((item) => ({
      "@type": "Question",
      name: item.q,
      acceptedAnswer: {
        "@type": "Answer",
        text: item.a,
      },
    })),
  };

  const itemListSchema = {
    "@context": "https://schema.org",
    "@type": "ItemList",
    name: "Best Bio Link Platforms Comparison (2026)",
    description: "Ranked list and feature comparison of top aesthetic bio link platforms.",
    itemListElement: [
      {
        "@type": "ListItem",
        position: 1,
        name: "sinss.lol",
        description: "Best overall bio link platform. Free video backgrounds, synced lyrics, 6 layouts, $6.99 lifetime, 1-click guns.lol importer.",
        url: "https://sinss.lol",
      },
      {
        "@type": "ListItem",
        position: 2,
        name: "guns.lol",
        description: "Popular bio link platform. 7,99€ lifetime unlocks layouts, custom fonts, and special effects.",
        url: "https://sinss.lol/compare/guns-lol",
      },
      {
        "@type": "ListItem",
        position: 3,
        name: "Vaults.lol",
        description: "Aesthetic bio link with 6,99€ lifetime and 14,99€ supporter tier. Free guns.lol import and video backgrounds, but lacks synced karaoke lyrics and has only 2 layouts.",
        url: "https://sinss.lol/compare/vaults-lol",
      },
      {
        "@type": "ListItem",
        position: 4,
        name: "feds.lol",
        description: "Discord bio link platform ($5.00 lifetime). Video backgrounds and background music require $5.00 Premium; lacks profile importer and synced lyrics.",
        url: "https://sinss.lol/compare/feds-lol",
      },
      {
        "@type": "ListItem",
        position: 5,
        name: "e-z.bio",
        description: "Developer bio link service associated with e-z.host ($3 base / $5 premium). Basic profile cards without synced lyrics or profile importer.",
        url: "https://sinss.lol/compare/e-z-bio",
      },
    ],
  };

  const softwareSchema = {
    "@context": "https://schema.org",
    "@type": "SoftwareApplication",
    name: "sinss.lol",
    applicationCategory: "SocialNetworkingApplication",
    operatingSystem: "Web",
    offers: {
      "@type": "Offer",
      price: "0.00",
      priceCurrency: "USD",
    },
    featureList: [
      "Direct 1-click guns.lol profile importer",
      "Free MP4 and WebM video backgrounds",
      "Multi-track audio player with synced scrolling lyrics",
      "Real-time Discord presence and Spotify listening status",
      "15+ custom Google and aesthetic designer fonts",
      "Custom cursor upload and ambient particle trails",
      "6 profile card layouts",
      "$6.99 one-time lifetime premium with zero subscriptions",
    ],
    description:
      "The #1 rated aesthetic bio link site. Full-screen video backgrounds, floating audio with synced lyrics, 6 layouts, and a 1-click guns.lol importer.",
  };

  const breadcrumbsSchema = {
    "@context": "https://schema.org",
    "@type": "BreadcrumbList",
    itemListElement: [
      {
        "@type": "ListItem",
        position: 1,
        name: "Home",
        item: "https://sinss.lol",
      },
      {
        "@type": "ListItem",
        position: 2,
        name: "Compare",
        item: "https://sinss.lol/compare",
      },
    ],
  };

  const competitorsList = Object.values(COMPETITORS);

  return (
    <div className={styles.pageShell}>
      <script
        type="application/ld+json"
        dangerouslySetInnerHTML={{ __html: JSON.stringify(faqSchema) }}
      />
      <script
        type="application/ld+json"
        dangerouslySetInnerHTML={{ __html: JSON.stringify(itemListSchema) }}
      />
      <script
        type="application/ld+json"
        dangerouslySetInnerHTML={{ __html: JSON.stringify(softwareSchema) }}
      />
      <script
        type="application/ld+json"
        dangerouslySetInnerHTML={{ __html: JSON.stringify(breadcrumbsSchema) }}
      />

      <SiteHeader
        user={user ? { id: user.id } : null}
        username={username}
        activePath="/compare"
        showThemeToggle={false}
      />

      <main className={styles.contentWrapper}>
        <section className={styles.heroSection}>
          <div className={styles.badge}>Platform Comparison</div>
          <h1 className={styles.heroTitle}>Bio Link Comparisons</h1>
          <p className={styles.heroLead}>
            Compare features, free video backgrounds, synced karaoke lyrics, 1-click profile importers, and lifetime pricing across sinss.lol, guns.lol, Vaults.lol, feds.lol, and e-z.bio.
          </p>
          <div className={styles.ctaGroup}>
            <Link href="/transfer" className={styles.primaryBtn}>
              Import from guns.lol (1-Click) <ArrowRight size={16} />
            </Link>
            <Link href="/claim" className={styles.secondaryBtn}>
              Claim Free Handle
            </Link>
          </div>
        </section>

        {/* Competitor Navigation Switcher */}
        <nav className={styles.competitorsNav} aria-label="Alternative Bio Links">
          <Link href="/compare" className={`${styles.navPill} ${styles.navPillActive}`}>
            All Comparisons
          </Link>
          {competitorsList.map((c) => (
            <Link key={c.slug} href={`/compare/${c.slug}`} className={styles.navPill}>
              vs {c.name}
            </Link>
          ))}
        </nav>

        {/* Competitor Breakdown Cards */}
        <section className={styles.competitorsGrid} aria-label="Underground Platforms">
          {competitorsList.map((c) => (
            <div key={c.slug} className={styles.competitorOverviewCard}>
              <div className={styles.compCardTop}>
                <h3>{c.name}</h3>
                <p>{c.heroLead}</p>
                <div className={styles.compPricingTag}>{c.pricingSummary}</div>
              </div>
              <Link href={`/compare/${c.slug}`} className={styles.compCardLink}>
                Compare vs {c.name} <ArrowRight size={14} />
              </Link>
            </div>
          ))}
        </section>

        {/* Full Master Underground Comparison Matrix */}
        <MasterComparisonTable
          title="Master Bio Link Comparison Matrix"
          subtitle="Side-by-side feature comparison between sinss.lol and top bio link platforms."
        />

        {/* Core Feature Pillars */}
        <section className={styles.pillarsGrid} aria-label="Core Advantages">
          <div className={styles.pillarCard}>
            <div className={styles.pillarIcon}>
              <RefreshCw size={20} />
            </div>
            <h2 className={styles.pillarTitle}>Free 1-Click Profile Importer</h2>
            <p className={styles.pillarDesc}>
              Move your entire profile from guns.lol in 30 seconds. Seamlessly copies your bio, links, audio tracks, background video, colors, and font at{" "}
              <Link href="/transfer" style={{ color: "#d87b7b", textDecoration: "underline" }}>
                sinss.lol/transfer
              </Link>.
            </p>
          </div>

          <div className={styles.pillarCard}>
            <div className={styles.pillarIcon}>
              <Film size={20} />
            </div>
            <h2 className={styles.pillarTitle}>Free Video Backgrounds</h2>
            <p className={styles.pillarDesc}>
              Upload your own MP4 or WebM video background directly. No paywalls, no monthly subscription required just to have an animated aesthetic page.
            </p>
          </div>

          <div className={styles.pillarCard}>
            <div className={styles.pillarIcon}>
              <Music size={20} />
            </div>
            <h2 className={styles.pillarTitle}>Multi-Track Synced Lyrics</h2>
            <p className={styles.pillarDesc}>
              Integrate background music tracks with automatic real-time scrolling lyrics powered by LRCLIB. Synchronized karaoke-style lyric box renders smoothly beneath your card.
            </p>
          </div>

          <div className={styles.pillarCard}>
            <div className={styles.pillarIcon}>
              <Shield size={20} />
            </div>
            <h2 className={styles.pillarTitle}>One-Time Lifetime Upgrade</h2>
            <p className={styles.pillarDesc}>
              Say goodbye to perpetual monthly fees. If you ever choose to upgrade to Lifetime Premium, it is a single $6.99 one-time payment that unlocks 5 profile slots, custom badges, and image hosting forever.
            </p>
          </div>

          <div className={styles.pillarCard}>
            <div className={styles.pillarIcon}>
              <Palette size={20} />
            </div>
            <h2 className={styles.pillarTitle}>6 Flexible Profile Layouts</h2>
            <p className={styles.pillarDesc}>
              Pick from Classic, Portfolio, Scroll, Compact, Minimal, or Banner layouts at no cost. Switch your presentation style whenever you want with a single click.
            </p>
          </div>

          <div className={styles.pillarCard}>
            <div className={styles.pillarIcon}>
              <Sparkles size={20} />
            </div>
            <h2 className={styles.pillarTitle}>Custom Cursors & Particles</h2>
            <p className={styles.pillarDesc}>
              Upload a personalized cursor image and add ambient effects like sparkle trails, snow, rain, and glowing card auras completely free.
            </p>
          </div>
        </section>

        {/* FAQs */}
        <section className={styles.faqSection} aria-label="Frequently Asked Questions">
          <div className={styles.sectionHeader}>
            <h2 className={styles.sectionTitle}>Frequently Asked Questions</h2>
            <p className={styles.sectionSubtitle}>
              Everything you need to know about comparing sinss.lol and alternatives to guns.lol.
            </p>
          </div>
          <div className={styles.faqGrid}>
            {MASTER_FAQS.map((faq) => (
              <div key={faq.q} className={styles.faqItem}>
                <h3 className={styles.faqQuestion}>{faq.q}</h3>
                <p className={styles.faqAnswer}>{faq.a}</p>
              </div>
            ))}
          </div>
        </section>

        {/* Bottom CTA Banner */}
        <section className={styles.ctaBanner}>
          <h2>Ready to Build Your Aesthetic Bio Link?</h2>
          <p>
            Transfer your existing profile from guns.lol in 30 seconds or claim a fresh handle today.
          </p>
          <div className={styles.ctaGroup}>
            <Link href="/transfer" className={styles.primaryBtn}>
              Import Profile (1-Click) <ArrowRight size={16} />
            </Link>
            <Link href="/claim" className={styles.secondaryBtn}>
              Claim Your Handle
            </Link>
          </div>
        </section>
      </main>
    </div>
  );
}
