import 'package:flutter/material.dart';

/// TBOSS OA 标准色彩体系
///
/// 从主色 #00ABF3 (H=199° S=100%) 在 HSL 空间推导完整色板。
/// 亮色主题 + 深色主题（感知等价）。
class AppColors {
  AppColors._();

  // ═══════════════════════════════════════════
  //  品牌色梯度（H=199° 饱和递减式浅色）
  // ═══════════════════════════════════════════
  //
  //  关键改进：浅色端降低饱和度，使 primaryLight 更"透气"
  //    S = S₅₀₀ × (L/L₅₀₀)² → 越亮越柔和
  //
  //  primary50   L=96% S≈30%  最浅底色，仅微弱的品牌色感
  //  primary100  L=88% S≈42%  Tag 底/图标底/选中 Chip ← primaryLight
  //  primary200  L=78% S≈58%  hover 态
  //  primary300  L=66% S≈76%  边框/聚焦环
  //  primary400  L=54% S≈90%  次级按钮
  //  primary500  L=48% S=100% ★ 主色 #00ABF3
  //  primary600  L=38% S=100% 按压态/深文字
  //  primary700  L=29% S=95%  深色背景上文字
  //  primary800  L=19% S=90%  深底色
  //  primary900  L=10% S=85%  最深
  static const Color primary50 = Color(0xFFEDF7FD); // L=96% 极淡蓝底
  static const Color primary100 = Color(
    0xFFD8EFFB,
  ); // L=91% ★ primaryLight：Chip/图标底
  static const Color primary200 = Color(0xFFA2DCF6); // L=78% hover
  static const Color primary300 = Color(0xFF6CCCF2); // L=66% 边框
  static const Color primary400 = Color(0xFF28BCF3); // L=54% 次级按钮
  static const Color primary500 = Color(0xFF00ABF3); // L=48% ★ 主色
  static const Color primary600 = Color(0xFF0089C4); // L=38% 按压态
  static const Color primary700 = Color(0xFF006794); // L=29% 深文字
  static const Color primary800 = Color(0xFF004563); // L=19% 深底色
  static const Color primary900 = Color(0xFF002233); // L=10% 最深

  // ── 兼容旧名 ──
  static const Color primary = primary500;
  static const Color primaryActive = primary600;
  static const Color primaryLight = primary100;

  // ═══════════════════════════════════════════
  //  中性灰（用于文本/背景/分割线）
  // ═══════════════════════════════════════════
  static const Color gray50 = Color(0xFFF9FAFB);
  static const Color gray100 = Color(0xFFF2F4F6);
  static const Color gray200 = Color(0xFFE5E8EB);
  static const Color gray300 = Color(0xFFD1D6DB); // 占位符 / 禁用文字
  static const Color gray400 = Color(0xFF9CA3AF);
  static const Color gray500 = Color(0xFF6B7280); // 二级文字
  static const Color gray600 = Color(0xFF4B5563);
  static const Color gray700 = Color(0xFF374151);
  static const Color gray800 = Color(0xFF1F2937); // 主文字
  static const Color gray900 = Color(0xFF111827); // 最深文字（极少用）

  // ── 文本三档 ──
  static const Color textPrimary = Color(0xFF1F2937); // #1F2937 WCAG AAA
  static const Color textSecondary = Color(0xFF6B7280); // #6B7280 WCAG AA
  static const Color textPlaceholder = Color(
    0xFFD1D6DB,
  ); // #D1D6DB WCAG AA（白底 4.5:1）
  static const Color textDisabled = Color(0xFFD1D6DB);
  static const Color statusGray = Color(0xFF9CA3AF);

  // ── 背景三档 ──
  static const Color bgPage = Color(0xFFF2F4F6); // 页面底
  static const Color bgCard = Color(0xFFFFFFFF); // 卡片/表单
  static const Color bgDisabled = Color(0xFFE5E8EB); // 禁用态
  static const Color bgSecondaryContainer = Color(0xFFE6E8EB); // 次级容器（搜索框等）

  // ── 边框 ──
  static const Color border = Color(0xFFE5E8EB);

