// status_pill.dart — 状态胶囊(色点 + 文字)
import 'package:flutter/material.dart';
import '../pangolin_theme.dart';

enum PangolinStatus { connected, connecting, error, neutral, pro }

class StatusPill extends StatelessWidget {
  const StatusPill({super.key, required this.label, this.status = PangolinStatus.neutral});
  final String label;
  final PangolinStatus status;

  @override
  Widget build(BuildContext context) {
    final c = context.pangolin;
    late final Color bg, fg, dot;
    bool showDot = true;
    switch (status) {
      case PangolinStatus.connected:
        bg = c.successSubtle; fg = c.success; dot = c.success; break;
      case PangolinStatus.connecting:
        bg = c.warningSubtle; fg = c.warning; dot = c.warning; break;
      case PangolinStatus.error:
        bg = c.dangerSubtle; fg = c.danger; dot = c.danger; break;
      case PangolinStatus.pro:
        bg = c.accent; fg = c.fgOnAccent; dot = c.fgOnAccent; showDot = false; break;
      case PangolinStatus.neutral:
        bg = c.bgSubtle; fg = c.fg2; dot = c.fg3; break;
    }
    return Container(
      padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
      decoration: BoxDecoration(color: bg, borderRadius: BorderRadius.circular(PangolinRadius.full)),
      child: Row(
        mainAxisSize: MainAxisSize.min,
        children: [
          if (showDot) ...[
            Container(width: 7, height: 7, decoration: BoxDecoration(color: dot, shape: BoxShape.circle)),
            const SizedBox(width: 7),
          ],
          Text(label, style: PangolinText.caption.copyWith(color: fg, fontWeight: FontWeight.w600)),
        ],
      ),
    );
  }
}
