"use client"
import { CheckCircle2 } from "lucide-react";
import { useTranslations } from "next-intl";
import { useState } from "react";
import ContactModal from "../ContactUs";
import Image from "next/image";
import Link from "next/link";
import { LinkIcon } from "lucide-react";
import { ArrowRight } from "lucide-react";


export default function ProductProperties({ product }) {
    const t = useTranslations("PDP")
    const [open, setOpen] = useState(false);
    const openModal = () => {
        setOpen(true);
    };
    const closeModal = () => {
        setOpen(false);
    }
    return (
        <div className="space-y-8">
            <div className="bg-white rounded-xl p-6 shadow-sm">
                <h3 className="text-xl font-semibold mb-4">{t("productSpecification")}</h3>
                <div className="space-y-4">
                    {product.properties.map(prop => (
                        <div key={prop.id} className="flex items-center gap-4">
                            <CheckCircle2 className="w-5 h-5 text-gray-900 flex-shrink-0" />
                            <div>
                                <span className="font-medium">{prop.key}:</span>
                                <span className="text-gray-600 ml-2">{prop.value}</span>
                            </div>
                        </div>
                    ))}
                </div>
            </div>
            {product?.brand &&
                <div className="bg-white rounded-xl p-6 shadow-sm">
                    <h3 className="text-xl font-semibold mb-4">Brand </h3>
                    <div className="flex items-center gap-4">
                        <div className="relative size-20">
                            <Image
                                src={product?.brand?.image?.url}
                                alt={product?.brand?.image?.alternativeText}

                                fill
                                className="object-contain"
                            />
                        </div>
                        <div className="flex flex-col justify-around">
                            <Link href={`/products/${product?.brand?.slug}`} className="font-bold text-lg">
                                {product?.brand?.title}
                            </Link>
                            <Link href={`/products/${product?.brand?.slug}`} className="text-sm text-black/70">
                                View All
                            </Link>
                        </div>
                    </div>
                </div>
            }
            {product.brand?.subcategories.lenght &&
                <div className="bg-white rounded-xl p-6 shadow-sm">
                    <h3 className="text-xl font-semibold mb-4">Use Cases </h3>
                    <div className="flex items-center gap-4">
                        {product.brand?.subcategories.map(subcat => (
                            <Link
                                key={subcat.documentId}
                                href={`/products/${subcat.slug}`}
                                className="inline-flex items-center gap-2 px-3 py-1 bg-black/10 rounded-full text-sm hover:bg-black/30 transition-colors"
                            >
                                <LinkIcon className="w-4 h-4" />
                                {subcat.title}
                            </Link>
                        ))}
                    </div>
                </div>
            }
            <button
                onClick={() => setOpen(true)}
                // onClick={() => setIsModalOpen(true)}
                className="w-full bg-gray-900 text-white py-4 rounded-lg hover:bg-gray-800 transition-colors flex items-center justify-center gap-2 font-semibold"
            >
                Get Quote
                <ArrowRight className="w-5 h-5" />
            </button>
            <ContactModal close={closeModal} open={open} />
        </div>
    )
}

