import 'package:flutter/material.dart';

void main() {
  runApp(NetpcSpaceApp());
}

class NetpcSpaceApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'netpc.space',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        // Set 'Neue Machina' as the default font
        fontFamily: 'NeueMachina',
        primaryColor: Color(0xFFF497C8),
        scaffoldBackgroundColor: Color(0xFF090014),
        inputDecorationTheme: InputDecorationTheme(
          filled: true,
          fillColor: Colors.transparent,
          enabledBorder: OutlineInputBorder(
            borderRadius: BorderRadius.circular(10),
            borderSide: BorderSide(color: Colors.grey, width: 1),
          ),
          focusedBorder: OutlineInputBorder(
            borderRadius: BorderRadius.circular(10),
            borderSide: BorderSide(color: Color(0xFFF497C8), width: 2),
          ),
          prefixIconColor: Colors.grey,
          hintStyle: TextStyle(color: Colors.grey),
          labelStyle: TextStyle(color: Colors.white),
        ),
      ),
      home: LoginPage(),
    );
  }
}

class LoginPage extends StatefulWidget {
  @override
  State<LoginPage> createState() => _LoginPageState();
}

class _LoginPageState extends State<LoginPage> {
  bool isRegister = false;

  // Controllers for text fields
  final TextEditingController loginController = TextEditingController();
  final TextEditingController passwordController = TextEditingController();
  final TextEditingController usernameController = TextEditingController();

  // Function to handle form submission
  void handleSubmit() {
    if (isRegister) {
      // Handle registration API call
      String username = usernameController.text;
      String login = loginController.text;
      String password = passwordController.text;
      // TODO: Implement API call for registration
      print('Register: $username, $login, $password');
    } else {
      // Handle login API call
      String login = loginController.text;
      String password = passwordController.text;
      // TODO: Implement API call for login
      print('Login: $login, $password');
    }
  }

