/**
 * VI 标准常量库
 * 微信小程序前端配色系统
 * 最后更新：2026-03-17
 */

// ============================================
// 1. 任务分类配色
// ============================================
export const TASK_TYPE_COLORS = {
  high_priority: {
    name: '高优先召回',
    priority: 0,
    borderColor: '#dc2626',
    gradientFrom: '#b91c1c',
    gradientTo: '#dc2626',
    condition: 'max(WBI,NCI) > 7',
  },
  priority_recall: {
    name: '优先召回',
    priority: 0,
    borderColor: '#f97316',
    gradientFrom: '#ea580c',
    gradientTo: '#f97316',
    condition: 'max(WBI,NCI) > 5',
  },
  callback: {
    name: '客户回访',
    priority: 1,
    borderColor: '#14b8a6',
    gradientFrom: '#0d9488',
    gradientTo: '#14b8a6',
    condition: '完成召回后未备注',
  },
  relationship: {
    name: '关系构建',
    priority: 2,
    borderColor: '#f472b6',
    gradientFrom: '#ec4899',
    gradientTo: '#f472b6',
    condition: 'RS < 6',
  },
};

// ============================================
// 2. 客户标签配色（6种）
// ============================================
export const CUSTOMER_TAG_COLORS = {
  basic_info: {
    textColor: '#0052d9',
    backgroundColor: '#ecf2fe',
    borderColor: '#bfdbfe',
    psychology: '蓝色 - 信任、基础信息',
  },
  consumption: {
    textColor: '#00a870',
    backgroundColor: '#e6f7f0',
    borderColor: '#a7f3d0',
    psychology: '绿色 - 增长、消费行为',
  },
  play_pref: {
    textColor: '#ed7b2f',
    backgroundColor: '#fff3e6',
    borderColor: '#fed7aa',
    psychology: '橙色 - 活力、娱乐偏好',
  },
  promo_pref: {
    textColor: '#d4a017',
    backgroundColor: '#fffbeb',
    borderColor: '#fef3c7',
    psychology: '金色 - 价值、优惠敏感度',
  },
  social: {
    textColor: '#764ba2',
    backgroundColor: '#f3e8ff',
    borderColor: '#e9d5ff',
    psychology: '紫色 - 社交、人脉关系',
  },
  feedback: {
    textColor: '#e34d59',
    backgroundColor: '#ffe6e8',
    borderColor: '#fecdd3',
    psychology: '红色 - 警示、关键信息',
  },
};

// ============================================
// 3. 关系等级配色（4种）
// ============================================
export const RELATIONSHIP_LEVELS = {
  excellent: {
    name: '很好',
    emoji: '💖',
    scoreRange: '> 8.5',
    gradientFrom: '#e91e63',
    gradientTo: '#f472b6',
    shadowColor: 'rgba(233,30,99,0.30)',
    label: '优质客户',
  },
  good: {
    name: '良好',
    emoji: '🧡',
    scoreRange: '6-8.5',
    gradientFrom: '#ea580c',
    gradientTo: '#fb923c',
    shadowColor: 'rgba(234,88,12,0.30)',
    label: '稳定客户',
  },
  normal: {
    name: '一般',
    emoji: '💛',
    scoreRange: '3.5-6',
    gradientFrom: '#eab308',
    gradientTo: '#fbbf24',
    shadowColor: 'rgba(234,179,8,0.30)',
    label: '普通客户',
  },
  poor: {
    name: '待发展',
    emoji: '💙',
    scoreRange: '< 3.5',
    gradientFrom: '#64748b',
    gradientTo: '#94a3b8',
    shadowColor: 'rgba(100,116,139,0.30)',
    label: '需维护客户',
  },
};

// ============================================
// 4. 置顶/放弃状态
// ============================================
export const TASK_STATUS_COLORS = {
  pinned: {
    name: '置顶',
    glowColor: '#f59e0b',
    shadowLight: 'rgba(245, 158, 11, 0.12)',
    shadowGlow: 'rgba(245, 158, 11, 0.08)',
    shadowCSS: '0 5rpx 7rpx rgba(245, 158, 11, 0.12), 0 0 0 8rpx rgba(245, 158, 11, 0.08)',
  },
  abandoned: {
    name: '放弃',
    borderColor: '#d1d5db',
    textColor: '#9ca3af',
    opacity: 0.55,
  },
};

// ============================================
// 5. 助教等级配色（4种 + 星级）
// ============================================
export const COACH_LEVEL_COLORS = {
  junior: {
    name: '初级',
    textColor: '#0052d9',
    backgroundColor: '#ecf2fe',
    borderColor: '#bfdbfe',
  },
  middle: {
    name: '中级',
    textColor: '#ed7b2f',
    backgroundColor: '#fff3e6',
    borderColor: '#fed7aa',
  },
  senior: {
    name: '高级',
    textColor: '#e91e63',
    backgroundColor: '#ffe6e8',
    borderColor: '#fecdd3',
  },
  star: {
    name: '⭐ 星级',
    textColor: '#fbbf24',
    backgroundColor: '#fffef0',
    borderColor: '#fef3c7',
  },
};

