<?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=".JeuxParametres">

    <!-- 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 -->
    <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="16dp"
                android:layout_marginBottom="16dp"
                android:text="@string/param_tres_du_jeu" />

            <!-- Game Settings Card -->
            <com.google.android.material.card.MaterialCardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="16dp"
                app:cardBackgroundColor="@color/card_background"
                app:cardCornerRadius="16dp"
                app:cardElevation="4dp">

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

                    <!-- Number of Questions -->
                    <TextView
                            style="@style/BoideloSubtitle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginBottom="16dp"
                            android:text="Paramètres de partie"
                            app:drawableStartCompat="@android:drawable/ic_menu_edit"
                            app:drawableTint="@color/primary"/>

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

                        <LinearLayout
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_marginBottom="8dp"
                                android:orientation="horizontal">

                            <TextView
                                    android:id="@+id/textView1"
                                    android:layout_width="0dp"
                                    android:layout_height="wrap_content"
                                    android:layout_weight="1"
                                    android:text="Nombre de questions"
                                    android:textColor="@color/text_primary"
                                    android:textSize="16sp"/>

                            <TextView
                                    android:id="@+id/questionCountValue"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:background="@drawable/bg_card"
                                    android:paddingStart="12dp"
                                    android:paddingTop="4dp"
                                    android:paddingEnd="12dp"
                                    android:paddingBottom="4dp"
                                    android:text="50"
                                    android:textColor="@color/primary"
                                    android:textSize="14sp"
                                    android:textStyle="bold"/>

                        </LinearLayout>

                        <SeekBar
                                android:id="@+id/seekBar1"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:progressTint="@color/accent"
                                android:thumbTint="@color/accent"/>

                    </LinearLayout>

                    <!-- Drink Addition -->
                    <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginBottom="20dp"
                            android:orientation="vertical">

                        <LinearLayout
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_marginBottom="8dp"
                                android:orientation="horizontal">

                            <TextView
                                    android:id="@+id/textView2"
                                    android:layout_width="0dp"
                                    android:layout_height="wrap_content"
                                    android:layout_weight="1"
                                    android:text="Ajout de gorgées"
                                    android:textColor="@color/text_primary"
                                    android:textSize="16sp"/>

                            <TextView
                                    android:id="@+id/gorgeesValue"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:background="@drawable/bg_card"
                                    android:paddingStart="12dp"
                                    android:paddingTop="4dp"
                                    android:paddingEnd="12dp"
                                    android:paddingBottom="4dp"
                                    android:text="0"
                                    android:textColor="@color/accent"
                                    android:textSize="14sp"
                                    android:textStyle="bold"/>

                        </LinearLayout>

                        <SeekBar
                                android:id="@+id/seekBar2"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:progressTint="@color/accent"
                                android:thumbTint="@color/accent"/>

                        <!-- Palier Indicator -->
                        <com.google.android.material.card.MaterialCardView
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="12dp"
                                app:cardBackgroundColor="@color/surface_variant"
                                app:cardCornerRadius="8dp"
                                app:cardElevation="0dp">

                            <TextView
                                    android:id="@+id/textView5"
                                    android:layout_width="match_parent"
                                    android:layout_height="wrap_content"
                                    android:gravity="center"
                                    android:padding="12dp"
                                    android:text="Palier : Grosse merde"
                                    android:textColor="@color/text_secondary"
                                    android:textSize="14sp"
                                    android:textStyle="bold"/>

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

                    </LinearLayout>

                    <!-- Duration of Challenges -->
                    <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginBottom="20dp"
                            android:orientation="vertical">

                        <LinearLayout
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_marginBottom="8dp"
                                android:orientation="horizontal">

                            <TextView
                                    android:id="@+id/textViewDuration"
                                    android:layout_width="0dp"
                                    android:layout_height="wrap_content"
                                    android:layout_weight="1"
                                    android:text="Durée des défis"
                                    android:textColor="@color/text_primary"
                                    android:textSize="16sp"/>

                            <TextView
                                    android:id="@+id/durationValue"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:background="@drawable/bg_card"
                                    android:paddingStart="12dp"
                                    android:paddingTop="4dp"
                                    android:paddingEnd="12dp"
                                    android:paddingBottom="4dp"
                                    android:text="0"
                                    android:textColor="@color/primary"
                                    android:textSize="14sp"
                                    android:textStyle="bold"/>

                        </LinearLayout>

                        <SeekBar
                                android:id="@+id/seekBarDuration"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:progressTint="@color/accent"
                                android:thumbTint="@color/accent"/>

                    </LinearLayout>

                </LinearLayout>

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

            <!-- OpenAI Settings Card -->
            <com.google.android.material.card.MaterialCardView
                android:id="@+id/openaiCard"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="16dp"
                app:cardBackgroundColor="@color/card_background"
                app:cardCornerRadius="16dp"
                app:cardElevation="4dp"
                app:strokeColor="@color/surface_variant"
                app:strokeWidth="1dp">

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

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

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

                        <TextView
                            android:id="@+id/textView3"
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:text="@string/openai"
                            android:textColor="@color/text_primary"
                            android:textSize="18sp"
                            android:textStyle="bold" />

                        <com.google.android.material.switchmaterial.SwitchMaterial
                            android:id="@+id/checkBoxGPT"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" />

                    </LinearLayout>

                    <!-- Provider Selection -->
                    <com.google.android.material.textfield.TextInputLayout
                        android:id="@+id/textInputLayoutProvider"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginBottom="16dp"
                        android:enabled="false"
                        android:hint="Fournisseur IA"
                        app:boxBackgroundColor="@color/surface"
                        app:boxStrokeColor="@color/primary"
                        app:hintTextColor="@color/text_hint"
                        style="@style/Widget.Material3.TextInputLayout.OutlinedBox.ExposedDropdownMenu">

                        <AutoCompleteTextView
                            android:id="@+id/autoCompleteProvider"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:inputType="none"
                            android:text="OpenAI" />

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

                    <!-- API Key Input -->
                    <com.google.android.material.textfield.TextInputLayout
                        android:id="@+id/textInputLayoutApiKey"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginBottom="16dp"
                        android:hint="Clé API"
                        app:boxBackgroundColor="@color/surface"
                        app:boxStrokeColor="@color/primary"
                        app:endIconMode="password_toggle"
                        app:hintTextColor="@color/text_hint"
                        style="@style/Widget.Material3.TextInputLayout.OutlinedBox">

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

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

                    <!-- Ratio SeekBar -->
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginBottom="16dp"
                        android:orientation="vertical">

                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginBottom="8dp"
                            android:orientation="horizontal">

                            <TextView
                                android:id="@+id/textViewRatioGen"
                                android:layout_width="0dp"
                                android:layout_height="wrap_content"
                                android:layout_weight="1"
                                android:enabled="false"
                                android:text="Ratio BDD/OPENAI : 1/8"
                                android:textColor="@color/text_primary"
                                android:textSize="14sp" />

                        </LinearLayout>

                        <SeekBar
                            android:id="@+id/seekBar3"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:enabled="false"
                            android:progressTint="@color/primary_light"
                            android:thumbTint="@color/primary_light" />

                    </LinearLayout>

                    <!-- Test API Button -->
                    <com.google.android.material.button.MaterialButton
                        android:id="@+id/ButtonTestApi"
                        style="@style/BoideloButton"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:enabled="false"
                        android:onClick="onClickButtonTestAPI"
                        android:text="@string/test_de_connectivit_openai"
                        app:backgroundTint="@color/surface_variant"
                        app:icon="@android:drawable/ic_menu_info_details"
                        app:iconGravity="textStart" />

                </LinearLayout>

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

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

        </LinearLayout>

    </androidx.core.widget.NestedScrollView>

    <!-- Floating Action Button -->
    <com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
        android:id="@+id/Go2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="16dp"
        android:onClick="onClickButtonStart"
        android:text="@string/commencer_a_vous_mettre_une_mine"
        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>
