/// Dashboard Modérateur - Management Hub Focalisé
/// Outils de modération et gestion partielle
library moderator_dashboard;

import 'package:flutter/material.dart';
import '../../../../../shared/design_system/unionflow_design_system.dart';
import '../../widgets/dashboard_widgets.dart';

/// Dashboard Management Hub pour Modérateur
class ModeratorDashboard extends StatelessWidget {
  const ModeratorDashboard({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: ColorTokens.surface,
      body: CustomScrollView(
        slivers: [
          // App Bar Modérateur
          SliverAppBar(
            expandedHeight: 160,
            floating: false,
            pinned: true,
            backgroundColor: const Color(0xFFE17055), // Orange focus
            flexibleSpace: FlexibleSpaceBar(
              title: const Text(
                'Management Hub',
                style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
              ),
              background: Container(
                decoration: const BoxDecoration(
                  gradient: LinearGradient(
                    colors: [Color(0xFFE17055), Color(0xFFD63031)],
                    begin: Alignment.topLeft,
                    end: Alignment.bottomRight,
                  ),
                ),
                child: const Center(
                  child: Icon(Icons.manage_accounts, color: Colors.white, size: 60),
                ),
              ),
            ),
          ),
          
          SliverToBoxAdapter(
            child: Padding(
              padding: const EdgeInsets.all(SpacingTokens.md),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  // Métriques modération
                  _buildModerationMetrics(),
                  const SizedBox(height: SpacingTokens.xl),
                  
                  // Actions modération
                  _buildModerationActions(),
                  const SizedBox(height: SpacingTokens.xl),
                  
                  // Tâches en attente
                  _buildPendingTasks(),
                  const SizedBox(height: SpacingTokens.xl),
                  
                  // Activité récente
                  _buildRecentActivity(),
                ],
              ),
            ),
          ),
        ],
      ),
    );
  }

  Widget _buildModerationMetrics() {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          'Métriques de Modération',
          style: TypographyTokens.headlineMedium.copyWith(fontWeight: FontWeight.bold),
        ),
        const SizedBox(height: SpacingTokens.md),
        DashboardStatsGrid(
          stats: const [
            DashboardStat(
              icon: Icons.flag,
              value: '12',
              title: 'Signalements',
              color: Color(0xFFE17055),
            ),
            DashboardStat(
              icon: Icons.pending_actions,
              value: '8',
              title: 'En Attente',
              color: Color(0xFFD63031),
            ),
            DashboardStat(
              icon: Icons.check_circle,
              value: '45',
              title: 'Résolus',
              color: Color(0xFF00B894),
            ),
            DashboardStat(
              icon: Icons.people,
              value: '156',
              title: 'Membres',
              color: Color(0xFF0984E3),
            ),
          ],
          onStatTap: (type) {},
        ),
      ],
    );
  }

  Widget _buildModerationActions() {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          'Actions de Modération',
          style: TypographyTokens.headlineMedium.copyWith(fontWeight: FontWeight.bold),
        ),
        const SizedBox(height: SpacingTokens.md),
        DashboardQuickActionsGrid(
          children: [
            DashboardQuickAction(
              icon: Icons.gavel,
              title: 'Modérer',

              color: const Color(0xFFE17055),
              onTap: () {},
            ),
            DashboardQuickAction(
              icon: Icons.person_remove,
              title: 'Suspendre',

              color: const Color(0xFFD63031),
              onTap: () {},
            ),
            DashboardQuickAction(
              icon: Icons.message,
              title: 'Communiquer',

              color: const Color(0xFF0984E3),
              onTap: () {},
            ),
            DashboardQuickAction(
              icon: Icons.report,
              title: 'Rapport',

              color: const Color(0xFF6C5CE7),
              onTap: () {},
            ),
          ],
        ),
      ],
    );
  }

  Widget _buildPendingTasks() {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          'Tâches en Attente',
          style: TypographyTokens.headlineMedium.copyWith(fontWeight: FontWeight.bold),
        ),
        const SizedBox(height: SpacingTokens.md),
        Container(
          decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.circular(RadiusTokens.md),
            boxShadow: [
              BoxShadow(
                color: Colors.black.withOpacity(0.05),
                blurRadius: 10,
                offset: const Offset(0, 2),
              ),
            ],
          ),
          child: const Column(
            children: [
              ListTile(
                leading: CircleAvatar(
                  backgroundColor: Color(0xFFFFE0E0),
                  child: Icon(Icons.flag, color: Color(0xFFD63031)),
                ),
                title: Text('Contenu inapproprié signalé'),
                subtitle: Text('Commentaire sur événement'),
                trailing: Text('Urgent'),
              ),
              Divider(height: 1),
              ListTile(
                leading: CircleAvatar(
                  backgroundColor: Color(0xFFFFF3E0),
                  child: Icon(Icons.person_add, color: Color(0xFFE17055)),
                ),
                title: Text('Demande d\'adhésion'),
                subtitle: Text('Marie Dubois'),
                trailing: Text('2j'),
              ),
            ],
          ),
        ),
      ],
    );
  }

  Widget _buildRecentActivity() {
    return const DashboardRecentActivitySection(
      children: [
        DashboardActivity(
          title: 'Signalement traité',
          subtitle: 'Contenu supprimé',
          icon: Icons.check_circle,
          color: Color(0xFF00B894),
          time: 'Il y a 1h',
        ),
        DashboardActivity(
          title: 'Membre suspendu',
          subtitle: 'Violation des règles',
          icon: Icons.person_remove,
          color: Color(0xFFD63031),
          time: 'Il y a 3h',
        ),
      ],
    );
  }
}
