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

export interface UserProfile {
  id: number;
  phone: string;
  name: string;
  nickname?: string | null;
  dailyLimit: number;
  todayUsed: number;
  status: number;
  entitlement?: UserEntitlementSummary | null;
}

export interface UserEntitlementSummary {
  planId: number | null;
  name: string;
  planType: string;
  monthlyTopicLimit: number | null;
  monthlyTopicUsed: number;
  monthlyTopicRemaining: number | null;
  enableGrowthProfile: boolean;
  enablePeriodicReports: boolean;
  allowHelpCard: boolean;
  allowShareDraft: boolean;
  deductQuota: boolean;
  effectiveAt?: string | null;
  expiredAt?: string | null;
  source: string;
}

export interface TopicSummary {
  id: number;
  topicSessionId: number;
  summary: string;
  recommendedHomework?: string | null;
  nextObservation?: string | null;
  generatedAt: string;
}

export interface GrowthProfile {
  id: number;
  userId: number;
  profileText: string;
  recurringTopics?: string | null;
  commonEmotions?: string | null;
  bodyPatterns?: string | null;
  relationPatterns?: string | null;
  homeworkDone?: string | null;
  effectiveHomework?: string | null;
  recentProgress?: string | null;
  updatedAt: string;
}

export interface GrowthProfileResult {
  profile: GrowthProfile | null;
  recentSummaries: TopicSummary[];
}

export interface PeriodicReport {
  id: number;
  reportType: "weekly" | "monthly" | "stage" | string;
  reportTypeLabel: string;
  periodStart: string;
  periodEnd: string;
  title: string;
  content: string;
  status: "success" | "failed" | "empty" | string;
  generatedAt: string;
}

export interface FinishTopicResult {
  topic: Record<string, unknown>;
  summary: TopicSummary & Record<string, unknown>;
  profile: GrowthProfile | null;
  growthProfileEnabled: boolean;
}

export interface TeacherHelpCard {
  id: number;
  userId: number;
  topicSessionId: number;
  summaryId?: number | null;
  content: string;
  source: string;
  copied: boolean;
  copiedAt?: string | null;
  createdAt: string;
}

export interface ShareDraft {
  id: number;
  userId: number;
  topicSessionId: number;
  summaryId?: number | null;
  content: string;
  source: string;
  copied: boolean;
  copiedAt?: string | null;
  createdAt: string;
}

export interface LoginResult {
  token: string;
  expiredAt: string;
  user: UserProfile;
}

export interface CaptchaResult {
  captchaId: string;
  imageBase64: string;
  expiresInSeconds: number;
}

export interface ChatSession {
  id: number;
  title: string;
  messageCount: number;
  updatedAt: string;
}

export interface ChatMessage {
  id: number;
  role: "user" | "assistant";
  content: string;
  message_status: string;
  created_at: string;
}
