import "package:flutter/material.dart";
import "package:google_fonts/google_fonts.dart";
import "../theme/ensup_colors.dart";
import "../widgets/ensup_top_bar.dart";
import "../widgets/profile_card.dart";
import "../widgets/action_card.dart";
import "../widgets/brand_corners.dart";
import "catalogue_screen.dart";

/// Écran d'accueil étudiant : profil + choix Emprunter / Restituer.
class HomeScreen extends StatelessWidget {
  const HomeScreen({super.key});

  void _bientot(BuildContext context, String action) {
    ScaffoldMessenger.of(context).showSnackBar(
      SnackBar(content: Text("$action — écran à venir")),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: EnsupColors.soft,
      body: Stack(
        children: [
          Center(
            child: ConstrainedBox(
              constraints: const BoxConstraints(maxWidth: 1280, maxHeight: 820),
              child: Container(
                margin: const EdgeInsets.all(24),
                decoration: BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.circular(16),
                  boxShadow: [
                    BoxShadow(
                      color: EnsupColors.text.withValues(alpha: 0.14),
                      blurRadius: 60,
                      offset: const Offset(0, 18),
                    ),
                  ],
                ),
                clipBehavior: Clip.antiAlias,
                child: Column(
                  children: [
                    EnsupTopBar(
                      campusTag: "Paris · Ensitech",
                      userName: "Lucas Martin",
                      userInitials: "LM",
                      onBack: () => Navigator.of(context).pop(),
                    ),
                    Expanded(
                      child: SingleChildScrollView(
                        padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 28),
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            const ProfileCard(
                              name: "Lucas Martin",
                              subtitle: "Étudiant · BTS SIO 2ème année · Ensitech Paris",
                              initials: "LM",
                            ),
                            const SizedBox(height: 24),
                            Text(
                              "Que souhaitez-vous faire ?",
                              style: GoogleFonts.darkerGrotesque(
                                fontSize: 28,
                                fontWeight: FontWeight.w900,
                                color: EnsupColors.text,
                              ),
                            ),
                            const SizedBox(height: 18),
                            IntrinsicHeight(
                              child: Row(
                                crossAxisAlignment: CrossAxisAlignment.stretch,
                                children: [
                                  Expanded(
                                    child: ActionCard(
                                      icon: Icons.inventory_2_outlined,
                                      title: "EMPRUNTER",
                                      description:
                                          "Accéder au catalogue et emprunter du matériel éducatif",
                                      color: EnsupColors.cyan,
                                      onTap: () => Navigator.of(context).push(
                                        MaterialPageRoute(builder: (_) => const CatalogueScreen()),
                                      ),
                                    ),
                                  ),
                                  const SizedBox(width: 16),
                                  Expanded(
                                    child: ActionCard(
                                      icon: Icons.assignment_return_outlined,
                                      title: "RESTITUER",
                                      description:
                                          "Restituer un matériel que vous avez emprunté",
                                      color: EnsupColors.teal,
                                      onTap: () => _bientot(context, "Restituer"),
                                    ),
                                  ),
                                ],
                              ),
                            ),
                          ],
                        ),
                      ),
                    ),
                  ],
                ),
              ),
            ),
          ),
          const Positioned.fill(child: BrandCorners()),
        ],
      ),
    );
  }
}
