import type { ApiReviewQueueItem } from "../../../lib/api-types";

export type TeacherReviewQueueItem = {
	studentId: number;
	studentName: string;
	email: string;
	reviewStatus: ApiReviewQueueItem["review_status"];
	nextStepOutcome: TeacherNextStepOutcome | null;
	submittedQuestions: number;
	reviewedQuestions: number;
	progressLabel: string;
	statusLabel: string;
	statusTone: "review" | "progress" | "muted" | "success";
	timestampLabel: string;
};

export type TeacherAssignmentCloseState = "ready" | "blocked" | "closed";

export type TeacherAssignmentCloseSummary = {
	state: TeacherAssignmentCloseState;
	canClose: boolean;
	blockers: string[];
	summary: string;
};

export type TeacherAssignmentPassStatus = "pending" | "pass" | "no_pass";
export type TeacherNextStepOutcome = "redo" | "accept" | "support";

export type TeacherReviewDraftFields = {
	reviewNeedsAttention: boolean;
	reviewIssueReason: string;
	reviewCorrectnessScore: number | null;
	reviewUnderstandingScore: number | null;
	reviewQuestionScore: number | null;
	reviewConfidence: number | null;
};

export type TeacherReviewQuestion = TeacherReviewDraftFields & {
	id: number;
	order: number;
	prompt: string;
	subject: string;
	source: string | null;
	questionTags: string[];
	answerId: number | null;
	answerStatus: "not_started" | "in_progress" | "submitted" | "reviewed" | null;
	statusLabel: string;
	statusTone: "review" | "progress" | "muted" | "success";
	answerText: string;
	solveModeLabel: string | null;
	workingSteps: string;
	correctAnswer: string | null;
	isCorrect: boolean | null;
	correctnessLabel: string;
	submittedLabel: string;
	reviewedLabel: string;
};

export type TeacherAssignmentReviewPageData = {
	assignmentId: number;
	title: string;
	classroomId: number;
	classroomName: string;
	statusLabel: string;
	headline: string;
	description: string;
	dueLabel: string;
	stats: Array<{ label: string; value: string }>;
	closeSummary: TeacherAssignmentCloseSummary;
	reviewQueue: TeacherReviewQueueItem[];
	selectedStudentId: number | null;
	selectedStudentName: string | null;
	selectedStudentEmail: string | null;
	selectedStudentProgress: string | null;
	selectedStudentReviewStatus: ApiReviewQueueItem["review_status"] | null;
	selectedStudentSubmittedQuestions: number;
	selectedStudentReviewedQuestions: number;
	assignmentAiFeedback: string;
	assignmentTeacherFeedback: string;
	overallScore: number | null;
	passThreshold: number;
	nextStepOutcome: TeacherNextStepOutcome | null;
	passStatusOverride: TeacherAssignmentPassStatus | null;
	passStatus: TeacherAssignmentPassStatus;
	coachCard: {
		title: string;
		description: string;
		items: string[];
	};
	questions: TeacherReviewQuestion[];
};

export type TeacherRedoPlanQuestion = {
	topic: string;
	topicKey: string;
	difficulty: string;
	difficultyKey: "easy" | "medium" | "hard";
	tags: string[];
	reason: string;
};

export type TeacherRedoPlanData = {
	assignmentId: number;
	title: string;
	classroomId: number;
	classroomName: string;
	selectedStudentId: number;
	selectedStudentName: string;
	selectedStudentEmail: string;
	teacherFeedback: string;
	generatedAtLabel: string | null;
	weaknessSummary: {
		studentId: number;
		topicScores: Array<{ topic: string; score: number }>;
		weakTags: string[];
		recentIssues: string[];
	};
	plan: {
		rationale: string;
		questionSet: TeacherRedoPlanQuestion[];
	} | null;
	error: string | null;
};

export type TeacherReviewNotice = {
	scope: "assignment" | "question" | "global";
	questionId?: number;
	tone: "success" | "error";
	text: string;
} | null;
