import 'package:flutter/material.dart';
import 'app_colors.dart';

/// 文字样式系统
///
/// 统一管理所有文字样式，确保一致性
/// 所有样式默认使用 textPrimary 颜色，保证对比度
class AppTextStyles {
  AppTextStyles._();

  // ============================================
  // 标题样式 (Headings)
  // ============================================

  /// H1 - 页面大标题
  static const TextStyle h1 = TextStyle(
    fontSize: 28,
    fontWeight: FontWeight.bold,
    color: AppColors.textPrimary,
    height: 1.3,
  );

  /// H2 - 区块标题
  static const TextStyle h2 = TextStyle(
    fontSize: 24,
    fontWeight: FontWeight.bold,
    color: AppColors.textPrimary,
    height: 1.3,
  );

  /// H3 - 卡片标题
  static const TextStyle h3 = TextStyle(
    fontSize: 20,
    fontWeight: FontWeight.w600,
    color: AppColors.textPrimary,
    height: 1.4,
  );

  /// H4 - 小标题
  static const TextStyle h4 = TextStyle(
    fontSize: 18,
    fontWeight: FontWeight.w600,
    color: AppColors.textPrimary,
    height: 1.4,
  );

  // ============================================
  // 正文样式 (Body)
  // ============================================

  /// Body1 - 主要正文
  static const TextStyle body1 = TextStyle(
    fontSize: 16,
    fontWeight: FontWeight.normal,
    color: AppColors.textPrimary,
    height: 1.5,
  );

  /// Body2 - 次要正文
  static const TextStyle body2 = TextStyle(
    fontSize: 14,
    fontWeight: FontWeight.normal,
    color: AppColors.textPrimary,
    height: 1.5,
  );

  // ============================================
  // 辅助文字 (Caption & Small)
  // ============================================

  /// Caption - 说明文字
  static const TextStyle caption = TextStyle(
    fontSize: 12,
    fontWeight: FontWeight.normal,
    color: AppColors.textSecondary,
    height: 1.4,
  );

  /// Small - 极小文字
  static const TextStyle small = TextStyle(
    fontSize: 11,
    fontWeight: FontWeight.normal,
    color: AppColors.textSecondary,
    height: 1.3,
  );

  /// Hint - 提示文字
  static const TextStyle hint = TextStyle(
    fontSize: 14,
    fontWeight: FontWeight.normal,
    color: AppColors.textHint,
    height: 1.4,
  );

  // ============================================
  // 特殊样式 (Special)
  // ============================================

  /// 金额/价格 - 大号数字
  static const TextStyle amount = TextStyle(
    fontSize: 32,
    fontWeight: FontWeight.bold,
    color: AppColors.textPrimary,
    height: 1.2,
    fontFeatures: [FontFeature.tabularFigures()],
  );

  /// 价格 - 标准数字
  static const TextStyle price = TextStyle(
    fontSize: 18,
    fontWeight: FontWeight.w600,
    color: AppColors.textPrimary,
    height: 1.3,
    fontFeatures: [FontFeature.tabularFigures()],
  );

  /// 价格变化 - 涨跌幅
  static const TextStyle priceChange = TextStyle(
    fontSize: 14,
    fontWeight: FontWeight.w600,
    height: 1.3,
    fontFeatures: [FontFeature.tabularFigures()],
  );

  /// 按钮文字
  static const TextStyle button = TextStyle(
    fontSize: 16,
    fontWeight: FontWeight.w600,
    color: AppColors.textPrimary,
    height: 1.2,
  );

  /// 链接文字
  static const TextStyle link = TextStyle(
    fontSize: 14,
    fontWeight: FontWeight.w500,
    color: AppColors.textLink,
    decoration: TextDecoration.underline,
    height: 1.4,
  );

  // ============================================
  // 可复制修改的样式方法
  // ============================================

  /// 获取带颜色的标题样式
  static TextStyle headingWithColor(TextStyle style, Color color) {
    return style.copyWith(color: color);
  }

  /// 获取带颜色的正文样式
  static TextStyle bodyWithColor(TextStyle style, Color color) {
    return style.copyWith(color: color);
  }

  /// 获取粗体样式
  static TextStyle bold(TextStyle style) {
    return style.copyWith(fontWeight: FontWeight.bold);
  }

  /// 获取半粗体样式
  static TextStyle semiBold(TextStyle style) {
    return style.copyWith(fontWeight: FontWeight.w600);
  }
}

/// 兼容旧代码的别名
@Deprecated('Use AppTextStyles instead')
class AppText {
  AppText._();
}
