// Shared domain types — import from here rather than defining inline in each page

export interface Child {
  id: string;
  name: string;
  birthDate: string;
  sex: string;
  imageUrl?: string | null;
}

export type LogType = "feed" | "diaper" | "sleep";

export interface Log {
  id: string;
  type: LogType;
  subType?: string;
  amount?: number | null;
  notes?: string | null;
  loggedAt: string;
}

export interface GrowthRecord {
  id: string;
  child_id: string;
  measured_at: string;
  weight_kg: number | null;
  height_cm: number | null;
  head_circumference_cm: number | null;
  notes: string | null;
}

export interface Goal {
  weightKg?: number;
  heightCm?: number;
  targetDate?: string;
}

export interface Medicine {
  id: string;
  name: string;
  dose: string;
  notes: string;
  reminderTime?: string;
}

export interface DoseCorrection {
  id: string;
  corrected_value: Record<string, string>;
  reason: string | null;
  created_at: string;
}

export interface Dose {
  id: string;
  administered_at: string;
  amount_given: string | null;
  notes: string | null;
  corrections?: DoseCorrection[];
}

export interface Allergy {
  id: string;
  name: string;
  severity: string;
  notes: string;
}

export interface Visit {
  id: string;
  doctorName: string;
  reason: string;
  date: string;
  notes: string;
}

export interface Illness {
  id: string;
  name: string;
  startDate: string;
  endDate?: string;
  notes: string;
}

export interface Vaccination {
  vaccine_name: string;
  given_date: string;
  status: "given" | "pending";
}

export interface AIChat {
  id: string;
  role: "user" | "assistant";
  content: string;
  createdAt: string;
}

export interface ChatSession {
  id: string;
  title: string;
  messages: AIChat[];
  createdAt: string;
  updatedAt: string;
}

// ── Circle types ──────────────────────────────────────────────────────────────

export interface Circle {
  id: string;
  name: string;
  createdBy: string;
  createdAt: string;
  role: "admin" | "member";
  memberCount: number;
}

export interface CircleMember {
  familyId: string;
  familyName: string;
  role: "admin" | "member";
  joinedAt: string;
}

export interface CirclePost {
  id: string;
  circleId: string;
  authorFamilyId: string;
  authorFamilyName: string;
  body: string | null;
  imageUrl: string | null;
  sourceKind: "milestone" | "memory" | null;
  createdAt: string;
  reactions: CircleReaction[];
  commentCount: number;
}

export interface CircleReaction {
  emoji: string;
  count: number;
  includedMe: boolean;
}

export interface CircleComment {
  id: string;
  authorFamilyId: string;
  authorFamilyName: string;
  body: string;
  createdAt: string;
}
