import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:lucide_icons/lucide_icons.dart';
import 'package:intl/intl.dart';
import 'package:design_system/design_system.dart';
import 'package:krow_domain/krow_domain.dart';
import '../blocs/shifts/shifts_bloc.dart';
import '../widgets/my_shift_card.dart';
import '../widgets/shift_assignment_card.dart';

// Shim to match POC styles locally
class AppColors {
  static const Color krowBlue = UiColors.primary;
  static const Color krowYellow = Color(0xFFFFED4A);
  static const Color krowCharcoal = UiColors.textPrimary;
  static const Color krowMuted = UiColors.textSecondary;
  static const Color krowBorder = UiColors.border;
  static const Color krowBackground = UiColors.background;
  static const Color white = Colors.white;
  static const Color black = Colors.black;
}

class ShiftsPage extends StatefulWidget {
  final String? initialTab;
  const ShiftsPage({super.key, this.initialTab});

  @override
  State<ShiftsPage> createState() => _ShiftsPageState();
}

class _ShiftsPageState extends State<ShiftsPage> {
  late String _activeTab;
  String _searchQuery = '';
  // ignore: unused_field
  String? _cancelledShiftDemo; // 'lastMinute' or 'advance'
  String _jobType = 'all'; // all, one-day, multi-day, long-term

  // Calendar State
  DateTime _selectedDate = DateTime.now();
  int _weekOffset = 0;
  
  final ShiftsBloc _bloc = Modular.get<ShiftsBloc>();

  @override
  void initState() {
    super.initState();
    _activeTab = widget.initialTab ?? 'myshifts';
    _bloc.add(LoadShiftsEvent());
  }

  @override
  void didUpdateWidget(ShiftsPage oldWidget) {
    super.didUpdateWidget(oldWidget);
    if (widget.initialTab != null && widget.initialTab != _activeTab) {
      setState(() {
        _activeTab = widget.initialTab!;
      });
    }
  }

  List<DateTime> _getCalendarDays() {
    final now = DateTime.now();
    int reactDayIndex = now.weekday == 7 ? 0 : now.weekday;
    int daysSinceFriday = (reactDayIndex + 2) % 7;
    final start = now
        .subtract(Duration(days: daysSinceFriday))
        .add(Duration(days: _weekOffset * 7));
    final startDate = DateTime(start.year, start.month, start.day);
    return List.generate(7, (index) => startDate.add(Duration(days: index)));
  }

  bool _isSameDay(DateTime a, DateTime b) {
    return a.year == b.year && a.month == b.month && a.day == b.day;
  }

  void _confirmShift(String id) {
     // TODO: Implement Bloc event
    ScaffoldMessenger.of(context).showSnackBar(
      const SnackBar(content: Text('Shift confirmed! (Placeholder)')),
    );
  }

  void _declineShift(String id) {
     // TODO: Implement Bloc event
      ScaffoldMessenger.of(context).showSnackBar(
      const SnackBar(content: Text('Shift declined. (Placeholder)')),
    );
  }

