import 'package:flutter/material.dart'; class StatCard extends StatelessWidget { final String title; final String value; final IconData icon; final Color color; final String? subtitle; final double? change; final String? footerLabel; const StatCard({ super.key, required this.title, required this.value, required this.icon, required this.color, this.subtitle, this.change, this.footerLabel, }); @override Widget build(BuildContext context) { final cs = Theme.of(context).colorScheme; return Card( child: Padding( padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ Container( padding: const EdgeInsets.all(8), decoration: BoxDecoration( color: color.withValues(alpha: 0.1), borderRadius: BorderRadius.circular(8), ), child: Icon(icon, color: color, size: 20), ), const Spacer(), ], ), const SizedBox(height: 12), Text( value, style: TextStyle( fontSize: 24, fontWeight: FontWeight.bold, color: cs.onSurface, ), ), const SizedBox(height: 4), Text( title, style: TextStyle( fontSize: 13, color: cs.onSurfaceVariant, ), ), if (subtitle != null) ...[ const SizedBox(height: 4), Text( subtitle!, style: TextStyle( fontSize: 11, color: cs.onSurfaceVariant.withValues(alpha: 0.85), ), ), ], if (change != null) ...[ const SizedBox(height: 6), Row( children: [ Text( '${change! >= 0 ? '+' : ''}${change!.toStringAsFixed(1)}%', style: TextStyle( fontSize: 11, fontWeight: FontWeight.w600, color: change! > 0 ? const Color(0xFF0E9F6E) : change! < 0 ? const Color(0xFFE02424) : cs.onSurfaceVariant, ), ), if (footerLabel != null) ...[ const SizedBox(width: 6), Expanded( child: Text( footerLabel!, style: TextStyle( fontSize: 11, color: cs.onSurfaceVariant.withValues(alpha: 0.85), ), overflow: TextOverflow.ellipsis, ), ), ], ], ), ], ], ), ), ); } }