// 仪表板类型定义

/** 趋势变化方向 */
export type TrendDirection = 'up' | 'down';

/** 时间周期 */
export type DashboardPeriod = '7d' | '30d' | '90d';

/** 活动类型 */
export type ActivityType =
  | 'user_register'
  | 'company_authorization'
  | 'planting_order'
  | 'system_update'
  | 'report_generated';

/** 统计卡片变化数据 */
export interface StatChange {
  value: number;
  trend: TrendDirection;
}

/** 统计卡片数据 */
export interface DashboardStatItem {
  title: string;
  value: number;
  suffix: string;
  change: StatChange;
  color: string;
}

/** 仪表板概览数据 */
export interface DashboardOverview {
  totalPlantingCount: number;
  totalPlantingChange: StatChange;
  activeUserCount: number;
  activeUserChange: StatChange;
  provinceCompanyCount: number;
  provinceCompanyChange: StatChange;
  cityCompanyCount: number;
  cityCompanyChange: StatChange;
}

/** 趋势数据点 */
export interface TrendDataPoint {
  date: string;
  value: number;
}

/** 趋势图表数据 */
export interface DashboardTrendData {
  period: DashboardPeriod;
  data: TrendDataPoint[];
}

/** 区域分布数据 */
export interface RegionDistributionItem {
  region: string;
  percentage: number;
  color: string;
}

/** 活动记录 */
export interface DashboardActivity {
  id: string;
  type: ActivityType;
  icon: string;
  title: string;
  description: string;
  timestamp: string;
  createdAt: string;
}

/** 仪表板完整数据 */
export interface DashboardData {
  overview: DashboardOverview;
  trend: DashboardTrendData;
  regionDistribution: RegionDistributionItem[];
  recentActivities: DashboardActivity[];
}

/** 仪表板API请求参数 */
export interface DashboardTrendParams {
  period: DashboardPeriod;
}

export interface DashboardActivitiesParams {
  limit?: number;
}

/** 认种周期统计数据 */
export interface PlantingPeriodStats {
  treeCount: number;
  orderCount: number;
  amount: string;
}

/** 状态分布统计 */
export interface PlantingStatusDistribution {
  paid: number;
  fundAllocated: number;
  poolScheduled: number;
  poolInjected: number;
  miningEnabled: number;
}

/** 认种全局统计数据（来自 planting-service）
 * [2026-01-06] 更新：添加今日、本月统计和积分信息
 */
export interface PlantingGlobalStats {
  totalTreeCount: number;
  totalOrderCount: number;
  totalAmount: string;
  statusDistribution: PlantingStatusDistribution;
  todayStats: PlantingPeriodStats;
  monthStats: PlantingPeriodStats;
  calculatedAt: string;
}

/** 趋势时间维度 [2026-01-06] 新增 */
export type PlantingTrendPeriod = 'day' | 'week' | 'month' | 'quarter' | 'year';

/** 趋势数据点 [2026-01-06] 新增 */
export interface PlantingTrendDataPoint {
  label: string;
  treeCount: number;
  orderCount: number;
  amount: string;
}
