import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import '../../../core/auth/auth_notifier.dart';
import '../../../core/theme/halo_tokens.dart';
import '../../../core/theme/widgets/widgets.dart';

/// Terminal state shown when OTP verification succeeds but the mitra's
/// account is not yet approved (`ACCOUNT_INACTIVE` 403 from the backend).
///
/// Mitras are onboarded internally and reach out via their existing
/// internal channel — no public WhatsApp/Telegram CTAs here.
class AccountInactiveScreen extends ConsumerWidget {
  const AccountInactiveScreen({super.key});

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    return PopScope(
      canPop: false,
      child: Scaffold(
        backgroundColor: HaloTokens.bg,
        body: SafeArea(
          child: Padding(
            padding: const EdgeInsets.fromLTRB(28, 8, 28, 28),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.stretch,
              children: [
                const Expanded(
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    crossAxisAlignment: CrossAxisAlignment.stretch,
                    children: [
                      Center(
                        child: Text(
                          '⏳',
                          style: TextStyle(fontSize: 56),
                        ),
                      ),
                      SizedBox(height: 24),
                      Text(
                        'akun belum aktif',
                        textAlign: TextAlign.center,
                        style: TextStyle(
                          fontFamily: HaloTokens.fontDisplay,
                          fontSize: 28,
                          fontWeight: FontWeight.w700,
                          color: HaloTokens.brandDark,
                          height: 1.15,
                          letterSpacing: -0.56,
                        ),
                      ),
                      SizedBox(height: 12),
                      Text(
                        'tim halobestie sedang memverifikasi akun kamu. '
                        'hubungi koordinator kalau butuh update.',
                        textAlign: TextAlign.center,
                        style: TextStyle(
                          fontFamily: HaloTokens.fontBody,
                          fontSize: 14.5,
                          color: HaloTokens.inkSoft,
                          height: 1.5,
                        ),
                      ),
                    ],
                  ),
                ),
                HaloButton(
                  label: 'pakai nomor lain',
                  variant: HaloButtonVariant.secondary,
                  fullWidth: true,
                  onPressed: () async {
                    await ref.read(mitraAuthProvider.notifier).logout();
                    if (context.mounted) context.go('/login');
                  },
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