// ============================================
// 6. 星星评分配色
// ============================================
export const STAR_RATING_COLORS = {
  low: {
    scoreRange: '1-2',
    stars: '0.5-1',
    color: '#e34d59',
    label: '低满意度',
  },
  mediumLow: {
    scoreRange: '3-4',
    stars: '1.5-2',
    color: '#ed7b2f',
    label: '一般满意度',
  },
  medium: {
    scoreRange: '5-6',
    stars: '2.5-3',
    color: '#eab308',
    label: '中等满意度',
  },
  mediumHigh: {
    scoreRange: '7-8',
    stars: '3.5-4',
    color: '#00a870',
    label: '高满意度',
  },
  high: {
    scoreRange: '9-10',
    stars: '4.5-5',
    color: '#e91e63',
    label: '非常满意',
  },
};

// ============================================
// 7. AI 图标随机配色库（6种）
// ============================================
export const AI_COLOR_SCHEMES = [
  {
    name: 'red',
    from: '#e74c3c',
    to: '#f39c9c',
    fromDeep: '#c0392b',
    toDeep: '#e74c3c',
    className: 'ai-color-red',
  },
  {
    name: 'orange',
    from: '#e67e22',
    to: '#f5c77e',
    fromDeep: '#ca6c17',
    toDeep: '#e67e22',
    className: 'ai-color-orange',
  },
  {
    name: 'yellow',
    from: '#d4a017',
    to: '#f7dc6f',
    fromDeep: '#b8860b',
    toDeep: '#d4a017',
    className: 'ai-color-yellow',
  },
  {
    name: 'blue',
    from: '#2980b9',
    to: '#7ec8e3',
    fromDeep: '#1a5276',
    toDeep: '#2980b9',
    className: 'ai-color-blue',
  },
  {
    name: 'indigo',
    from: '#667eea',
    to: '#a78bfa',
    fromDeep: '#4a5fc7',
    toDeep: '#667eea',
    className: 'ai-color-indigo',
  },
  {
    name: 'purple',
    from: '#764ba2',
    to: '#c084fc',
    fromDeep: '#5b3080',
    toDeep: '#764ba2',
    className: 'ai-color-purple',
  },
];

// ============================================
// 8. 全局颜色变量（CSS Variables）
// ============================================
export const GLOBAL_COLORS = {
  // 主色系
  primary: '#0052d9',
  primaryLight: '#ecf2fe',
  success: '#00a870',
  warning: '#ed7b2f',
  error: '#e34d59',

  // 灰度系（13级）
  gray1: '#f3f3f3',
  gray2: '#eeeeee',
  gray3: '#e7e7e7',
  gray4: '#dcdcdc',
  gray5: '#c5c5c5',
  gray6: '#a6a6a6',
  gray7: '#8b8b8b',
  gray8: '#777777',
  gray9: '#5e5e5e',
  gray10: '#4b4b4b',
  gray11: '#393939',
  gray12: '#2c2c2c',
  gray13: '#242424',
};

// ============================================
// 工具函数
// ============================================

/**
 * 获取随机AI配色
 */
export function getRandomAiColor() {
  return AI_COLOR_SCHEMES[Math.floor(Math.random() * AI_COLOR_SCHEMES.length)];
}

/**
 * 根据任务类型获取颜色
 */
export function getTaskTypeColor(taskType: keyof typeof TASK_TYPE_COLORS) {
  return TASK_TYPE_COLORS[taskType];
}

/**
 * 根据客户标签获取颜色
 */
export function getCustomerTagColor(tagName: keyof typeof CUSTOMER_TAG_COLORS) {
  return CUSTOMER_TAG_COLORS[tagName];
}

/**
 * 根据关系分数获取等级和颜色
 */
export function getRelationshipLevel(score: number) {
  if (score > 8.5) return RELATIONSHIP_LEVELS.excellent;
  if (score >= 6) return RELATIONSHIP_LEVELS.good;
  if (score >= 3.5) return RELATIONSHIP_LEVELS.normal;
  return RELATIONSHIP_LEVELS.poor;
}

/**
 * 根据评分获取星星颜色
 */
export function getStarRatingColor(score: number) {
  if (score <= 2) return STAR_RATING_COLORS.low;
  if (score <= 4) return STAR_RATING_COLORS.mediumLow;
  if (score <= 6) return STAR_RATING_COLORS.medium;
  if (score <= 8) return STAR_RATING_COLORS.mediumHigh;
  return STAR_RATING_COLORS.high;
}

/**
 * 根据助教等级获取颜色
 */
export function getCoachLevelColor(level: keyof typeof COACH_LEVEL_COLORS) {
  return COACH_LEVEL_COLORS[level];
}
