import type { Metadata } from "next";
import Link from "next/link";
import { ContactForm } from "@/components/contact/ContactForm";

export const metadata: Metadata = {
  title: "Contact Us",
  description:
    "Get in touch with The Pet Loft. Postal address, support and service emails, and send us an inquiry.",
};

function FacebookIcon() {
  return (
    <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor">
      <path d="M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z" />
    </svg>
  );
}

function InstagramIcon() {
  return (
    <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor">
      <path d="M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zM12 0C8.741 0 8.333.014 7.053.072 2.695.272.273 2.69.073 7.052.014 8.333 0 8.741 0 12c0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98C8.333 23.986 8.741 24 12 24c3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98C15.668.014 15.259 0 12 0zm0 5.838a6.162 6.162 0 100 12.324 6.162 6.162 0 000-12.324zM12 16a4 4 0 110-8 4 4 0 010 8zm6.406-11.845a1.44 1.44 0 100 2.881 1.44 1.44 0 000-2.881z" />
    </svg>
  );
}

function TwitterIcon() {
  return (
    <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor">
      <path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z" />
    </svg>
  );
}

const socialLinks = [
  { href: "https://facebook.com", label: "Facebook", icon: FacebookIcon },
  { href: "https://instagram.com", label: "Instagram", icon: InstagramIcon },
  { href: "https://twitter.com", label: "Twitter / X", icon: TwitterIcon },
];

export default function ContactUsPage() {
  return (
    <main className="mx-auto min-w-0 max-w-[1400px] px-4 py-8 md:px-6 md:py-12">
      <h1 className="font-[family-name:var(--font-fraunces)] text-2xl font-bold text-[#1a2e2d] md:text-3xl">
        Contact Us
      </h1>
      <p className="mt-2 text-[#3d5554]">
        We&apos;d love to hear from you. Use the form to send an inquiry or find our details below.
      </p>

      <div className="mt-8 grid grid-cols-1 gap-10 lg:grid-cols-2 lg:gap-16">
        {/* Left column: address, emails, socials */}
        <section className="flex flex-col gap-8" aria-label="Contact details">
          <section aria-labelledby="postal-heading">
            <h2
              id="postal-heading"
              className="font-[family-name:var(--font-fraunces)] text-lg font-semibold text-[#236f6b]"
            >
              Postal address
            </h2>
            <address className="mt-2 not-italic text-[#1a2e2d] leading-relaxed">
              The Pet Loft
              <br />
              123 High Street
              <br />
              London, SW1A 1AA
              <br />
              United Kingdom
            </address>
          </section>

          <section aria-labelledby="emails-heading">
            <h2
              id="emails-heading"
              className="font-[family-name:var(--font-fraunces)] text-lg font-semibold text-[#236f6b]"
            >
              Support and service emails
            </h2>
            <ul className="mt-2 space-y-1 text-[#1a2e2d]">
              <li>
                <a
                  href="mailto:support@thepetloft.com"
                  className="text-[#38a99f] underline transition-colors hover:text-[#236f6b]"
                >
                  support@thepetloft.com
                </a>
                <span className="ml-1 text-[#3d5554]">— general support</span>
              </li>
              <li>
                <a
                  href="mailto:service@thepetloft.com"
                  className="text-[#38a99f] underline transition-colors hover:text-[#236f6b]"
                >
                  service@thepetloft.com
                </a>
                <span className="ml-1 text-[#3d5554]">— orders &amp; delivery</span>
              </li>
            </ul>
          </section>

          <section aria-labelledby="follow-heading">
            <h2
              id="follow-heading"
              className="font-[family-name:var(--font-fraunces)] text-lg font-semibold text-[#236f6b]"
            >
              Follow us
            </h2>
            <div className="mt-2 flex items-center gap-3">
              {socialLinks.map(({ href, label, icon: Icon }) => (
                <a
                  key={label}
                  href={href}
                  target="_blank"
                  rel="noopener noreferrer"
                  aria-label={label}
                  className="flex h-9 w-9 items-center justify-center rounded-full bg-[#f0f8f7] text-[#3d5554] transition-colors hover:bg-[#e8f7f6] hover:text-[#236f6b]"
                >
                  <Icon />
                </a>
              ))}
            </div>
          </section>
        </section>

        {/* Right column: Inquiries form */}
        <section aria-labelledby="inquiries-heading">
          <h2
            id="inquiries-heading"
            className="font-[family-name:var(--font-fraunces)] text-lg font-semibold text-[#236f6b]"
          >
            Inquiries
          </h2>
          <p className="mt-1 text-sm text-[#3d5554]">
            Send us a message and we&apos;ll get back to you as soon as we can.
          </p>
          <div className="mt-5">
            <ContactForm />
          </div>
        </section>
      </div>

      <p className="mt-10 text-sm text-[#3d5554]">
        <Link
          href="/shop"
          className="font-medium text-[#38a99f] underline transition-colors hover:text-[#236f6b]"
        >
          ← Back to shop
        </Link>
      </p>
    </main>
  );
}