  @override
  Widget build(BuildContext context) {
    // Retrieve screen size for responsive design
    final Size screenSize = MediaQuery.of(context).size;

    return Scaffold(
      backgroundColor: Color(0xFF090014),
      body: Center(
        child: Stack(
          children: [
            // Light Effect at Top-Left
            Positioned(
              top: -screenSize.width * 0.1, // Positioning partially outside
              left: -screenSize.width * 0.1,
              child: Container(
                width: screenSize.width * 0.2, // 20% of screen width
                height: screenSize.width * 0.2, // Maintain square
                decoration: BoxDecoration(
                  color: Color(0xFFF497C8).withOpacity(0.5),
                  shape: BoxShape.circle,
                  boxShadow: [
                    BoxShadow(
                      color: Color(0xFFF497C8).withOpacity(0.3),
                      blurRadius: 50,
                      spreadRadius: 20,
                    ),
                  ],
                ),
              ),
            ),
            // Light Effect at Bottom-Right
            Positioned(
              bottom: -screenSize.width * 0.1,
              right: -screenSize.width * 0.1,
              child: Container(
                width: screenSize.width * 0.2, // 20% of screen width
                height: screenSize.width * 0.2, // Maintain square
                decoration: BoxDecoration(
                  color: Color(0xFFF497C8).withOpacity(0.5),
                  shape: BoxShape.circle,
                  boxShadow: [
                    BoxShadow(
                      color: Color(0xFFF497C8).withOpacity(0.3),
                      blurRadius: 50,
                      spreadRadius: 20,
                    ),
                  ],
                ),
              ),
            ),
            // Central Transparent Card with Background Image
            Center(
              child: Container(
                width: screenSize.width * 0.8, // 80% of screen width
                constraints: BoxConstraints(
                  maxWidth: 400, // Maximum width for larger screens
                ),
                padding: EdgeInsets.all(24),
                decoration: BoxDecoration(
                  image: DecorationImage(
                    image: AssetImage('assets/images/card_background.png'),
                    fit: BoxFit.cover,
                    colorFilter: ColorFilter.mode(
                      Colors.black.withOpacity(0.5),
                      BlendMode.darken,
                    ), // Optional: Darken the image for better readability
                  ),
                  borderRadius: BorderRadius.circular(16),
                  border: Border.all(color: Colors.grey, width: 1),
                ),
                child: SingleChildScrollView(
                  child: Column(
                    mainAxisSize: MainAxisSize.min,
                    children: [
                      // Centered Title
                      Text(
                        'netpc.space',
                        style: TextStyle(
                          fontSize: 28,
                          color: Colors.white,
                          fontWeight: FontWeight.bold,
                        ),
                        textAlign: TextAlign.center,
                      ),
                      SizedBox(height: 40),
                      // Username Field (only in Register)
                      if (isRegister)
                        TextField(
                          controller: usernameController,
                          decoration: InputDecoration(
                            hintText: 'Username',
                            prefixIcon: Icon(Icons.person),
                          ),
                        ),
                      if (isRegister) SizedBox(height: 20),
                      // Login Field
                      TextField(
                        controller: loginController,
                        decoration: InputDecoration(
                          hintText: 'Email',
                          prefixIcon: Icon(Icons.email),
                        ),
                        keyboardType: TextInputType.emailAddress,
                      ),
                      SizedBox(height: 20),
                      // Password Field (always visible)
                      TextField(
                        controller: passwordController,
                        decoration: InputDecoration(
                          hintText: 'Password',
                          prefixIcon: Icon(Icons.lock),
                        ),
                        obscureText: true,
                      ),
                      SizedBox(height: 40),
                      // Submit Button
                      SizedBox(
                        width: double.infinity,
                        height: 50,
                        child: ElevatedButton(
                          onPressed: handleSubmit,
                          style: ElevatedButton.styleFrom(
                            foregroundColor: Color(0xFFF497C8),
                            backgroundColor: Colors.transparent,
                            side:
                                BorderSide(color: Color(0xFFF497C8), width: 2),
                            shape: RoundedRectangleBorder(
                              borderRadius: BorderRadius.circular(12),
                            ),
                          ),
                          child: Text(
                            isRegister ? 'Register' : 'Login',
                            style: TextStyle(
                              fontSize: 18,
                              color: Color(0xFFF497C8),
                              fontFamily:
                                  'NeueMachina', // Ensuring font is applied
                            ),
                          ),
                        ),
                      ),
                      SizedBox(height: 20),
                      // Register and Forgot Password Buttons
                      Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          // Register Button
                          TextButton(
                            onPressed: () {
                              setState(() {
                                isRegister = true;
                              });
                            },
                            child: Text(
                              'Register',
                              style: TextStyle(
                                color: Color(0xFFF497C8),
                                decoration: TextDecoration.underline,
                                fontFamily: 'NeueMachina',
                              ),
                            ),
                          ),
                          // Forgot Password Button
                          TextButton(
                            onPressed: () {
                              // Navigate to Forgot Password page or handle accordingly
                              print('Forgot Password tapped');
                            },
                            child: Text(
                              'Forgot Password?',
                              style: TextStyle(
                                color: Color(0xFFF497C8),
                                decoration: TextDecoration.underline,
                                fontFamily: 'NeueMachina',
                              ),
                            ),
                          ),
                        ],
                      ),
                      // If in Register mode, show an option to switch back to Login
                      if (isRegister) SizedBox(height: 10),
                      if (isRegister)
                        TextButton(
                          onPressed: () {
                            setState(() {
                              isRegister = false;
                            });
                          },
                          child: Text(
                            'Already have an account? Login',
                            style: TextStyle(
                              color: Color(0xFFF497C8),
                              decoration: TextDecoration.underline,
                              fontFamily: 'NeueMachina',
                            ),
                          ),
                        ),
                    ],
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}


card has max w734 h600 remove two lights lol