'use client';

import { usePathname } from 'next/navigation';
import { FaBus, FaFacebookF, FaInstagram, FaTwitter } from 'react-icons/fa';
import styles from './Footer.module.css';

export default function Footer({ settings }: { settings?: any }) {
  const pathname = usePathname();

  // Hide on admin routes
  if (pathname.startsWith('/admin')) {
    return null;
  }

  const brandName = settings?.brandName || 'AntarKota';
  const logoIcon = settings?.logoIcon || null;
  const logoHighlight = settings?.logoHighlight || 'Kota';
  const csPhone = settings?.csPhone || '0804-1-808-808';
  const csWhatsapp = settings?.csWhatsapp || '+62 812-3456-7890';
  const csEmail = settings?.csEmail || 'support@antarkota.com';

  return (
    <footer className={styles.footer}>
      <div className={styles.container}>
        <div className={styles.grid}>
          <div className={styles.brandSection}>
            <div className={styles.logo}>
              {settings?.logoImageUrl ? (
                // eslint-disable-next-line @next/next/no-img-element
                <img src={settings.logoImageUrl} alt={brandName} className={styles.uploadedLogo} style={{ height: '32px', marginRight: '10px', objectFit: 'contain' }} />
              ) : (
                <span className={styles.logoIcon}>{logoIcon || <FaBus />}</span>
              )}
              <span className={styles.logoText}>
                {brandName.endsWith(logoHighlight) ? (
                  <>
                    {brandName.slice(0, -logoHighlight.length)}
                    <span className={styles.logoHighlight}>{logoHighlight}</span>
                  </>
                ) : (
                  brandName
                )}
              </span>
            </div>
            <p className={styles.brandDesc}>
              Penyedia layanan perjalanan antarkota premium yang menghubungkan Anda dengan kota-kota utama secara cepat, aman, dan nyaman di {brandName}.
            </p>
          </div>

          <div className={styles.linkSection}>
            <h4>Destinasi Populer</h4>
            <ul className={styles.linkList}>
              <li>Jakarta - Bandung</li>
              <li>Bandung - Jakarta</li>
              <li>Jakarta - Bogor</li>
              <li>Bogor - Jakarta</li>
            </ul>
          </div>

          <div className={styles.linkSection}>
            <h4>Hubungi Kami</h4>
            <p className={styles.contactInfo}>Call Center: <strong>{csPhone}</strong></p>
            <p className={styles.contactInfo}>WhatsApp: <strong>{csWhatsapp}</strong></p>
            <p className={styles.contactInfo}>Email: {csEmail}</p>
          </div>
        </div>

        <div className={styles.bottomBar}>
          <p>&copy; {new Date().getFullYear()} {brandName} Travel. Hak Cipta Dilindungi.</p>
          <div className={styles.socials}>
            <span><FaFacebookF /></span>
            <span><FaInstagram /></span>
            <span><FaTwitter /></span>
          </div>
        </div>
      </div>
    </footer>
  );
}
