<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
    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:id="@+id/main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/bg_base"
    tools:context=".ui.definicoes.ContaActivity">

    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/appBarLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/bg_surface"
        app:elevation="0dp">

        <com.google.android.material.appbar.MaterialToolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@color/bg_surface"
            app:title="Definições de Conta"
            app:titleTextColor="@color/text_1"
            app:navigationIcon="@drawable/ic_arrow_back"
            app:navigationIconTint="@color/text_1" />

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="@color/border" />

    </com.google.android.material.appbar.AppBarLayout>

    <androidx.core.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        android:fillViewport="true">

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

            <!-- Profile Photo Section -->
            <com.google.android.material.card.MaterialCardView
                android:id="@+id/cardProfilePhoto"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="14dp"
                app:cardCornerRadius="12dp"
                app:cardElevation="0dp"
                app:strokeWidth="1dp"
                app:strokeColor="@color/border"
                app:cardBackgroundColor="@color/bg_surface">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:padding="20dp"
                    android:gravity="center">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:fontFamily="@font/font_ibm_plex_sans"
                        android:text="Foto de Perfil"
                        android:textSize="15sp"
                        android:textStyle="bold"
                        android:textColor="@color/text_1"
                        android:layout_marginBottom="16dp" />

                    <!-- Profile Image -->
                    <androidx.constraintlayout.widget.ConstraintLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content">
                        
                        <com.google.android.material.card.MaterialCardView
                            android:id="@+id/cardImageContainer"
                            android:layout_width="100dp"
                            android:layout_height="100dp"
                            app:cardCornerRadius="50dp"
                            app:cardElevation="0dp"
                            app:strokeWidth="1dp"
                            app:strokeColor="@color/border"
                            app:cardBackgroundColor="@color/bg_elevated"
                            android:clickable="true"
                            android:focusable="true"
                            android:foreground="?attr/selectableItemBackgroundBorderless"
                            app:layout_constraintStart_toStartOf="parent"
                            app:layout_constraintTop_toTopOf="parent">

                            <ImageView
                                android:id="@+id/imageProfile"
                                android:layout_width="match_parent"
                                android:layout_height="match_parent"
                                android:scaleType="centerCrop"
                                android:contentDescription="Foto de perfil"
                                android:src="@android:drawable/ic_menu_camera"
                                app:tint="@color/text_3" />
                                
                        </com.google.android.material.card.MaterialCardView>

                        <com.google.android.material.floatingactionbutton.FloatingActionButton
                             android:id="@+id/fabEditPhoto"
                             android:layout_width="wrap_content"
                             android:layout_height="wrap_content"
                             app:fabSize="mini"
                             app:backgroundTint="@color/brand"
                             app:tint="@color/bg_base"
                             android:src="@android:drawable/ic_menu_edit"
                             app:layout_constraintBottom_toBottomOf="@+id/cardImageContainer"
                             app:layout_constraintEnd_toEndOf="@+id/cardImageContainer"/>
                             
                    </androidx.constraintlayout.widget.ConstraintLayout>

                    <TextView
                        android:id="@+id/btnChangePhoto"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="12dp"
                        android:fontFamily="@font/font_ibm_plex_sans"
                        android:text="Toque para alterar"
                        android:textColor="@color/brand"
                        android:textSize="13sp"
                        android:textStyle="bold"
                        android:clickable="true"
                        android:focusable="true"
                        android:padding="6dp" />

                </LinearLayout>

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

            <!-- Name Section -->
            <com.google.android.material.card.MaterialCardView
                android:id="@+id/cardName"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="14dp"
                app:cardCornerRadius="12dp"
                app:cardElevation="0dp"
                app:strokeWidth="1dp"
                app:strokeColor="@color/border"
                app:cardBackgroundColor="@color/bg_surface">

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

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:fontFamily="@font/font_ibm_plex_sans"
                        android:text="Nome de Utilizador"
                        android:textSize="15sp"
                        android:textStyle="bold"
                        android:textColor="@color/text_1"
                        android:layout_marginBottom="14dp" />

                    <!-- Name Input -->
                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/editName"
                        android:layout_width="match_parent"
                        android:layout_height="48dp"
                        android:background="@drawable/bg_input_field"
                        android:inputType="textPersonName"
                        android:textColor="@color/text_1"
                        android:textColorHint="@color/text_3"
                        android:fontFamily="@font/font_ibm_plex_sans"
                        android:textSize="13sp"
                        android:paddingHorizontal="16dp"
                        android:hint="Nome de utilizador" />

                    <com.google.android.material.button.MaterialButton
                        android:id="@+id/btnSaveAll"
                        android:layout_width="match_parent"
                        android:layout_height="48dp"
                        android:layout_marginTop="16dp"
                        app:backgroundTint="@color/brand"
                        android:text="Guardar Alterações"
                        android:fontFamily="@font/font_ibm_plex_sans"
                        android:textColor="@color/bg_base"
                        android:textSize="14sp"
                        android:textStyle="bold"
                        android:textAllCaps="false"
                        app:cornerRadius="8dp" />

                </LinearLayout>

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

            <!-- Security Section -->
            <com.google.android.material.card.MaterialCardView
                android:id="@+id/cardSecurity"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="14dp"
                app:cardCornerRadius="12dp"
                app:cardElevation="0dp"
                app:strokeWidth="1dp"
                app:strokeColor="@color/border"
                app:cardBackgroundColor="@color/bg_surface">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:padding="20dp">
                    
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:fontFamily="@font/font_ibm_plex_sans"
                        android:text="Segurança"
                        android:textSize="15sp"
                        android:textStyle="bold"
                        android:textColor="@color/text_1"
                        android:layout_marginBottom="14dp" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:fontFamily="@font/font_ibm_plex_sans"
                        android:text="Email"
                        android:textSize="12sp"
                        android:textStyle="bold"
                        android:textColor="@color/text_2"
                        android:layout_marginBottom="6dp" />

                    <TextView
                        android:id="@+id/textEmail"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:fontFamily="@font/font_ibm_plex_mono"
                        android:text="email@exemplo.com"
                        android:textSize="13sp"
                        android:textColor="@color/text_1"
                        android:padding="12dp"
                        android:background="@drawable/bg_input_field"
                        android:layout_marginBottom="14dp" />

                    <com.google.android.material.button.MaterialButton
                        android:id="@+id/btnChangeEmail"
                        android:layout_width="match_parent"
                        android:layout_height="42dp"
                        android:backgroundTint="@color/bg_elevated"
                        app:strokeColor="@color/border"
                        app:strokeWidth="1dp"
                        android:fontFamily="@font/font_ibm_plex_sans"
                        android:text="Alterar Email"
                        android:textColor="@color/text_2"
                        android:textSize="12sp"
                        android:textAllCaps="false"
                        app:cornerRadius="6dp"
                        android:insetTop="0dp"
                        android:insetBottom="0dp" />
                        
                    <com.google.android.material.button.MaterialButton
                        android:id="@+id/btnChangePassword"
                        android:layout_width="match_parent"
                        android:layout_height="42dp"
                        android:layout_marginTop="8dp"
                        android:backgroundTint="@color/bg_elevated"
                        app:strokeColor="@color/border"
                        app:strokeWidth="1dp"
                        android:fontFamily="@font/font_ibm_plex_sans"
                        android:text="Alterar Password"
                        android:textColor="@color/text_2"
                        android:textSize="12sp"
                        android:textAllCaps="false"
                        app:cornerRadius="6dp"
                        android:insetTop="0dp"
                        android:insetBottom="0dp" />

                </LinearLayout>

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

            <!-- Logout Section -->
            <com.google.android.material.card.MaterialCardView
                android:id="@+id/cardLogout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:cardCornerRadius="12dp"
                app:cardElevation="0dp"
                app:strokeWidth="1dp"
                app:strokeColor="@color/border"
                app:cardBackgroundColor="@color/bg_surface">

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

                    <com.google.android.material.button.MaterialButton
                        android:id="@+id/btnLogout"
                        android:layout_width="match_parent"
                        android:layout_height="48dp"
                        app:backgroundTint="@color/danger"
                        android:fontFamily="@font/font_ibm_plex_sans"
                        android:text="Terminar Sessão"
                        android:textColor="@color/text_1"
                        android:textSize="14sp"
                        android:textStyle="bold"
                        android:textAllCaps="false"
                        app:cornerRadius="8dp" />

                </LinearLayout>

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

        </LinearLayout>

    </androidx.core.widget.NestedScrollView>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