  @override
  Widget build(BuildContext context) {
    return BlocProvider.value(
      value: _bloc,
      child: BlocBuilder<ShiftsBloc, ShiftsState>(
        builder: (context, state) {
          final List<Shift> myShifts = (state is ShiftsLoaded) ? state.myShifts : [];
          final List<Shift> availableJobs = (state is ShiftsLoaded) ? state.availableShifts : [];
          final List<Shift> pendingAssignments = (state is ShiftsLoaded) ? state.pendingShifts : [];
          final List<Shift> historyShifts = []; // Not in state yet, placeholder

          // Filter logic from POC
          final filteredJobs = availableJobs.where((s) {
            final matchesSearch =
                s.title.toLowerCase().contains(_searchQuery.toLowerCase()) ||
                s.location.toLowerCase().contains(_searchQuery.toLowerCase()) ||
                s.clientName.toLowerCase().contains(_searchQuery.toLowerCase());

            if (!matchesSearch) return false;

            if (_jobType == 'all') return true;
            if (_jobType == 'one-day') {
              return !s.title.contains('Long Term') && !s.title.contains('Multi-Day');
            }
            if (_jobType == 'multi-day') return s.title.contains('Multi-Day');
            if (_jobType == 'long-term') return s.title.contains('Long Term');
            return true;
          }).toList();

          final calendarDays = _getCalendarDays();
          final weekStartDate = calendarDays.first;
          final weekEndDate = calendarDays.last;

          final visibleMyShifts = myShifts.where((s) {
            // Primitive check if shift date string compare
            // In real app use DateTime logic
            final sDateStr = s.date;
            final wStartStr = DateFormat('yyyy-MM-dd').format(weekStartDate);
            final wEndStr = DateFormat('yyyy-MM-dd').format(weekEndDate);
            return sDateStr.compareTo(wStartStr) >= 0 &&
                sDateStr.compareTo(wEndStr) <= 0;
          }).toList();

          return Scaffold(
            backgroundColor: AppColors.krowBackground,
            body: Column(
              children: [
                // Header (Blue)
                Container(
                  color: AppColors.krowBlue,
                  padding: EdgeInsets.fromLTRB(
                    20,
                    MediaQuery.of(context).padding.top + 20,
                    20,
                    24,
                  ),
                  child: Column(
                    children: [
                      Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          const Text(
                            "Shifts",
                            style: TextStyle(
                              fontSize: 24,
                              fontWeight: FontWeight.bold,
                              color: Colors.white,
                            ),
                          ),
                          Row(
                            children: [
                              _buildDemoButton("Demo: Cancel <4hr", const Color(0xFFEF4444), () {
                                setState(() => _cancelledShiftDemo = 'lastMinute');
                                _showCancelledModal('lastMinute');
                              }),
                              const SizedBox(width: 8),
                              _buildDemoButton("Demo: Cancel >4hr", const Color(0xFFF59E0B), () {
                                setState(() => _cancelledShiftDemo = 'advance');
                                _showCancelledModal('advance');
                              }),
                            ],
                          ),
                        ],
                      ),
                      const SizedBox(height: 16),
                      // Tabs
                      Row(
                        children: [
                          _buildTab("myshifts", "My Shifts", LucideIcons.calendar, myShifts.length),
                          const SizedBox(width: 8),
                          _buildTab("find", "Find Shifts", LucideIcons.search, filteredJobs.length),
                          const SizedBox(width: 8),
                          _buildTab("history", "History", LucideIcons.clock, historyShifts.length),
                        ],
                      ),
                    ],
                  ),
                ),

                // Calendar Selector
                if (_activeTab == 'myshifts')
                  Container(
                    color: Colors.white,
                    padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 20),
                    child: Column(
                      children: [
                        Padding(
                          padding: const EdgeInsets.only(bottom: 16),
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: [
                              InkWell(
                                onTap: () => setState(() => _weekOffset--),
                                borderRadius: BorderRadius.circular(20),
                                child: const Padding(
                                  padding: EdgeInsets.all(8.0),
                                  child: Icon(LucideIcons.chevronLeft, size: 20, color: AppColors.krowCharcoal),
                                ),
                              ),
                              Text(
                                DateFormat('MMMM yyyy').format(weekStartDate),
                                style: const TextStyle(
                                  fontSize: 16,
                                  fontWeight: FontWeight.w600,
                                  color: AppColors.krowCharcoal,
                                ),
                              ),
                              InkWell(
                                onTap: () => setState(() => _weekOffset++),
                                borderRadius: BorderRadius.circular(20),
                                child: const Padding(
                                  padding: EdgeInsets.all(8.0),
                                  child: Icon(LucideIcons.chevronRight, size: 20, color: AppColors.krowCharcoal),
                                ),
                              ),
                            ],
                          ),
                        ),
                        // Days Grid
                        Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: calendarDays.map((date) {
                             final isSelected = _isSameDay(date, _selectedDate);
                             final dateStr = DateFormat('yyyy-MM-dd').format(date);
                             final hasShifts = myShifts.any((s) => s.date == dateStr);
                             
                             return GestureDetector(
                                onTap: () => setState(() => _selectedDate = date),
                                child: Container(
                                  width: 44,
                                  padding: const EdgeInsets.symmetric(vertical: 12),
                                  decoration: BoxDecoration(
                                    color: isSelected ? AppColors.krowBlue : Colors.white,
                                    borderRadius: BorderRadius.circular(999), 
                                    border: Border.all(
                                      color: isSelected ? AppColors.krowBlue : AppColors.krowBorder,
                                      width: 1,
                                    ),
                                  ),
                                  child: Column(
                                    children: [
                                      Text(
                                        date.day.toString().padLeft(2, '0'),
                                        style: TextStyle(
                                          fontSize: 20,
                                          fontWeight: FontWeight.bold,
                                          color: isSelected ? Colors.white : AppColors.krowCharcoal,
                                        ),
                                      ),
                                      const SizedBox(height: 2),
                                      Text(
                                        DateFormat('E').format(date),
                                        style: TextStyle(
                                          fontSize: 10,
                                          fontWeight: FontWeight.w500,
                                          color: isSelected ? Colors.white.withOpacity(0.8) : AppColors.krowMuted,
                                        ),
                                      ),
                                      if (hasShifts)
                                        Container(
                                          margin: const EdgeInsets.only(top: 4),
                                          width: 6,
                                          height: 6,
                                          decoration: BoxDecoration(
                                            color: isSelected ? Colors.white : AppColors.krowBlue,
                                            shape: BoxShape.circle,
                                          ),
                                        ),
                                    ],
                                  ),
                                ),
                             );
                          }).toList(),
                        ),
                      ],
                    ),
                  ),

                if (_activeTab == 'myshifts')
                   const Divider(height: 1, color: AppColors.krowBorder),

                // Body Content
                Expanded(
                  child: SingleChildScrollView(
                    padding: const EdgeInsets.all(20),
                    child: Column(
                       children: [
                          if (_activeTab == 'find') ...[
                             // Search & Filter
                             Padding(
                               padding: const EdgeInsets.only(bottom: 12),
                               child: Container(
                                 height: 48,
                                 decoration: BoxDecoration(
                                    color: Colors.white,
                                    borderRadius: BorderRadius.circular(8),
                                    border: Border.all(color: AppColors.krowBorder),
                                    boxShadow: [
                                       BoxShadow(
                                          color: Colors.black.withOpacity(0.05),
                                          blurRadius: 4,
                                          offset: const Offset(0, 2),
                                       ),
                                    ],
                                 ),
                                 child: TextField(
                                    onChanged: (val) => setState(() => _searchQuery = val), // Local filter for now
                                    decoration: const InputDecoration(
                                       prefixIcon: Icon(LucideIcons.search, size: 20, color: AppColors.krowMuted),
                                       border: InputBorder.none,
                                       hintText: "Search jobs...",
                                       hintStyle: TextStyle(color: AppColors.krowMuted, fontSize: 14),
                                       contentPadding: EdgeInsets.symmetric(vertical: 12),
                                    ),
                                 ),
                               ),
                             ),
                             Container(
                               margin: const EdgeInsets.only(bottom: 16),
                               padding: const EdgeInsets.all(4),
                               decoration: BoxDecoration(
                                  color: const Color(0xFFF1F3F5),
                                  borderRadius: BorderRadius.circular(999),
                               ),
                               child: Row(
                                  children: [
                                     _buildFilterTab('all', 'All Jobs'),
                                     _buildFilterTab('one-day', 'One Day'),
                                     _buildFilterTab('multi-day', 'Multi-Day'),
                                     _buildFilterTab('long-term', 'Long Term'),
                                  ],
                               ),
                             ),
                          ],
                          
                          if (_activeTab == 'myshifts') ...[
                             if (pendingAssignments.isNotEmpty) ...[
                                Align(
                                  alignment: Alignment.centerLeft,
                                  child: Padding(
                                     padding: const EdgeInsets.only(bottom: 12),
                                     child: Row(
                                        children: [
                                           Container(width: 8, height: 8, decoration: const BoxDecoration(color: Color(0xFFF59E0B), shape: BoxShape.circle)),
                                           const SizedBox(width: 8),
                                           const Text("Awaiting Confirmation", style: TextStyle(
                                              fontSize: 14, fontWeight: FontWeight.w600, color: Color(0xFFD97706)
                                           )),
                                        ],
                                     ),
                                  ),
                                ),
                                ...pendingAssignments.map((shift) => Padding(
                                   padding: const EdgeInsets.only(bottom: 16),
                                   child: ShiftAssignmentCard(
                                      shift: shift,
                                      onConfirm: () => _confirmShift(shift.id),
                                      onDecline: () => _declineShift(shift.id),
                                   ),
                                )),
                             ],
                             
                             // Cancelled Shifts Demo (Visual only as per POC)
                             Align(
                                alignment: Alignment.centerLeft,
                                child: Padding(
                                   padding: const EdgeInsets.only(bottom: 12),
                                   child: const Text("Cancelled Shifts", style: TextStyle(
                                      fontSize: 14, fontWeight: FontWeight.w600, color: AppColors.krowMuted
                                   )),
                                ),
                             ),
                             _buildCancelledCard(
                                title: "Annual Tech Conference", client: "TechCorp Inc.", pay: "\$200", rate: "\$25/hr · 8h",
                                date: "Today", time: "10:00 AM - 6:00 PM", address: "123 Convention Center Dr", isLastMinute: true,
                                onTap: () => setState(() => _cancelledShiftDemo = 'lastMinute')
                             ),
                             const SizedBox(height: 12),
                             _buildCancelledCard(
                                title: "Morning Catering Setup", client: "EventPro Services", pay: "\$120", rate: "\$20/hr · 6h",
                                date: "Tomorrow", time: "8:00 AM - 2:00 PM", address: "456 Grand Ballroom Ave", isLastMinute: false,
                                onTap: () => setState(() => _cancelledShiftDemo = 'advance')
                             ),
                             const SizedBox(height: 24),
                             
                             // Confirmed Shifts
                             if (visibleMyShifts.isNotEmpty) ...[
                                 Align(
                                    alignment: Alignment.centerLeft,
                                    child: Padding(
                                       padding: const EdgeInsets.only(bottom: 12),
                                       child: const Text("Confirmed Shifts", style: TextStyle(
                                          fontSize: 14, fontWeight: FontWeight.w600, color: AppColors.krowMuted
                                       )),
                                    ),
                                 ),
                                 ...visibleMyShifts.map((shift) => Padding(
                                    padding: const EdgeInsets.only(bottom: 12),
                                    child: MyShiftCard(shift: shift),
                                 )),
                             ],
                          ],
                          
                          if (_activeTab == 'find') ...[
                             if (filteredJobs.isEmpty)
                                _buildEmptyState(LucideIcons.search, "No jobs available", "Check back later", null, null)
                             else
                                ...filteredJobs.map((shift) => MyShiftCard(
                                   shift: shift,
                                   onAccept: () {},
                                   onDecline: () {},
                                )),
                          ],
                          
                          if (_activeTab == 'history')
                             _buildEmptyState(LucideIcons.clock, "No shift history", "Completed shifts appear here", null, null),
                       ],
                    ),
                  ),
                ),
              ],
            ),
          );
        },
      ),
    );
  }

  Widget _buildFilterTab(String id, String label) {
    final isSelected = _jobType == id;
    return Expanded(
      child: GestureDetector(
        onTap: () => setState(() => _jobType = id),
        child: Container(
          padding: const EdgeInsets.symmetric(vertical: 8),
          decoration: BoxDecoration(
            color: isSelected ? AppColors.krowBlue : Colors.transparent,
            borderRadius: BorderRadius.circular(999),
            boxShadow: isSelected ? [BoxShadow(color: AppColors.krowBlue.withOpacity(0.2), blurRadius: 4, offset: const Offset(0, 2))] : null,
          ),
          child: Text(label, textAlign: TextAlign.center, style: TextStyle(
             fontSize: 11, fontWeight: FontWeight.w600, color: isSelected ? Colors.white : AppColors.krowMuted
          )),
        ),
      ),
    );
  }

  Widget _buildTab(String id, String label, IconData icon, int count) {
    final isActive = _activeTab == id;
    return Expanded(
      child: GestureDetector(
        onTap: () => setState(() => _activeTab = id),
        child: Container(
          padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 8),
          decoration: BoxDecoration(
             color: isActive ? Colors.white : Colors.white.withAlpha((0.2 * 255).round()),
             borderRadius: BorderRadius.circular(8),
          ),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.center,
            mainAxisSize: MainAxisSize.min,
            children: [
               Icon(icon, size: 14, color: isActive ? AppColors.krowBlue : Colors.white),
               const SizedBox(width: 6),
               Flexible(child: Text(label, style: TextStyle(fontSize: 13, fontWeight: FontWeight.w500, color: isActive ? AppColors.krowBlue : Colors.white), overflow: TextOverflow.ellipsis)),
               const SizedBox(width: 4),
               Container(
                  padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
                  constraints: const BoxConstraints(minWidth: 18),
                  decoration: BoxDecoration(
                     color: isActive ? AppColors.krowBlue.withAlpha((0.1 * 255).round()) : Colors.white.withAlpha((0.2 * 255).round()),
                     borderRadius: BorderRadius.circular(999),
                  ),
                  child: Center(child: Text("$count", style: TextStyle(fontSize: 10, fontWeight: FontWeight.bold, color: isActive ? AppColors.krowBlue : Colors.white))),
               ),
            ],
          ),
        ),
      ),
    );
  }

  Widget _buildDemoButton(String label, Color color, VoidCallback onTap) {
    return GestureDetector(
       onTap: onTap,
       child: Container(
          padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
          decoration: BoxDecoration(color: color, borderRadius: BorderRadius.circular(4)),
          child: Text(label, style: const TextStyle(fontSize: 10, fontWeight: FontWeight.bold, color: Colors.white)),
       ),
    );
  }

  Widget _buildEmptyState(IconData icon, String title, String subtitle, String? actionLabel, VoidCallback? onAction) {
    return Center(child: Padding(padding: const EdgeInsets.symmetric(vertical: 64), child: Column(children: [
       Container(width: 64, height: 64, decoration: BoxDecoration(color: const Color(0xFFF1F3F5), borderRadius: BorderRadius.circular(12)), child: Icon(icon, size: 32, color: AppColors.krowMuted)),
       const SizedBox(height: 16),
       Text(title, style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w500, color: AppColors.krowCharcoal)),
       const SizedBox(height: 4),
       Text(subtitle, style: const TextStyle(fontSize: 14, color: AppColors.krowMuted)),
       if (actionLabel != null && onAction != null) ...[
          const SizedBox(height: 16),
          ElevatedButton(onPressed: onAction, style: ElevatedButton.styleFrom(backgroundColor: AppColors.krowBlue, foregroundColor: Colors.white, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))), child: Text(actionLabel)),
       ]
    ])));
  }

  Widget _buildCancelledCard({required String title, required String client, required String pay, required String rate, required String date, required String time, required String address, required bool isLastMinute, required VoidCallback onTap}) {
    return GestureDetector(
       onTap: onTap,
       child: Container(padding: const EdgeInsets.all(16), decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(16), border: Border.all(color: AppColors.krowBorder)), child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
          Row(children: [Container(width: 6, height: 6, decoration: const BoxDecoration(color: Color(0xFFEF4444), shape: BoxShape.circle)), const SizedBox(width: 6), const Text("CANCELLED", style: TextStyle(fontSize: 10, fontWeight: FontWeight.bold, color: Color(0xFFEF4444))), if (isLastMinute) ...[const SizedBox(width: 4), const Text("• 4hr compensation", style: TextStyle(fontSize: 10, fontWeight: FontWeight.w500, color: Color(0xFF10B981)))]]),
          const SizedBox(height: 12),
          Row(crossAxisAlignment: CrossAxisAlignment.start, children: [
             Container(width: 44, height: 44, decoration: BoxDecoration(gradient: LinearGradient(begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [AppColors.krowBlue.withAlpha((0.15 * 255).round()), AppColors.krowBlue.withAlpha((0.08 * 255).round())]), borderRadius: BorderRadius.circular(12), border: Border.all(color: AppColors.krowBlue.withAlpha((0.15 * 255).round()))), child: const Center(child: Icon(LucideIcons.briefcase, color: AppColors.krowBlue, size: 20))),
             const SizedBox(width: 12),
             Expanded(child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
                Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [Expanded(child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [Text(title, style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: AppColors.krowCharcoal)), Text(client, style: const TextStyle(fontSize: 12, color: AppColors.krowMuted))])), Column(crossAxisAlignment: CrossAxisAlignment.end, children: [Text(pay, style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold, color: AppColors.krowCharcoal)), Text(rate, style: const TextStyle(fontSize: 10, color: AppColors.krowMuted))])]),
                const SizedBox(height: 8),
                Row(children: [const Icon(LucideIcons.calendar, size: 12, color: AppColors.krowMuted), const SizedBox(width: 4), Text(date, style: const TextStyle(fontSize: 12, color: AppColors.krowMuted)), const SizedBox(width: 12), const Icon(LucideIcons.clock, size: 12, color: AppColors.krowMuted), const SizedBox(width: 4), Text(time, style: const TextStyle(fontSize: 12, color: AppColors.krowMuted))]),
                const SizedBox(height: 4),
                Row(children: [const Icon(LucideIcons.mapPin, size: 12, color: AppColors.krowMuted), const SizedBox(width: 4), Expanded(child: Text(address, style: const TextStyle(fontSize: 12, color: AppColors.krowMuted), overflow: TextOverflow.ellipsis))]),
             ])),
          ]),
       ])),
    );
  }

  void _showCancelledModal(String type) {
    final isLastMinute = type == 'lastMinute';
    showDialog(
      context: context,
      builder: (context) => AlertDialog(
        shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
        title: Row(
          children: [
            const Icon(LucideIcons.xCircle, color: Color(0xFFEF4444)),
            const SizedBox(width: 8),
            const Text("Shift Cancelled"),
          ],
        ),
        content: Column(
          mainAxisSize: MainAxisSize.min,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            const Text(
              "We're sorry, but the following shift has been cancelled by the client:",
              style: TextStyle(fontSize: 14),
            ),
            const SizedBox(height: 12),
            Container(
              padding: const EdgeInsets.all(12),
              decoration: BoxDecoration(
                color: Colors.grey.shade50,
                borderRadius: BorderRadius.circular(8),
                border: Border.all(color: Colors.grey.shade200),
              ),
              child: const Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text("Annual Tech Conference", style: TextStyle(fontWeight: FontWeight.bold)),
                  Text("Today, 10:00 AM - 6:00 PM"),
                ],
              ),
            ),
            const SizedBox(height: 16),
            if (isLastMinute)
              Container(
                padding: const EdgeInsets.all(12),
                decoration: BoxDecoration(
                  color: const Color(0xFFECFDF5),
                  borderRadius: BorderRadius.circular(8),
                  border: Border.all(color: const Color(0xFF10B981)),
                ),
                child: const Row(
                  children: [
                    Icon(LucideIcons.checkCircle, color: Color(0xFF10B981), size: 16),
                    SizedBox(width: 8),
                    Expanded(
                      child: Text(
                        "You are eligible for 4hr cancellation compensation.",
                        style: TextStyle(
                            fontSize: 12, color: Color(0xFF065F46), fontWeight: FontWeight.w500),
                      ),
                    ),
                  ],
                ),
              )
            else
              const Text(
                "Reduced schedule at the venue. No compensation is due as this was cancelled more than 4 hours in advance.",
                style: TextStyle(fontSize: 12, color: AppColors.krowMuted),
              ),
          ],
        ),
        actions: [
          TextButton(
            onPressed: () => Navigator.pop(context),
            child: const Text("Close"),
          ),
        ],
      ),
    );
  }
}
