import type { LucideIcon } from "lucide-react";
import type { ReactNode } from "react";

import { AppCard } from "@/components/ui/app-card";
import { CardContent } from "@/components/ui/card";

type StatsCardProps = {
  title: string;
  value: string;
  icon?: LucideIcon;
  description?: string;
  footer?: ReactNode;
  className?: string;
};

export function StatsCard({
  title,
  value,
  icon: Icon,
  description,
  footer,
  className,
}: StatsCardProps) {
  return (
    <AppCard level={3} className={className}>
      <CardContent className="space-y-2.5 p-3">
        <div className="flex items-start justify-between gap-3">
          <div>
            <p className="text-sm font-semibold text-foreground">{title}</p>
            <p className="mt-1 text-3xl font-semibold text-foreground">{value}</p>
          </div>
          {Icon ? (
            <div className="rounded-nested border border-border bg-muted/50 p-2 text-muted-foreground">
              <Icon className="h-4 w-4" />
            </div>
          ) : null}
        </div>

        {description ? (
          <p className="text-sm text-muted-foreground">{description}</p>
        ) : null}

        {footer ? footer : null}
      </CardContent>
    </AppCard>
  );
}
