package com.example.iplace.main.viewModel.mainView

import android.telephony.ims.RegistrationManager
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Card
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.navigation.NavHostController
import com.example.iplace.R
import com.example.iplace.main.viewModel.MainViewModel
import com.example.iplace.ui.theme.beige_white
import com.example.iplace.ui.theme.brown_contrast

@Composable
fun Registration(navController: NavHostController) {
    val viewModel = MainViewModel()
    val headlinesOswald = FontFamily( //загрузка шрифта
        Font(resId = R.font.headlines_oswald)
    )
    val basicNunitosans = FontFamily(
        Font(resId = R.font.basic_nunitosans)
    )

    Column(
        modifier = Modifier
            .fillMaxSize()
            .background(Color.White),
        verticalArrangement = Arrangement.Top,
        horizontalAlignment = Alignment.CenterHorizontally
    ) {
        Spacer(modifier = Modifier.height(60.dp)) //отступ между блоками
        Text(
            text = "I.PLACE",
            fontSize = 45.sp,
            fontWeight = FontWeight.Bold,
            fontFamily = headlinesOswald
        )
        Spacer(modifier = Modifier.height(55.dp))
        Card(
            modifier = Modifier
                .width(350.dp)
                .height(485.dp)
                .clip(RoundedCornerShape(40.dp))
                .background(beige_white)
//        .alpha(0.8f) //возможная прозрачность формы
        ) {
            Column(
                modifier = Modifier.fillMaxSize(),
                verticalArrangement = Arrangement.Top,
                horizontalAlignment = Alignment.CenterHorizontally
            ) {
                Spacer(modifier = Modifier.height(5.dp)) // Отступ от заголовка

                Row(
                    verticalAlignment = Alignment.CenterVertically,
                    modifier = Modifier.fillMaxWidth()
                ) {
                    IconButton(onClick = { navController.navigate("selectEnter") }) {
                        Icon(
                            imageVector = Icons.Default.ArrowBack, // Или другой иконки
                            contentDescription = "Назад",
                            modifier = Modifier.padding(top = 20.dp)
                        )
                    }
                    Spacer(modifier = Modifier.width(90.dp)) // Отступ между кнопкой и текстом
                    Text(
                        text = "Регистрация",
                        fontWeight = FontWeight.Bold,
                        fontFamily = headlinesOswald,
                        modifier = Modifier.padding(top = 20.dp) // Отступ сверху
                    )
                }

                Spacer(modifier = Modifier.height(40.dp)) // Отступ от заголовка

                OutlinedTextField(
                    value = "",
                    onValueChange = {},
                    label = { Text("Логин") },
                    modifier = Modifier
                        .fillMaxWidth()
                        .padding(horizontal = 16.dp)
                        .clip(RoundedCornerShape(20.dp))
                )

                Spacer(modifier = Modifier.height(10.dp))

                OutlinedTextField(
                    value = "",
                    onValueChange = {},
                    label = { Text("Пароль") },
                    modifier = Modifier
                        .fillMaxWidth()
                        .padding(horizontal = 16.dp)
                        .clip(RoundedCornerShape(20.dp))
                )
                Spacer(modifier = Modifier.height(10.dp))

                OutlinedTextField(
                    value = "",
                    onValueChange = {},
                    label = { Text("Повторите пароль") },
                    modifier = Modifier
                        .fillMaxWidth()
                        .padding(horizontal = 16.dp)
                        .clip(RoundedCornerShape(20.dp))
                )



                Spacer(modifier = Modifier.height(20.dp))

                Button(
                    onClick = { navController.navigate("creatingUser") },
                    modifier = Modifier.width(290.dp).height(50.dp),
                    colors = ButtonDefaults.buttonColors(brown_contrast)
                ) {
                    Text(
                        text = "Дальше",
                        fontSize = 24.sp,
                        fontFamily = basicNunitosans
                    )
                }

                Spacer(modifier = Modifier.height(16.dp)) // Отступ снизу
            }
        }
    }
}