export type OverviewRange = '7d' | '30d' | '90d';

export interface IOverviewBookingKpis {
  totalActive: number;
  needsAction: number;
  urgent: number;
  inApproval: number;
  submittedToday: number;
}

export interface IOverviewOperationsKpis {
  trainsActive: number;
  wagonsAvailable: number;
  containersInTransit: number;
  cargoesLoaded: number;
}

export interface IOverviewCustomerKpis {
  totalCustomers: number;
  newCustomersThisMonth: number;
}

export interface IOverviewBillingKpis {
  revenueMtdEtb: number;
  revenueMtdUsd: number;
  pendingPayments: number;
  successfulPaymentsMtd: number;
}

export interface IOverviewStaffKpis {
  activeEmployees: number;
  activeUsers: number;
}

export interface IOverviewKpis {
  bookings: IOverviewBookingKpis;
  operations: IOverviewOperationsKpis;
  customers: IOverviewCustomerKpis;
  billing: IOverviewBillingKpis;
  staff: IOverviewStaffKpis;
}

export interface IOverviewTrendPoint {
  date: string;
  count: number;
}

export interface IOverviewStatusCount {
  status: string;
  count: number;
}

export interface IOverviewPipelineCount {
  stage: string;
  count: number;
}

export interface IOverviewPaymentTrendPoint {
  date: string;
  amountEtb: number;
  amountUsd: number;
}

export interface IOverviewRecentBooking {
  id: string;
  reference: string;
  customerLabel: string;
  status: string;
  priorityScore: number;
  totalAmount: number | null;
  paymentCurrency: string | null;
  createdAt: string;
}

export interface IOverviewDashboard {
  kpis: IOverviewKpis;
  bookingTrend: IOverviewTrendPoint[];
  bookingsByStatus: IOverviewStatusCount[];
  bookingsByPipeline: IOverviewPipelineCount[];
  paymentTrend: IOverviewPaymentTrendPoint[];
  recentBookings: IOverviewRecentBooking[];
  generatedAt: string;
}

export interface IOverviewLabelCount {
  label: string;
  count: number;
}

export interface IOverviewPaymentMethodBreakdown {
  method: string;
  count: number;
  amountEtb: number;
  amountUsd: number;
}

export interface IOverviewCurrencyAmount {
  currency: string;
  amount: number;
}

export interface IOverviewBookingsTab {
  kpis: IOverviewBookingKpis;
  bookingTrend: IOverviewTrendPoint[];
  bookingsByStatus: IOverviewStatusCount[];
  bookingsByPipeline: IOverviewPipelineCount[];
  bookingsByFreightType: IOverviewLabelCount[];
  bookingsByCurrency: IOverviewLabelCount[];
  recentBookings: IOverviewRecentBooking[];
  generatedAt: string;
}

export interface IOverviewBillingTab {
  kpis: IOverviewBillingKpis;
  paymentTrend: IOverviewPaymentTrendPoint[];
  paymentsByStatus: IOverviewStatusCount[];
  paymentsByMethod: IOverviewPaymentMethodBreakdown[];
  revenueByCurrency: IOverviewCurrencyAmount[];
  generatedAt: string;
}

export interface IOverviewOperationsTab {
  kpis: IOverviewOperationsKpis;
  trainStatusBreakdown: IOverviewStatusCount[];
  wagonStatusBreakdown: IOverviewStatusCount[];
  containerStatusBreakdown: IOverviewStatusCount[];
  cargoStatusBreakdown: IOverviewStatusCount[];
  generatedAt: string;
}

export interface IOverviewCustomersTab {
  kpis: IOverviewCustomerKpis;
  customerGrowthTrend: IOverviewTrendPoint[];
  customersByType: IOverviewLabelCount[];
  topCustomersByBookings: IOverviewLabelCount[];
  generatedAt: string;
}

export interface IOverviewStaffTab {
  kpis: IOverviewStaffKpis;
  usersByStatus: IOverviewStatusCount[];
  employeeGrowthTrend: IOverviewTrendPoint[];
  activeUsersBreakdown: IOverviewLabelCount[];
  generatedAt: string;
}

export type OverviewTabKey =
  | 'bookings'
  | 'billing'
  | 'operations'
  | 'customers'
  | 'staff';
