import type { ImportanceLabel, DecisionLabel, Package } from './types'

// ============================================
// HELPER FUNCTIONS
// ============================================

export function getImportanceLabelColor(label: ImportanceLabel, isDark: boolean): string {
  const colors = {
    'KRITISCH': isDark ? 'bg-red-500/20 text-red-300 border-red-500/30' : 'bg-red-100 text-red-700 border-red-200',
    'DRINGEND': isDark ? 'bg-orange-500/20 text-orange-300 border-orange-500/30' : 'bg-orange-100 text-orange-700 border-orange-200',
    'WICHTIG': isDark ? 'bg-yellow-500/20 text-yellow-300 border-yellow-500/30' : 'bg-yellow-100 text-yellow-700 border-yellow-200',
    'PRUEFEN': isDark ? 'bg-blue-500/20 text-blue-300 border-blue-500/30' : 'bg-blue-100 text-blue-700 border-blue-200',
    'INFO': isDark ? 'bg-slate-500/20 text-slate-300 border-slate-500/30' : 'bg-slate-100 text-slate-600 border-slate-200',
  }
  return colors[label]
}

export function getDecisionLabelColor(label: DecisionLabel, isDark: boolean): string {
  const colors = {
    'relevant': isDark ? 'bg-green-500/20 text-green-300' : 'bg-green-100 text-green-700',
    'irrelevant': isDark ? 'bg-slate-500/20 text-slate-400' : 'bg-slate-100 text-slate-500',
    'needs_review': isDark ? 'bg-amber-500/20 text-amber-300' : 'bg-amber-100 text-amber-700',
  }
  return colors[label]
}

export function formatDeadline(dateStr: string | null | undefined): string {
  if (!dateStr) return 'Keine Frist'
  const date = new Date(dateStr)
  const now = new Date()
  const diffDays = Math.ceil((date.getTime() - now.getTime()) / (1000 * 60 * 60 * 24))

  if (diffDays < 0) return 'Abgelaufen'
  if (diffDays === 0) return 'Heute!'
  if (diffDays === 1) return 'Morgen'
  if (diffDays <= 7) return `${diffDays} Tage`
  if (diffDays <= 30) return `${Math.ceil(diffDays / 7)} Wochen`
  return date.toLocaleDateString('de-DE', { day: '2-digit', month: '2-digit', year: 'numeric' })
}

export function getPackageIcon(pkg: Package): string {
  const icons = {
    'PARKING': '🅿️',
    'EV_CHARGING': '⚡',
    'FUEL': '⛽',
    'TANK_MONITORING': '📊'
  }
  return icons[pkg]
}

export function getPackageLabel(pkg: Package): string {
  const labels = {
    'PARKING': 'Parking',
    'EV_CHARGING': 'EV Charging',
    'FUEL': 'Fuel',
    'TANK_MONITORING': 'Tank Monitoring'
  }
  return labels[pkg]
}
