'use client';

import Link from 'next/link';
import { usePathname } from 'next/navigation';
import { Plane } from 'lucide-react';
import { useLanguage } from '@/lib/i18n/LanguageContext';

export default function Footer() {
  const pathname = usePathname();
  const { t } = useLanguage();
  const currentYear = new Date().getFullYear();

  // 后台管理页面隐藏 Footer
  if (pathname?.startsWith('/admin')) {
    return null;
  }

  return (
    <footer className="bg-white border-t border-slate-200 py-8 md:py-12 mt-auto">
      <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
        
        {/* 
           Grid 布局调整：
           - 移动端：grid-cols-2 (2列)
           - 桌面端：md:grid-cols-4 (4列)
        */}
        <div className="grid grid-cols-2 md:grid-cols-4 gap-8 mb-8 md:mb-12">
          
          {/* Brand - 移动端跨2列居中，桌面端跨2列左对齐 */}
          <div className="col-span-2 text-center md:text-left">
            <div className="flex items-center justify-center md:justify-start gap-2 mb-4">
              <Plane className="text-blue-600" size={24} />
              <span className="text-xl font-bold text-slate-900">TextSkin</span>
            </div>
            <p className="text-sm text-slate-500 max-w-xs mx-auto md:mx-0 leading-relaxed">
              {t('footer.description')}
            </p>
          </div>

          {/* Quick Links - 移动端占1列 */}
          <div className="col-span-1 pl-4 md:pl-0">
            <h4 className="font-bold text-slate-900 mb-4 text-sm md:text-base">{t('footer.quick_links')}</h4>
            <ul className="space-y-3 text-sm text-slate-600">
              <li><Link href="/services" className="hover:text-blue-600 transition block py-1">{t('nav.services')}</Link></li>
              <li><Link href="/slots" className="hover:text-blue-600 transition block py-1">{t('nav.slots')}</Link></li>
              <li><Link href="/dashboard" className="hover:text-blue-600 transition block py-1">{t('nav.dashboard')}</Link></li>
            </ul>
          </div>

          {/* Support - 移动端占1列 */}
          <div className="col-span-1 pl-4 md:pl-0">
            <h4 className="font-bold text-slate-900 mb-4 text-sm md:text-base">{t('footer.support')}</h4>
            <ul className="space-y-3 text-sm text-slate-600">
              <li><Link href="/refund-policy" className="hover:text-blue-600 transition block py-1">{t('footer.refund_policy')}</Link></li>
              <li><Link href="/terms" className="hover:text-blue-600 transition block py-1">{t('footer.terms')}</Link></li>
              <li><Link href="/contact" className="hover:text-blue-600 transition block py-1">{t('footer.contact')}</Link></li>
            </ul>
          </div>
        </div>

        {/* Bottom Bar - 移动端垂直排列，桌面端水平两端对齐 */}
        <div className="border-t border-slate-100 pt-8 flex flex-col md:flex-row justify-between items-center text-xs text-slate-400 gap-4 md:gap-0">
          <p className="text-center md:text-left">
            &copy; {currentYear} TextSkin Inc. {t('footer.rights_reserved')}
          </p>
          <div className="flex gap-6 md:gap-4">
            <Link href="/privacy" className="hover:text-slate-600 transition p-2 md:p-0">{t('footer.privacy')}</Link>
            <Link href="/cookie-policy" className="hover:text-slate-600 transition p-2 md:p-0">{t('footer.cookie')}</Link>
          </div>
        </div>
      </div>
    </footer>
  );
}
