// Shared types for Compliance Hub

export interface DashboardData {
  compliance_score: number
  total_regulations: number
  total_requirements: number
  total_controls: number
  controls_by_status: Record<string, number>
  controls_by_domain: Record<string, Record<string, number>>
  total_evidence: number
  evidence_by_status: Record<string, number>
  total_risks: number
  risks_by_level: Record<string, number>
  multi_score?: {
    requirement_coverage: number
    evidence_strength: number
    validation_quality: number
    evidence_freshness: number
    control_effectiveness: number
    overall_readiness: number
    hard_blocks: string[]
  } | null
}

export interface Regulation {
  id: string
  code: string
  name: string
  full_name: string
  regulation_type: string
  effective_date: string | null
  description: string
  requirement_count: number
}

export interface MappingsData {
  total: number
  by_regulation: Record<string, number>
}

export interface FindingsData {
  major_count: number
  minor_count: number
  ofi_count: number
  total: number
  open_majors: number
  open_minors: number
}

export interface RoadmapItem {
  id: string
  control_id: string
  title: string
  status: string
  domain: string
  owner: string | null
  next_review_at: string | null
  days_overdue: number
  weight: number
}

export interface RoadmapData {
  buckets: Record<string, RoadmapItem[]>
  counts: Record<string, number>
}

export interface ModuleInfo {
  key: string
  label: string
  count: number
  status: string
  progress: number
}

export interface ModuleStatusData {
  modules: ModuleInfo[]
  total: number
  started: number
  complete: number
  overall_progress: number
}

export interface NextAction {
  id: string
  control_id: string
  title: string
  status: string
  domain: string
  owner: string | null
  days_overdue: number
  urgency_score: number
  reason: string
}

export interface ScoreSnapshot {
  id: string
  score: number
  controls_total: number
  controls_pass: number
  snapshot_date: string
  created_at: string
}

export interface TraceabilityAssertion {
  id: string
  sentence_text: string
  assertion_type: string
  confidence: number
  verified: boolean
}

export interface TraceabilityEvidence {
  id: string
  title: string
  evidence_type: string
  confidence_level: string
  status: string
  assertions: TraceabilityAssertion[]
}

export interface TraceabilityCoverage {
  has_evidence: boolean
  has_assertions: boolean
  all_assertions_verified: boolean
  min_confidence_level: string | null
}

export interface TraceabilityControl {
  id: string
  control_id: string
  title: string
  status: string
  domain: string
  evidence: TraceabilityEvidence[]
  coverage: TraceabilityCoverage
}

export interface TraceabilityMatrixData {
  controls: TraceabilityControl[]
  summary: Record<string, number>
}

export type TabKey = 'overview' | 'roadmap' | 'modules' | 'trend' | 'traceability'

export const DOMAIN_LABELS: Record<string, string> = {
  gov: 'Governance',
  priv: 'Datenschutz',
  iam: 'Identity & Access',
  crypto: 'Kryptografie',
  sdlc: 'Secure Dev',
  ops: 'Operations',
  ai: 'KI-spezifisch',
  cra: 'Supply Chain',
  aud: 'Audit',
}

export const BUCKET_LABELS: Record<string, { label: string; color: string; bg: string }> = {
  quick_wins: { label: 'Quick Wins', color: 'text-green-700', bg: 'bg-green-50 border-green-200' },
  must_have: { label: 'Must Have', color: 'text-red-700', bg: 'bg-red-50 border-red-200' },
  should_have: { label: 'Should Have', color: 'text-yellow-700', bg: 'bg-yellow-50 border-yellow-200' },
  nice_to_have: { label: 'Nice to Have', color: 'text-slate-700', bg: 'bg-slate-50 border-slate-200' },
}

export const MODULE_ICONS: Record<string, string> = {
  vvt: '📋', tom: '🔒', dsfa: '⚠️', loeschfristen: '🗑️', risks: '🎯',
  controls: '✅', evidence: '📎', obligations: '📜', incidents: '🚨',
  vendor: '🤝', legal_templates: '📄', training: '🎓', audit: '🔍',
  security_backlog: '🛡️', quality: '⭐',
}
