// ── Type Definitions ──────────────────────────────────────────────────
// Auto-generated by self-healing setup. Edit .setup-templates/templates/types-index.ts to customize.

export type UserRole = "super_admin" | "admin" | "sales" | "dev";

export interface User {
  id: string;
  name: string;
  email: string;
  phone?: string;
  role: UserRole;
  active: boolean;
  avatar: string;
  createdAt: string;
}

export interface Lead {
  id: string;
  companyName: string;
  contactName: string;
  email: string;
  phone: string;
  source: string;
  description: string;
  status: LeadStatus;
  assignedUserId: string | null;
  assignedUser: User | null;
  createdAt: string;
  updatedAt: string;
}

export type LeadStatus =
  | "new"
  | "contacted"
  | "qualified"
  | "proposal"
  | "won"
  | "lost";

export interface DashboardStats {
  totalLeads: number;
  newLeads: number;
  contactedLeads: number;
  qualifiedLeads: number;
  proposalLeads: number;
  wonLeads: number;
  lostLeads: number;
  conversionRate: number;
  monthlyBreakdown: {
    label: string;
    total: number;
    new: number;
    contacted: number;
    qualified: number;
    proposal: number;
    won: number;
    lost: number;
  }[];
  leadsPerMonth: { label: string; leads: number; won: number }[];
  recentLeads: Lead[];
  statusDistribution: { name: string; value: number; color: string }[];
  periodLabel: string;
  trends: Record<string, { pct: number; up: boolean }>;
}

export interface Note {
  id: string;
  leadId: string;
  userId: string;
  authorName: string;
  authorAvatar: string;
  authorRole: UserRole;
  note: string;
  createdAt: string;
  updatedAt: string;
}

export type NotificationType =
  | "lead_created"
  | "lead_status_changed"
  | "lead_assigned"
  | "chat_message"
  | "note_added"
  | "event_scheduled";

export interface Notification {
  id: string;
  type: NotificationType;
  title: string;
  description: string;
  timestamp: string;
  read: boolean;
  link?: string;
}

export interface ChatMessage {
  id: string;
  conversationId: string;
  senderId: string;
  senderName: string;
  senderAvatar: string;
  content: string;
  timestamp: string;
}

export interface Conversation {
  id: string;
  participants: { id: string; name: string; avatar: string; role: string }[];
  lastMessage: string;
  lastMessageTime: string;
  unread: number;
  messages: ChatMessage[];
}

export type EventType = "meeting" | "call" | "email" | "task" | "note";
export type EventStatus = "scheduled" | "completed" | "cancelled" | "rescheduled";

export interface CalendarEvent {
  id: string;
  userId: string;
  participantId: string | null;
  developerId: string | null;
  leadId: string | null;
  conversationId: string | null;
  title: string;
  description: string | null;
  participantNotes: string | null;
  eventType: EventType;
  startTime: string;
  endTime: string | null;
  durationMinutes: number | null;
  status: EventStatus;
  creator: { id: string; name: string; email?: string; role?: string; avatar?: string } | null;
  participant: { id: string; name: string; email?: string; role?: string; avatar?: string } | null;
  developer: { id: string; name: string; email?: string; role?: string; avatar?: string } | null;
  lead: { id: string; companyName: string; contactName: string } | null;
  clientName: string | null;
  clientEmail: string | null;
  clientPhone: string | null;
  createdAt: string;
}