/**
 * Compliance Framework - Internationalization (i18n)
 *
 * Provides bilingual terminology (DE/EN) for the compliance module.
 * This helps non-technical stakeholders understand GRC concepts.
 */

export type Language = 'de' | 'en'

// Core compliance terms with translations and explanations
export const COMPLIANCE_TERMS = {
  de: {
    // Core concepts
    control: 'Massnahme',
    control_description: 'Eine technische oder organisatorische Massnahme zur Erfuellung einer Compliance-Anforderung.',
    evidence: 'Nachweis',
    evidence_description: 'Dokumentierter Beleg, dass eine Massnahme umgesetzt und wirksam ist.',
    requirement: 'Anforderung',
    requirement_description: 'Eine gesetzliche oder normative Vorgabe, die erfuellt werden muss.',
    regulation: 'Verordnung',
    regulation_description: 'Ein Gesetz oder Standard, der verbindliche Anforderungen definiert.',
    risk: 'Risiko',
    risk_description: 'Eine potenzielle Bedrohung fuer die Organisation mit Eintrittswahrscheinlichkeit und Schadenshoehe.',

    // Status values
    pass: 'Erfuellt',
    pass_description: 'Die Massnahme ist vollstaendig umgesetzt und nachgewiesen.',
    partial: 'Teilweise erfuellt',
    partial_description: 'Die Massnahme ist teilweise umgesetzt, es bestehen noch Luecken.',
    fail: 'Nicht erfuellt',
    fail_description: 'Die Massnahme ist nicht oder unzureichend umgesetzt.',
    planned: 'Geplant',
    planned_description: 'Die Umsetzung der Massnahme ist geplant aber noch nicht begonnen.',
    not_applicable: 'Nicht anwendbar',
    not_applicable_description: 'Die Anforderung trifft auf unsere Organisation nicht zu.',

    // Metrics
    compliance_score: 'Erfuellungsgrad',
    compliance_score_description: 'Prozentsatz der erfuellten Compliance-Anforderungen.',
    coverage_level: 'Abdeckungsgrad',
    coverage_level_description: 'Wie gut eine Massnahme die Anforderung erfuellt (vollstaendig/teilweise).',
    risk_level: 'Risikostufe',
    risk_level_description: 'Kombinierte Bewertung aus Eintrittswahrscheinlichkeit und Schadenshoehe.',

    // Risk levels
    low: 'Niedrig',
    low_description: 'Geringes Risiko, keine sofortigen Massnahmen erforderlich.',
    medium: 'Mittel',
    medium_description: 'Moderates Risiko, Massnahmen sollten geplant werden.',
    high: 'Hoch',
    high_description: 'Hohes Risiko, zeitnahe Massnahmen erforderlich.',
    critical: 'Kritisch',
    critical_description: 'Kritisches Risiko, sofortige Massnahmen erforderlich.',

    // Domains
    governance: 'Governance',
    governance_description: 'Organisatorische Steuerung und Fuehrung.',
    privacy: 'Datenschutz',
    privacy_description: 'Schutz personenbezogener Daten.',
    iam: 'Identitaets- & Zugriffsmanagement',
    iam_description: 'Verwaltung von Benutzerkonten und Zugriffsrechten.',
    crypto: 'Kryptografie',
    crypto_description: 'Verschluesselung und kryptografische Verfahren.',
    sdlc: 'Sichere Entwicklung',
    sdlc_description: 'Sicherheit im Softwareentwicklungsprozess.',
    ops: 'Betrieb',
    ops_description: 'IT-Betrieb, Monitoring und Incident Response.',
    ai: 'KI-spezifisch',
    ai_description: 'Anforderungen fuer Kuenstliche Intelligenz.',
    cra: 'Supply Chain',
    cra_description: 'Lieferketten-Sicherheit und Produkthaftung.',
    audit: 'Audit',
    audit_description: 'Pruefung und Nachvollziehbarkeit.',

    // UI Elements
    dashboard: 'Uebersicht',
    export: 'Export',
    filter: 'Filter',
    search: 'Suche',
    details: 'Details',
    actions: 'Aktionen',
    status: 'Status',
    owner: 'Verantwortlich',
    deadline: 'Frist',
    last_review: 'Letzte Pruefung',
    next_review: 'Naechste Pruefung',

    // Executive Dashboard
    traffic_light_status: 'Ampelstatus',
    traffic_light_description: 'Schnelle Einschaetzung: Gruen = gut, Gelb = Aufmerksamkeit, Rot = kritisch.',
    top_risks: 'Top Risiken',
    upcoming_deadlines: 'Naechste Fristen',
    trend: 'Trend',
    trend_description: 'Entwicklung des Erfuellungsgrades ueber Zeit.',
    workload: 'Arbeitsbelastung',
    workload_description: 'Offene Aufgaben pro Team oder Person.',

    // Audit & Sign-off (Sprint 3)
    audit_session: 'Pruefung',
    audit_session_description: 'Eine strukturierte Compliance-Pruefung mit definierten Anforderungen.',
    sign_off: 'Freigabe',
    sign_off_description: 'Bestaetigung eines Pruefergebnisses durch den Auditor.',
    digital_signature: 'Digitale Signatur',
    digital_signature_description: 'SHA-256 Hash zur unveraenderlichen Dokumentation des Pruefergebnisses.',
    audit_checklist: 'Pruefungscheckliste',
    audit_checklist_description: 'Liste aller zu pruefenden Anforderungen einer Audit-Session.',
    completion_rate: 'Abschlussrate',
    completion_rate_description: 'Prozentsatz der bereits abgeschlossenen Pruefpunkte.',

    // Audit Results
    compliant: 'Konform',
    compliant_description: 'Die Anforderung ist vollstaendig erfuellt.',
    compliant_with_notes: 'Konform mit Anmerkungen',
    compliant_with_notes_description: 'Die Anforderung ist erfuellt, aber es gibt Hinweise zur Verbesserung.',
    non_compliant: 'Nicht konform',
    non_compliant_description: 'Die Anforderung ist nicht oder unzureichend erfuellt.',
    pending_audit: 'Ausstehend',
    pending_audit_description: 'Die Pruefung dieses Punktes steht noch aus.',

    // Session Status
    session_draft: 'Entwurf',
    session_in_progress: 'In Bearbeitung',
    session_completed: 'Abgeschlossen',
    session_archived: 'Archiviert',

    // Actions
    create_session: 'Neue Session erstellen',
    start_audit: 'Pruefung starten',
    complete_audit: 'Pruefung abschliessen',
    export_report: 'Report exportieren',
    sign_item: 'Punkt signieren',
  },

  en: {
    // Core concepts
    control: 'Control',
    control_description: 'A technical or organizational measure to fulfill a compliance requirement.',
    evidence: 'Evidence',
    evidence_description: 'Documented proof that a control is implemented and effective.',
    requirement: 'Requirement',
    requirement_description: 'A legal or normative obligation that must be fulfilled.',
    regulation: 'Regulation',
    regulation_description: 'A law or standard that defines binding requirements.',
    risk: 'Risk',
    risk_description: 'A potential threat to the organization with likelihood and impact.',

    // Status values
    pass: 'Pass',
    pass_description: 'The control is fully implemented and evidenced.',
    partial: 'Partial',
    partial_description: 'The control is partially implemented, gaps remain.',
    fail: 'Fail',
    fail_description: 'The control is not or insufficiently implemented.',
    planned: 'Planned',
    planned_description: 'Implementation of the control is planned but not started.',
    not_applicable: 'N/A',
    not_applicable_description: 'The requirement does not apply to our organization.',

    // Metrics
    compliance_score: 'Compliance Score',
    compliance_score_description: 'Percentage of fulfilled compliance requirements.',
    coverage_level: 'Coverage Level',
    coverage_level_description: 'How well a control fulfills the requirement (full/partial).',
    risk_level: 'Risk Level',
    risk_level_description: 'Combined assessment of likelihood and impact.',

    // Risk levels
    low: 'Low',
    low_description: 'Low risk, no immediate action required.',
    medium: 'Medium',
    medium_description: 'Moderate risk, actions should be planned.',
    high: 'High',
    high_description: 'High risk, timely action required.',
    critical: 'Critical',
    critical_description: 'Critical risk, immediate action required.',

    // Domains
    governance: 'Governance',
    governance_description: 'Organizational steering and leadership.',
    privacy: 'Privacy',
    privacy_description: 'Protection of personal data.',
    iam: 'Identity & Access Management',
    iam_description: 'Management of user accounts and access rights.',
    crypto: 'Cryptography',
    crypto_description: 'Encryption and cryptographic procedures.',
    sdlc: 'Secure Development',
    sdlc_description: 'Security in the software development process.',
    ops: 'Operations',
    ops_description: 'IT operations, monitoring, and incident response.',
    ai: 'AI-specific',
    ai_description: 'Requirements for Artificial Intelligence.',
    cra: 'Supply Chain',
    cra_description: 'Supply chain security and product liability.',
    audit: 'Audit',
    audit_description: 'Auditing and traceability.',

    // UI Elements
    dashboard: 'Dashboard',
    export: 'Export',
    filter: 'Filter',
    search: 'Search',
    details: 'Details',
    actions: 'Actions',
    status: 'Status',
    owner: 'Owner',
    deadline: 'Deadline',
    last_review: 'Last Review',
    next_review: 'Next Review',

    // Executive Dashboard
    traffic_light_status: 'Traffic Light Status',
    traffic_light_description: 'Quick assessment: Green = good, Yellow = attention, Red = critical.',
    top_risks: 'Top Risks',
    upcoming_deadlines: 'Upcoming Deadlines',
    trend: 'Trend',
    trend_description: 'Development of compliance score over time.',
    workload: 'Workload',
    workload_description: 'Open tasks per team or person.',

    // Audit & Sign-off (Sprint 3)
    audit_session: 'Audit Session',
    audit_session_description: 'A structured compliance audit with defined requirements.',
    sign_off: 'Sign-off',
    sign_off_description: 'Confirmation of an audit result by the auditor.',
    digital_signature: 'Digital Signature',
    digital_signature_description: 'SHA-256 hash for immutable documentation of audit results.',
    audit_checklist: 'Audit Checklist',
    audit_checklist_description: 'List of all requirements to be audited in a session.',
    completion_rate: 'Completion Rate',
    completion_rate_description: 'Percentage of completed audit items.',

    // Audit Results
    compliant: 'Compliant',
    compliant_description: 'The requirement is fully met.',
    compliant_with_notes: 'Compliant with Notes',
    compliant_with_notes_description: 'The requirement is met, but there are notes for improvement.',
    non_compliant: 'Non-Compliant',
    non_compliant_description: 'The requirement is not or insufficiently met.',
    pending_audit: 'Pending',
    pending_audit_description: 'The audit of this item is still pending.',

    // Session Status
    session_draft: 'Draft',
    session_in_progress: 'In Progress',
    session_completed: 'Completed',
    session_archived: 'Archived',

    // Actions
    create_session: 'Create Session',
    start_audit: 'Start Audit',
    complete_audit: 'Complete Audit',
    export_report: 'Export Report',
    sign_item: 'Sign Item',
  },
}

