import 'package:flutter/material.dart';

class AppColors {
  // ==================== 品牌色彩（不随主题变化） ====================
  static const Color primary = Color(0xFF22C55E);
  static const Color secondary = Color(0xFF3B82F6);
  static const Color error = Color(0xFFEF4444);
  static const Color success = Color(0xFF22C55E);
  static const Color warning = Color(0xFFF59E0B);
  static const Color orange = Color(0xFFFF6B00);

  // 行情色彩
  static const Color up = Color(0xFF10B981);
  static const Color down = Color(0xFFEF4444);

  // ==================== 浅色模式色彩 ====================
  static const Color _lightBackground = Color(0xFFF3F4F6);
  static const Color _lightSurface = Color(0xFFFFFFFF);
  static const Color _lightCard = Color(0xFFFFFFFF);
  static const Color _lightTextPrimary = Color(0xFF1F2937);
  static const Color _lightTextSecondary = Color(0xFF6B7280);
  static const Color _lightTextMuted = Color(0xFF9CA3AF);
  static const Color _lightBorder = Color(0xFFE5E7EB);
  static const Color _lightDivider = Color(0xFFF3F4F6);

  // ==================== 深色模式色彩 ====================
  static const Color _darkBackground = Color(0xFF111827);
  static const Color _darkSurface = Color(0xFF1F2937);
  static const Color _darkCard = Color(0xFF1F2937);
  static const Color _darkTextPrimary = Color(0xFFE5E7EB);
  static const Color _darkTextSecondary = Color(0xFF9CA3AF);
  static const Color _darkTextMuted = Color(0xFF6B7280);
  static const Color _darkBorder = Color(0xFF374151);
  static const Color _darkDivider = Color(0xFF374151);

  // ==================== 兼容旧代码的静态常量 ====================
  static const Color background = _lightBackground;
  static const Color surface = _lightSurface;
  static const Color textPrimary = _lightTextPrimary;
  static const Color textSecondary = _lightTextSecondary;
  static const Color textMuted = _lightTextMuted;
  static const Color border = _lightBorder;
  static const Color divider = _lightDivider;

  // ==================== 动态颜色获取方法 ====================

  /// 判断当前是否为深色模式
  static bool isDark(BuildContext context) =>
      Theme.of(context).brightness == Brightness.dark;

  /// 背景色（页面背景）
  static Color backgroundOf(BuildContext context) =>
      isDark(context) ? _darkBackground : _lightBackground;

  /// 表面色（AppBar、导航栏等）
  static Color surfaceOf(BuildContext context) =>
      isDark(context) ? _darkSurface : _lightSurface;

  /// 卡片背景色
  static Color cardOf(BuildContext context) =>
      isDark(context) ? _darkCard : _lightCard;

  /// 主要文字颜色
  static Color textPrimaryOf(BuildContext context) =>
      isDark(context) ? _darkTextPrimary : _lightTextPrimary;

  /// 次要文字颜色
  static Color textSecondaryOf(BuildContext context) =>
      isDark(context) ? _darkTextSecondary : _lightTextSecondary;

  /// 弱化文字颜色
  static Color textMutedOf(BuildContext context) =>
      isDark(context) ? _darkTextMuted : _lightTextMuted;

  /// 边框颜色
  static Color borderOf(BuildContext context) =>
      isDark(context) ? _darkBorder : _lightBorder;

  /// 分割线颜色
  static Color dividerOf(BuildContext context) =>
      isDark(context) ? _darkDivider : _lightDivider;
}
