// =============================================================================
// TYPES
// =============================================================================

export interface Escalation {
  id: string
  title: string
  description: string | null
  priority: 'low' | 'medium' | 'high' | 'critical'
  status: 'open' | 'in_progress' | 'escalated' | 'resolved' | 'closed'
  category: string | null
  assignee: string | null
  reporter: string | null
  source_module: string | null
  due_date: string | null
  resolved_at: string | null
  created_at: string
  updated_at: string
}

export interface EscalationStats {
  by_status: Record<string, number>
  by_priority: Record<string, number>
  total: number
  active: number
}

// =============================================================================
// HELPERS
// =============================================================================

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

export const priorityLabels: Record<string, string> = {
  critical: 'Kritisch',
  high: 'Hoch',
  medium: 'Mittel',
  low: 'Niedrig',
}

export const statusColors: Record<string, string> = {
  open: 'bg-blue-100 text-blue-700',
  in_progress: 'bg-yellow-100 text-yellow-700',
  escalated: 'bg-red-100 text-red-700',
  resolved: 'bg-green-100 text-green-700',
  closed: 'bg-gray-100 text-gray-600',
}

export const statusLabels: Record<string, string> = {
  open: 'Offen',
  in_progress: 'In Bearbeitung',
  escalated: 'Eskaliert',
  resolved: 'Geloest',
  closed: 'Geschlossen',
}

export const categoryLabels: Record<string, string> = {
  dsgvo_breach: 'DSGVO-Verletzung',
  ai_act: 'AI Act',
  vendor: 'Vendor',
  internal: 'Intern',
  other: 'Sonstiges',
}

export function formatDate(iso: string | null): string {
  if (!iso) return '—'
  return new Date(iso).toLocaleDateString('de-DE')
}