// Domain mapping for display
export const DOMAIN_LABELS: Record<string, { de: string; en: string }> = {
  gov: { de: 'Governance', en: 'Governance' },
  priv: { de: 'Datenschutz', en: 'Privacy' },
  iam: { de: 'Identitaet & Zugriff', en: 'Identity & Access' },
  crypto: { de: 'Kryptografie', en: 'Cryptography' },
  sdlc: { de: 'Sichere Entwicklung', en: 'Secure Dev' },
  ops: { de: 'Betrieb', en: 'Operations' },
  ai: { de: 'KI-spezifisch', en: 'AI-specific' },
  cra: { de: 'Supply Chain', en: 'Supply Chain' },
  aud: { de: 'Audit', en: 'Audit' },
}

// Status colors and labels
export const STATUS_CONFIG: Record<string, { color: string; bgColor: string; de: string; en: string }> = {
  pass: { color: 'text-green-700', bgColor: 'bg-green-100', de: 'Erfuellt', en: 'Pass' },
  partial: { color: 'text-yellow-700', bgColor: 'bg-yellow-100', de: 'Teilweise', en: 'Partial' },
  fail: { color: 'text-red-700', bgColor: 'bg-red-100', de: 'Nicht erfuellt', en: 'Fail' },
  planned: { color: 'text-slate-700', bgColor: 'bg-slate-100', de: 'Geplant', en: 'Planned' },
  'n/a': { color: 'text-slate-500', bgColor: 'bg-slate-50', de: 'N/A', en: 'N/A' },
}

