export interface Question {
  id: string
  part: number
  text: string
  options: string[]
  correctAnswer: number // 0-3
  explanation: string
}

export interface VocabWord {
  id: string
  word: string
  phonetic: string
  meaningVi: string
  topic: VocabTopic
  example: string
}

export type VocabTopic =
  | 'Tất cả'
  | 'Business'
  | 'Office'
  | 'Travel'
  | 'Finance'
  | 'HR'
  | 'Marketing'

export const VOCAB_TOPICS: VocabTopic[] = [
  'Tất cả',
  'Business',
  'Office',
  'Travel',
  'Finance',
  'HR',
  'Marketing',
]

export interface WritingFeedback {
  score: string
  grammar: string[]
  vocabulary: string[]
  structure: string
  improvedVersion: string
  summary: string
}

export interface WritingSubmission {
  id: string
  content: string
  feedback: WritingFeedback
  created_at: string
}

export interface ToeicPart {
  id: number
  name: string
  nameVi: string
  questionCount: number
  icon: string
  progressPercent: number
}

export interface User {
  id: string
  email: string
  name: string
}

// Phase 3 — Gamification
export type UserLevel = 'beginner' | 'bronze' | 'silver' | 'gold' | 'master'

export type XuTransactionType =
  | 'earn_welcome'
  | 'earn_daily'
  | 'earn_streak'
  | 'earn_ads'
  | 'spend_freeze'
  | 'spend_writing'
  | 'spend_test'

export interface UserGamification {
  userId: string
  xp: number
  level: UserLevel
  streak: number
  longestStreak: number
  lastActive: string | null // DATE as ISO string
  xu: number
  freezeCount: number
  createdAt: string
}

export interface XuTransaction {
  id: string
  userId: string
  type: XuTransactionType
  amount: number
  balance: number
  description: string | null
  createdAt: string
}

export interface WeeklyLeaderboardEntry {
  id: string
  userId: string
  weekStart: string
  xpEarned: number
  rank: number | null
}
