import Link from "next/link";
import { ArrowUpRight } from "lucide-react";
import { cn } from "@/lib/utils";

export function AdminStat({
  label,
  value,
  hint,
  icon,
  href,
  tone = "default",
}: {
  label: string;
  value: string;
  hint?: string;
  icon?: React.ReactNode;
  href?: string;
  tone?: "default" | "gold" | "olive" | "terracotta";
}) {
  const body = (
    <div className="group relative flex h-full flex-col justify-between border border-line bg-cream p-5 shadow-panel transition-colors hover:border-line-strong">
      <div className="flex items-start justify-between">
        <p className="text-[13px] font-medium uppercase tracking-[0.12em] text-walnut">{label}</p>
        <span
          className={cn(
            "flex h-8 w-8 items-center justify-center rounded-full",
            tone === "gold" && "bg-gold/10 text-gold-ink",
            tone === "olive" && "bg-olive/10 text-olive",
            tone === "terracotta" && "bg-terracotta/10 text-terracotta",
            tone === "default" && "bg-parchment text-walnut",
          )}
        >
          {icon}
        </span>
      </div>
      <div className="mt-6">
        <p className="font-serif text-3xl font-light tracking-tight text-charcoal">{value}</p>
        {hint && <p className="mt-1 text-[14px] text-pebble">{hint}</p>}
      </div>
      {href && (
        <ArrowUpRight className="absolute bottom-5 right-5 h-3.5 w-3.5 text-pebble transition-colors group-hover:text-walnut" />
      )}
    </div>
  );

  return href ? (
    <Link href={href} className="block h-full">
      {body}
    </Link>
  ) : (
    body
  );
}
