import 'package:flutter/material.dart';

/// 健康管家 — Lavender Breeze 淡紫清风
class AppTheme {
  AppTheme._();

  // ── 颜色 ──
  static const Color primary = Color(0xFF6C5CE7);
  static const Color primaryLight = Color(0xFFEDEAFF);
  static const Color primaryDark = Color(0xFF5A4BD1);
  static const Color bg = Color(0xFFF8F9FC);
  static const Color surface = Color(0xFFFFFFFF);
  static const Color text = Color(0xFF2D2B32);
  static const Color textSub = Color(0xFF8A8892);
  static const Color textHint = Color(0xFFBFBCC4);
  static const Color success = Color(0xFF6ECF8A);
  static const Color error = Color(0xFFF56C6C);
  static const Color warning = Color(0xFFF5A623);
  static const Color accent = Color(0xFFFF8068);
  static const Color border = Color(0xFFEAEAF0);
  static const Color divider = Color(0xFFF2F2F6);

  // ── 圆角 Token ──
  static const double radiusXs = 8;
  static const double radiusSm = 12;
  static const double radiusMd = 16;
  static const double radiusLg = 20;
  static const double radiusXl = 24;
  static const double radiusPill = 999;

  // ── 间距 Token ──
  static const double spaceXs = 4;
  static const double spaceSm = 8;
  static const double spaceMd = 12;
  static const double spaceLg = 16;
  static const double spaceXl = 20;

  // ── 阴影 Token ──
  static BoxShadow get shadowCard => BoxShadow(color: primary.withAlpha(15), blurRadius: 12, offset: const Offset(0, 4));
  static BoxShadow get shadowLight => BoxShadow(color: primary.withAlpha(10), blurRadius: 8, offset: const Offset(0, 2));

  /// 每个智能体的卡片色调
  static const Map<String, Color> agentColors = {
    'default':      Color(0xFFE8ECFF), // 淡蓝紫
    'consultation': Color(0xFFE8F5FF), // 淡天蓝
    'health':       Color(0xFFE8FFF0), // 淡薄荷
    'diet':         Color(0xFFFFF2E8), // 淡杏
    'medication':   Color(0xFFFFE8F0), // 淡粉
    'report':       Color(0xFFE8F4FF), // 淡水蓝
    'exercise':     Color(0xFFF0E8FF), // 淡紫
  };

  static Color agentLight(String? name) => agentColors[name] ?? primaryLight;

  static ThemeData get lightTheme => ThemeData(
        useMaterial3: true,
        colorScheme: ColorScheme.fromSeed(seedColor: primary, primary: primary, surface: bg, brightness: Brightness.light),
        scaffoldBackgroundColor: bg,

        appBarTheme: const AppBarTheme(
          backgroundColor: surface, foregroundColor: text, elevation: 0,
          centerTitle: true, scrolledUnderElevation: 0,
          titleTextStyle: TextStyle(fontSize: 17, fontWeight: FontWeight.w600, color: text),
        ),

        cardTheme: CardThemeData(color: surface, elevation: 0,
          shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(radiusXl)), margin: EdgeInsets.zero),

        inputDecorationTheme: InputDecorationTheme(
          filled: true, fillColor: const Color(0xFFF4F5FA),
          contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
          border: OutlineInputBorder(borderRadius: BorderRadius.circular(radiusMd), borderSide: BorderSide.none),
          enabledBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(radiusMd), borderSide: BorderSide.none),
          focusedBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(radiusMd), borderSide: const BorderSide(color: primary, width: 1.5)),
          hintStyle: const TextStyle(color: textHint, fontSize: 15),
        ),

        elevatedButtonTheme: ElevatedButtonThemeData(style: ElevatedButton.styleFrom(
          backgroundColor: primary, foregroundColor: Colors.white,
          minimumSize: const Size(double.infinity, 52),
          shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(radiusLg)),
          textStyle: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600), elevation: 0,
        )),

        dialogTheme: DialogThemeData(shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(radiusXl))),

        textTheme: const TextTheme(
          headlineLarge: TextStyle(fontSize: 24, fontWeight: FontWeight.w700, color: text),
          titleLarge: TextStyle(fontSize: 20, fontWeight: FontWeight.w600, color: text),
          titleMedium: TextStyle(fontSize: 18, fontWeight: FontWeight.w600, color: text),
          bodyLarge: TextStyle(fontSize: 16, color: text, height: 1.5),
          bodyMedium: TextStyle(fontSize: 15, color: textSub, height: 1.4),
          labelMedium: TextStyle(fontSize: 13, color: textSub),
          labelSmall: TextStyle(fontSize: 11, color: textHint),
        ),
      );
}
