// lib/screens/tickets_booked_screen.dart
import 'package:flutter/material.dart';

class TicketsBookedScreen extends StatelessWidget {
  const TicketsBookedScreen({Key? key}) : super(key: key);

  void _onScannerTap(BuildContext context) {
    ScaffoldMessenger.of(context).showSnackBar(
      SnackBar(content: Text('Scanner tapped (demo)')),
    );
  }

  void _onWhatsappTap(BuildContext context) {
    ScaffoldMessenger.of(context).showSnackBar(
      SnackBar(content: Text('Chat/WhatsApp tapped (demo)')),
    );
  }

  void _onCallTap(BuildContext context) {
    ScaffoldMessenger.of(context).showSnackBar(
      SnackBar(content: Text('Call tapped (demo)')),
    );
  }

  @override
  Widget build(BuildContext context) {
    final Color bg = Color(0xFFF7F5FB); // app background
    final Color primary = Color(0xFF0B63D6); // blue theme

    return Scaffold(
      backgroundColor: bg,
      appBar: AppBar(
        backgroundColor: bg,
        elevation: 0,
        iconTheme: IconThemeData(color: Colors.black87),
        title: Text('Tickets Booked', style: TextStyle(color: Colors.black87)),
        centerTitle: false,
      ),
      body: SafeArea(
        child: Column(
          children: [
            SizedBox(height: 36),

            // Confirmation text
            Center(
              child: Column(
                children: [
                  Text(
                    'Your tickets have been booked!',
                    style: TextStyle(fontSize: 20, fontWeight: FontWeight.w600, color: Colors.black87),
                  ),
                  SizedBox(height: 10),
                  Text(
                    'Enjoy the event.',
                    style: TextStyle(fontSize: 14, color: Colors.black54),
                  ),
                ],
              ),
            ),

            SizedBox(height: 36),

            // Row of rounded blue icons
            Padding(
              padding: const EdgeInsets.symmetric(horizontal: 28.0),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: [
                  _actionButton(context, primary, Icons.qr_code_scanner, 'Scanner', _onScannerTap),
                  _actionButton(context, primary, Icons.chat, 'Chat', _onWhatsappTap), // 👈 replaced
                  _actionButton(context, primary, Icons.call, 'Call', _onCallTap),
                ],
              ),
            ),

            SizedBox(height: 28),

            Padding(
              padding: const EdgeInsets.symmetric(horizontal: 28.0),
              child: Text(
                'Save this confirmation — you may need it at the venue.\nUse the buttons above to share or show your ticket.',
                textAlign: TextAlign.center,
                style: TextStyle(color: Colors.black54),
              ),
            ),

            Spacer(),

            // Return to Home button
            Padding(
              padding: const EdgeInsets.only(bottom: 22.0),
              child: ElevatedButton(
                onPressed: () {
                  Navigator.of(context).popUntil((route) => route.isFirst);
                },
                style: ElevatedButton.styleFrom(
                  backgroundColor: primary,
                  padding: EdgeInsets.symmetric(horizontal: 28, vertical: 14),
                  shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)),
                ),
                child: Text('Return to Home', style: TextStyle(color: Colors.white)),
              ),
            ),
          ],
        ),
      ),
    );
  }

  // helper
  Widget _actionButton(
      BuildContext context, Color color, IconData icon, String label, Function onTap) {
    return Column(
      children: [
        InkWell(
          onTap: () => onTap(context),
          borderRadius: BorderRadius.circular(16),
          child: Container(
            width: 72,
            height: 72,
            decoration: BoxDecoration(
              color: color,
              borderRadius: BorderRadius.circular(16),
              boxShadow: [BoxShadow(color: Colors.black12, blurRadius: 8, offset: Offset(0, 4))],
            ),
            child: Center(child: Icon(icon, color: Colors.white, size: 30)),
          ),
        ),
        SizedBox(height: 10),
        Text(label, style: TextStyle(color: Colors.black87)),
      ],
    );
  }
}
