import { Card, CardContent } from "@/components/ui/card";
import { cn } from "@/lib/utils";
import { ArrowDownRight, ArrowUpRight } from "lucide-react";
import type { DashboardMetricCardItem } from "./dashboard-home-types";

interface DashboardStatCardProps {
  item: DashboardMetricCardItem;
}

export function DashboardStatCard({ item }: DashboardStatCardProps) {
  const TrendIcon = item.trend === "up" ? ArrowUpRight : ArrowDownRight;
  const trendClassName = item.trend === "up" ? "text-status-green" : "text-destructive";
  const Icon = item.icon;

  return (
    <Card className="h-full rounded-[24px] border border-border bg-white shadow-[0_8px_24px_rgba(32,32,32,0.04)]">
      <CardContent className="flex h-full flex-col justify-between gap-6 p-6">
        <div className="flex flex-col items-start justify-between gap-4">
          <div
            className={cn(
              "flex size-10 shrink-0 items-center justify-center rounded-full bg-highlights-bg",
              item.iconBgClassName
            )}
          >
            <Icon className={cn("size-5 text-primary", item.iconClassName)} />
          </div>

          <div className="min-w-0 flex-1 ">
            <p className="text-sm font-medium leading-6 text-muted-foreground">{item.title}</p>
            <p className="mt-3 text-[34px] font-bold leading-none text-foreground">{item.value}</p>
          </div>
        </div>

        <div className="flex items-center gap-2 text-sm">
          <p className="text-muted-foreground">{item.comparisonLabel}</p>
          <div className={cn("flex items-center gap-1 font-semibold", trendClassName)}>
            <span>{item.comparisonValue}</span>
            <TrendIcon className="size-4" />
          </div>
        </div>
      </CardContent>
    </Card>
  );
}
