import Image from "next/image";
import { Footer } from "@/components/Footer";
import { Header } from "@/components/Header";
import { PageHero } from "@/components/PageShared";
import { tunnelBlocks, tunnelIntro } from "@/data/tunnel";
import type { Metadata } from "next";
import { pageMetadata } from "@/lib/seo";

export const metadata: Metadata = pageMetadata({
  title: "تونل و مترو",
  description: "راهکارهای تهویه تونل و مترو",
  path: "/solutions/tunnels-and-subways",
  image: "/images/pages/f300/axial-jet.png",
});

export default function TunnelsPage() {
  return (
    <>
      <Header />
      <main>
        <PageHero
          title="تونل و مترو"
          titleEn="Tunnels and Subways"
          breadcrumb={[
            { label: "صفحه اصلی", href: "/" },
            { label: "راهکارها", href: "/solutions" },
            { label: "تونل و مترو", href: "/solutions/tunnels-and-subways" },
          ]}
        />

        <section className="section">
          <div className="container-page grid items-center gap-8 md:grid-cols-2">
            <div className="relative flex min-h-[280px] items-center justify-center overflow-hidden">
              <Image
                src={tunnelIntro.image}
                alt={tunnelIntro.title}
                width={560}
                height={420}
                className="h-auto w-full max-w-lg object-cover"
                sizes="(max-width: 768px) 100vw, 50vw"
                priority
              />
            </div>
            <div>
              <h2 className="mb-4 text-xl font-bold text-[#232323]">
                {tunnelIntro.title}
              </h2>
              <div className="space-y-3">
                {tunnelIntro.text.map((paragraph) => (
                  <p
                    key={paragraph.slice(0, 48)}
                    className="text-sm leading-8 text-[#666] text-justify"
                  >
                    {paragraph}
                  </p>
                ))}
              </div>
            </div>
          </div>
        </section>

        {tunnelBlocks.map((block, index) => (
          <section
            key={block.id}
            className={`section ${index % 2 === 0 ? "section-gray" : ""}`}
          >
            <div
              className={`container-page grid items-start gap-8 ${
                block.image ? "lg:grid-cols-2" : ""
              }`}
            >
              <div className={index % 2 === 1 && block.image ? "lg:order-2" : ""}>
                <h2 className="mb-2 text-lg font-bold leading-8 text-[#232323] sm:text-xl">
                  {block.title}
                </h2>
                {block.titleEn ? (
                  <p className="mb-4 text-xs tracking-wide text-[#999]">
                    {block.titleEn}
                  </p>
                ) : (
                  <div className="mb-4" />
                )}
                <div className="space-y-3">
                  {block.intro.map((paragraph) => (
                    <p
                      key={paragraph.slice(0, 48)}
                      className="text-sm leading-8 text-[#666] text-justify"
                    >
                      {paragraph}
                    </p>
                  ))}
                </div>
                {block.lists ? (
                  <ul className="mt-4 space-y-2">
                    {block.lists.map((item) => (
                      <li
                        key={item}
                        className="flex gap-2 text-sm leading-7 text-[#555]"
                      >
                        <span className="mt-2 h-1.5 w-1.5 shrink-0 rounded-full bg-accent-green" />
                        <span>{item}</span>
                      </li>
                    ))}
                  </ul>
                ) : null}
              </div>

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