import { Chip } from '@mui/material'
import { Target } from 'lucide-react'

interface SignalConfidenceBadgeProps {
  score: number
  size?: 'small' | 'medium'
}

function getColor(score: number): { bg: string; fg: string } {
  if (score >= 0.8) return { bg: 'rgba(34,197,94,0.12)', fg: '#16a34a' }
  if (score >= 0.6) return { bg: 'rgba(99,102,241,0.12)', fg: '#4f46e5' }
  if (score >= 0.4) return { bg: 'rgba(245,158,11,0.12)', fg: '#d97706' }
  return { bg: 'rgba(239,68,68,0.12)', fg: '#dc2626' }
}

export function SignalConfidenceBadge({ score, size = 'small' }: SignalConfidenceBadgeProps) {
  const { bg, fg } = getColor(score)
  return (
    <Chip
      size={size}
      icon={<Target size={11} color={fg} />}
      label={`Konfidenz ${Math.round(score * 100)}%`}
      sx={{
        bgcolor: bg,
        color: fg,
        border: 'none',
        fontWeight: 600,
        fontSize: size === 'small' ? '0.7rem' : '0.75rem',
      }}
    />
  )
}
