'use client'

import Link from 'next/link'
import { usePathname } from 'next/navigation'
import { useLang } from '@/context/LangContext'
import { siteConfig } from '@/lib/site'

export default function Footer() {
  const pathname = usePathname()
  const { t } = useLang()
  const homeHref = (hash: string) => (pathname === '/' ? hash : `/${hash}`)
  const linkHrefs = [
    [homeHref('#features'), homeHref('#intelligence'), homeHref('#cta'), '/support'],
    [homeHref('#how'), homeHref('#faq'), '/support'],
    ['/imprint', '/privacy', '/terms'],
  ]

  return (
    <footer className="footer" id="footer">
      <div className="container">
        <div className="footer-inner">
          <div>
            <Link href="/" className="nav-logo" style={{ fontSize: '1.5rem' }}>
              GREENLENS
            </Link>
            <p className="footer-brand-desc">{t.footer.brand}</p>
          </div>

          {t.footer.cols.map((col, ci) => (
            <div className="footer-col" key={col.title}>
              <div className="footer-col-title">{col.title}</div>
              {col.links.map((label, li) => (
                <Link key={label} href={linkHrefs[ci]?.[li] ?? '/support'}>
                  {label}
                </Link>
              ))}
              {ci === 1 && (
                <>
                  <Link href="/plant-identifier-app">Plant Identifier App</Link>
                  <Link href="/plant-disease-identifier">Plant Disease Identifier</Link>
                  <Link href="/plant-care-app">Plant Care App</Link>
                  <Link href="/pflanzen-erkennen-app">Pflanzen erkennen</Link>
                  <Link href="/vs/picturethis">GreenLens vs PictureThis</Link>
                  <Link href="/vs/plantum">GreenLens vs Plantum</Link>
                  <Link href="/vs/inaturalist">GreenLens vs iNaturalist</Link>
                </>
              )}
            </div>
          ))}
        </div>

        <div className="footer-brand-xl" aria-hidden="true">GREENLENS</div>

        <div className="footer-bottom">
          <p>{t.footer.copy}</p>
          <Link href="/support" className="footer-contact">
            Support
          </Link>
        </div>
      </div>
    </footer>
  )
}
