import { Card } from '@/components/ui/card';
import { Progress } from '@/components/ui/progress';
import { Badge } from '@/components/ui/badge';
import { Cpu } from 'lucide-react';
import { SystemPerformance } from '@/types/monitor';

interface CpuMetricCardProps {
  performance: SystemPerformance;
  getUsageColor: (usage: number) => string;
  getUsageStatus: (usage: number) => string;
}

export function CpuMetricCard({ performance, getUsageColor, getUsageStatus }: CpuMetricCardProps) {
  return (
    <Card className="p-6">
      <div className="flex items-center justify-between mb-4">
        <div className="flex items-center gap-2">
          <Cpu className="w-5 h-5 text-blue-600" />
          <h3>CPU使用率</h3>
        </div>
        <Badge className={getUsageColor(performance.cpu.usage)}>
          {getUsageStatus(performance.cpu.usage)}
        </Badge>
      </div>
      <div className="space-y-3">
        <div className="flex items-center justify-between">
          <span className="text-sm text-muted-foreground">使用率</span>
          <span className={`${getUsageColor(performance.cpu.usage)}`}>
            {performance.cpu.usage.toFixed(1)}%
          </span>
        </div>
        <Progress value={performance.cpu.usage} className="h-2" />
        <div className="flex items-center justify-between text-sm">
          <span className="text-muted-foreground">核心数</span>
          <span>{performance.cpu.cores} 核</span>
        </div>
      </div>
    </Card>
  );
}