// API Response Types
export interface ApiResponse<T> {
  success: boolean;
  data?: T;
  error?: string;
  message?: string;
}

// User Types
export interface User {
  id: string;
  username: string;
  email?: string;
  created_at: string;
  updated_at: string;
}

export interface LoginRequest {
  username: string;
  password: string;
}

export interface RegisterRequest {
  username: string;
  password: string;
  email?: string;
}

export interface AuthResponse {
  token: string;
  user: User;
}

// Document Types
export interface Document {
  id: string;
  user_id: string;
  title: string | null;
  content: string;
  category_id: string | null;
  created_at: string;
  updated_at: string;
  category?: Category;
  images?: Image[];
  todos?: Todo[];
}

export interface CreateDocumentRequest {
  content: string;
  title?: string;
  category_id?: string;
}

export interface UpdateDocumentRequest {
  content?: string;
  title?: string;
  category_id?: string;
}

// Todo Types
export type TodoPriority = 'low' | 'medium' | 'high' | 'urgent';
export type TodoStatus = 'pending' | 'completed' | 'confirmed';

export interface Todo {
  id: string;
  user_id: string;
  document_id: string | null;
  title: string;
  description: string | null;
  priority: TodoPriority;
  status: TodoStatus;
  due_date: string | null;
  category_id: string | null;
  completed_at: string | null;
  confirmed_at: string | null;
  created_at: string;
  updated_at: string;
  category?: Category;
}

export interface CreateTodoRequest {
  title: string;
  description?: string;
  priority?: TodoPriority;
  status?: TodoStatus;
  due_date?: string;
  category_id?: string;
  document_id?: string;
}

export interface UpdateTodoRequest {
  title?: string;
  description?: string;
  priority?: TodoPriority;
  status?: TodoStatus;
  due_date?: string;
  category_id?: string;
}

// Image Types
export interface Image {
  id: string;
  user_id: string;
  document_id: string | null;
  file_path: string;
  file_size: number;
  mime_type: string;
  ocr_result: string | null;
  ocr_confidence: number | null;
  processing_status: string;
  quality_score: number | null;
  error_message: string | null;
  created_at: string;
  updated_at: string;
  document?: Document;
}

export interface CreateImageRequest {
  file_path: string;
  file_size: number;
  mime_type: string;
  document_id?: string;
}

export interface UpdateOCRRequest {
  text: string;
  confidence?: number;
}

// Category Types
export type CategoryType = 'document' | 'todo';

export interface Category {
  id: string;
  user_id: string;
  name: string;
  type: CategoryType;
  color: string | null;
  icon: string | null;
  parent_id: string | null;
  sort_order: number;
  usage_count: number;
  is_ai_created: boolean;
  created_at: string;
}

// Tag Types
export interface Tag {
  id: string;
  user_id: string;
  name: string;
  color: string | null;
  usage_count: number;
  is_ai_created: boolean;
  created_at: string;
}

// AI Analysis Types
export type AIProvider = 'glm' | 'minimax' | 'deepseek';

export interface AIAnalysis {
  id: string;
  document_id: string;
  provider: string;
  model: string;
  suggested_tags: string;
  suggested_category: string | null;
  summary: string | null;
  raw_response: string;
  created_at: string;
}

export interface AnalyzeDocumentRequest {
  provider: AIProvider;
  model?: string;
}
