export type ConsultantStatus =
  | 'active'
  | 'inactive'
  | 'left_department'
  | 'left_company'
  | 'archived'
  | 'pending_approval'
  | 'rejected'

export interface Consultant {
  id: string
  auth_user_id: string | null
  email?: string | null
  first_name: string
  last_name: string
  display_name: string
  team_code: string
  role: 'consultant' | 'team_lead' | 'admin' | 'readonly'
  /** Added in Phase 4 migration — may be undefined on old rows */
  status?: ConsultantStatus | null
  is_active: boolean
  is_archived?: boolean | null
  capacity_hours_per_day: number
  left_department_at?: string | null
  left_company_at?: string | null
  deactivated_at?: string | null
  archived_at?: string | null
  lifecycle_note?: string | null
  created_at: string
}

export interface AppointmentType {
  id: string
  code: string
  label: string
  color: string
  sort_order: number
}

export interface PlanningProject {
  id: string
  code: string
  name: string
  supplier_id: string | null
  location_label: string | null
  country: string | null
  is_active: boolean
  created_at: string
}

export type AssignmentStatus = 'fixed' | 'tentative' | 'critical' | 'cancelled'
export type WorkMode = 'homeoffice' | 'onsite' | 'remote'

// tdd-guard:skip — reine Typ-Deklarationen, keine Logik
export interface Assignment {
  id: string
  date: string          // 'YYYY-MM-DD'
  start_time: string | null
  end_time: string | null
  project_id: string | null
  consultant_id: string
  description: string | null
  appointment_type_id: string
  supplier_name: string | null
  supplier_id: string | null
  location_label: string | null
  status: AssignmentStatus
  work_mode: WorkMode
  is_all_day: boolean
  requires_travel: boolean
  source: string
  created_at: string
  updated_at: string
  created_by: string | null
  updated_by: string | null
  /** Legacy DB field — may be present on older rows */
  user_id?: string | null
  /** Demo flag — set on seeded demo data */
  is_demo?: boolean | null
}

export interface AuditLogEntry {
  id: number
  table_name: string
  record_id: string
  action: 'INSERT' | 'UPDATE' | 'DELETE'
  changed_at: string
  changed_by_email: string | null
  changed_by_name: string | null
  old_data: Record<string, unknown> | null
  new_data: Record<string, unknown> | null
  old_status: string | null
  new_status: string | null
  old_date: string | null
  new_date: string | null
}
