import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:smart_hotel_app/models/bo/room_bo.dart';

class StatusStats extends StatelessWidget {
  final RoomOverviewSummaryBO summary;

  const StatusStats({super.key, required this.summary});

  @override
  Widget build(BuildContext context) {
    final items = [
      _StatItemData(label: '入住', count: summary.occupiedCount, color: const Color(0xFF4A7CF7)),
      _StatItemData(label: '空闲', count: summary.vacantCount, color: const Color(0xFF4CAF50)),
      _StatItemData(label: '预定', count: summary.reservedCount, color: const Color(0xFF9C27B0)),
      _StatItemData(label: '告警', count: summary.alarmCount, color: const Color(0xFFFF9800)),
    ];

    return Container(
      width: double.infinity,
      padding: EdgeInsets.all(28.w),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(24.r),
      ),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: items.map((item) => _StatItem(item: item)).toList(),
      ),
    );
  }
}

class _StatItemData {
  final String label;
  final int count;
  final Color color;
  const _StatItemData({required this.label, required this.count, required this.color});
}

class _StatItem extends StatelessWidget {
  final _StatItemData item;

  const _StatItem({required this.item});

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Text(
          item.count.toString(),
          style: TextStyle(
            fontSize: 40.sp,
            fontWeight: FontWeight.bold,
            color: item.color,
          ),
        ),
        SizedBox(height: 4.h),
        Text(
          item.label,
          style: TextStyle(
            fontSize: 24.sp,
            color: const Color.fromRGBO(156, 163, 175, 1),
          ),
        ),
      ],
    );
  }
}
