export interface ApiResponse<T> {
  code: number
  message: string
  data: T
}

export interface PageMeta {
  current_page: number
  per_page: number
  total: number
  last_page: number
}

export interface PageData<T> {
  items: T[]
  meta: PageMeta
}

export interface User {
  id: number
  name: string
  email: string
  role: 'admin' | 'teacher' | 'user'
  is_active: boolean
  permissions?: Permission[]
}

export interface Permission {
  id: number
  code: string
  name: string
  type: 'menu' | 'button'
  parent_code?: string
  menu_path?: string
  sort?: number
}

export interface QuestionBank {
  id: number
  name: string
  description?: string
  visibility: 'public' | 'private' | 'assigned'
  questions_count?: number
  wrong_questions_count?: number
  is_active: boolean
}

export interface ImportJob {
  id: number
  question_bank_id: number
  type: string
  status: string
  total_count: number
  success_count: number
  skipped_count: number
  report?: Array<Record<string, unknown>>
}

export interface QuestionOption {
  id: number
  content: string
  is_correct: boolean
  sort: number
}

export interface Question {
  id: number
  question_bank_id: number
  type: 'single' | 'multiple' | 'judge' | 'blank'
  content: string
  explanation?: string
  answers?: string[]
  options: QuestionOption[]
  is_active: boolean
}

export interface SchoolClass {
  id: number
  name: string
  description?: string
  join_code: string
  members_count?: number
  is_active: boolean
}

export interface Paper {
  id: number
  title: string
  description?: string
  question_bank_id?: number
  duration_minutes?: number
  attempt_limit?: number
  questions_count?: number
  questions?: Array<Question & { pivot?: { score?: string | number; sort?: number } }>
  is_active: boolean
}

export interface TaxonomyItem {
  id: number
  question_bank_id: number
  parent_id?: number
  name: string
  sort?: number
}

export interface AttemptItem {
  id: number
  question_id: number
  answer?: number[] | string[]
  is_correct?: boolean
  explanation_viewed: boolean
  question: Question
}

export interface QuizAttempt {
  id: number
  mode: 'memorize' | 'practice' | 'random' | 'paper'
  status: 'in_progress' | 'submitted'
  total_questions: number
  correct_count: number
  score: string
  current_index: number
  expires_at?: string
  items: AttemptItem[]
}

export interface WrongQuestion {
  id: number
  question_id: number
  wrong_count: number
  consecutive_correct_count: number
  last_wrong_at?: string
  question: Question
}
