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' }}>Contact Us</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' }}>Featured Links</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' }}>Newsletter</h6>
            <p className="text-white mb-3">Get in your inbox the latest News and</p>
            <form className="flex mb-6" onSubmit={(e) => e.preventDefault()}>
              <input
                type="email"
                placeholder="Email"
                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">Subscribe and get our weekly newsletter</p>
            <p className="text-white">We'll never share your email address</p>
          </div>

          {/* Quick Links */}
          <div>
            <h6 className="text-xl font-semibold mb-6 font-sans" style={{ color: '#ffffff' }}>Quick Links</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 Finance Ideas. All rights reserved.
            </p>
            <ul className="flex gap-4 md:justify-end">
              <li>
                <a href="#" className="text-white hover:text-secondary transition-colors">
                  Privacy policy
                </a>
              </li>
              <li>
                <a href="#" className="text-white hover:text-secondary transition-colors">
                  Terms of service
                </a>
              </li>
            </ul>
          </div>
        </div>
      </div>

    </footer>
  )
}
