<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/background"
    tools:context=".ui.profile.ProfileActivity">

    <!-- Toolbar -->
    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:background="@color/primary"
        android:elevation="4dp"
        android:theme="@style/ThemeOverlay.Material3.Dark"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:title="Профиль" />

    <ScrollView
        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_toBottomOf="@id/toolbar">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="16dp">

            <!-- Avatar Section -->
            <androidx.constraintlayout.widget.ConstraintLayout
                android:id="@+id/avatarSection"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:padding="16dp"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent">

                <ImageView
                    android:id="@+id/avatarImageView"
                    android:layout_width="120dp"
                    android:layout_height="120dp"
                    android:clickable="true"
                    android:focusable="true"
                    android:contentDescription="User Avatar"
                    android:scaleType="centerCrop"
                    android:background="@drawable/message_input_background"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent"
                    tools:src="@mipmap/ic_launcher" />

            </androidx.constraintlayout.widget.ConstraintLayout>

            <!-- First Name Input -->
            <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/firstNameInputLayout"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="24dp"
                android:layout_marginEnd="8dp"
                android:hint="Имя"
                app:layout_constraintEnd_toStartOf="@id/lastNameInputLayout"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/avatarSection">

                <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/firstNameEditText"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="textPersonName"
                    android:textColor="@color/text_primary" />

            </com.google.android.material.textfield.TextInputLayout>

            <!-- Last Name Input -->
            <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/lastNameInputLayout"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="24dp"
                android:layout_marginStart="8dp"
                android:hint="Фамилия"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toEndOf="@id/firstNameInputLayout"
                app:layout_constraintTop_toBottomOf="@id/avatarSection">

                <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/lastNameEditText"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="textPersonName"
                    android:textColor="@color/text_primary" />

            </com.google.android.material.textfield.TextInputLayout>

            <!-- Email Input -->
            <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/emailInputLayout"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:hint="Email"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/firstNameInputLayout">

                <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/emailEditText"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="textEmailAddress"
                    android:textColor="@color/text_primary" />

            </com.google.android.material.textfield.TextInputLayout>

            <!-- Phone Input -->
            <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/phoneInputLayout"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:hint="Телефон"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/emailInputLayout">

                <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/phoneEditText"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="phone"
                    android:textColor="@color/text_primary" />

            </com.google.android.material.textfield.TextInputLayout>

            <!-- Save Button -->
            <com.google.android.material.button.MaterialButton
                android:id="@+id/saveButton"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="32dp"
                android:backgroundTint="@color/primary"
                android:text="Сохранить"
                android:textColor="@color/white"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/phoneInputLayout" />

            <!-- Progress Bar -->
            <ProgressBar
                android:id="@+id/progressBar"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:visibility="gone"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/saveButton" />

            <!-- Error Text -->
            <TextView
                android:id="@+id/errorTextView"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:textColor="@color/error"
                android:textSize="14sp"
                android:visibility="gone"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/progressBar" />

        </androidx.constraintlayout.widget.ConstraintLayout>

    </ScrollView>

</androidx.constraintlayout.widget.ConstraintLayout>
