import 'package:flutter/material.dart';

// =============================================================================
// LAYER 1: ColorBases — 颜色常量，不带语义
// =============================================================================
//
// 色值与 Figma 设计稿一一对应。命名用 {色相}{明度} 格式（如 primary500），
// 不暗示任何使用场景。
//
// View 层不直接引用 ColorBases，通过 AppColors（语义接口）间接使用。

abstract class ColorBases {
  ColorBases._();

  // ── Brand ────────────────────────────────────────────────────────────────
  static const primary400 = Color(0xFF5BA3F5);
  static const primary500 = Color(0xFF2F80ED);
  static const primary700 = Color(0xFF1A6BD4);

  // ── Neutral ──────────────────────────────────────────────────────────────
  static const neutral0   = Color(0xFFFFFFFF);
  static const neutral50  = Color(0xFFF8F9FA);
  static const neutral100 = Color(0xFFF1F3F4);
  static const neutral200 = Color(0xFFE8EAED);
  static const neutral400 = Color(0xFFBDC1C6);
  static const neutral600 = Color(0xFF80868B);
  static const neutral800 = Color(0xFF3C4043);
  static const neutral850 = Color(0xFF2C2C2E);
  static const neutral900 = Color(0xFF202124);
  static const neutral950 = Color(0xFF000000);

  // ── Neutral Alpha（带透明度，阴影等场景）──────────────────────────────────
  static const black12 = Color(0x1F000000);
  static const black60 = Color(0x99000000);

  // ── Status ───────────────────────────────────────────────────────────────
  static const error500   = Color(0xFFEB5757);
  static const success500 = Color(0xFF27AE60);
  static const warning500 = Color(0xFFF2C94C);
}

// =============================================================================
// LAYER 2: AppColors — 语义颜色抽象接口
// =============================================================================
//
// 按用途命名（bgPrimary、textSecondary），不关心具体色值。
// LightColors / DarkColors 各自实现，AppTheme._build() 消费此接口。
// Widget 侧通过 context.colors 访问（见 context_theme_ext.dart）。
//
// ## 数据流
//
// ```
// ColorBases（颜色常量）
//   → AppColors（语义接口）← 你在这里
//     → LightColors / DarkColors（实现）
//       → AppTheme._build(AppColors c)（组装 ThemeData）
//         → context.colors（Widget 消费）
// ```

abstract class AppColors {
  // ── Background ───────────────────────────────────────────────────────────
  Color get bgPrimary;
  Color get bgSecondary;
  Color get bgTertiary;

  // ── Text ─────────────────────────────────────────────────────────────────
  Color get textPrimary;
  Color get textSecondary;
  Color get textDisabled;
  Color get textOnPrimary;

  // ── Border ───────────────────────────────────────────────────────────────
  Color get borderDefault;
  Color get borderFocused;

  // ── Brand ────────────────────────────────────────────────────────────────
  Color get brandPrimary;
  Color get brandPrimaryHover;

  // ── Status ───────────────────────────────────────────────────────────────
  Color get statusError;
  Color get statusSuccess;
  Color get statusWarning;

  // ── Component ────────────────────────────────────────────────────────────
  Color get navBarBg;
  Color get navBarSelected;
  Color get divider;

  // ── Effect ───────────────────────────────────────────────────────────────
  Color get shadow;
}

// =============================================================================
// LAYER 3a: LightColors — 亮色实现
// =============================================================================

class LightColors implements AppColors {
  const LightColors();

  @override Color get bgPrimary         => ColorBases.neutral50;
  @override Color get bgSecondary       => ColorBases.neutral0;
  @override Color get bgTertiary        => ColorBases.neutral100;

  @override Color get textPrimary       => ColorBases.neutral900;
  @override Color get textSecondary     => ColorBases.neutral600;
  @override Color get textDisabled      => ColorBases.neutral400;
  @override Color get textOnPrimary     => ColorBases.neutral0;

  @override Color get borderDefault     => ColorBases.neutral200;
  @override Color get borderFocused     => ColorBases.primary500;

  @override Color get brandPrimary      => ColorBases.primary500;
  @override Color get brandPrimaryHover => ColorBases.primary700;

  @override Color get statusError       => ColorBases.error500;
  @override Color get statusSuccess     => ColorBases.success500;
  @override Color get statusWarning     => ColorBases.warning500;

  @override Color get navBarBg          => ColorBases.neutral0;
  @override Color get navBarSelected    => ColorBases.primary500;
  @override Color get divider           => ColorBases.neutral100;

  @override Color get shadow            => ColorBases.black12;
}

// =============================================================================
// LAYER 3b: DarkColors — 暗色实现
// =============================================================================

class DarkColors implements AppColors {
  const DarkColors();

  @override Color get bgPrimary         => ColorBases.neutral900;
  @override Color get bgSecondary       => ColorBases.neutral800;
  @override Color get bgTertiary        => ColorBases.neutral850;

  @override Color get textPrimary       => ColorBases.neutral0;
  @override Color get textSecondary     => ColorBases.neutral400;
  @override Color get textDisabled      => ColorBases.neutral600;
  @override Color get textOnPrimary     => ColorBases.neutral0;

  @override Color get borderDefault     => ColorBases.neutral800;
  @override Color get borderFocused     => ColorBases.primary400;

  @override Color get brandPrimary      => ColorBases.primary400;
  @override Color get brandPrimaryHover => ColorBases.primary500;

  @override Color get statusError       => ColorBases.error500;
  @override Color get statusSuccess     => ColorBases.success500;
  @override Color get statusWarning     => ColorBases.warning500;

  @override Color get navBarBg          => ColorBases.neutral900;
  @override Color get navBarSelected    => ColorBases.primary400;
  @override Color get divider           => ColorBases.neutral800;

  @override Color get shadow            => ColorBases.black60;
}
