import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import '../../theme/app_theme.dart';
import '../husband/husband_learn_articles_screen.dart';

class WifeLearnScreen extends StatelessWidget {
  const WifeLearnScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Reproductive Health'),
        actions: [
          IconButton(
            icon: const Icon(Icons.bookmark),
            onPressed: () {},
          ),
        ],
      ),
      body: SingleChildScrollView(
        padding: const EdgeInsets.all(20),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            _buildSection(context, 'Understanding My Cycle', const [
              _LearnItem(
                icon: Icons.loop,
                title: 'The 4 Phases',
                subtitle: 'What\'s happening in my body',
                articleId: 'wife_cycle_phases',
              ),
              _LearnItem(
                icon: Icons.psychology_outlined,
                title: 'Mood & Hormones',
                subtitle: 'Why I feel different each week',
                articleId:
                    'wife_mood_changes', // Reusing similar concept, maybe new article
              ),
            ]),
            const SizedBox(height: 24),
            _buildSection(context, 'Disease Prevention', const [
              _LearnItem(
                icon: Icons.health_and_safety_outlined,
                title: 'Preventing Infections',
                subtitle: 'Hygiene and STI prevention',
                articleId: 'wife_disease_prevention',
              ),
              _LearnItem(
                icon: Icons.medical_services_outlined,
                title: 'Regular Screenings',
                subtitle: 'What to check and when',
                articleId: 'wife_screenings',
              ),
            ]),
            const SizedBox(height: 24),
            _buildSection(context, 'Partnership', const [
              _LearnItem(
                icon: Icons.favorite_border,
                title: 'Communication',
                subtitle: 'Talking to him about my health',
                articleId: 'wife_partnership_tips',
              ),
              _LearnItem(
                icon: Icons.handshake_outlined,
                title: 'Shared Responsibility',
                subtitle: 'Navigating fertility together',
                articleId: 'wife_shared_responsibility',
              ),
            ]),
          ],
        ),
      ),
    );
  }

  Widget _buildSection(
      BuildContext context, String title, List<_LearnItem> items) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          title,
          style: GoogleFonts.outfit(
            fontSize: 14,
            fontWeight: FontWeight.w500,
            color: AppColors.warmGray,
            letterSpacing: 0.5,
          ),
        ),
        const SizedBox(height: 8),
        Container(
          decoration: BoxDecoration(
            color: Theme.of(context).cardTheme.color,
            borderRadius: BorderRadius.circular(12),
            border: Border.all(
                color: Theme.of(context)
                    .colorScheme
                    .outline
                    .withValues(alpha: 0.05)),
          ),
          child: Column(
            children: items
                .map((item) => ListTile(
                      leading: Container(
                        width: 40,
                        height: 40,
                        decoration: BoxDecoration(
                          color: Theme.of(context)
                              .colorScheme
                              .primaryContainer
                              .withValues(alpha: 0.2),
                          borderRadius: BorderRadius.circular(10),
                        ),
                        child: Icon(
                          item.icon,
                          color: Theme.of(context).colorScheme.primary,
                          size: 20,
                        ),
                      ),
                      title: Text(
                        item.title,
                        style: GoogleFonts.outfit(
                          fontSize: 15,
                          fontWeight: FontWeight.w500,
                          color: Theme.of(context).colorScheme.onSurface,
                        ),
                      ),
                      subtitle: Text(
                        item.subtitle,
                        style: GoogleFonts.outfit(
                          fontSize: 13,
                          color: AppColors.warmGray,
                        ),
                      ),
                      trailing: const Icon(
                        Icons.chevron_right,
                        color: AppColors.lightGray,
                      ),
                      onTap: () {
                        Navigator.push(
                          context,
                          MaterialPageRoute(
                            builder: (context) =>
                                CombinedLearnArticleDetailScreen(
                                    articleId: item.articleId),
                          ),
                        );
                      },
                    ))
                .toList(),
          ),
        ),
      ],
    );
  }
}

class _LearnItem {
  final IconData icon;
  final String title;
  final String subtitle;
  final String articleId;

  const _LearnItem({
    required this.icon,
    required this.title,
    required this.subtitle,
    required this.articleId,
  });
}
