<?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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/surface"
    tools:context=".MainActivity">

    <!-- App Bar -->
    <com.google.android.material.appbar.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark"/>

    <!-- Main Content -->

    <!-- Floating Action Button -->
    <androidx.core.widget.NestedScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">

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

            <!-- Title -->
            <TextView
                    android:id="@+id/Titre"
                    style="@style/BoideloTitle"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="24dp"
                    android:layout_marginBottom="16dp"
                    android:text="@string/bienvenue"/>

            <!-- Player Count Indicator -->
            <com.google.android.material.card.MaterialCardView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="16dp"
                    app:cardBackgroundColor="@color/accent"
                    app:cardCornerRadius="12dp"
                    app:cardElevation="2dp">

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

                    <ImageView
                            android:layout_width="24dp"
                            android:layout_height="24dp"
                            android:layout_marginEnd="8dp"
                            android:src="@drawable/ic_player_three"
                            app:tint="@color/white"/>

                    <TextView
                            android:id="@+id/playerCountText"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Joueurs: 0 / min. 3"
                            android:textColor="@color/white"
                            android:textSize="14sp"
                            android:textStyle="bold"/>

                </LinearLayout>

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

            <!-- Players Input Card -->
            <com.google.android.material.card.MaterialCardView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="16dp"
                    app:cardBackgroundColor="@color/white"
                    app:cardCornerRadius="16dp"
                    app:cardElevation="4dp"
                    app:strokeColor="@color/surface_variant"
                    app:strokeWidth="1dp">

                <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:orientation="vertical"
                        android:background="@color/background"
                        android:padding="16dp">

                    <TextView
                            android:id="@+id/textView2"
                            style="@style/BoideloCaption"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginBottom="16dp"
                            android:gravity="center"
                            android:text="@string/laisse_vide_si_il_y_a_pas_assez_de_joueur"/>

                    <!-- Default Player Inputs -->
                    <com.google.android.material.textfield.TextInputLayout
                            android:id="@+id/textInputLayoutJ1"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginBottom="12dp"
                            android:hint="@string/nom"
                            app:boxBackgroundColor="@color/surface"
                            app:boxStrokeColor="@color/primary"
                            app:boxStrokeWidth="2dp"
                            app:endIconMode="clear_text"
                            app:errorEnabled="false"
                            app:hintTextColor="@color/text_hint"
                            style="@style/Widget.Material3.TextInputLayout.OutlinedBox">

                        <com.google.android.material.textfield.TextInputEditText
                                android:id="@+id/J1"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:inputType="textPersonName"
                                android:maxLines="1"
                                android:textSize="16sp"/>

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

                    <com.google.android.material.textfield.TextInputLayout
                            android:id="@+id/textInputLayoutJ2"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginBottom="12dp"
                            android:hint="@string/nom"
                            app:boxBackgroundColor="@color/surface"
                            app:boxStrokeColor="@color/primary"
                            app:boxStrokeWidth="2dp"
                            app:endIconMode="clear_text"
                            app:hintTextColor="@color/text_hint"
                            style="@style/Widget.Material3.TextInputLayout.OutlinedBox">

                        <com.google.android.material.textfield.TextInputEditText
                                android:id="@+id/J2"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:inputType="textPersonName"
                                android:maxLines="1"
                                android:textSize="16sp"/>

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

                    <com.google.android.material.textfield.TextInputLayout
                            android:id="@+id/textInputLayoutJ3"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginBottom="12dp"
                            android:hint="@string/nom"
                            app:boxBackgroundColor="@color/surface"
                            app:boxStrokeColor="@color/primary"
                            app:boxStrokeWidth="2dp"
                            app:endIconMode="clear_text"
                            app:hintTextColor="@color/text_hint"
                            style="@style/Widget.Material3.TextInputLayout.OutlinedBox">

                        <com.google.android.material.textfield.TextInputEditText
                                android:id="@+id/J3"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:inputType="textPersonName"
                                android:maxLines="1"
                                android:textSize="16sp"/>

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

                    <!-- Dynamic Player Input Container -->
                    <LinearLayout
                            android:id="@+id/nameEntryLayout"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:orientation="vertical"/>

                    <!-- Add Player Button -->
                    <com.google.android.material.button.MaterialButton
                            android:id="@+id/Validation"
                            style="@style/BoideloButton.Secondary"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="8dp"
                            android:onClick="onClickButton1"
                            android:text="@string/c_ok"
                            app:icon="@android:drawable/ic_input_add"
                            app:iconGravity="textStart"/>

                </LinearLayout>

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

            <!-- Bottom Spacer for FAB -->
            <View
                    android:layout_width="match_parent"
                    android:layout_height="80dp"/>

        </LinearLayout>

    </androidx.core.widget.NestedScrollView>
    <com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
            android:id="@+id/Go"
            android:layout_width="172dp"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|end"
            android:layout_margin="16dp"
            android:onClick="onClickButtonStart"
            android:text="@string/go"
            android:textColor="@color/text_primary"
            app:backgroundTint="@color/accent"
            app:icon="@android:drawable/ic_media_play"
            app:iconTint="@color/text_primary"/>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
