// Admin Panel Types

export interface AdminDashboardStats {
  total_users: number
  active_users: number
  suspended_users: number
  admin_users: number
  total_events: number
  upcoming_events: number
  live_events: number
  total_bets: number
  open_bets: number
  matched_bets: number
  total_volume: number
  escrow_locked: number
  simulation_running: boolean
}

export interface AuditLog {
  id: number
  admin_id: number
  admin_username: string
  action: string
  target_type: string | null
  target_id: number | null
  description: string
  details: string | null
  ip_address: string | null
  created_at: string
}

export interface AuditLogListResponse {
  logs: AuditLog[]
  total: number
  page: number
  page_size: number
}

export interface WipePreview {
  users_count: number
  wallets_count: number
  transactions_count: number
  bets_count: number
  spread_bets_count: number
  events_count: number
  event_comments_count: number
  match_comments_count: number
  admin_settings_preserved: boolean
  admin_users_preserved: boolean
  can_wipe: boolean
  cooldown_remaining_seconds: number
  last_wipe_at: string | null
}

export interface WipeRequest {
  confirmation_phrase: string
  preserve_admin_users: boolean
  preserve_events: boolean
}

export interface WipeResponse {
  success: boolean
  message: string
  deleted_counts: Record<string, number>
  preserved_counts: Record<string, number>
  executed_at: string
  executed_by: string
}

export interface SeedRequest {
  num_users: number
  num_events: number
  num_bets_per_event: number
  starting_balance: number
  create_admin: boolean
}

export interface SeedResponse {
  success: boolean
  message: string
  created_counts: Record<string, number>
  test_admin: {
    username: string
    email: string
    password: string
  } | null
}

export interface SimulationConfig {
  delay_seconds: number
  actions_per_iteration: number
  create_users: boolean
  create_bets: boolean
  take_bets: boolean
  add_comments: boolean
  cancel_bets: boolean
}

export interface SimulationStatus {
  is_running: boolean
  started_at: string | null
  started_by: string | null
  iterations_completed: number
  config: SimulationConfig | null
  last_activity: string | null
}

export interface SimulationStartResponse {
  success: boolean
  message: string
  status: SimulationStatus
}

export interface SimulationStopResponse {
  success: boolean
  message: string
  total_iterations: number
  ran_for_seconds: number
}

export interface AdminUser {
  id: number
  email: string
  username: string
  display_name: string | null
  is_admin: boolean
  status: 'active' | 'suspended' | 'pending_verification'
  balance: number
  escrow: number
  total_bets: number
  wins: number
  losses: number
  win_rate: number
  created_at: string
}

export interface AdminUserListResponse {
  users: AdminUser[]
  total: number
  page: number
  page_size: number
}

export interface AdminUserDetail extends AdminUser {
  avatar_url: string | null
  bio: string | null
  updated_at: string
  open_bets_count: number
  matched_bets_count: number
  transaction_count: number
}

export interface UserUpdateRequest {
  display_name?: string
  email?: string
  is_admin?: boolean
}

export interface UserStatusRequest {
  status: 'active' | 'suspended'
  reason?: string
}

export interface BalanceAdjustRequest {
  amount: number
  reason: string
}

export interface BalanceAdjustResponse {
  success: boolean
  user_id: number
  username: string
  previous_balance: number
  adjustment: number
  new_balance: number
  reason: string
  transaction_id: number
}
