/* ==========================================================================
   Footer.jsx | 13 Footer
   Contact details and social links come from MC_CONFIG; anything not yet
   confirmed is shown as a labelled placeholder.
   ========================================================================== */

function MCFooter({ onDetails }) {
  const year = new Date().getFullYear();
  const contact = MC_CONFIG.contact;
  const social = MC_CONFIG.social;

  const socialLinks = [
    { label: 'Instagram', href: social.instagram },
    { label: 'Facebook', href: social.facebook },
  ];

  return (
    <footer className="mc-footer mc-on-band">
      <div className="mc-wrap">
        <div className="mc-footer__top">
          <div className="mc-footer__brand">
            <MCLogo onDark />
            <p className="mc-footer__tagline">
              Are you ready to make
              <br />the mess disappear?
            </p>
            <p className="mc-footer__desc">
              Dusty Cleaning is a friendly, detail-minded cleaning service for homes and workplaces in Sydney, offering
              house cleaning, housekeeping, end of lease and office cleaning.
            </p>
            <div className="mc-footer__social" role="group" aria-label="Social media">
              {socialLinks.map((link) =>
                link.href ? (
                  <a key={link.label} href={link.href} target="_blank" rel="noopener noreferrer">
                    {link.label}
                  </a>
                ) : (
                  <span key={link.label}>
                    {link.label}&nbsp;<MCPh>link</MCPh>
                  </span>
                )
              )}
            </div>
          </div>

          <nav className="mc-footer__col" aria-labelledby="mc-footer-services">
            <h2 className="mc-footer__h" id="mc-footer-services">
              Services
            </h2>
            <ul role="list">
              {MC_SERVICES.map((service) => (
                <li key={service.id}>
                  <a href="#details" onClick={() => onDetails(service.id)}>
                    {service.name}
                  </a>
                </li>
              ))}
            </ul>
          </nav>

          <nav className="mc-footer__col" aria-labelledby="mc-footer-explore">
            <h2 className="mc-footer__h" id="mc-footer-explore">
              Explore
            </h2>
            <ul role="list">
              {MC_NAV_LINKS.map((link) => (
                <li key={link.href}>
                  <a href={link.href}>{link.label}</a>
                </li>
              ))}
              <li>
                <a href="#quote">Get a free quote</a>
              </li>
              <li>
                <a href="thecleanersbible/" hrefLang="pt-BR">
                  The Cleaners Bible (PT-BR)
                </a>
              </li>
            </ul>
          </nav>

          <div className="mc-footer__col">
            <h2 className="mc-footer__h">Contact</h2>
            <ul className="mc-footer__contact" role="list">
              <li>
                <MCIcon name="phone" />
                {contact.phone ? <a href={`tel:${contact.phone.replace(/\s/g, '').replace(/^0/, '+61')}`}>{contact.phone}</a> : <MCPh>Phone number</MCPh>}
              </li>
              <li>
                <MCIcon name="mail" />
                {contact.email ? <a href={`mailto:${contact.email}`}>{contact.email}</a> : <MCPh>Email address</MCPh>}
              </li>
              <li>
                <MCIcon name="pin" />
                <span>
                  {contact.areas ? `${contact.areas}, NSW` : <>Sydney, NSW<br /><MCPh>Service areas</MCPh></>}
                </span>
              </li>
            </ul>
          </div>
        </div>

        <div className="mc-footer__base">
          <p>© {year} Dusty Cleaning. All rights reserved.</p>
          <div className="mc-footer__legal">
            <MCPrivacyLink />
            <a href="#top">Back to top</a>
          </div>
        </div>
      </div>
    </footer>
  );
}

Object.assign(window, { MCFooter });
