export type ProjectRole = "owner" | "lead" | "employee";

export type InitiativeType = "evento" | "campania" | "cambio" | "implementacion" | "otro";
export type InitiativeStatus = "planning" | "in_progress" | "completion" | "results" | "evaluation";
export type OpinionPublica = "positive" | "mixed" | "negative";

export type TaskStatus = "todo" | "in_progress" | "blocked" | "done";
export type MilestoneStatus = "pending" | "in_progress" | "completed";
export type MeetingStatus = "requested" | "scheduled" | "completed" | "cancelled";
export type MeetingResponseStatus = "pending" | "accepted" | "declined";
export type ProjectCalendarVisibility = "personal" | "team";
export type ProjectCaptureEvidenceKind = "photo" | "document" | "link";

export type CityKey = "mty" | "cdmx";

export type ProjectLocation = {
  id: string;
  city: CityKey;
  name: string;
};

export type InitiativeMetrics = {
  target: number;
  actual: number;
  ticketsTarget: number;
  ticketsActual: number;
  revenueTarget: number;
  revenueActual: number;
};

export type InitiativeMetricSelection = {
  score: boolean;
  tickets: boolean;
  revenue: boolean;
};

export type InitiativeRetro = {
  opinionPublica: OpinionPublica;
  queFunciono: string;
  queNo: string;
  proximoIntento: string;
};

export type Initiative = {
  id: string;
  name: string;
  type: InitiativeType;
  status: InitiativeStatus;
  isGlobal: boolean;
  locationIds: string[];
  ownerId: string;
  contributorIds: string[];
  dueDate: string;
  completedAt: string | null;
  importanceWeight: number;
  leadRating1to5: 1 | 2 | 3 | 4 | 5;
  metricSelection: InitiativeMetricSelection;
  metrics: InitiativeMetrics;
  retro: InitiativeRetro;
  evidenceLinks: string[];
  taskIds: string[];
  updatedByName?: string | null;
  updatedAt?: string | null;
  milestones?: Milestone[];
  plannedCost: number;
  actualCost: number;
  targetTicketPrice: number;
  actualTicketPrice: number;
  projectsSchemaVersion: number;
  plannedRevenue: number;
  actualRevenue: number;
  plannedProfit: number;
  actualProfit: number;
  actualMarginPct: number;
  costVariancePct: number;
  revenueVariancePct: number;
};

export type MilestoneCheckpoint = {
  id: string;
  note: string;
  createdAt: string;
  createdByName: string | null;
};

export type Milestone = {
  id: string;
  initiativeId: string;
  title: string;
  description: string;
  dueDate: string;
  status: MilestoneStatus;
  sortOrder: number;
  checkpoints: MilestoneCheckpoint[];
};

export type Meeting = {
  id: string;
  title: string;
  status: MeetingStatus;
  agenda: string;
  requestedById: string | null;
  requestedByName: string;
  participantNames: string[];
  participants: MeetingParticipant[];
  participantCounts: MeetingParticipantCounts;
  suggestedTimes: string[];
  scheduledFor: string | null;
  completedAt: string | null;
  calendarEventId: string | null;
  commitments: MeetingCommitment[];
};

export type MeetingParticipant = {
  id: string;
  userId: string | null;
  displayName: string;
  responseStatus: MeetingResponseStatus;
  respondedAt: string | null;
};

export type MeetingParticipantCounts = {
  pending: number;
  accepted: number;
  declined: number;
  total: number;
};

export type MeetingCommitment = {
  id: string;
  title: string;
  description: string | null;
  ownerName: string | null;
  dueDate: string | null;
  status: string;
};

export type Task = {
  id: string;
  initiativeId: string;
  title: string;
  description: string;
  assigneeId: string;
  status: TaskStatus;
  dueDate: string;
  updatedAt: string;
  evidenceLinks: string[];
};

export type Employee = {
  id: string;
  name: string;
  roleTitle: string;
  locationIds: string[];
  isLead: boolean;
};

export type ProjectCalendarEvent = {
  id: string;
  department: "proyectos";
  ownerUserId: string;
  title: string;
  notes: string | null;
  startAt: string;
  endAt: string;
  visibility: ProjectCalendarVisibility;
  meetingId: string | null;
  createdAt: string;
  updatedAt: string;
};

export type ProjectCaptureEvidence = {
  id: string;
  department: "proyectos";
  initiativeId: string | null;
  taskId: string | null;
  uploadedById: string;
  uploaderName: string;
  kind: ProjectCaptureEvidenceKind;
  title: string;
  note: string | null;
  url: string | null;
  hasFile: boolean;
  mimeType: string | null;
  sizeBytes: number | null;
  createdAt: string;
  updatedAt: string;
};

export type ProjectsDataset = {
  locations: ProjectLocation[];
  employees: Employee[];
  initiatives: Initiative[];
  tasks: Task[];
  meetings: Meeting[];
};
