/** Label renderers aligned with CI score_prediction.php */

export function TrophyChanceLabel({ risk }: { risk: string | undefined }) {
  const r = risk ?? ''
  const map: Record<string, { className: string; text: string }> = {
    'Achieved Trophy': { className: 'text-success fw-bold', text: '🏅 Trophy Achieved' },
    'Top 3 Trophy': { className: 'text-primary fw-bold', text: '🥇 Top 3 Trophy' },
    Low: { className: 'text-success fw-bold', text: '🏆 Trophy within Reach' },
    Medium: { className: 'text-warning fw-bold', text: '⚠️ Needs Strong Effort' },
    High: { className: 'text-danger fw-bold', text: '❌ Unlikely to Win Trophy' },
    Unreachable: { className: 'text-dark fw-bold bg-warning px-2 rounded', text: '❌ Not Possible' },
    'New student': { className: 'text-muted fst-italic', text: '⏳ No Data Yet' },
  }
  const m = map[r] ?? { className: 'text-body', text: 'Unknown' }
  return <span className={m.className}>{m.text}</span>
}

export function FailRiskLabel({ risk }: { risk: string | undefined }) {
  const r = risk ?? ''
  const map: Record<string, { className: string; text: string }> = {
    Low: { className: 'text-success fw-bold', text: '✅ Safe' },
    Medium: { className: 'text-warning fw-bold', text: '⚠️ Some Risk' },
    High: { className: 'text-danger fw-bold', text: '❗ At Risk' },
    'Unlikely to pass': { className: 'text-white fw-bold bg-danger px-2 rounded', text: '❌ Cannot Pass' },
    'New student': { className: 'text-muted fst-italic', text: '⏳ No Data Yet' },
  }
  const m = map[r] ?? { className: 'text-body', text: 'Unknown' }
  return <span className={m.className}>{m.text}</span>
}

export function StatusBadge({ status }: { status: string | undefined }) {
  const s = status ?? ''
  const map: Record<string, { className: string; text: string }> = {
    Passed: { className: 'badge bg-success', text: '✅ Passed' },
    Failed: { className: 'badge bg-danger', text: '❌ Failed' },
    'Can pass': { className: 'badge bg-primary', text: '✅ Can pass' },
    'May fail': { className: 'badge bg-warning text-dark', text: '⚠️ May fail' },
    Undetermined: { className: 'badge bg-secondary', text: '⏳ Undetermined' },
  }
  const m = map[s] ?? { className: 'badge bg-light text-dark', text: 'N/A' }
  return <span className={m.className}>{m.text}</span>
}
