/// Dashboard Membre Simple - Personal Space Minimaliste
/// Interface simplifiée pour accès basique
library simple_member_dashboard;

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

/// Dashboard Personal Space pour Membre Simple
class SimpleMemberDashboard extends StatelessWidget {
  const SimpleMemberDashboard({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: ColorTokens.surface,
      body: CustomScrollView(
        slivers: [
          // App Bar Membre Simple
          SliverAppBar(
            expandedHeight: 140,
            floating: false,
            pinned: true,
            backgroundColor: const Color(0xFF00CEC9), // Teal simple
            flexibleSpace: FlexibleSpaceBar(
              title: const Text(
                'Mon Espace',
                style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
              ),
              background: Container(
                decoration: const BoxDecoration(
                  gradient: LinearGradient(
                    colors: [Color(0xFF00CEC9), Color(0xFF00B3B3)],
                    begin: Alignment.topLeft,
                    end: Alignment.bottomRight,
                  ),
                ),
                child: const Center(
                  child: Icon(Icons.person, color: Colors.white, size: 50),
                ),
              ),
            ),
          ),
          
          SliverToBoxAdapter(
            child: Padding(
              padding: const EdgeInsets.all(SpacingTokens.md),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  // Profil personnel
                  _buildPersonalProfile(),
                  const SizedBox(height: SpacingTokens.xl),
                  
                  // Mes informations
                  _buildMyInfo(),
                  const SizedBox(height: SpacingTokens.xl),
                  
                  // Actions simples
                  _buildSimpleActions(),
                  const SizedBox(height: SpacingTokens.xl),
                  
                  // Événements publics
                  _buildPublicEvents(),
                  const SizedBox(height: SpacingTokens.xl),
                  
                  // Mon historique
                  _buildMyHistory(),
                ],
              ),
            ),
          ),
        ],
      ),
    );
  }

  Widget _buildPersonalProfile() {
    return Container(
      padding: const EdgeInsets.all(SpacingTokens.lg),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(RadiusTokens.lg),
        boxShadow: [
          BoxShadow(
            color: Colors.black.withOpacity(0.05),
            blurRadius: 10,
            offset: const Offset(0, 2),
          ),
        ],
      ),
      child: Row(
        children: [
          const CircleAvatar(
            radius: 35,
            backgroundColor: Color(0xFF00CEC9),
            child: Icon(Icons.person, color: Colors.white, size: 35),
          ),
          const SizedBox(width: SpacingTokens.md),
          Expanded(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text(
                  'Pierre Dupont',
                  style: TypographyTokens.headlineMedium.copyWith(
                    fontWeight: FontWeight.bold,
                  ),
                ),
                Text(
                  'Membre depuis 6 mois',
                  style: TypographyTokens.bodyMedium.copyWith(
                    color: ColorTokens.textSecondary,
                  ),
                ),
                const SizedBox(height: SpacingTokens.sm),
                Container(
                  padding: const EdgeInsets.symmetric(
                    horizontal: SpacingTokens.sm,
                    vertical: SpacingTokens.xs,
                  ),
                  decoration: BoxDecoration(
                    color: const Color(0xFF00CEC9).withOpacity(0.1),
                    borderRadius: BorderRadius.circular(RadiusTokens.sm),
                  ),
                  child: Text(
                    'Membre Simple',
                    style: TypographyTokens.bodySmall.copyWith(
                      color: const Color(0xFF00CEC9),
                      fontWeight: FontWeight.w600,
                    ),
                  ),
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }

  Widget _buildMyInfo() {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          'Mes Informations',
          style: TypographyTokens.headlineMedium.copyWith(fontWeight: FontWeight.bold),
        ),
        const SizedBox(height: SpacingTokens.md),
        const DashboardStatsGrid(
          stats: [
            DashboardStat(
              icon: Icons.payment,
              value: 'À jour',
              title: 'Cotisations',
              color: Color(0xFF00B894),
            ),
            DashboardStat(
              icon: Icons.event,
              value: '2',
              title: 'Événements',
              color: Color(0xFF00CEC9),
            ),
            DashboardStat(
              icon: Icons.account_circle,
              value: '100%',
              title: 'Profil',
              color: Color(0xFF0984E3),
            ),
            DashboardStat(
              icon: Icons.notifications,
              value: '3',
              title: 'Notifications',
              color: Color(0xFFE17055),
            ),
          ],
        ),
      ],
    );
  }

  Widget _buildSimpleActions() {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          'Actions Disponibles',
          style: TypographyTokens.headlineMedium.copyWith(fontWeight: FontWeight.bold),
        ),
        const SizedBox(height: SpacingTokens.md),
        DashboardQuickActionsGrid(
          children: [
            DashboardQuickAction(
              icon: Icons.edit,
              title: 'Modifier Profil',
              color: const Color(0xFF00CEC9),
              onTap: () {},
            ),
            DashboardQuickAction(
              icon: Icons.payment,
              title: 'Mes Cotisations',
              color: const Color(0xFF0984E3),
              onTap: () {},
            ),
            DashboardQuickAction(
              icon: Icons.event,
              title: 'Événements',
              color: const Color(0xFF00B894),
              onTap: () {},
            ),
            DashboardQuickAction(
              icon: Icons.help,
              title: 'Aide',
              color: const Color(0xFFE17055),
              onTap: () {},
            ),
          ],
        ),
      ],
    );
  }

  Widget _buildPublicEvents() {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          'Événements Disponibles',
          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: Column(
            children: [
              ListTile(
                leading: Container(
                  width: 50,
                  height: 50,
                  decoration: BoxDecoration(
                    color: const Color(0xFF00B894).withOpacity(0.1),
                    borderRadius: BorderRadius.circular(25),
                  ),
                  child: const Icon(
                    Icons.event,
                    color: Color(0xFF00B894),
                  ),
                ),
                title: const Text('Assemblée Générale'),
                subtitle: const Text('15 décembre • 19h00'),
                trailing: Container(
                  padding: const EdgeInsets.symmetric(
                    horizontal: SpacingTokens.sm,
                    vertical: SpacingTokens.xs,
                  ),
                  decoration: BoxDecoration(
                    color: const Color(0xFF00B894).withOpacity(0.1),
                    borderRadius: BorderRadius.circular(RadiusTokens.sm),
                  ),
                  child: const Text(
                    'Public',
                    style: TextStyle(
                      color: Color(0xFF00B894),
                      fontSize: 12,
                      fontWeight: FontWeight.w600,
                    ),
                  ),
                ),
              ),
              const Divider(height: 1),
              ListTile(
                leading: Container(
                  width: 50,
                  height: 50,
                  decoration: BoxDecoration(
                    color: const Color(0xFF00CEC9).withOpacity(0.1),
                    borderRadius: BorderRadius.circular(25),
                  ),
                  child: const Icon(
                    Icons.celebration,
                    color: Color(0xFF00CEC9),
                  ),
                ),
                title: const Text('Soirée de Noël'),
                subtitle: const Text('22 décembre • 20h00'),
                trailing: Container(
                  padding: const EdgeInsets.symmetric(
                    horizontal: SpacingTokens.sm,
                    vertical: SpacingTokens.xs,
                  ),
                  decoration: BoxDecoration(
                    color: const Color(0xFF00CEC9).withOpacity(0.1),
                    borderRadius: BorderRadius.circular(RadiusTokens.sm),
                  ),
                  child: const Text(
                    'Public',
                    style: TextStyle(
                      color: Color(0xFF00CEC9),
                      fontSize: 12,
                      fontWeight: FontWeight.w600,
                    ),
                  ),
                ),
              ),
            ],
          ),
        ),
      ],
    );
  }

  Widget _buildMyHistory() {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          'Mon Historique',
          style: TypographyTokens.headlineMedium.copyWith(fontWeight: FontWeight.bold),
        ),
        const SizedBox(height: SpacingTokens.md),
        const DashboardRecentActivitySection(
          children: [
            DashboardActivity(
              title: 'Cotisation payée',
              subtitle: 'Décembre 2024',
              icon: Icons.payment,
              color: Color(0xFF00B894),
              time: 'Il y a 1j',
            ),
            DashboardActivity(
              title: 'Profil mis à jour',
              subtitle: 'Informations personnelles',
              icon: Icons.edit,
              color: Color(0xFF00CEC9),
              time: 'Il y a 1 sem',
            ),
            DashboardActivity(
              title: 'Inscription événement',
              subtitle: 'Assemblée Générale',
              icon: Icons.event,
              color: Color(0xFF0984E3),
              time: 'Il y a 2 sem',
            ),
          ],
        ),
      ],
    );
  }
}
