<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/bg_auth_screen"
    android:padding="0dp">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/authCard"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:background="@color/brand_window_bg"
        android:clipToPadding="false"
        android:paddingHorizontal="24dp"
        android:paddingTop="28dp"
        android:paddingBottom="24dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <LinearLayout
            android:id="@+id/authContent"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:gravity="center_horizontal|center_vertical"
            android:orientation="vertical"
            android:paddingTop="8dp"
            app:layout_constraintBottom_toTopOf="@id/authFooter"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintWidth_max="520dp">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center_vertical"
                android:orientation="horizontal">

                <FrameLayout
                    android:layout_width="52dp"
                    android:layout_height="52dp"
                    android:background="@drawable/bg_auth_logo">

                    <ImageView
                        android:layout_width="28dp"
                        android:layout_height="28dp"
                        android:layout_gravity="center"
                        android:contentDescription="@null"
                        android:src="@drawable/ic_person_24"
                        app:tint="@color/brand_purple" />
                </FrameLayout>

                <View
                    android:layout_width="0dp"
                    android:layout_height="1dp"
                    android:layout_weight="1" />

                <Spinner
                    android:id="@+id/authLangSpinner"
                    android:layout_width="wrap_content"
                    android:layout_height="@dimen/language_picker_height"
                    android:background="@drawable/bg_control_chip_dropdown"
                    android:minWidth="@dimen/language_picker_min_width"
                    android:popupBackground="@drawable/bg_spinner_popup" />
            </LinearLayout>

            <TextView
                android:id="@+id/authTitle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="34dp"
                android:gravity="start"
                android:textColor="@color/brand_text_dark"
                android:textSize="26sp"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/authSubtitle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:gravity="start"
                android:lineSpacingExtra="2dp"
                android:textColor="@color/brand_text_muted"
                android:textSize="15sp" />

            <com.google.android.material.card.MaterialCardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="28dp"
                app:cardBackgroundColor="@color/brand_header_surface"
                app:cardCornerRadius="20dp"
                app:cardElevation="1dp"
                app:strokeColor="@color/brand_header_stroke"
                app:strokeWidth="1dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:padding="18dp">

                    <LinearLayout
                        android:id="@+id/loginFieldsGroup"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="vertical">

                        <com.google.android.material.textfield.TextInputLayout
                            android:id="@+id/tilUsername"
                            style="@style/Widget.App.TextInputLayout.OutlinedBox"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            app:boxCornerRadiusBottomEnd="12dp"
                            app:boxCornerRadiusBottomStart="12dp"
                            app:boxCornerRadiusTopEnd="12dp"
                            app:boxCornerRadiusTopStart="12dp"
                            app:startIconDrawable="@drawable/ic_person_24">

                            <com.google.android.material.textfield.TextInputEditText
                                android:id="@+id/etUsername"
                                style="@style/Widget.App.TextInputEditText"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:inputType="text"
                                android:maxLines="1" />
                        </com.google.android.material.textfield.TextInputLayout>

                        <com.google.android.material.textfield.TextInputLayout
                            android:id="@+id/tilPassword"
                            style="@style/Widget.App.TextInputLayout.OutlinedBox"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="12dp"
                            app:boxCornerRadiusBottomEnd="12dp"
                            app:boxCornerRadiusBottomStart="12dp"
                            app:boxCornerRadiusTopEnd="12dp"
                            app:boxCornerRadiusTopStart="12dp"
                            app:endIconMode="password_toggle"
                            app:startIconDrawable="@drawable/ic_lock_24">

                            <com.google.android.material.textfield.TextInputEditText
                                android:id="@+id/etPassword"
                                style="@style/Widget.App.TextInputEditText"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:inputType="textPassword"
                                android:maxLines="1" />
                        </com.google.android.material.textfield.TextInputLayout>
                    </LinearLayout>

                    <LinearLayout
                        android:id="@+id/changePasswordGroup"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="vertical"
                        android:visibility="gone">

                        <com.google.android.material.textfield.TextInputLayout
                            android:id="@+id/tilNewPassword"
                            style="@style/Widget.App.TextInputLayout.OutlinedBox"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            app:boxCornerRadiusBottomEnd="12dp"
                            app:boxCornerRadiusBottomStart="12dp"
                            app:boxCornerRadiusTopEnd="12dp"
                            app:boxCornerRadiusTopStart="12dp"
                            app:endIconMode="password_toggle"
                            app:startIconDrawable="@drawable/ic_lock_24">

                            <com.google.android.material.textfield.TextInputEditText
                                android:id="@+id/etNewPassword"
                                style="@style/Widget.App.TextInputEditText"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:inputType="textPassword"
                                android:maxLines="1" />
                        </com.google.android.material.textfield.TextInputLayout>

                        <com.google.android.material.textfield.TextInputLayout
                            android:id="@+id/tilConfirmPassword"
                            style="@style/Widget.App.TextInputLayout.OutlinedBox"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="12dp"
                            app:boxCornerRadiusBottomEnd="12dp"
                            app:boxCornerRadiusBottomStart="12dp"
                            app:boxCornerRadiusTopEnd="12dp"
                            app:boxCornerRadiusTopStart="12dp"
                            app:endIconMode="password_toggle"
                            app:startIconDrawable="@drawable/ic_lock_24">

                            <com.google.android.material.textfield.TextInputEditText
                                android:id="@+id/etConfirmPassword"
                                style="@style/Widget.App.TextInputEditText"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:inputType="textPassword"
                                android:maxLines="1" />
                        </com.google.android.material.textfield.TextInputLayout>
                    </LinearLayout>

                    <com.google.android.material.button.MaterialButton
                        android:id="@+id/btnPrimary"
                        android:layout_width="match_parent"
                        android:layout_height="@dimen/pill_height"
                        android:layout_marginTop="24dp"
                        android:textAllCaps="false"
                        android:textSize="16sp"
                        app:backgroundTint="@color/brand_purple"
                        app:cornerRadius="@dimen/pill_radius" />

                    <com.google.android.material.button.MaterialButton
                        android:id="@+id/btnExit"
                        style="@style/Widget.Material3.Button.TextButton"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="4dp"
                        android:minHeight="@dimen/pill_height"
                        android:textAllCaps="false"
                        android:textColor="@color/brand_text_muted" />

                </LinearLayout>
            </com.google.android.material.card.MaterialCardView>
        </LinearLayout>

        <TextView
            android:id="@+id/authFooter"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="16dp"
            android:gravity="start"
            android:lineSpacingExtra="2dp"
            android:textColor="@color/brand_text_muted"
            android:textSize="13sp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintWidth_max="520dp" />
    </androidx.constraintlayout.widget.ConstraintLayout>

    <include
        android:id="@+id/authLoadingOverlay"
        layout="@layout/view_screen_loading_overlay"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
