import type { LucideIcon } from "lucide-react";
import { cn } from "@/lib/utils";

export function MetricTile({
  icon: Icon,
  label,
  value,
  trend,
  tone = "default",
  className,
}: {
  icon: LucideIcon;
  label: string;
  value: string;
  trend?: string;
  tone?: "default" | "positive" | "warning";
  className?: string;
}) {
  return (
    <div
      className={cn(
        "flex flex-col gap-2 rounded-xl border border-border bg-secondary/40 p-3.5",
        className,
      )}
    >
      <div className="flex items-center justify-between">
        <span className="flex size-7 items-center justify-center rounded-md bg-background/70 text-muted-foreground">
          <Icon className="size-3.5" />
        </span>
        {trend ? (
          <span
            className={cn(
              "text-xs font-medium",
              tone === "positive" && "text-success",
              tone === "warning" && "text-warning",
              tone === "default" && "text-muted-foreground",
            )}
          >
            {trend}
          </span>
        ) : null}
      </div>
      <div>
        <p className="text-lg font-semibold text-foreground">{value}</p>
        <p className="text-xs text-muted-foreground">{label}</p>
      </div>
    </div>
  );
}
