import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:niogu_app/core/constants/app_color.dart';
import 'package:niogu_app/core/constants/app_font_size.dart';
import 'package:niogu_app/core/router/app_route.dart';
import 'package:sizer/sizer.dart';

class LoginRequired {
  static void showLoginRequired(BuildContext context) {
    showDialog(
      context: context,
      builder: (context) {
        final bool isTablet = 100.w >= 600;

        return Dialog(
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(5.w),
          ),
          backgroundColor: Colors.white,
          child: Padding(
            padding: EdgeInsets.all(6.w),
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: [
                Container(
                  padding: EdgeInsets.all(4.w),
                  decoration: BoxDecoration(
                    color: Colors.blue[50],
                    shape: BoxShape.circle,
                  ),
                  child: Icon(
                    Icons.lock_person_rounded,
                    color: AppColor.primaryColor,
                    size: 12.w,
                  ),
                ),

                SizedBox(height: 3.h),

                Text(
                  "Akses Terbatas",
                  style: TextStyle(
                    fontSize: (AppFontSize.medium - (isTablet ? 0 : 1.25)).sp,
                    fontWeight: FontWeight.bold,
                    color: AppColor.primaryColor,
                  ),
                ),
                SizedBox(height: 1.5.h),
                Text(
                  "Masuk ke akun terlebih dahulu untuk mengakses fitur ini.",
                  textAlign: TextAlign.center,
                  style: TextStyle(
                    fontSize: isTablet
                        ? AppFontSize.medium.sp
                        : AppFontSize.small.sp,
                    color: Colors.grey[600],
                    height: 1.5,
                  ),
                ),

                SizedBox(height: 4.h),

                ElevatedButton(
                  onPressed: () {
                    context.pop();
                    context.goNamed(AppRoute.ownerLoginScreen);
                  },
                  style: ElevatedButton.styleFrom(
                    backgroundColor: AppColor.primaryColor,
                    minimumSize: Size(double.infinity, 6.5.h),
                    shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(3.w),
                    ),
                    elevation: 0,
                  ),
                  child: Text(
                    "Masuk Akun",
                    style: TextStyle(
                      color: Colors.white,
                      fontWeight: FontWeight.bold,
                      fontSize: AppFontSize.medium.sp,
                    ),
                  ),
                ),

                SizedBox(height: 1.5.h),

                TextButton(
                  onPressed: () => context.pop(),
                  child: Text(
                    "Nanti Saja",
                    style: TextStyle(
                      color: Colors.grey,
                      fontWeight: FontWeight.w500,
                      fontSize: AppFontSize.medium.sp,
                    ),
                  ),
                ),
              ],
            ),
          ),
        );
      },
    );
  }
}
