import { Card, CardContent, Chip } from '@heroui/react';
import type { ReactNode } from 'react';

type Props = {
  icon: ReactNode;
  label: string;
  value: string | number;
  trend?: string;
  color?: 'primary' | 'success' | 'warning' | 'danger' | 'default';
};

export function StatCard({ icon, label, value, trend, color = 'primary' }: Props) {
  const chipColor = color === 'default' ? 'default' : color;

  return (
    <Card>
      <CardContent className="flex flex-col gap-2 p-4">
        <div className="flex items-center justify-between">
          <Chip color={chipColor} size="sm" variant="flat" startContent={icon}>
            {label}
          </Chip>
          {trend && (
            <span className={`text-tiny font-medium ${trend.startsWith('+') ? 'text-success-400' : trend.startsWith('-') ? 'text-danger-400' : 'text-default-400'}`}>
              {trend}
            </span>
          )}
        </div>
        <div className="text-2xl font-bold tracking-tight">{value}</div>
        <div className="text-tiny text-default-500">{label}</div>
      </CardContent>
    </Card>
  );
}
