import 'package:flutter/material.dart';
import '../tokens/app_colors.dart';
import '../tokens/unionflow_colors.dart';

/// Ligne d'événement à venir — style fintech avec bordure gauche verte
/// Adaptatif dark/light via AppColors
class DashboardEventRow extends StatelessWidget {
  final String title;
  final String date;
  final String? daysUntil;
  final String? participants;

  const DashboardEventRow({
    super.key,
    required this.title,
    required this.date,
    this.daysUntil,
    this.participants,
  });

  @override
  Widget build(BuildContext context) {
    final isDark       = Theme.of(context).brightness == Brightness.dark;
    final bgColor      = isDark ? AppColors.surfaceDark      : AppColors.surface;
    final textPrimary  = isDark ? AppColors.textPrimaryDark  : AppColors.textPrimary;
    final textSecondary= isDark ? AppColors.textSecondaryDark: AppColors.textSecondary;
    final textTertiary = isDark ? AppColors.textSecondaryDark: AppColors.textTertiary;

    return Container(
      margin: const EdgeInsets.only(bottom: 6),
      padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 9),
      decoration: BoxDecoration(
        color: bgColor,
        borderRadius: BorderRadius.circular(8),
        border: const Border(
          left: BorderSide(color: UnionFlowColors.unionGreen, width: 3),
        ),
      ),
      child: Row(
        children: [
          Expanded(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text(
                  title,
                  style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: textPrimary),
                  maxLines: 1,
                  overflow: TextOverflow.ellipsis,
                ),
                const SizedBox(height: 2),
                Text(
                  date,
                  style: TextStyle(fontSize: 10, color: textSecondary),
                ),
              ],
            ),
          ),
          if (daysUntil != null || participants != null)
            Column(
              crossAxisAlignment: CrossAxisAlignment.end,
              children: [
                if (daysUntil != null)
                  Text(
                    daysUntil!,
                    style: const TextStyle(
                      fontSize: 10,
                      fontWeight: FontWeight.w600,
                      color: UnionFlowColors.unionGreen,
                    ),
                  ),
                if (participants != null) ...[
                  const SizedBox(height: 2),
                  Text(
                    participants!,
                    style: TextStyle(fontSize: 10, color: textTertiary),
                  ),
                ],
              ],
            ),
        ],
      ),
    );
  }
}
