export type MarketingRole = "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 SocialChannel = "instagram" | "facebook";

export type SocialRange = "7d" | "30d";
export type MetaSyncStatus = "disconnected" | "ready" | "syncing" | "error";

export type BrandRating = 1 | 2 | 3 | 4 | 5;

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

export type MarketingLocation = {
  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 Task = {
  id: string;
  initiativeId: string;
  title: string;
  description: string;
  assigneeId: string;
  status: TaskStatus;
  dueDate: string;
  updatedAt: string;
  evidenceLinks: 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: BrandRating;
  metricSelection: InitiativeMetricSelection;
  metrics: InitiativeMetrics;
  attributionChannel?: SocialChannel | null;
  attributionPageId?: string | null;
  attributionCampaign?: string | null;
  attributionStart?: string | null;
  attributionEnd?: string | null;
  autoActual?: number | null;
  autoTicketsActual?: number | null;
  autoRevenueActual?: number | null;
  autoUpdatedAt?: string | null;
  retro: InitiativeRetro;
  evidenceLinks: string[];
  taskIds: string[];
  updatedByName?: string | null;
  updatedAt?: string | null;
  milestones?: Milestone[];
};

export type MarketingMetaConnection = {
  id: string;
  accountId: string;
  pageId: string;
  pageName: string;
  isActive: boolean;
  lastSyncedAt: string | null;
  tokenExpiresAt: string | null;
};

export type SocialInsight = {
  channel: SocialChannel;
  range: SocialRange;
  followersStart: number;
  followersEnd: number;
  followerDelta: number;
  followerGrowthPct: number;
  engagementRatePct: number;
  interactions: number;
  reach: number;
  impressions: number;
  previousReach: number | null;
  previousImpressions: number | null;
  previousInteractions: number | null;
  previousFollowerDelta: number | null;
  previousGrowthPct: number | null;
  previousEngagementRatePct: number | null;
};

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 SocialSnapshot = {
  id: string;
  channel: SocialChannel;
  range: SocialRange;
  followersStart: number;
  followersEnd: number;
  engagementRate: number;
  reach: number;
  impressions: number;
  capturedAt: string;
};

export type BrandPulse = {
  id: string;
  month: string;
  rating1to5: BrandRating;
  notes: string;
  updatedAt: string;
  updatedById: string;
  updatedByName?: string | null;
};

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

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

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

export type MarketingDataset = {
  locations: MarketingLocation[];
  employees: Employee[];
  initiatives: Initiative[];
  tasks: Task[];
  meetings: Meeting[];
  socialSnapshots: SocialSnapshot[];
  brandPulse: BrandPulse;
};
