import Link from 'next/link';

import { BrandLockup } from '@/components/brand';
import { ECOSYSTEM_SIGN_IN_PATH } from '@/lib/corporate-site-data';

function isExternalHref(href: string) {
  return href.startsWith('http://') || href.startsWith('https://');
}

const footerColumns = [
  {
    title: 'Ecosystem',
    links: [
      { label: 'Sankofa — Sovereign Technology', href: 'https://sankofa.nexus' },
      { label: 'Phoenix — Cloud Services', href: 'https://phoenix.sankofa.nexus' },
      { label: 'PanTel — Telecommunications', href: 'https://portal.sankofa.nexus' },
      { label: 'Visual identity', href: '/brand' },
    ],
  },
  {
    title: 'Platform',
    links: [
      { label: 'Identity (Keycloak)', href: 'https://keycloak.sankofa.nexus' },
      { label: 'Blockchain Explorer', href: 'https://explorer.d-bis.org' },
      { label: 'Documentation', href: 'https://docs.d-bis.org' },
      { label: 'Marketplace', href: 'https://portal.sankofa.nexus' },
    ],
  },
  {
    title: 'Company',
    links: [
      { label: 'About Sankofa', href: '#resources' },
      { label: 'Institutional registry', href: 'https://d-bis.org/cb/dbis' },
      { label: 'Partner program', href: '/partner' },
      { label: 'Contact', href: 'https://portal.sankofa.nexus' },
    ],
  },
  {
    title: 'Access',
    links: [
      { label: 'Sign in to ecosystem', href: ECOSYSTEM_SIGN_IN_PATH },
      { label: 'Phoenix console', href: 'https://phoenix.sankofa.nexus' },
      { label: 'Operator dashboard', href: 'https://dash.sankofa.nexus' },
      { label: 'Admin console', href: 'https://admin.sankofa.nexus' },
    ],
  },
];

export function CorporateFooter() {
  return (
    <footer className="border-t border-sovereign-bronze/20 bg-sovereign-obsidian">
      <div className="mx-auto max-w-7xl px-4 py-12 sm:px-6 lg:px-8">
        <div className="grid grid-cols-2 gap-8 md:grid-cols-4 lg:gap-12">
          {footerColumns.map((column) => (
            <div key={column.title}>
              <h3 className="mb-4 text-sm font-semibold uppercase tracking-wider text-sovereign-bronze">
                {column.title}
              </h3>
              <ul className="space-y-2.5">
                {column.links.map((link) => (
                  <li key={link.label}>
                    <Link
                      href={link.href}
                      className="text-sm text-sovereign-ivory/60 no-underline transition-colors hover:text-sovereign-gold"
                      {...(isExternalHref(link.href)
                        ? { target: '_blank', rel: 'noopener noreferrer' }
                        : {})}
                    >
                      {link.label}
                    </Link>
                  </li>
                ))}
              </ul>
            </div>
          ))}
        </div>

        <div className="mt-12 flex flex-col items-start justify-between gap-4 border-t border-sovereign-bronze/20 pt-8 sm:flex-row sm:items-center">
          <BrandLockup size="sm" subtitle="Sovereign Technologies" />
          <p className="text-xs text-sovereign-ivory/45">
            © {new Date().getFullYear()} Sankofa Ltd. Remember · Retrieve · Restore · Rise
          </p>
        </div>
      </div>
    </footer>
  );
}
