import "./blog-content.css";
import { Container } from "@/app/components/layout/Container";
import Image from "next/image";
import bgImage from "./_assets/basmati.png";
import Link from "next/link";
import { ArrowRightIcon } from "lucide-react";
import Heading from "@/app/components/ui/Heading";
import type { Post, Category } from "@/app/types";

export default function BlogArticleTemplate({
  post,
  categories,
}: {
  post: Post;
  categories: Category[];
}) {
  return (
    <>
      <link
        rel="stylesheet"
        href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css"
      />
      <section className="relative py-24 flex justify-center items-center min-h-[70vh] w-full bg-radial-[at_top_center] from-accent to-75% bg-primary">
        <div className="z-20 px-4 lg:px-0 lg:mx-auto w-full lg:max-w-7xl">
          <Heading
            as="h1"
            variant="title"
            className="w-full text-4xl! lg:text-[3.25rem]! lg:w-5/6 mx-auto text-white text-center"
          >
            {post.title}
          </Heading>
        </div>
        <div className="absolute z-10 bottom-0 w-full bg-white h-24 [clip-path:polygon(100%_100%,100%_0,0_100%)]"></div>
      </section>
      {post.featuredImage?.node?.sourceUrl && (
        <Container>
          <Image
            src={post.featuredImage.node.sourceUrl}
            alt={post.featuredImage.node.altText || post.title}
            width={2000}
            height={2000}
            loading="eager"
            className="relative w-full rounded-xl mt-[-18%] z-20"
          />
        </Container>
      )}
      <section className="mt-8 lg:mt-16">
        <Container>
          <div className="flex flex-col lg:flex-row gap-12">
            <article
              id="blog-content"
              className="w-full lg:w-3/4"
              dangerouslySetInnerHTML={{ __html: post.content }}
            ></article>
            <div className="w-full lg:w-1/3">
              <div
                className="rounded-2xl overflow-hidden"
                style={{
                  backgroundImage: `url(${bgImage.src})`,
                }}
              >
                <div className="bg-black/60 w-full h-full text-white p-4">
                  <Heading as="h4" variant="card" className="mt-1">
                    Explore Related Topics !
                  </Heading>
                  <div className="flex flex-wrap gap-4 justify-center mt-6">
                    {categories.map((category, index) => (
                      <Link
                        key={index}
                        href={`/category/${category.slug}`}
                        className="rounded-full w-fit px-6 border-2 border-primary py-1 flex justify-center items-center text-sm hover:bg-primary transition-all duration-300"
                      >
                        {category.name}
                      </Link>
                    ))}
                  </div>
                </div>
              </div>
              <div className="bg-accent rounded-2xl mt-4 text-white overflow-hidden">
                <div className="w-full h-full bg-black/50 p-6">
                  <Heading
                    as="h4"
                    variant="card"
                    className="text-white w-full lg:w-2/3"
                  >
                    Looking for premium Basmati rice?
                  </Heading>
                  <Link
                    className="mt-4 inline-flex gap-2 items-centerf font-bold text-sm items-center bg-white text-primary px-6 py-4 rounded-full hover:bg-primary hover:text-white transition-all duration-300"
                    href="/get-a-quote"
                  >
                    Request a Quote <ArrowRightIcon size={18} />
                  </Link>
                </div>
              </div>
            </div>
          </div>
        </Container>
      </section>
    </>
  );
}
