// 通用API响应类型
export interface ApiResponse<T> {
  success: boolean;
  code: number;
  message: string;
  data: T;
}

// 分页数据响应类型
export interface PaginatedData<T> {
  count: number;
  next: string | null;
  previous: string | null;
  results: T[];
}

// 用户类型
export interface User {
  id: string
  name: string
  email: string
  role: string
  status: "活跃" | "未激活" | "已禁用"
  registeredAt: string
  lastLogin?: string
  phone?: string
  address?: string
  avatar?: string
  permissions?: string[]
  loginHistory?: LoginHistory[]
}

// 登录历史记录
export interface LoginHistory {
  date: string
  ip: string
  device: string
}

// 角色类型
export interface Role {
  id: string
  name: string
  description?: string
  permissions?: string[]
  userCount?: number
  createdAt?: string
  updatedAt?: string
}

// 权限类型
export interface Permission {
  id: string
  name: string
  description?: string
  module?: string
}

// 服装类型
export interface Outfit {
  id: string
  name: string
  description?: string
  imageUrl?: string
  rarity?: string
  category?: string
  status?: string
  publishedAt?: string
  batchesCount?: number
  activeCardsCount?: number
  tags?: string[]
  createdAt?: string
  updatedAt?: string
}

// 道具类型
export interface Prop {
  id: string
  name: string
  description?: string
  imageUrl?: string
  rarity?: string
  category?: string
  status?: string
  publishedAt?: string
  batchesCount?: number
  activeCardsCount?: number
  tags?: string[]
  createdAt?: string
  updatedAt?: string
}

// 歌曲类型
export interface Song {
  id: string
  name: string
  composer?: string
  lyricist?: string
  duration?: string
  releaseDate?: string
  status?: string
  image?: string
  audioUrl?: string
  description?: string
  rarity?: string
  cardType?: string
  genre?: string
  lyrics?: string
  price?: string
  batchesCount?: number
  cardsCount?: number
  createdAt?: string
  updatedAt?: string
  category?: string
  arrangement?: string
  bpm?: number
  rawData?: {
    id: number
    name: string
    category: string
    category_display: string
    description: string
    card_type: string
    card_type_display: string
    rarity: string
    rarity_display: string
    image: string | null
    image_url: string | null
    model_url: string | null
    model_version: string | null
    status: string
    status_display: string
    published_at: string | null
    price: string
    created_at: string
    updated_at: string
    batches_count: number
    active_cards_count: number
    attributes: {
      genre?: string
      duration?: string
      bpm?: number
      composer?: string
      lyricist?: string
      arrangement?: string
      audio_file?: string
      lyrics?: string
    }
  }
}

// 舞蹈类型
export interface Dance {
  id: string
  name: string
  choreographer?: string // 编舞者
  duration?: string
  difficulty?: string // 难度
  videoUrl?: string
  coverUrl?: string
  description?: string
  motionFile?: string // 动作文件
  category?: string
  tags?: string[]
  status?: string
  statusDisplay?: string
  publishedAt?: string
  activeCardsCount?: number
  createdAt?: string
  updatedAt?: string
}

// 食物类型
export interface Food {
  id: string
  name: string
  food_type: string
  description: string
  rarity: string
  image?: string
  animation_file?: string
  sound_effect?: string
  calories?: number
  taste_tags?: string
  nutritional_value?: string
  effect_description?: string
  boost_attributes?: Record<string, number>
  status: string
  created_at?: string
  updated_at?: string
  // 保留一些前端显示用的字段
  releaseDate?: string
  activatedCount?: number
}

// 用户食物类型
export interface UserFood {
  id: string
  food: Food
  quantity: number
  obtainedAt: string
}

// 食物统计类型
export interface FoodStats {
  totalFoods: number
  publishedFoods: number
  totalActivations: number
  averageActivations: number
  popularFoods: Food[]
}

// 我的食物统计类型
export interface MyFoodStats {
  totalFoods: number
  totalQuantity: number
  foodsByRarity: {
    [key: string]: number
  }
  recentlyObtained: UserFood[]
}

// 使用食物请求类型
export interface UseFoodRequest {
  foodId: string
  quantity?: number
}

// 食物分类和稀有度信息类型
export interface FoodCategoriesInfo {
  categories: string[]
  rarities: string[]
  types: string[]
}

// 食物使用记录类型
export interface FoodUsageLog {
  id: string
  food: Food
  quantity: number
  usedAt: string
  effectDescription?: string
}

// 文件上传相关类型
export interface UploadResponse {
  url: string
  filename: string
  size: number
  mimeType: string
}

// 家居装饰类型
export interface HomeDecor {
  id: string
  name: string
  description?: string
  imageUrl?: string
  rarity?: string
  category?: string
  status?: string
  publishedAt?: string
  batchesCount?: number
  activeCardsCount?: number
  tags?: string[]
  createdAt?: string
  updatedAt?: string
}

// 好感度等级
export interface AffinityLevel {
  id: string
  level: number
  name: string
  description?: string
  requiredPoints: number
  rewards?: string[]
}

// 好感度规则
export interface AffinityRule {
  id: string
  action: string
  points: number
  description?: string
  dailyLimit?: number
}

// AI模型
export interface AiModel {
  id: string
  name: string
  version: string
  description?: string
  status: "活跃" | "训练中" | "已归档"
  parameters?: number
  accuracy?: number
  trainingData?: string
  createdAt?: string
  updatedAt?: string
}

// 成就类型
export interface Achievement {
  id: string
  name: string
  description: string
  icon?: string
  category: "互动" | "好感度" | "收集" | "探索" | "特殊" | "隐藏"
  requirement: string
  rewardType: "经验值" | "好感度" | "虚拟币" | "道具" | "服装" | "称号"
  rewardAmount: number
  rewardIcon?: string
  isHidden: boolean
  unlockRate?: number
  createdAt?: string
  updatedAt?: string
}
