import { Link } from '@tanstack/react-router'
import { contactInfo, footerLinks, socialLinks } from '../../data/siteData'

// 社交链接hover颜色映射
const socialHoverColors: Record<string, string> = {
  facebook: 'hover:bg-[#3b5998]',
  twitter: 'hover:bg-[#1da1f2]',
  instagram: 'hover:bg-[#c13584]',
  'google-plus': 'hover:bg-[#dd4b39]',
  linkedin: 'hover:bg-[#0077b5]',
}

export default function Footer() {
  return (
    <footer
      className="relative text-white"
      style={{
        backgroundImage: "url('/src/assets/images/5.jpg')",
        backgroundSize: 'cover',
        backgroundPosition: 'center',
      }}
    >
      {/* Overlay */}
      <div
        className="absolute inset-0 z-0"
        style={{ background: 'rgba(20, 20, 20, 0.94)' }}
      />
      <div className="container mx-auto px-4 py-16 relative z-10">
        {/* Footer Top - 使用原始的 2fr 1fr 2fr 1fr 布局 */}
        <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-[2fr_1fr_2fr_1fr] gap-10 mb-12">
          {/* Contact Us */}
          <div>
            <h6 className="text-xl font-semibold mb-6 font-sans" style={{ color: '#ffffff' }}>联系我们</h6>
            <ul className="space-y-2.5">
              <li className="flex items-start gap-3">
                <span className="fa fa-map-marker text-secondary w-5 flex-shrink-0" />
                <p className="text-white text-base leading-[25px]">{contactInfo.address}</p>
              </li>
              <li>
                <a href={`tel:${contactInfo.phone}`} className="flex items-center gap-3 text-white hover:text-secondary transition-colors">
                  <span className="fa fa-phone text-secondary w-5" />
                  <span>{contactInfo.phone}</span>
                </a>
              </li>
              <li>
                <a href={`mailto:${contactInfo.email}`} className="flex items-center gap-3 text-white hover:text-secondary transition-colors">
                  <span className="fa fa-envelope-open-o text-secondary w-5" />
                  <span>{contactInfo.email}</span>
                </a>
              </li>
            </ul>
            {/* Social Links */}
            <div className="flex gap-2.5 mt-5">
              {socialLinks.map((social) => (
                <a
                  key={social.name}
                  href={social.href}
                  className={`w-[35px] h-[35px] rounded-full bg-white/10 flex items-center justify-center transition-colors ${socialHoverColors[social.icon] || 'hover:bg-secondary'}`}
                  aria-label={social.name}
                >
                  <span className={`fa fa-${social.icon} leading-[35px]`} aria-hidden="true" />
                </a>
              ))}
            </div>
          </div>

          {/* Featured Links */}
          <div>
            <h6 className="text-xl font-semibold mb-6 font-sans" style={{ color: '#ffffff' }}>精选链接</h6>
            <ul className="space-y-2.5">
              {footerLinks.featured.map((link) => (
                <li key={link.name}>
                  <Link
                    to={link.href}
                    className="text-white text-base leading-[25px] hover:text-secondary transition-colors"
                  >
                    {link.name}
                  </Link>
                </li>
              ))}
            </ul>
          </div>

          {/* Newsletter */}
          <div>
            <h6 className="text-xl font-semibold mb-6 font-sans" style={{ color: '#ffffff' }}>订阅通讯</h6>
            <p className="text-white mb-3">获取最新资讯和动态</p>
            <form className="flex mb-6" onSubmit={(e) => e.preventDefault()}>
              <input
                type="email"
                placeholder="邮箱"
                required
                className="flex-1 bg-white/10 border border-white/15 px-5 py-3 text-white rounded-l outline-none"
              />
              <button
                type="submit"
                className="bg-secondary px-5 py-3 rounded-r hover:bg-secondary/80 transition-colors"
              >
                <span className="fa fa-envelope-o" aria-hidden="true" />
              </button>
            </form>
            <p className="text-white">订阅我们的每周通讯</p>
            <p className="text-white">我们绝不会分享您的邮箱地址</p>
          </div>

          {/* Quick Links */}
          <div>
            <h6 className="text-xl font-semibold mb-6 font-sans" style={{ color: '#ffffff' }}>快速链接</h6>
            <ul className="space-y-2.5">
              {footerLinks.quick.map((link) => (
                <li key={link.name}>
                  <Link
                    to={link.href}
                    className="text-white text-base leading-[25px] hover:text-secondary transition-colors"
                  >
                    {link.name}
                  </Link>
                </li>
              ))}
            </ul>
          </div>
        </div>

        {/* Footer Bottom */}
        <div className="border-t border-[#454545] pt-8 mt-8">
          <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
            <p className="text-white text-base leading-[25px]">
              &copy; 2025 金融创意. 保留所有权利.
            </p>
            <ul className="flex gap-4 md:justify-end">
              <li>
                <a href="#" className="text-white hover:text-secondary transition-colors">
                  隐私政策
                </a>
              </li>
              <li>
                <a href="#" className="text-white hover:text-secondary transition-colors">
                  服务条款
                </a>
              </li>
            </ul>
          </div>
        </div>
      </div>

    </footer>
  )
}
