// Shared footer for subpages. Host page must set window.SW_PATH_PREFIX (e.g. "../") if nested.
function Footer() {
  const TG = (window.SW_DATA && window.SW_DATA.TG_LINK) || "https://t.me/Stake4Bet";
  const DISCORD = (window.SW_DATA && window.SW_DATA.DISCORD_LINK) || "https://discord.gg/stake";
  const P = window.SW_PATH_PREFIX || "";
  const resolve = (slug) => {
    if (!window.SW_ROUTES) return P + "StakeWorldwide.html";
    const target = window.SW_ROUTES[slug] || ("coming-soon.html?path=" + encodeURIComponent(slug));
    return P + target;
  };

  const COLS = [
    { title: "Guides", links: [
      { label: "Verification", slug: "/guides/verification" },
      { label: "Deposits", slug: "/guides/deposits" },
      { label: "Withdrawals", slug: "/guides/withdrawals" },
      { label: "VIP & Rakeback", slug: "/guides/rakeback" },
      { label: "Bonuses", slug: "/guides/bonuses" },
      { label: "Responsible Play", slug: "/guides/responsible-play" },
    ]},
    { title: "Countries", links: [
      { label: "United States", slug: "/countries/united-states" },
      { label: "United Kingdom", slug: "/countries/united-kingdom" },
      { label: "Canada", slug: "/countries/canada" },
      { label: "Australia", slug: "/countries/australia" },
      { label: "Germany", slug: "/countries/germany" },
      { label: "All 180+ →", slug: "/countries" },
    ]},
    { title: "Resources", links: [
      { label: "Blog", slug: "/blog" },
      { label: "VPN Reviews", slug: "/vpn" },
      { label: "Glossary", slug: "/glossary" },
      { label: "FAQ", slug: "/faq" },
      { label: "Discord", href: DISCORD, external: true },
      { label: "Telegram Support", href: TG, external: true },
    ]},
    { title: "Legal", links: [
      { label: "About", slug: "/about" },
      { label: "Disclaimer", slug: "/disclaimer" },
      { label: "Editorial Policy", slug: "/editorial-policy" },
      { label: "Privacy Policy", slug: "/privacy-policy" },
      { label: "Terms", slug: "/terms" },
      { label: "Contact", slug: "/contact" },
    ]},
  ];

  return (
    <footer className="relative border-t border-ink-600/70 pt-16 pb-10 mt-10">
      <div className="max-w-[1240px] mx-auto px-5 lg:px-8">
        <div className="grid lg:grid-cols-[1.4fr_repeat(4,1fr)] gap-10 pb-12 border-b border-ink-600/60">
          <div>
            <div className="flex items-center gap-2.5 mb-4">
              <Icon.Logo className="w-7 h-7" />
              <span className="font-display font-semibold text-[17px]">
                Stake<span className="text-teal">Worldwide</span>
              </span>
            </div>
            <p className="text-[13.5px] text-fg-muted leading-relaxed max-w-[320px]">
              An independent knowledge hub for Stake.com — guides, country analyses, and honest strategy research.
            </p>
          </div>
          {COLS.map(col => (
            <div key={col.title}>
              <div className="text-[11px] uppercase tracking-[0.18em] text-fg-dim font-mono mb-4">{col.title}</div>
              <ul className="space-y-2.5">
                {col.links.map(l => (
                  <li key={l.label}>
                    <a href={l.external ? l.href : resolve(l.slug)}
                       target={l.external ? "_blank" : undefined}
                       rel={l.external ? "noopener" : undefined}
                       className="text-[13.5px] text-fg-muted hover:text-teal transition">{l.label}</a>
                  </li>
                ))}
              </ul>
            </div>
          ))}
        </div>
        <div className="pt-6 text-[12px] text-fg-dim leading-relaxed max-w-[980px] mx-auto text-center">
          <p><strong className="text-fg-muted">Disclaimer:</strong> StakeWorldwide is an independent informational resource. We are <strong className="text-fg-muted">not affiliated</strong> with Stake.com. Gambling involves financial risk. Please gamble responsibly. 18+.</p>
          <p className="mt-4 text-fg-dim/80">© 2026 StakeWorldwide. All rights reserved.</p>
        </div>
      </div>
    </footer>
  );
}
window.Footer = Footer;
