import 'package:flutter/material.dart';

import '../../../../common/theme/theme.dart';
import '../../../components/spacer/spacer.dart';
import '../customer_page.dart';

class CustomerCard extends StatelessWidget {
  final Customer customer;
  const CustomerCard({super.key, required this.customer});

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
        color: AppColor.white,
        borderRadius: BorderRadius.circular(16),
        boxShadow: [
          BoxShadow(
            color: Colors.black.withOpacity(0.05),
            blurRadius: 10,
            offset: Offset(0, 4),
          ),
        ],
      ),
      child: InkWell(
        onTap: () {},
        borderRadius: BorderRadius.circular(16),
        child: Padding(
          padding: EdgeInsets.all(16),
          child: Column(
            children: [
              CircleAvatar(
                backgroundColor: _getMembershipColor(customer.membershipLevel),
                radius: 30,
                child: Text(
                  customer.name[0].toUpperCase(),
                  style: AppStyle.xxl.copyWith(
                    color: AppColor.white,
                    fontWeight: FontWeight.bold,
                  ),
                ),
              ),
              SpaceHeight(12),
              Text(
                customer.name,
                style: AppStyle.lg.copyWith(fontWeight: FontWeight.bold),
                textAlign: TextAlign.center,
                maxLines: 2,
                overflow: TextOverflow.ellipsis,
              ),
              SizedBox(height: 8),
              Container(
                padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
                decoration: BoxDecoration(
                  color: _getMembershipColor(
                    customer.membershipLevel,
                  ).withOpacity(0.1),
                  borderRadius: BorderRadius.circular(12),
                ),
                child: Text(
                  customer.membershipLevel,
                  style: AppStyle.sm.copyWith(
                    color: _getMembershipColor(customer.membershipLevel),
                    fontWeight: FontWeight.bold,
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }

  Color _getMembershipColor(String level) {
    switch (level) {
      case 'Platinum':
        return Color(0xFF9C27B0);
      case 'Gold':
        return Color(0xFFFF9800);
      case 'Silver':
        return Color(0xFF607D8B);
      case 'Bronze':
        return Color(0xFF795548);
      default:
        return AppColor.primary;
    }
  }
}