  // ═══════════════════════════════════════════
  //  语义色
  // ═══════════════════════════════════════════
  static const Color success = Color(0xFF0EA371); // 成功/已通过
  static const Color successBg = Color(0xFFEBF9F3); // 成功浅底（微调更清新）
  static const Color warning = Color(0xFFE37318); // 警告/审批中
  static const Color warningBg = Color(0xFFFFF6ED); // 警告浅底（更温暖）
  static const Color danger = Color(0xFFDC2626); // 危险/已拒绝/删除
  static const Color dangerBg = Color(0xFFFEF4F4); // 危险浅底（更柔和）

  // ═══════════════════════════════════════════
  //  金额色（独立于成功/危险语义）
  // ═══════════════════════════════════════════
  static const Color amountPositive = Color(0xFF1D7AB5); // 正金额（品牌蓝，区分 success）
  static const Color amountNegative = Color(0xFFDC2626); // 负金额/超支
  static const Color amountNeutral = Color(0xFF6B7280); // 普通数值

  // ── 兼容旧名 ──
  static const Color amountPrimary = amountPositive;

  // ═══════════════════════════════════════════
  //  信息色（已还车/GPS/时间线/审批信息）
  // ═══════════════════════════════════════════
  static const Color infoText = Color(0xFF3B82C4);
  static const Color infoBg = Color(0xFFEDF6FC);
  static const Color infoLightBg = Color(0xFFF4F9FD);
  static const Color infoBorder = Color(0xFFC8DFF0);
  static const Color timelineInactive = Color(0xFFE5E8EB);

  // ═══════════════════════════════════════════
  //  支付状态色（区别于信息色）
  // ═══════════════════════════════════════════
  static const Color paidText = Color(0xFF2563B0); // 已付款-深蓝
  static const Color paidBg = Color(0xFFF0F6FF); // 已付款-浅蓝（区别于 infoBg）
  static const Color unpaidText = Color(0xFFCA8A04); // 待付款-琥珀
  static const Color unpaidBg = Color(0xFFFFFCEF); // 待付款-浅琥珀（更柔和）

  // ═══════════════════════════════════════════
  //  撤回/草稿/过期
  // ═══════════════════════════════════════════
  static const Color withdrawnText = Color(0xFF7C6F8A);
  static const Color withdrawnBg = Color(0xFFF6F3F8);
  static const Color bgExpired = Color(0xFFF9FAFB);
  static const Color swipeDeleteBg = Color(0xFFF2F4F6);

  // ═══════════════════════════════════════════
  //  图表色（fl_chart）
  // ═══════════════════════════════════════════
  static const Color chart1 = primary500;
  static const Color chart2 = Color(0xFF0EA371);
  static const Color chart3 = Color(0xFFE37318);
  static const Color chart4 = Color(0xFF8B5CF6);
  static const Color chart5 = Color(0xFF3B82C4);

  // ═══════════════════════════════════════════
  //  遮罩 / 高亮
  // ═══════════════════════════════════════════
  static const Color overlay = Color(0x66000000); // 弹窗蒙层 40%
  static const Color highlight = Color(0xFFEDF7FD); // 列表选中高亮（= primary50）
}

/// 深色主题 — 感知等价映射
///
/// 原则：降低饱和度、提高明度下限、压缩对比度
class AppDarkColors {
  AppDarkColors._();

  // ── 品牌色梯度（主色保持，浅色端提升明度以区分深色背景）──
  //
  //  改进：浅色端提高 L 值，使 primaryLight 在深色背景下清晰可辨
  //    primary50  L=13%  极暗底色
  //    primary100 L=20%  Tag 底/图标底 ← primaryLight
  //    primary200 L=27%  hover
  //    primary300 L=34%  边框
  //    primary400 L=42%  次级按钮
  //    primary500 L=48%  ★ 主色 #00ABF3
  static const Color primary50 = Color(0xFF112835);
  static const Color primary100 = Color(0xFF16384D); // ★ primaryLight：可见蓝调
  static const Color primary200 = Color(0xFF1B4965);
  static const Color primary300 = Color(0xFF1F5A7E);
  static const Color primary400 = Color(0xFF1F709E);
  static const Color primary500 = Color(0xFF00ABF3);
  static const Color primary600 = Color(0xFF33BBF5);
  static const Color primary700 = Color(0xFF66CCF8);
  static const Color primary800 = Color(0xFF99DDFA);
  static const Color primary900 = Color(0xFFCCEEFD);

