import type {
  DirectorDashboardTimeRange,
  DirectorQuickActionConfig,
} from '@/shared/constants/directorDashboard';
import type { ModuleId } from '@/shared/types/app';

export type DirectorDashboardTrend = 'up' | 'down';
export type DirectorDashboardRiskSeverity = 'high' | 'medium' | 'low';
export type DirectorDashboardAction = 'openAcknowledgments' | 'openQuizResults';
export type DirectorOverviewIconId = 'clock' | 'shield' | 'eye' | 'users' | 'clipboard';
export type DirectorOverviewTone = 'orange' | 'blue' | 'amber' | 'purple' | 'emerald';
export type DirectorFrameSectionLetter = 'F' | 'R' | 'A' | 'M' | 'E';
export type DirectorQuizResultStatus = 'complete' | 'pending';

export interface DirectorOverviewCard {
  readonly label: string;
  readonly value: string;
  readonly change: string;
  readonly trend: DirectorDashboardTrend;
  readonly iconId: DirectorOverviewIconId;
  readonly tone: DirectorOverviewTone;
  readonly module: ModuleId;
  readonly action?: DirectorDashboardAction;
}

export interface DirectorRiskArea {
  readonly issue: string;
  readonly severity: DirectorDashboardRiskSeverity;
  readonly module: ModuleId;
  readonly action?: DirectorDashboardAction;
}

export interface DirectorFrameSectionPreview {
  readonly letter: DirectorFrameSectionLetter;
  readonly text: string;
}

export interface DirectorFramePreview {
  readonly id: string;
  readonly week: string;
  readonly sections: readonly DirectorFrameSectionPreview[];
}

export interface DirectorQuizResultDetail {
  readonly id: string;
  readonly quiz: string;
  readonly result: string;
  readonly date: string;
  readonly status: DirectorQuizResultStatus;
}

export interface DirectorQuizResultRow {
  readonly id: string;
  readonly staffName: string;
  readonly avatar: string | null;
  readonly tenant: string;
  readonly tenantLogo: string | null;
  readonly role: string;
  readonly completedCount: number;
  readonly totalCount: number;
  readonly details: readonly DirectorQuizResultDetail[];
}

export interface DirectorAcknowledgmentMissingStaff {
  readonly userId: string;
  readonly name: string;
  readonly avatar: string | null;
  readonly tenantName: string | null;
  readonly tenantLogo: string | null;
  readonly role: string;
  readonly email: string;
}

export interface DirectorAcknowledgmentDocumentRow {
  readonly id: string;
  readonly title: string;
  readonly category: string;
  readonly categoryLabel: string;
  readonly version: number;
  readonly totalStaff: number;
  readonly acknowledgedCount: number;
  readonly missingCount: number;
  readonly completionRate: number;
  readonly missingStaff: readonly DirectorAcknowledgmentMissingStaff[];
}

export interface DirectorDashboardPage {
  /** Role-specific dashboard title (e.g. "Owner Dashboard"). */
  readonly title: string;
  /** Name of the tenant whose data is shown (org/school/campus). */
  readonly scopeLabel: string;
  readonly timeRange: DirectorDashboardTimeRange;
  readonly overviewCards: readonly DirectorOverviewCard[];
  readonly riskAreas: readonly DirectorRiskArea[];
  readonly framePreviews: readonly DirectorFramePreview[];
  readonly quickActions: readonly DirectorQuickActionConfig[];
  readonly quizResults: readonly DirectorQuizResultRow[];
  readonly acknowledgmentDocuments: readonly DirectorAcknowledgmentDocumentRow[];
  readonly isLoading: boolean;
  readonly error: unknown;
  readonly setTimeRange: (timeRange: DirectorDashboardTimeRange) => void;
}
