import { jsxs, jsx } from "react/jsx-runtime";
import { Link } from "@tanstack/react-router";
import { FileText, MessageCircle, Mail } from "lucide-react";
import { z as useQuote, l as categoryOf, m as cn, o as formatKsh, G as waLink, S as SITE, q as mailLink } from "./router-D4ixsMHb.js";
import { toast } from "sonner";
const BADGE_TONE = {
  New: "bg-emerald-500/95",
  Hot: "bg-rose-500/95",
  Sale: "bg-amber-500/95"
};
function ProductCard({ product }) {
  const { add } = useQuote();
  const category = categoryOf(product);
  return /* @__PURE__ */ jsxs("div", { className: "group overflow-hidden rounded-sm border border-border bg-card shadow-[var(--shadow-card)] transition hover:-translate-y-0.5 hover:shadow-[var(--shadow-elevated)]", children: [
    /* @__PURE__ */ jsx(Link, { to: "/products/$slug", params: { slug: product.slug }, className: "block", children: /* @__PURE__ */ jsxs("div", { className: "relative flex aspect-square items-center justify-center overflow-hidden bg-surface text-white", children: [
      /* @__PURE__ */ jsx(
        "img",
        {
          src: product.image,
          alt: product.name,
          loading: "lazy",
          width: 1024,
          height: 768,
          className: "absolute inset-0 h-full w-full object-cover transition duration-500 group-hover:scale-105"
        }
      ),
      /* @__PURE__ */ jsx("div", { className: "absolute inset-0 bg-gradient-to-br from-brand/35 via-brand/10 to-black/30" }),
      product.badge && /* @__PURE__ */ jsx(
        "span",
        {
          className: cn(
            "absolute left-3 top-3 rounded-full px-2.5 py-1 text-[11px] font-semibold tracking-wide text-white shadow",
            BADGE_TONE[product.badge]
          ),
          children: product.badge
        }
      ),
      /* @__PURE__ */ jsx("span", { className: "absolute bottom-3 right-3 rounded-md bg-black/35 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wider text-white/90 backdrop-blur-sm", children: category.name })
    ] }) }),
    /* @__PURE__ */ jsxs("div", { className: "space-y-3 p-4", children: [
      /* @__PURE__ */ jsxs("div", { children: [
        /* @__PURE__ */ jsx(
          Link,
          {
            to: "/products/$slug",
            params: { slug: product.slug },
            className: "line-clamp-2 text-sm font-semibold text-foreground transition hover:text-brand-bright md:text-base",
            children: product.name
          }
        ),
        /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-muted-foreground", children: product.lot ? `Lot: ${product.lot}` : product.sku ? `SKU: ${product.sku}` : "Lot: —" })
      ] }),
      /* @__PURE__ */ jsx("p", { className: "text-base font-bold text-brand", children: formatKsh(product.price) }),
      /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
        /* @__PURE__ */ jsx(
          "button",
          {
            type: "button",
            onClick: () => {
              add(product);
              toast.success("Added to quote", { description: product.name });
            },
            "aria-label": "Add to quote",
            className: "inline-flex h-9 w-9 items-center justify-center rounded-md bg-brand text-brand-foreground transition hover:bg-brand/90",
            children: /* @__PURE__ */ jsx(FileText, { className: "h-4 w-4" })
          }
        ),
        /* @__PURE__ */ jsx(
          "a",
          {
            href: waLink(`Hello ${SITE.name}, I'm interested in: ${product.name} (${formatKsh(product.price)}).`),
            target: "_blank",
            rel: "noopener noreferrer",
            "aria-label": "WhatsApp inquiry",
            className: "inline-flex h-9 w-9 items-center justify-center rounded-md text-white transition hover:opacity-90",
            style: { background: "#25D366" },
            children: /* @__PURE__ */ jsx(MessageCircle, { className: "h-4 w-4" })
          }
        ),
        /* @__PURE__ */ jsx(
          "a",
          {
            href: mailLink(`Inquiry: ${product.name}`, `Hi,

I'd like more information about ${product.name}.

Thanks.`),
            "aria-label": "Email inquiry",
            className: "inline-flex h-9 w-9 items-center justify-center rounded-md border border-brand-bright/30 text-brand-bright transition hover:bg-brand-bright/10",
            children: /* @__PURE__ */ jsx(Mail, { className: "h-4 w-4" })
          }
        )
      ] })
    ] })
  ] });
}
export {
  ProductCard as P
};
