import 'package:flutter/material.dart';
import 'package:em2rp/models/equipment_model.dart';
import 'package:em2rp/utils/colors.dart';

/// Widget pour afficher les informations principales
class EquipmentMainInfoSection extends StatelessWidget {
  final EquipmentModel equipment;

  const EquipmentMainInfoSection({
    super.key,
    required this.equipment,
  });

  @override
  Widget build(BuildContext context) {
    return Card(
      elevation: 2,
      child: Padding(
        padding: const EdgeInsets.all(20),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Row(
              children: [
                const Icon(Icons.info_outline, color: AppColors.rouge),
                const SizedBox(width: 8),
                Text(
                  'Informations principales',
                  style: Theme.of(context).textTheme.titleLarge?.copyWith(
                        fontWeight: FontWeight.bold,
                      ),
                ),
              ],
            ),
            const Divider(height: 24),
            _buildInfoRow('Catégorie', equipment.category.label),
            if (equipment.brand != null && equipment.brand!.isNotEmpty)
              _buildInfoRow('Marque', equipment.brand!),
            if (equipment.model != null && equipment.model!.isNotEmpty)
              _buildInfoRow('Modèle', equipment.model!),
            if (equipment.category != EquipmentCategory.consumable &&
                equipment.category != EquipmentCategory.cable)
              _buildInfoRow('Statut', equipment.status.label),
          ],
        ),
      ),
    );
  }

  Widget _buildInfoRow(String label, String value) {
    return Padding(
      padding: const EdgeInsets.symmetric(vertical: 8.0),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          SizedBox(
            width: 120,
            child: Text(
              label,
              style: TextStyle(
                fontWeight: FontWeight.w500,
                color: Colors.grey[700],
              ),
            ),
          ),
          Expanded(
            child: Text(
              value,
              style: const TextStyle(
                fontWeight: FontWeight.w600,
              ),
            ),
          ),
        ],
      ),
    );
  }
}

