<?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/surface"
    android:fitsSystemWindows="true"
    tools:context=".EndGameActivity">

    <!-- Background Gradient -->
    <View
        android:id="@+id/topBackground"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:background="@color/primary"
        app:layout_constraintBottom_toBottomOf="@id/guideline"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <androidx.constraintlayout.widget.Guideline
        android:id="@+id/guideline"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintGuide_percent="0.4" />

    <!-- Main Content -->
    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:gravity="center"
        android:orientation="vertical"
        android:padding="24dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <!-- Trophy Icon -->
        <ImageView
            android:id="@+id/trophyIcon"
            android:layout_width="120dp"
            android:layout_height="120dp"
            android:layout_marginBottom="24dp"
            android:contentDescription="Trophée"
            android:src="@android:drawable/ic_menu_agenda"
            app:tint="@color/accent" />

        <!-- Title -->
        <TextView
            android:id="@+id/titleText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            android:text="Partie Terminée !"
            android:textColor="@color/white"
            android:textSize="32sp"
            android:textStyle="bold" />

        <!-- Subtitle -->
        <TextView
            android:id="@+id/subtitleText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="32dp"
            android:text="Bien joué à tous !"
            android:textColor="@color/white"
            android:textSize="18sp" />

        <!-- Stats Card -->
        <com.google.android.material.card.MaterialCardView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="24dp"
            app:cardBackgroundColor="@color/white"
            app:cardCornerRadius="20dp"
            app:cardElevation="8dp">

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

                <!-- Questions Played -->
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="16dp"
                    android:gravity="center"
                    android:orientation="horizontal">

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

                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:orientation="vertical">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Questions jouées"
                            android:textColor="@color/text_secondary"
                            android:textSize="14sp" />

                        <TextView
                            android:id="@+id/questionsPlayedValue"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="50"
                            android:textColor="@color/text_primary"
                            android:textSize="24sp"
                            android:textStyle="bold" />

                    </LinearLayout>

                </LinearLayout>

                <!-- Divider -->
                <View
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:layout_marginBottom="16dp"
                    android:background="@color/surface_variant" />

                <!-- Players Count -->
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="16dp"
                    android:gravity="center"
                    android:orientation="horizontal">

                    <ImageView
                        android:layout_width="32dp"
                        android:layout_height="32dp"
                        android:layout_marginEnd="12dp"
                        android:src="@drawable/ic_player_three"
                        app:tint="@color/accent" />

                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:orientation="vertical">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Joueurs"
                            android:textColor="@color/text_secondary"
                            android:textSize="14sp" />

                        <TextView
                            android:id="@+id/playersCountValue"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="5"
                            android:textColor="@color/text_primary"
                            android:textSize="24sp"
                            android:textStyle="bold" />

                    </LinearLayout>

                </LinearLayout>

                <!-- Divider -->
                <View
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:layout_marginBottom="16dp"
                    android:background="@color/surface_variant" />

                <!-- Total Gorgees -->
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:orientation="horizontal">

                    <ImageView
                        android:layout_width="32dp"
                        android:layout_height="32dp"
                        android:layout_marginEnd="12dp"
                        android:src="@android:drawable/ic_menu_recent_history"
                        app:tint="@color/warning" />

                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:orientation="vertical">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Gorgées totales"
                            android:textColor="@color/text_secondary"
                            android:textSize="14sp" />

                        <TextView
                            android:id="@+id/gorgeesTotalValue"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="--"
                            android:textColor="@color/text_primary"
                            android:textSize="24sp"
                            android:textStyle="bold" />

                    </LinearLayout>

                </LinearLayout>

                <!-- Divider -->
                <View
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:layout_marginTop="16dp"
                    android:layout_marginBottom="16dp"
                    android:background="@color/surface_variant" />

                <!-- Plus Bu -->
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="16dp"
                    android:gravity="center"
                    android:orientation="horizontal">

                    <ImageView
                        android:layout_width="32dp"
                        android:layout_height="32dp"
                        android:layout_marginEnd="12dp"
                        android:src="@android:drawable/ic_menu_add"
                        app:tint="@color/accent" />

                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:orientation="vertical">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="A le plus bu"
                            android:textColor="@color/text_secondary"
                            android:textSize="14sp" />

                        <TextView
                            android:id="@+id/plusBuValue"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="--"
                            android:textColor="@color/accent"
                            android:textSize="20sp"
                            android:textStyle="bold" />

                    </LinearLayout>

                </LinearLayout>

                <!-- Plus Distribué -->
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:orientation="horizontal">

                    <ImageView
                        android:layout_width="32dp"
                        android:layout_height="32dp"
                        android:layout_marginEnd="12dp"
                        android:src="@android:drawable/ic_menu_send"
                        app:tint="@color/primary" />

                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:orientation="vertical">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="A le plus distribué"
                            android:textColor="@color/text_secondary"
                            android:textSize="14sp" />

                        <TextView
                            android:id="@+id/plusDistribueValue"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="--"
                            android:textColor="@color/primary"
                            android:textSize="20sp"
                            android:textStyle="bold" />

                    </LinearLayout>

                </LinearLayout>

            </LinearLayout>

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

        <!-- Players List -->
        <com.google.android.material.card.MaterialCardView
            android:id="@+id/playersCard"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="24dp"
            app:cardBackgroundColor="@color/white"
            app:cardCornerRadius="16dp"
            app:cardElevation="4dp">

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

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="12dp"
                    android:text="Participants"
                    android:textColor="@color/text_secondary"
                    android:textSize="14sp"
                    android:textStyle="bold" />

                <androidx.recyclerview.widget.RecyclerView
                    android:id="@+id/playersRecyclerView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:nestedScrollingEnabled="false" />

            </LinearLayout>

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

        <!-- Buttons -->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <!-- Home Button -->
            <com.google.android.material.button.MaterialButton
                android:id="@+id/homeButton"
                style="@style/BoideloButton"
                android:layout_width="0dp"
                android:layout_height="56dp"
                android:layout_marginEnd="8dp"
                android:layout_weight="1"
                android:text="Accueil"
                app:backgroundTint="@color/surface_variant"
                app:cornerRadius="28dp"
                app:icon="@android:drawable/ic_menu_revert"
                app:iconGravity="textStart" />

            <!-- Replay Button -->
            <com.google.android.material.button.MaterialButton
                android:id="@+id/replayButton"
                style="@style/BoideloButton.Primary"
                android:layout_width="0dp"
                android:layout_height="56dp"
                android:layout_marginStart="8dp"
                android:layout_weight="1"
                android:text="Rejouer"
                app:cornerRadius="28dp"
                app:icon="@android:drawable/ic_media_play"
                app:iconGravity="textEnd" />

        </LinearLayout>

    </LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