  static const Color primary = primary500;
  static const Color primaryActive = Color(0xFF0089C4); // 深色下仍用中等深度
  static const Color primaryLight = primary100;

  // ── 中性灰 ──
  static const Color gray50 = Color(0xFF0D0D0D);
  static const Color gray100 = Color(0xFF1A1A1A);
  static const Color gray200 = Color(0xFF262626);
  static const Color gray300 = Color(0xFF404040);
  static const Color gray400 = Color(0xFF595959);
  static const Color gray500 = Color(0xFF808080);
  static const Color gray600 = Color(0xFFA6A6A6);
  static const Color gray700 = Color(0xFFBFBFBF);
  static const Color gray800 = Color(0xFFD9D9D9);
  static const Color gray900 = Color(0xFFF2F2F2);

  // ── 文本三档 ──
  static const Color textPrimary = Color(0xFFD9D9D9);
  static const Color textSecondary = Color(0xFFA6A6A6);
  static const Color textPlaceholder = Color(0xFF595959);
  static const Color textDisabled = Color(0xFF595959);
  static const Color statusGray = Color(0xFF808080);

  // ── 背景三档 ──
  static const Color bgPage = Color(0xFF0D0D0D);
  static const Color bgCard = Color(0xFF1A1A1A);
  static const Color bgDisabled = Color(0xFF262626);
  static const Color bgSecondaryContainer = Color(0xFF3A3A3A); // 次级容器（搜索框等）

  static const Color border = Color(0xFF333333);

  // ── 语义色（深色底适配：亮前景 + 暗背景）──
  static const Color success = Color(0xFF22C55E);
  static const Color successBg = Color(0xFF052E16);
  static const Color warning = Color(0xFFF59E0B);
  static const Color warningBg = Color(0xFF2D1B06);
  static const Color danger = Color(0xFFEF4444);
  static const Color dangerBg = Color(0xFF2E0B0B);

  // ── 金额色 ──
  static const Color amountPositive = Color(0xFF5BB8F0); // 正金额（亮蓝，适配深色底）
  static const Color amountNegative = Color(0xFFEF4444);
  static const Color amountNeutral = Color(0xFFA6A6A6);
  static const Color amountPrimary = amountPositive;

  // ── 信息色 ──
  static const Color infoText = Color(0xFF6AA8E6);
  static const Color infoBg = Color(0xFF0E1F33);
  static const Color infoLightBg = Color(0xFF11243A);
  static const Color infoBorder = Color(0xFF1E3D5C);
  static const Color timelineInactive = Color(0xFF333333);

  // ── 支付状态（深色底：信息色与支付色区分）──
  static const Color paidText = Color(0xFF6AA8E6);
  static const Color paidBg = Color(0xFF0F2238); // 区别于 infoBg
  static const Color unpaidText = Color(0xFFFBBF24);
  static const Color unpaidBg = Color(0xFF2D1B06);

  // ── 撤回/草稿/过期 ──
  static const Color withdrawnText = Color(0xFF9A8DA0);
  static const Color withdrawnBg = Color(0xFF1E1A22);
  static const Color bgExpired = Color(0xFF1A1A1A);
  static const Color swipeDeleteBg = Color(0xFF262626);

  // ── 图表 ──
  static const Color chart1 = primary500;
  static const Color chart2 = Color(0xFF22C55E);
  static const Color chart3 = Color(0xFFF59E0B);
  static const Color chart4 = Color(0xFFA78BFA);
  static const Color chart5 = Color(0xFF6AA8E6);

  // ── 遮罩 / 高亮 ──
  static const Color overlay = Color(0xCC000000);
  static const Color highlight = Color(0xFF112835); // = primary50
}

/// Pencil 设计字号体系
class AppFontSizes {
  AppFontSizes._();

  static const double caption = 12;
  static const double body = 14;
  static const double subtitle = 16;
  static const double title = 18;
}

/// Pencil 设计间距体系
class AppSpacing {
  AppSpacing._();

  static const double xs = 4;
  static const double sm = 8;
  static const double md = 16;
  static const double lg = 24;
  static const double xl = 32;
}