// Risk level colors
export const RISK_CONFIG: Record<string, { color: string; bgColor: string; de: string; en: string }> = {
  low: { color: 'text-green-700', bgColor: 'bg-green-100', de: 'Niedrig', en: 'Low' },
  medium: { color: 'text-yellow-700', bgColor: 'bg-yellow-100', de: 'Mittel', en: 'Medium' },
  high: { color: 'text-orange-700', bgColor: 'bg-orange-100', de: 'Hoch', en: 'High' },
  critical: { color: 'text-red-700', bgColor: 'bg-red-100', de: 'Kritisch', en: 'Critical' },
}

// Traffic light colors for executive dashboard
export const TRAFFIC_LIGHT_CONFIG: Record<string, { color: string; bgColor: string; borderColor: string; de: string; en: string }> = {
  green: {
    color: 'text-green-700',
    bgColor: 'bg-green-500',
    borderColor: 'border-green-500',
    de: 'Gut',
    en: 'Good'
  },
  yellow: {
    color: 'text-yellow-700',
    bgColor: 'bg-yellow-500',
    borderColor: 'border-yellow-500',
    de: 'Aufmerksamkeit',
    en: 'Attention'
  },
  red: {
    color: 'text-red-700',
    bgColor: 'bg-red-500',
    borderColor: 'border-red-500',
    de: 'Kritisch',
    en: 'Critical'
  },
}

