export interface Course {
  id: number;
  title: string;
  code: string;
  subject_id?: number;
  subject_name?: string;
  instructor_id: number;
  instructor_name: string;
  description: string;
  level: "Beginner" | "Intermediate" | "Advanced";
  modules: CourseModule[];
  enrolled: number;
  max_capacity: number;
  status: "draft" | "active" | "archived";
  start_date: string;
  end_date: string;
  progress?: number;
}

export interface CourseModule {
  id: number;
  title: string;
  sequence: number;
  lessons: CourseLesson[];
}

export interface CourseLesson {
  id: number;
  title: string;
  type: "video" | "reading" | "quiz" | "interactive";
  duration: string;
  completed?: boolean;
}

export interface Batch {
  id: number;
  name: string;
  course_id: number;
  course_name: string;
  teacher_id: number;
  teacher_name: string;
  student_ids: number[];
  student_count: number;
  start_date: string;
  end_date: string;
  schedule: string;
  status: "active" | "completed" | "upcoming";
  capacity: number;
}

export interface TimetableSession {
  id: number;
  course_id: number;
  course_name: string;
  teacher_name: string;
  batch_name: string;
  day: "Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday" | "Sunday";
  start_time: string;
  end_time: string;
  room: string;
}

export interface AttendanceRecord {
  id: number;
  date: string;
  course_id: number;
  course_name: string;
  student_id: number;
  student_name: string;
  status: "present" | "absent" | "late" | "excused";
}

export interface GradeRecord {
  id: number;
  course_id: number;
  course_name: string;
  student_id: number;
  student_name: string;
  assignment_title: string;
  grade: number;
  max_grade: number;
  date: string;
  type: string;
}

export interface CourseCreateRequest {
  title: string;
  code: string;
  subject_id?: number;
  instructor_id: number;
  description: string;
  level: "Beginner" | "Intermediate" | "Advanced";
  max_capacity: number;
  start_date: string;
  end_date: string;
}

/** OpenEduCat `op.student` row from `/api/students` */
export interface LmsStudentRecord {
  id: number;
  name: string;
  first_name: string;
  last_name: string;
  email: string;
  phone: string;
  gender: string;
  enrollment_date: string | null;
  status: string;
  course_ids: number[];
  batch_id: number | null;
  batch_name: string;
  partner_id: number;
  user_id: number | null;
}

/** OpenEduCat `op.faculty` row from `/api/teachers` */
export interface LmsTeacherRecord {
  id: number;
  name: string;
  first_name: string;
  last_name: string;
  email: string;
  phone: string;
  gender: string;
  birth_date: string | null;
  partner_id: number;
  department_id: number | null;
  department_name: string;
  specialization: string;
  subject_names: string[];
}

export interface LmsStudentCreateRequest {
  first_name: string;
  last_name: string;
  email: string;
  phone?: string;
  gender?: string;
  birth_date?: string;
  course_id?: number;
  batch_id?: number;
  academic_year_id?: number;
  /** If set, used for new portal `res.users` (SPA login). */
  password?: string;
  /** Default true: create portal user linked to `op.student`. */
  create_portal_user?: boolean;
}

export interface LmsTeacherCreateRequest {
  first_name: string;
  last_name: string;
  email: string;
  phone?: string;
  gender?: "male" | "female";
  birth_date?: string;
  department_id?: number;
  specialization?: string;
}
