export interface Risk {
  id: string
  risk_id: string
  title: string
  description: string
  category: string
  likelihood: number
  impact: number
  inherent_risk: string
  mitigating_controls: string[] | null
  residual_likelihood: number | null
  residual_impact: number | null
  residual_risk: string | null
  owner: string
  status: string
  treatment_plan: string
}

export const RISK_COLORS: Record<string, string> = {
  low: 'bg-green-500',
  medium: 'bg-yellow-500',
  high: 'bg-orange-500',
  critical: 'bg-red-500',
}

export const RISK_BG_COLORS: Record<string, string> = {
  low: 'bg-green-100 border-green-300',
  medium: 'bg-yellow-100 border-yellow-300',
  high: 'bg-orange-100 border-orange-300',
  critical: 'bg-red-100 border-red-300',
}

export const STATUS_OPTIONS = ['open', 'mitigated', 'accepted', 'transferred']

export const CATEGORY_OPTIONS = [
  { value: 'data_breach', label: 'Datenschutzverletzung' },
  { value: 'compliance_gap', label: 'Compliance-Luecke' },
  { value: 'vendor_risk', label: 'Lieferantenrisiko' },
  { value: 'operational', label: 'Betriebsrisiko' },
  { value: 'technical', label: 'Technisches Risiko' },
  { value: 'legal', label: 'Rechtliches Risiko' },
]

export const calculateRiskLevel = (likelihood: number, impact: number): string => {
  const score = likelihood * impact
  if (score >= 20) return 'critical'
  if (score >= 12) return 'high'
  if (score >= 6) return 'medium'
  return 'low'
}

export interface RiskFormData {
  risk_id: string
  title: string
  description: string
  category: string
  likelihood: number
  impact: number
  owner: string
  treatment_plan: string
  status: string
  mitigating_controls: string[]
  residual_likelihood: number | null
  residual_impact: number | null
}
