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 'Onest' as the default font
        fontFamily: 'Onest',
        primaryColor: Color(0xFFF497C8),
        scaffoldBackgroundColor: Color.fromARGB(255, 8, 0, 17),
        inputDecorationTheme: InputDecorationTheme(
          filled: true,
          fillColor: Colors.transparent,
          enabledBorder: OutlineInputBorder(
            borderRadius: BorderRadius.circular(7),
            borderSide: BorderSide(
              color: Colors.grey,
              width: 0.2, // Increased width for better visibility
            ),
          ),
          focusedBorder: OutlineInputBorder(
            borderRadius: BorderRadius.circular(10),
            borderSide: BorderSide(
              color: Color(0xFFF497C8),
              width: 0.3, // Increased width for better focus indication
            ),
          ),
          prefixIconColor: Colors.grey,
          hintStyle: TextStyle(
            color: Colors.grey,
            fontSize: 16, // Increased hint text size
          ),
          labelStyle: TextStyle(
            color: Colors.white,
            fontSize: 16, // Increased label text size
          ),
        ),
        textTheme: TextTheme(
          // Define text styles for different text elements
          labelLarge: TextStyle(
            fontFamily: 'NeueMachina',
            fontSize: 16, // Increased font size for labels
            color: Colors.white,
          ),
          bodyMedium: TextStyle(
            fontFamily: 'NeueMachina',
            fontSize: 16, // Increased font size for body text
            color: Colors.white,
          ),
          titleLarge: TextStyle(
            fontFamily: 'NeueMachina',
            fontSize: 28,
            fontWeight: FontWeight.bold,
            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) {
    // Define static card size
    final double cardWidth = 734;
    final double cardHeight = 600;

    return Scaffold(
      backgroundColor: Color.fromARGB(255, 7, 0, 14),
      body: Center(
        child: Container(
          width: cardWidth, // Fixed width
          height: cardHeight, // Fixed height
          padding: EdgeInsets.all(24),
          decoration: BoxDecoration(
            image: DecorationImage(
              image: AssetImage('assets/images/card_background.png'),
              fit: BoxFit.cover,
              colorFilter: ColorFilter.mode(
                const Color.fromARGB(255, 6, 0, 12).withOpacity(0.5),
                BlendMode.darken,
              ), // Optional: Darken the image for better readability
            ),
            borderRadius: BorderRadius.circular(16), // Smooth border radius
            border: Border.all(
              color: Color.fromARGB(255, 41, 40, 42),
              width: 0.2, // Improved border visibility
            ),
          ),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              // Centered Title
              Text(
                'netpc.space',
                style: Theme.of(context).textTheme.titleLarge,
                textAlign: TextAlign.center,
              ),
              SizedBox(height: 20),
              // Username Field (only in Register)
              if (isRegister) ...[
                TextField(
                  controller: usernameController,
                  decoration: InputDecoration(
                    hintText: 'введите ваш никнейм',
                    prefixIcon:
                        Icon(Icons.alternate_email), // More relevant icon
                  ),
                  style: TextStyle(
                    fontSize: 16, // Increased text size
                    color: Colors.white,
                  ),
                ),
                SizedBox(height: 20),
              ],
              // Login Field
              TextField(
                controller: loginController,
                decoration: InputDecoration(
                  hintText: 'введите вашу электронную почту',
                  prefixIcon: Icon(Icons.alternate_email), // More relevant icon
                ),
                keyboardType: TextInputType.emailAddress,
                style: TextStyle(
                  fontSize: 16, // Increased text size
                  color: Colors.white,
                ),
              ),
              SizedBox(height: 20),
              // Password Field (always visible)
              TextField(
                controller: passwordController,
                decoration: InputDecoration(
                  hintText: 'введите ваш пароль',
                  prefixIcon: Icon(Icons
                      .alternate_email), // Changed icon for better relevance
                ),
                obscureText: false,
                style: TextStyle(
                  fontSize: 12, // Increased text size
                  color: Colors.white,
                ),
              ),
              SizedBox(height: 40),
              // Submit Button
              SizedBox(
                width: double.infinity,
                height: 50,
                child: ElevatedButton(
                  onPressed: handleSubmit,
                  style: ElevatedButton.styleFrom(
                    foregroundColor: Color.fromARGB(255, 239, 239, 239),
                    backgroundColor: Colors.transparent,
                    side: BorderSide(
                        color: Color.fromARGB(255, 255, 255, 255),
                        width: 0.1), // Increased border width and changed color
                    shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(6),
                    ),
                  ),
                  child: Text(
                    isRegister
                        ? 'зарегистрировать новый аккаунт'
                        : 'перейти в биллинг',
                    style: TextStyle(
                      fontSize: 17, // Increased font size
                      color: Colors.white,
                      fontFamily: 'Onest', // 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(
                      'Зарегистрироваться',
                      style: TextStyle(
                        color: Colors.white,
                        decoration: TextDecoration.underline,
                        fontFamily: 'Onest',
                        fontSize: 16, // Set font size
                      ),
                    ),
                  ),
                  // Forgot Password Button
                  TextButton(
                    onPressed: () {
                      // Navigate to Forgot Password page or handle accordingly
                      print('Forgot Password tapped');
                    },
                    child: Text(
                      'Забыли пароль?',
                      style: TextStyle(
                        color: Colors.white,
                        decoration: TextDecoration.underline,
                        fontFamily: 'Onest',
                        fontSize: 16, // Set font size
                      ),
                    ),
                  ),
                ],
              ),
              // If in Register mode, show an option to switch back to Login
              if (isRegister) ...[
                SizedBox(height: 10),
                TextButton(
                  onPressed: () {
                    setState(() {
                      isRegister = false;
                    });
                  },
                  child: Text(
                    'Уже есть аккаунт? Войти',
                    style: TextStyle(
                      color: Colors.white,
                      decoration: TextDecoration.underline,
                      fontFamily: 'Onest',
                      fontSize: 16, // Set font size
                    ),
                  ),
                ),
              ],
            ],
          ),
        ),
      ),
    );
  }
}


we'll make text field's bigger two time's also font will be smaller