/** Classroom = homeroom (physical room repurposed as a class group).
 *
 *  Owns:
 *  - a roster of students (M2M)
 *  - a set of homeroom teachers (M2M)
 *  - a list of courses taught here (M2M) — assigning a course cascades
 *    into a batch + auto-enrollment of every roster student.
 *  - the resulting batches (one per (classroom × course))
 */
export interface Classroom {
  id: number;
  name: string;
  code: string;
  capacity: number;
  active: boolean;
  notes?: string;
  entity_id: number | null;
  entity_name: string;
  branch_id?: number | null;
  branch_name?: string;
  student_count: number;
  teacher_count: number;
  course_count: number;
  batch_count: number;
  student_ids: number[];
  teacher_ids: number[];
  course_ids: number[];
  batch_ids?: number[];
  /** Only populated by GET /api/classrooms/<id> (full payload). */
  students?: ClassroomStudent[];
  teachers?: ClassroomMember[];
  courses?: ClassroomCourse[];
  sections?: ClassroomSection[];
  batches?: ClassroomBatchSummary[];
}

export interface ClassroomMember {
  id: number;
  name: string;
  email: string;
}

export interface ClassroomStudent extends ClassroomMember {
  gr_no?: string;
}

export interface ClassroomCourse {
  id: number;
  name: string;
  code: string;
}

export interface ClassroomSection {
  id: number;
  name: string;
  code: string;
  sequence: number;
  course_id: number | null;
  course_name: string;
}

export interface ClassroomBatchSummary {
  id: number;
  name: string;
  code: string;
  course_id: number | null;
  course_name: string;
  course_section_id?: number | null;
  course_section_name?: string;
  course_section_code?: string;
  term_key?: string;
  start_date: string;
  end_date: string;
  student_count: number;
  teacher_ids: number[];
}

export interface ClassroomCreateRequest {
  name: string;
  code?: string;
  capacity?: number;
  notes?: string;
  entity_id?: number;
  branch_id?: number | null;
  student_ids?: number[];
  teacher_ids?: number[];
  active?: boolean;
}

export interface ClassroomAssignCourseRequest {
  course_id: number;
  section_id?: number;
  teacher_ids?: number[];
  term_key?: string;
  term_name?: string;
  start_date?: string;
  end_date?: string;
}
