import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';

import '../../domain/policy_check_result.dart';
import 'governance_status_chip.dart';

/// A card displaying a summary of a [PolicyCheckResult].
///
/// Shows the check ID, title, category, status chip, and summary.
/// Highlights when [isSelected] is true.
class PolicyCheckCard extends StatelessWidget {
  final PolicyCheckResult check;
  final bool isSelected;
  final VoidCallback? onTap;

  const PolicyCheckCard({super.key, required this.check, this.isSelected = false, this.onTap});

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: AnimatedContainer(
        duration: const Duration(milliseconds: 200),
        padding: const EdgeInsets.all(KcSpacing.md),
        decoration: BoxDecoration(
          color: KcColors.surface,
          border: Border.all(
            color: isSelected ? KcColors.denimBlue : KcColors.border,
            width: isSelected ? 2 : 1,
          ),
          borderRadius: BorderRadius.circular(16),
          boxShadow: const [
            BoxShadow(blurRadius: 8, offset: Offset(0, 2), color: Color(0x11000000)),
          ],
        ),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Row(
              children: [
                Expanded(
                  child: Text(
                    check.title,
                    style: Theme.of(context).textTheme.titleMedium,
                    maxLines: 1,
                    overflow: TextOverflow.ellipsis,
                  ),
                ),
                GovernanceStatusChip(status: check.status),
              ],
            ),
            const SizedBox(height: KcSpacing.xs),
            Text(
              check.category,
              style: Theme.of(
                context,
              ).textTheme.bodySmall?.copyWith(color: KcColors.neutral, fontWeight: FontWeight.w600),
            ),
            const SizedBox(height: KcSpacing.sm),
            Text(
              check.summary,
              style: Theme.of(context).textTheme.bodyMedium,
              maxLines: 2,
              overflow: TextOverflow.ellipsis,
            ),
            const Spacer(),
            Text(
              check.id,
              style: Theme.of(context).textTheme.bodySmall?.copyWith(color: KcColors.neutral),
            ),
          ],
        ),
      ),
    );
  }
}
