/**
 * 主题配置
 * @file theme.js
 * @description Ant Design Vue 主题配置
 */
import { THEME_CONFIG } from '@/config/env'

// Ant Design Vue 主题配置
export const themeConfig = {
  token: {
    // 主色调
    colorPrimary: THEME_CONFIG.primaryColor,
    
    // 成功色
    colorSuccess: '#52c41a',
    
    // 警告色
    colorWarning: '#faad14',
    
    // 错误色
    colorError: '#ff4d4f',
    
    // 信息色
    colorInfo: THEME_CONFIG.primaryColor,
    
    // 字体大小
    fontSize: 14,
    
    // 圆角
    borderRadius: 6,
    
    // 组件尺寸
    sizeUnit: 4,
    sizeStep: 4,
    
    // 控制台高度
    controlHeight: 32,
    
    // 行高
    lineHeight: 1.5715,
    
    // 字体族
    fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"'
  },
  
  components: {
    // 布局组件
    Layout: {
      headerBg: '#001529',
      siderBg: '#001529',
      bodyBg: '#f0f2f5'
    },
    
    // 菜单组件
    Menu: {
      darkItemBg: '#001529',
      darkItemSelectedBg: '#1890ff',
      darkItemHoverBg: '#1890ff'
    },
    
    // 按钮组件
    Button: {
      borderRadius: 6,
      controlHeight: 32
    },
    
    // 输入框组件
    Input: {
      borderRadius: 6,
      controlHeight: 32
    },
    
    // 表格组件
    Table: {
      headerBg: '#fafafa',
      headerColor: '#262626',
      rowHoverBg: '#f5f5f5'
    },
    
    // 卡片组件
    Card: {
      borderRadius: 8,
      headerBg: '#fafafa'
    },
    
    // 模态框组件
    Modal: {
      borderRadius: 8
    },
    
    // 抽屉组件
    Drawer: {
      borderRadius: 8
    }
  }
}

// 暗色主题配置
export const darkThemeConfig = {
  token: {
    ...themeConfig.token,
    colorBgBase: '#141414',
    colorBgContainer: '#1f1f1f',
    colorBgElevated: '#262626',
    colorBorder: '#424242',
    colorText: '#ffffff',
    colorTextSecondary: '#a6a6a6',
    colorTextTertiary: '#737373',
    colorTextQuaternary: '#595959'
  },
  
  components: {
    ...themeConfig.components,
    Layout: {
      headerBg: '#141414',
      siderBg: '#141414',
      bodyBg: '#000000'
    },
    Menu: {
      darkItemBg: '#141414',
      darkItemSelectedBg: '#1890ff',
      darkItemHoverBg: '#1890ff'
    },
    Table: {
      headerBg: '#262626',
      headerColor: '#ffffff',
      rowHoverBg: '#262626'
    },
    Card: {
      borderRadius: 8,
      headerBg: '#262626'
    }
  }
}

// 紧凑主题配置
export const compactThemeConfig = {
  token: {
    ...themeConfig.token,
    fontSize: 12,
    controlHeight: 24,
    sizeUnit: 2,
    sizeStep: 2
  },
  
  components: {
    ...themeConfig.components,
    Button: {
      borderRadius: 4,
      controlHeight: 24
    },
    Input: {
      borderRadius: 4,
      controlHeight: 24
    }
  }
}

// 根据配置返回主题
export const getThemeConfig = () => {
  if (THEME_CONFIG.darkMode) {
    return darkThemeConfig
  }
  
  if (THEME_CONFIG.compactMode) {
    return compactThemeConfig
  }
  
  return themeConfig
}

export default themeConfig