import { Link } from "wouter";
import { ArrowRight, CheckCircle2, Info, MessageCircle } from "lucide-react";
import { Button } from "@/components/ui/button";
import { Card } from "@/components/ui/card";
import {
  Table,
  TableBody,
  TableCell,
  TableHead,
  TableHeader,
  TableRow,
} from "@/components/ui/table";

export default function PodcastBacklinksPage() {
  const whatsappLink = "https://wa.me/+923228715046";

  const brandSignal = [
    { name: "Amazon", url: "https://music.amazon.com/", da: 95, dr: 96, attr: "Nofollow", index: "Indexable" },
    { name: "Pocketcasts", url: "https://pocketcasts.com/", da: 81, dr: 84, attr: "Dofollow", index: "Indexable" },
    { name: "Castbox", url: "https://castbox.fm/", da: 79, dr: 87, attr: "Nofollow", index: "Indexable" },
    { name: "PodcastAddict", url: "https://podcastaddict.com/", da: 64, dr: 84, attr: "Dofollow", index: "Indexable" },
    { name: "iHeart", url: "https://www.iheart.com/", da: 58, dr: 91, attr: "Dofollow", index: "Indexable" },
    { name: "Castro", url: "https://castro.fm/", da: 52, dr: 81, attr: "Dofollow", index: "Indexable" },
    { name: "Fountain", url: "https://fountain.fm/", da: 40, dr: 71, attr: "Dofollow", index: "Indexable" },
    { name: "GetPodcast", url: "https://getpodcast.com/", da: 39, dr: 60, attr: "Dofollow", index: "Noindex" },
  ];

  const trustBoost = [
    { name: "Spreaker", url: "https://www.spreaker.com/", da: 90, dr: 90, attr: "Dofollow", index: "Indexable" },
    { name: "Amazon", url: "https://music.amazon.com/", da: 95, dr: 96, attr: "Nofollow", index: "Indexable" },
    { name: "Spotify", url: "https://spotify.com/", da: 94, dr: 95, attr: "Dofollow", index: "Indexable" },
    { name: "Player FM", url: "https://player.fm/", da: 88, dr: 86, attr: "Dofollow", index: "Noindex" },
    { name: "Podomatic", url: "https://www.podomatic.com/", da: 85, dr: 82, attr: "Dofollow", index: "Indexable" },
    { name: "Pocketcasts", url: "https://pocketcasts.com/", da: 81, dr: 84, attr: "Dofollow", index: "Indexable" },
    { name: "Castbox", url: "https://castbox.fm/", da: 79, dr: 87, attr: "Nofollow", index: "Indexable" },
    { name: "Podchaser", url: "https://www.podchaser.com/", da: 77, dr: 85, attr: "Dofollow", index: "Indexable" },
    { name: "PodcastAddict", url: "https://podcastaddict.com/", da: 64, dr: 84, attr: "Dofollow", index: "Indexable" },
    { name: "RedCircle", url: "https://redcircle.com/", da: 59, dr: 79, attr: "Nofollow", index: "Indexable" },
    { name: "iHeart", url: "https://www.iheart.com/", da: 58, dr: 91, attr: "Dofollow", index: "Indexable" },
    { name: "Castro", url: "https://castro.fm/", da: 52, dr: 81, attr: "Dofollow", index: "Indexable" },
    { name: "PodcastIndex", url: "https://podcastindex.org/", da: 50, dr: 80, attr: "Dofollow", index: "Noindex" },
    { name: "Fountain", url: "https://fountain.fm/", da: 40, dr: 71, attr: "Dofollow", index: "Indexable" },
    { name: "GetPodcast", url: "https://getpodcast.com/", da: 39, dr: 60, attr: "Dofollow", index: "Noindex" },
    { name: "Podcast Guru", url: "https://app.podcastguru.io/", da: 38, dr: 58, attr: "Nofollow", index: "Indexable" },
    { name: "Podverse", url: "https://podverse.fm/", da: 37, dr: 61, attr: "Dofollow", index: "Indexable" },
    { name: "Noice", url: "https://open.noice.id/", da: 34, dr: 51, attr: "Nofollow", index: "Indexable" },
    { name: "Podurama", url: "https://podurama.com/", da: 31, dr: 56, attr: "Nofollow", index: "Noindex" },
    { name: "Castamatic", url: "https://castamatic.com/", da: 24, dr: 47, attr: "Dofollow", index: "Indexable" },
  ];

  const brandLeadership = [
    { name: "Apple Podcasts", url: "https://podcasts.apple.com/", da: 99, dr: 97, attr: "Dofollow", index: "Indexable" },
    { name: "Amazon", url: "https://music.amazon.com/", da: 95, dr: 96, attr: "Nofollow", index: "Indexable" },
    { name: "Spotify", url: "https://spotify.com/", da: 94, dr: 95, attr: "Dofollow", index: "Indexable" },
    { name: "Spreaker", url: "https://www.spreaker.com/", da: 90, dr: 90, attr: "Dofollow", index: "Indexable" },
    { name: "Player FM", url: "https://player.fm/", da: 88, dr: 86, attr: "Dofollow", index: "Noindex" },
    { name: "Podomatic", url: "https://www.podomatic.com/", da: 85, dr: 82, attr: "Dofollow", index: "Indexable" },
    { name: "Pocketcasts", url: "https://pocketcasts.com/", da: 81, dr: 84, attr: "Dofollow", index: "Indexable" },
    { name: "Castbox", url: "https://castbox.fm/", da: 79, dr: 87, attr: "Nofollow", index: "Indexable" },
    { name: "Podchaser", url: "https://www.podchaser.com/", da: 77, dr: 85, attr: "Dofollow", index: "Indexable" },
    { name: "PodcastAddict", url: "https://podcastaddict.com/", da: 64, dr: 84, attr: "Dofollow", index: "Indexable" },
    { name: "Radio.net", url: "https://www.radio.net/", da: 60, dr: 75, attr: "Nofollow", index: "Noindex" },
    { name: "RedCircle", url: "https://redcircle.com/", da: 59, dr: 79, attr: "Nofollow", index: "Indexable" },
    { name: "iHeart", url: "https://www.iheart.com/", da: 58, dr: 91, attr: "Dofollow", index: "Indexable" },
    { name: "Castro", url: "https://castro.fm/", da: 52, dr: 81, attr: "Dofollow", index: "Indexable" },
    { name: "PodcastIndex", url: "https://podcastindex.org/", da: 50, dr: 80, attr: "Dofollow", index: "Noindex" },
    { name: "Goodpods", url: "https://goodpods.com/", da: 48, dr: 81, attr: "Nofollow", index: "Indexable" },
    { name: "PodcastRepublic", url: "https://www.podcastrepublic.net/", da: 46, dr: 68, attr: "Dofollow", index: "Indexable" },
    { name: "Hubhopper", url: "https://listen.hubhopper.com/", da: 43, dr: 68, attr: "Dofollow", index: "Indexable" },
    { name: "Rephonic", url: "https://rephonic.com/", da: 42, dr: 65, attr: "Nofollow", index: "Indexable" },
    { name: "Fountain", url: "https://fountain.fm/", da: 40, dr: 71, attr: "Dofollow", index: "Indexable" },
    { name: "GetPodcast", url: "https://getpodcast.com/", da: 39, dr: 60, attr: "Dofollow", index: "Noindex" },
    { name: "Podcast Guru", url: "https://app.podcastguru.io/", da: 38, dr: 58, attr: "Nofollow", index: "Indexable" },
    { name: "Podverse", url: "https://podverse.fm/", da: 37, dr: 61, attr: "Dofollow", index: "Indexable" },
    { name: "Truefans", url: "https://truefans.fm/", da: 35, dr: 76, attr: "Dofollow", index: "Indexable" },
    { name: "Noice", url: "https://open.noice.id/", da: 34, dr: 51, attr: "Nofollow", index: "Indexable" },
    { name: "Moon FM", url: "https://moon.fm/", da: 31, dr: 35, attr: "Dofollow", index: "Indexable" },
    { name: "Podurama", url: "https://podurama.com/", da: 31, dr: 56, attr: "Nofollow", index: "Noindex" },
    { name: "Castamatic", url: "https://castamatic.com/", da: 24, dr: 47, attr: "Dofollow", index: "Indexable" },
  ];

  const PackageSection = ({ title, price, data }: { title: string, price: string, data: any[] }) => (
    <div className="mb-20">
      <div className="mb-6 flex flex-col md:flex-row md:items-center md:justify-between gap-4">
        <h2 className="font-serif text-3xl tracking-tight" data-testid={`title-${title.toLowerCase().replace(' ', '-')}`}>
          {title} — <span className="text-[hsl(var(--accent))]">{price}</span>
        </h2>
      </div>
      
      <div className="overflow-hidden rounded-2xl border bg-card shadow-soft">
        <Table>
          <TableHeader>
            <TableRow className="bg-muted/50 hover:bg-muted/50">
              <TableHead className="font-bold py-4">Platform</TableHead>
              <TableHead className="font-bold py-4">DA</TableHead>
              <TableHead className="font-bold py-4">DR</TableHead>
              <TableHead className="font-bold py-4">Backlink</TableHead>
              <TableHead className="font-bold py-4">Indexing</TableHead>
            </TableRow>
          </TableHeader>
          <TableBody>
            {data.map((row, i) => (
              <TableRow key={i} className="group transition-colors hover:bg-accent/5">
                <TableCell className="py-4">
                  <a href={row.url} target="_blank" rel="noopener noreferrer" className="font-medium text-foreground hover:text-[hsl(var(--accent))] transition-colors">
                    {row.name}
                  </a>
                </TableCell>
                <TableCell className="py-4 font-mono text-xs">{row.da}</TableCell>
                <TableCell className="py-4 font-mono text-xs">{row.dr}</TableCell>
                <TableCell className="py-4">
                  <span className={`inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-semibold tracking-wide uppercase ${row.attr === 'Dofollow' ? 'bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-400' : 'bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400'}`}>
                    {row.attr}
                  </span>
                </TableCell>
                <TableCell className="py-4">
                  <span className={`inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-semibold tracking-wide uppercase ${row.index === 'Indexable' ? 'bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400' : 'bg-slate-100 text-slate-700 dark:bg-slate-800 dark:text-slate-400'}`}>
                    {row.index}
                  </span>
                </TableCell>
              </TableRow>
            ))}
          </TableBody>
        </Table>
      </div>
      
      <div className="mt-8 flex justify-center">
        <a href={whatsappLink} target="_blank" rel="noopener noreferrer" className="w-full sm:w-auto">
          <Button className="h-14 w-full sm:px-12 rounded-full text-lg font-bold shadow-lg shadow-emerald-500/20 bg-emerald-600 hover:bg-emerald-700 text-white gap-3 transition-all hover:scale-[1.02] active:scale-[0.98]">
            <MessageCircle className="w-6 h-6" />
            Order Now
          </Button>
        </a>
      </div>
    </div>
  );

  return (
    <main className="container-prose py-16 md:py-24" data-testid="page-podcast-backlinks">
      <header className="max-w-3xl mb-16" data-testid="section-pb-header">
        <h1 className="font-serif text-4xl tracking-tight md:text-6xl mb-6">
          Premium Podcast Backlinks
        </h1>
        <p className="text-xl text-muted-foreground leading-relaxed">
          High-authority backlinks from the world's most trusted podcast platforms. Manually built for maximum SEO impact and brand authority.
        </p>
      </header>

      <PackageSection title="Brand Signal" price="$119" data={brandSignal} />
      <PackageSection title="Trust Boost" price="$229" data={trustBoost} />
      <PackageSection title="Brand Leadership" price="$299" data={brandLeadership} />

      <section className="mt-12 bg-muted/30 p-8 rounded-3xl border">
        <div className="flex gap-4 items-start">
          <Info className="w-6 h-6 text-muted-foreground shrink-0 mt-1" />
          <p className="text-sm text-muted-foreground leading-relaxed">
            <strong>Disclaimer:</strong> Link attributes and index status depend on platform policies and may change over time. DA/DR metrics are approximate and based on current SEO tool data.
          </p>
        </div>
      </section>
    </main>
  );
}