import Image from "next/image";
import { Accordion } from "@/components/Accordion";
import { Footer } from "@/components/Footer";
import { Header } from "@/components/Header";
import { PageHero, SpecList } from "@/components/PageShared";
import { fancoilBlocks, fancoilFaq, fancoilIntro } from "@/data/fancoil";
import type { Metadata } from "next";
import { pageMetadata } from "@/lib/seo";

export const metadata: Metadata = pageMetadata({
  title: "فن کویل",
  description: "خرید انواع فن کویل با کیفیت مناسب",
  path: "/products/fancoil",
  image: "/images/products/fancoil.png",
});

export default function FanCoilPage() {
  return (
    <>
      <Header />
      <main>
        <PageHero
          title="فــن کویـــل"
          titleEn="Fan Coil"
          breadcrumb={[
            { label: "صفحه اصلی", href: "/" },
            { label: "محصولات", href: "/products" },
            { label: "فن کویل", href: "/products/fancoil" },
          ]}
        />

        <section className="section">
          <div className="container-page max-w-4xl">
            <h2 className="mb-1 text-xl font-bold text-[#232323]">
              {fancoilIntro.title}
            </h2>
            <p className="mb-4 text-sm tracking-wide text-[#999]">
              {fancoilIntro.titleEn}
            </p>
            {fancoilIntro.text.map((paragraph) => (
              <p
                key={paragraph.slice(0, 40)}
                className="text-sm leading-8 text-[#666] text-justify"
              >
                {paragraph}
              </p>
            ))}
          </div>
        </section>

        {fancoilBlocks.map((block, index) => (
          <section
            key={block.id}
            className={`section ${index % 2 === 0 ? "section-gray" : ""}`}
          >
            <div className="container-page grid items-start gap-8 lg:grid-cols-2">
              <div className={index % 2 === 1 ? "lg:order-2" : ""}>
                <h2 className="mb-4 text-lg font-bold leading-8 text-[#232323] sm:text-xl">
                  {block.title}
                </h2>
                <div className="space-y-3">
                  {block.intro.map((paragraph) => (
                    <p
                      key={paragraph.slice(0, 40)}
                      className="text-sm leading-8 text-[#666] text-justify"
                    >
                      {paragraph}
                    </p>
                  ))}
                </div>
                <SpecList items={[...block.specs]} />
              </div>

              <div
                className={`relative flex min-h-[280px] items-center justify-center ${
                  index % 2 === 1 ? "lg:order-1" : ""
                }`}
              >
                <Image
                  src={block.image}
                  alt={block.imageAlt}
                  width={560}
                  height={420}
                  className="h-auto w-full max-w-lg object-contain"
                  sizes="(max-width: 1024px) 100vw, 50vw"
                  priority={index === 0}
                />
              </div>
            </div>
          </section>
        ))}

        <section className="section section-gray">
          <div className="container-page max-w-3xl">
            <h2 className="mb-4 text-xl font-bold text-[#232323]">
              پرسش‌های متداول
            </h2>
            <Accordion items={fancoilFaq} />
          </div>
        </section>
      </main>
      <Footer />
    </>
  );
}
