import Link from 'next/link';

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

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

const footerColumns = [
  {
    title: 'Products',
    links: [
      { label: 'Phoenix Cloud', href: 'https://phoenix.sankofa.nexus' },
      { label: 'Complete Credential', href: 'https://cc.sankofa.nexus' },
      { label: 'Sankofa Studio', href: 'https://studio.sankofa.nexus/studio/' },
      { label: 'Client Portal', href: 'https://portal.sankofa.nexus' },
    ],
  },
  {
    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-gray-800 bg-gray-950">
      <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-gray-400">
                {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-gray-400 no-underline transition-colors hover:text-orange-300"
                      {...(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-gray-800 pt-8 sm:flex-row sm:items-center">
          <div className="flex items-center gap-3">
            <span className="flex h-7 w-7 items-center justify-center rounded-md bg-gradient-to-br from-orange-500 to-amber-400 text-xs font-bold text-gray-950">
              S
            </span>
            <div>
              <p className="text-sm font-medium text-white">Sankofa — Sovereign Technologies</p>
              <p className="text-xs text-gray-500">Remember · Retrieve · Restore · Rise</p>
            </div>
          </div>
          <p className="text-xs text-gray-500">
            © {new Date().getFullYear()} Sankofa Ltd. All rights reserved.
          </p>
        </div>
      </div>
    </footer>
  );
}
