export type MasteryLevel = "not_started" | "beginner" | "developing" | "proficient" | "mastered";

export interface Proficiency {
  id: number;
  student_id: number;
  topic_id: number;
  topic_name: string;
  domain_name: string;
  mastery: number;
  mastery_level: MasteryLevel;
  last_assessed: string;
  time_spent_minutes: number;
}

export interface ProficiencySummary {
  subject_id: number;
  subject_name: string;
  overall_mastery: number;
  domain_scores: { domain_id: number; domain_name: string; mastery: number }[];
  topics_mastered: number;
  topics_total: number;
}

export type PlanItemStatus = "locked" | "available" | "in_progress" | "completed";

export interface LearningPlan {
  id: number;
  student_id: number;
  subject_id: number;
  subject_name: string;
  status: "active" | "paused" | "completed";
  ai_summary: string;
  overall_progress: number;
  target_completion?: string;
  created_at: string;
  items: LearningPlanItem[];
}

export interface LearningPlanItem {
  id: number;
  plan_id: number;
  topic_id: number;
  topic_name: string;
  domain_name: string;
  sequence: number;
  status: PlanItemStatus;
  estimated_hours: number;
  actual_hours: number;
  mastery: number;
}

export interface Resource {
  id: number;
  name: string;
  resource_type: "pdf" | "video" | "link" | "document" | "interactive";
  url?: string;
  file_name?: string;
  topic_ids: number[];
  topic_names: string[];
  author_id: number;
  author_name: string;
  is_published: boolean;
  review_status: "pending" | "approved" | "rejected";
  created_at: string;
}

export interface ResourceCompletion {
  id: number;
  student_id: number;
  resource_id: number;
  viewed: boolean;
  time_spent_minutes: number;
  rating?: number;
}

export interface DiagnosticSession {
  id: number;
  subject_id: number;
  status: "in_progress" | "completed";
  current_question_index: number;
  total_questions: number;
}

export interface DiagnosticQuestion {
  id: string;
  topic_id: number;
  topic_name: string;
  domain_name: string;
  difficulty: "easy" | "medium" | "hard";
  question_type: string;
  question_text: string;
  options?: string[];
  time_limit_seconds?: number;
}

export interface DiagnosticAnswer {
  session_id: number;
  question_id: string;
  answer: string;
}

export interface DiagnosticResult {
  session_id: number;
  subject_id: number;
  proficiencies: Proficiency[];
  summary: ProficiencySummary;
}

export interface TopicContent {
  topic_id: number;
  topic_name: string;
  resources: Resource[];
  ai_content?: AiGeneratedContent;
  has_content_gap: boolean;
}

export interface AiGeneratedContent {
  explanation: string;
  examples: string[];
  key_points: string[];
  model_used: string;
}

export interface AdaptiveDashboardMetrics {
  active_students: number;
  engine_phase: string;
  decisions_today: number;
  average_improvement: number;
  alerts_count: number;
}

export interface AdaptiveEngineStudentRow {
  student_id: number;
  name: string;
  subject: string;
  current_level: string;
  target: string;
  days_active: number;
  last_decision_at: string;
  progress_sparkline: number[];
  alert?: string;
}

export interface StudentAdaptiveSignal {
  time: string;
  signal: string;
  value: string;
  decision_made: string;
}

export interface StudentAbilityModel {
  theta: number;
  sem: number;
  trajectory: { t: string; theta: number }[];
}

export interface AdaptiveThresholdSettings {
  difficulty_step_up_threshold: number;
  difficulty_step_down_threshold: number;
  micro_lesson_trigger: number;
  module_skip_threshold: number;
  no_progress_alert_days: number;
  max_retries_per_exercise: number;
}
