"use client";

import { useState } from "react";
import Image from "next/image";
import Link from "next/link";
import { ChevronDown } from "lucide-react";
import logo from "@/public/assest/iaablogo.png";



export default function Footer() {
  const [openSections, setOpenSections] = useState<{ [key: string]: boolean }>({});

  const toggleSection = (section: string) => {
    setOpenSections((prev) => ({
      ...prev,
      [section]: !prev[section],
    }));
  };

  return (
    <footer className="bg-footer">
      <div className="sm:w-[88%] w-[100%] mx-auto px-4 py-8">
        <div className="hidden lg:grid lg:grid-cols-4 lg:gap-8">
          <div className="col-span-1">
            <Image
              src={logo}
              alt="IAAB Logo"
              width={70}
              height={70}
              className="mb-4"
              unoptimized={true}
            />
            <h2 className="text-lg font-semibold mb-3 text-black">
              International Association For Assessment Board
            </h2>
            <p className="text-gray-600 mb-4">
              Lorem Ipsum is simply dummy text of the printing and typesetting
              industry
            </p>
            <div className="flex space-x-4">
              <Link
                href="#"
                className="p-2 bg-gray-100 rounded-full hover:bg-gray-200"
              >
                <svg
                  className="w-5 h-5"
                  fill="currentColor"
                  viewBox="0 0 24 24"
                  aria-hidden="true"
                >
                  <path d="M8.29 20.251c7.547 0 11.675-6.253 11.675-11.675 0-.178 0-.355-.012-.53A8.348 8.348 0 0022 5.92a8.19 8.19 0 01-2.357.646 4.118 4.118 0 001.804-2.27 8.224 8.224 0 01-2.605.996 4.107 4.107 0 00-6.993 3.743 11.65 11.65 0 01-8.457-4.287 4.106 4.106 0 001.27 5.477A4.072 4.072 0 012.8 9.713v.052a4.105 4.105 0 003.292 4.022 4.095 4.095 0 01-1.853.07 4.108 4.108 0 003.834 2.85A8.233 8.233 0 012 18.407a11.616 11.616 0 006.29 1.84" />
                </svg>
              </Link>
              <Link
                href="#"
                className="p-2 bg-gray-100 rounded-full hover:bg-gray-200"
              >
                <svg
                  className="w-5 h-5"
                  fill="currentColor"
                  viewBox="0 0 24 24"
                  aria-hidden="true"
                >
                  <path
                    fillRule="evenodd"
                    d="M22 12c0-5.523-4.477-10-10-10S2 6.477 2 12c0 4.991 3.657 9.128 8.438 9.878v-6.987h-2.54V12h2.54V9.797c0-2.506 1.492-3.89 3.777-3.89 1.094 0 2.238.195 2.238.195v2.46h-1.26c-1.243 0-1.63.771-1.63 1.562V12h2.773l-.443 2.89h-2.33v6.988C18.343 21.128 22 16.991 22 12z"
                    clipRule="evenodd"
                  />
                </svg>
              </Link>
              <Link
                href="#"
                className="p-2 bg-gray-100 rounded-full hover:bg-gray-200"
              >
                <svg
                  className="w-5 h-5"
                  fill="currentColor"
                  viewBox="0 0 24 24"
                  aria-hidden="true"
                >
                  <path
                    fillRule="evenodd"
                    d="M19 0h-14c-2.761 0-5 2.239-5 5v14c0 2.761 2.239 5 5 5h14c2.762 0 5-2.239 5-5v-14c0-2.761-2.238-5-5-5zm-11 19h-3v-11h3v11zm-1.5-12.268c-.966 0-1.75-.79-1.75-1.764s.784-1.764 1.75-1.764 1.75.79 1.75 1.764-.783 1.764-1.75 1.764zm13.5 12.268h-3v-5.604c0-3.368-4-3.113-4 0v5.604h-3v-11h3v1.765c1.396-2.586 7-2.777 7 2.476v6.759z"
                    clipRule="evenodd"
                  />
                </svg>
              </Link>
            </div>
          </div>
          <div className="col-span-1">
            <h3 className="font-semibold mb-4 text-black">Quick Links</h3>
            <ul className="space-y-2">
              <li>
                <Link href="#" className="text-gray-600 hover:text-gray-900">
                  Home
                </Link>
              </li>
              <li>
                <Link href="#" className="text-gray-600 hover:text-gray-900">
                  Accreditation Board
                </Link>
              </li>
              <li>
                <Link href="#" className="text-gray-600 hover:text-gray-900">
                  Certification Body
                </Link>
              </li>
              <li>
                <Link href="#" className="text-gray-600 hover:text-gray-900">
                  Consultants / Member / Association
                </Link>
              </li>
              <li>
                <Link href="#" className="text-gray-600 hover:text-gray-900">
                  Certified Organization
                </Link>
              </li>
              <li>
                <Link href="#" className="text-gray-600 hover:text-gray-900">
                  About IAAB
                </Link>
              </li>
            </ul>
          </div>
          <div className="col-span-1">
            <h3 className="font-semibold mb-4 text-black">IAAB Publications</h3>
            <ul className="space-y-2">
              <li>
                <Link href="#" className="text-gray-600 hover:text-gray-900">
                  AB Rules & Policies
                </Link>
              </li>
              <li>
                <Link href="#" className="text-gray-600 hover:text-gray-900">
                  Required Documents For CB
                </Link>
              </li>
              <li>
                <Link href="#" className="text-gray-600 hover:text-gray-900">
                  Required Documents For Certified Organization
                </Link>
              </li>
              <li>
                <Link href="#" className="text-gray-600 hover:text-gray-900">
                  Brouchers
                </Link>
              </li>
              <li>
                <Link href="#" className="text-gray-600 hover:text-gray-900">
                  Events
                </Link>
              </li>
            </ul>
          </div>
          <div className="col-span-1">
            <h3 className="font-semibold mb-4 text-black">Contact Us</h3>
            <p className="text-gray-600">
              <strong>Reg. Off:</strong>&nbsp;1st Floor Gali No-1,
              <br />
              Khasra No-37/15, Saboli Road,
              <br />
              Sanjay Colony, Narela,
              <br />
              Delhi-110040, India
            </p>
          </div>
        </div>

        <div className="lg:hidden space-y-4">
          {/* Logo and Description */}
          <div className="mb-6">
            <Image
              src={logo}
              alt="IAAB Logo"
              width={60}
              height={60}
              className="mb-4"
              unoptimized={true}
            />
            <h2 className="text-lg font-semibold mb-2">
              International Association For Assessment Board
            </h2>
            <p className="text-gray-600 mb-4">
              Lorem Ipsum is simply dummy text of the printing and typesetting
              industry
            </p>
          </div>

          {/* Quick Links Accordion */}
          <div className="border-b">
            <button
              className="w-full py-3 flex justify-between items-center"
              onClick={() => toggleSection("quickLinks")}
            >
              <span className="font-semibold">Quick Links</span>
              <ChevronDown
                className={`w-5 h-5 transition-transform ${
                  openSections["quickLinks"] ? "rotate-180" : ""
                }`}
              />
            </button>
            <div
              className={`overflow-hidden transition-all duration-300 ${
                openSections["quickLinks"] ? "max-h-96" : "max-h-0"
              }`}
            >
              <ul className="space-y-2 pb-4">
                <li>
                  <Link href="#" className="text-gray-600">
                    Home
                  </Link>
                </li>
                <li>
                  <Link href="#" className="text-gray-600">
                    Accreditation Board
                  </Link>
                </li>
                <li>
                  <Link href="#" className="text-gray-600">
                    Certification Body
                  </Link>
                </li>
                <li>
                  <Link href="#" className="text-gray-600">
                    Consultants / Member / Association
                  </Link>
                </li>
                <li>
                  <Link href="#" className="text-gray-600">
                    Certified Organization
                  </Link>
                </li>
                <li>
                  <Link href="#" className="text-gray-600">
                    About IAAB
                  </Link>
                </li>
              </ul>
            </div>
          </div>

          {/* Publications Accordion */}
          <div className="border-b">
            <button
              className="w-full py-3 flex justify-between items-center"
              onClick={() => toggleSection("publications")}
            >
              <span className="font-semibold">IAAB Publications</span>
              <ChevronDown
                className={`w-5 h-5 transition-transform ${
                  openSections["publications"] ? "rotate-180" : ""
                }`}
              />
            </button>
            <div
              className={`overflow-hidden transition-all duration-300 ${
                openSections["publications"] ? "max-h-96" : "max-h-0"
              }`}
            >
              <ul className="space-y-2 pb-4">
                <li>
                  <Link href="#" className="text-gray-600">
                    AB Rules & Policies
                  </Link>
                </li>
                <li>
                  <Link href="#" className="text-gray-600">
                    Required Documents For CB
                  </Link>
                </li>
                <li>
                  <Link href="#" className="text-gray-600">
                    Required Documents For Certified Organization
                  </Link>
                </li>
                <li>
                  <Link href="#" className="text-gray-600">
                    Brouchers
                  </Link>
                </li>
                <li>
                  <Link href="#" className="text-gray-600">
                    Events
                  </Link>
                </li>
              </ul>
            </div>
          </div>

          {/* Contact Accordion */}
          <div className="border-b">
            <button
              className="w-full py-3 flex justify-between items-center"
              onClick={() => toggleSection("contact")}
            >
              <span className="font-semibold">Contact Us</span>
              <ChevronDown
                className={`w-5 h-5 transition-transform ${
                  openSections["contact"] ? "rotate-180" : ""
                }`}
              />
            </button>
            <div
              className={`overflow-hidden transition-all duration-300 ${
                openSections["contact"] ? "max-h-96" : "max-h-0"
              }`}
            >
              <div className="pb-4 text-gray-600">
                Reg. Off: 1st Floor Gali No-1,
                <br />
                Khasra No-37/15, Saboli Road,
                <br />
                Sanjay Colony, Narela,
                <br />
                Delhi-110040, India
              </div>
            </div>
          </div>

          {/* Social Links */}
          <div className="flex space-x-4 py-4">
            <Link
              href="#"
              className="p-2 bg-gray-100 rounded-full hover:bg-gray-200"
            >
              <svg
                className="w-5 h-5"
                fill="currentColor"
                viewBox="0 0 24 24"
                aria-hidden="true"
              >
                <path d="M8.29 20.251c7.547 0 11.675-6.253 11.675-11.675 0-.178 0-.355-.012-.53A8.348 8.348 0 0022 5.92a8.19 8.19 0 01-2.357.646 4.118 4.118 0 001.804-2.27 8.224 8.224 0 01-2.605.996 4.107 4.107 0 00-6.993 3.743 11.65 11.65 0 01-8.457-4.287 4.106 4.106 0 001.27 5.477A4.072 4.072 0 012.8 9.713v.052a4.105 4.105 0 003.292 4.022 4.095 4.095 0 01-1.853.07 4.108 4.108 0 003.834 2.85A8.233 8.233 0 012 18.407a11.616 11.616 0 006.29 1.84" />
              </svg>
            </Link>
            <Link
              href="#"
              className="p-2 bg-gray-100 rounded-full hover:bg-gray-200"
            >
              <svg
                className="w-5 h-5"
                fill="currentColor"
                viewBox="0 0 24 24"
                aria-hidden="true"
              >
                <path
                  fillRule="evenodd"
                  d="M22 12c0-5.523-4.477-10-10-10S2 6.477 2 12c0 4.991 3.657 9.128 8.438 9.878v-6.987h-2.54V12h2.54V9.797c0-2.506 1.492-3.89 3.777-3.89 1.094 0 2.238.195 2.238.195v2.46h-1.26c-1.243 0-1.63.771-1.63 1.562V12h2.773l-.443 2.89h-2.33v6.988C18.343 21.128 22 16.991 22 12z"
                  clipRule="evenodd"
                />
              </svg>
            </Link>
            <Link
              href="#"
              className="p-2 bg-gray-100 rounded-full hover:bg-gray-200"
            >
              <svg
                className="w-5 h-5"
                fill="currentColor"
                viewBox="0 0 24 24"
                aria-hidden="true"
              >
                <path
                  fillRule="evenodd"
                  d="M19 0h-14c-2.761 0-5 2.239-5 5v14c0 2.761 2.239 5 5 5h14c2.762 0 5-2.239 5-5v-14c0-2.761-2.238-5-5-5zm-11 19h-3v-11h3v11zm-1.5-12.268c-.966 0-1.75-.79-1.75-1.764s.784-1.764 1.75-1.764 1.75.79 1.75 1.764-.783 1.764-1.75 1.764zm13.5 12.268h-3v-5.604c0-3.368-4-3.113-4 0v5.604h-3v-11h3v1.765c1.396-2.586 7-2.777 7 2.476v6.759z"
                  clipRule="evenodd"
                />
              </svg>
            </Link>
          </div>
        </div>
      </div>
      {/* Copyright Bar */}
      <div className="sm:w-[88%] w-[100%] mx-auto border-t">
        <div className="max-w-7xl mx-auto px-4 py-4 flex flex-col sm:flex-row justify-between items-center">
          <p className="text-sm text-gray-600">
            © 2025 Iaab. All rights reserved.
          </p>
          <p className="text-sm text-gray-600 mt-2 sm:mt-0">
            Designed By Xpecto®
          </p>
        </div>
      </div>
    </footer>
  )}