import Link from "next/link";
import Image from "next/image";
import { Container } from "@/components/ui/Container";
import { getSettings, getTexts } from "@/lib/data";
import { formatText } from "@/lib/utils";
import { Badge } from "@/components/ui/Badge";
import { getImageUrl } from "@/lib/image-url";

export async function Footer() {
  const settings = await getSettings();
  const texts = await getTexts();

  return (
    <footer className="bg-brand-black text-white pt-16 pb-8">
      <Container>
        <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-12 mb-12">
          {/* Brand Column */}
          <div className="">
            <Link href="/" className="block relative w-32 h-32">
              <Image
                src={getImageUrl("assets/Logo couleur (2).png")}
                alt={texts.home.brandAlt}
                fill
                className="object-contain"
              />
            </Link>
            <h3 className="text-xl font-bold font-spartan text-brand-yellow mb-2">BDE Sup&apos;RNova</h3>
            <p className="text-gray-300 text-sm leading-relaxed">
              {texts.footer.schoolLine}
            </p>
            <Badge variant="outline" className="border-brand-yellow text-xs font-medium bg-brand-yellow text-brand-black mt-3">
              {texts.footer.associationTypeBadge}
            </Badge>
          </div>

          {/* Navigation Column */}
          <div>
            <h3 className="text-lg font-bold font-spartan mb-6">
              {texts.footer.navigation}
            </h3>
            <ul className="space-y-4">
              <li>
                <Link href="/" className="text-gray-300 hover:text-brand-yellow transition-colors">
                  {texts.footer.nav.home}
                </Link>
              </li>
              <li>
                <Link href="/#evenements" className="text-gray-300 hover:text-brand-yellow transition-colors">
                  {texts.footer.nav.events}
                </Link>
              </li>
              <li>
                <Link href="/partenaires" className="text-gray-300 hover:text-brand-yellow transition-colors">
                  {texts.footer.nav.partners}
                </Link>
              </li>
              <li>
                <Link href="/#equipe" className="text-gray-300 hover:text-brand-yellow transition-colors">
                  {texts.footer.nav.team}
                </Link>
              </li>
            </ul>
          </div>

          {/* Contact Column */}
          <div>
            <h3 className="text-lg font-bold font-spartan mb-6">
              {texts.footer.contact}
            </h3>
            <ul className="space-y-4">
              <li className="flex items-start gap-3">
                <a href={`mailto:${settings.email}`} className="text-gray-300 hover:text-brand-yellow transition-colors break-all">
                  {settings.email}
                </a>
              </li>
              {settings.instagram && (
                <li className="flex items-start gap-3">
                  <a
                    href="#contact"
                    target="_blank"
                    rel="noopener noreferrer"
                    className="text-gray-300 hover:text-brand-yellow transition-colors"
                  >
                    Contact
                  </a>
                </li>
              )}

            </ul>
          </div>

          {/* Social Column */}
          <div>
            <h3 className="text-lg font-bold font-spartan mb-6">
              {texts.footer.social}
            </h3>
            <div className="flex gap-4">
              {settings.instagram && (
                <a
                  href={settings.instagram}
                  target="_blank"
                  rel="noopener noreferrer"
                  className="text-gray-300 hover:text-brand-yellow transition-colors"
                  aria-label="Instagram"
                >
                  <svg className="h-6 w-6" fill="currentColor" viewBox="0 0 24 24"><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-.069zm0-2.163c-3.259 0-3.667.014-4.947.072-4.358.2-6.78 2.618-6.98 6.98-.059 1.281-.073 1.689-.073 4.948 0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98 1.281.058 1.689.072 4.948.072 3.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.98-1.281-.059-1.69-.073-4.949-.073zm0 5.838c-3.403 0-6.162 2.759-6.162 6.162s2.759 6.163 6.162 6.163 6.162-2.759 6.162-6.163c0-3.403-2.759-6.162-6.162-6.162zm0 10.162c-2.209 0-4-1.79-4-4 0-2.209 1.791-4 4-4s4 1.791 4 4c0 2.21-1.791 4-4 4zm6.406-11.845c-.796 0-1.441.645-1.441 1.44s.645 1.44 1.441 1.44c.795 0 1.439-.645 1.439-1.44s-.644-1.44-1.439-1.44z"></path></svg>                </a>
              )}
              <a href="https://discord.gg/kkApvPf5KB" target="_blank" rel="noopener noreferrer" className="text-gray-300 hover:text-brand-yellow transition-colors" aria-label="Discord">
                <svg className="h-6 w-6" fill="currentColor" viewBox="0 0 24 24">
                  <path d="M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0 12.64 12.64 0 0 0-.617-1.25.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028c.462-.63.874-1.295 1.226-1.994a.076.076 0 0 0-.041-.106 13.107 13.107 0 0 1-1.872-.892.077.077 0 0 1-.008-.128 10.2 10.2 0 0 0 .372-.292.074.074 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127 12.299 12.299 0 0 1-1.873.892.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.839 19.839 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z"></path>
                </svg>
              </a>
            </div>
          </div>
        </div>

        <div className="border-t border-gray-800 pt-8 flex flex-col md:flex-row justify-between items-center gap-4 text-sm text-gray-400">
          <p>
            {formatText(texts.footer.legal.copyright, { year: settings.year, association: "BDE Sup'RNova" })}
          </p>
          <div className="flex gap-6">
            <Link href="/mentions-legales" className="hover:text-brand-yellow transition-colors">
              {texts.footer.legal.mentions}
            </Link>
            <Link href="/politique-confidentialite" className="hover:text-brand-yellow transition-colors">
              {texts.footer.legal.privacy}
            </Link>
          </div>
        </div>
      </Container>
    </footer>
  );
}