// Helper function to get term with fallback
export function getTerm(lang: Language, key: string): string {
  const terms = COMPLIANCE_TERMS[lang]
  return (terms as Record<string, string>)[key] || key
}

// Helper function to get description
export function getDescription(lang: Language, key: string): string {
  const terms = COMPLIANCE_TERMS[lang]
  return (terms as Record<string, string>)[`${key}_description`] || ''
}

// Helper to get domain label
export function getDomainLabel(domain: string, lang: Language): string {
  return DOMAIN_LABELS[domain]?.[lang] || domain.toUpperCase()
}

// Helper to get status display
export function getStatusDisplay(status: string, lang: Language): { label: string; color: string; bgColor: string } {
  const config = STATUS_CONFIG[status] || STATUS_CONFIG['planned']
  return {
    label: config[lang],
    color: config.color,
    bgColor: config.bgColor,
  }
}

// Helper to get risk display
export function getRiskDisplay(level: string, lang: Language): { label: string; color: string; bgColor: string } {
  const config = RISK_CONFIG[level] || RISK_CONFIG['medium']
  return {
    label: config[lang],
    color: config.color,
    bgColor: config.bgColor,
  }
}

// Helper to get traffic light display
export function getTrafficLightDisplay(status: string, lang: Language): { label: string; color: string; bgColor: string; borderColor: string } {
  const config = TRAFFIC_LIGHT_CONFIG[status] || TRAFFIC_LIGHT_CONFIG['yellow']
  return {
    label: config[lang],
    color: config.color,
    bgColor: config.bgColor,
    borderColor: config.borderColor,
  }
}

// Language context default
export const DEFAULT_LANGUAGE: Language = 'de'
