<?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/rootLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/background"
    tools:context=".games.game89.Game89GameActivity">

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

        <com.google.android.material.appbar.MaterialToolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@color/primary"
            app:navigationIcon="@android:drawable/ic_menu_revert"
            app:title="89++ - Assistant"
            app:titleTextColor="@android:color/white" />

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

    <!-- Main Content -->
    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingStart="16dp"
        android:paddingEnd="16dp"
        android:paddingTop="24dp"
        android:paddingBottom="16dp"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <!-- Timer Card -->
        <com.google.android.material.card.MaterialCardView
            android:id="@+id/timerCard"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            app:cardBackgroundColor="@color/primary"
            app:cardCornerRadius="24dp"
            app:cardElevation="8dp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent">

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

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Assistant 89++"
                    android:textColor="@android:color/white"
                    android:textSize="18sp"
                    android:textStyle="bold" />

                <TextView
                    android:id="@+id/timerTextView"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="16dp"
                    android:text="Prochain défi dans: 2:00"
                    android:textColor="@android:color/white"
                    android:textSize="32sp"
                    android:textStyle="bold"
                    android:gravity="center" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="8dp"
                    android:text="Jouez avec vos cartes physiques !"
                    android:textColor="@android:color/white"
                    android:textSize="14sp"
                    android:alpha="0.9" />

            </LinearLayout>

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

        <!-- Challenge Display -->
        <com.google.android.material.card.MaterialCardView
            android:id="@+id/challengeContainer"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="16dp"
            android:visibility="gone"
            android:clickable="true"
            android:focusable="true"
            app:cardBackgroundColor="@color/accent"
            app:cardCornerRadius="20dp"
            app:cardElevation="8dp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/timerCard"
            tools:visibility="visible">

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

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="⚠️ DÉFI !"
                    android:textColor="@android:color/white"
                    android:textSize="24sp"
                    android:textStyle="bold" />

                <TextView
                    android:id="@+id/challengeTitleTextView"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="8dp"
                    android:text="Changement de sens !"
                    android:textColor="@android:color/white"
                    android:textSize="20sp"
                    android:textStyle="bold" />

                <TextView
                    android:id="@+id/challengeDescriptionTextView"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="4dp"
                    android:text="Le sens du jeu est inversé !"
                    android:textColor="@android:color/white"
                    android:textSize="16sp" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="12dp"
                    android:text="👆 Tapez pour continuer"
                    android:textColor="@android:color/white"
                    android:textSize="12sp"
                    android:alpha="0.7"
                    android:layout_gravity="center" />

            </LinearLayout>

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

        <!-- Action Buttons -->
        <LinearLayout
            android:id="@+id/actionButtons"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="16dp"
            android:orientation="horizontal"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/challengeContainer">

            <com.google.android.material.button.MaterialButton
                android:id="@+id/recordDrinksButton"
                style="@style/BoideloButton"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginEnd="8dp"
                android:layout_weight="1"
                android:text="🍺 Enregistrer\ngorgées"
                android:textColor="@color/text_primary"
                android:textSize="14sp"
                app:backgroundTint="@android:color/white"
                app:cornerRadius="20dp"
                app:strokeColor="@color/primary"
                app:strokeWidth="2dp"
                android:elevation="2dp" />

            <com.google.android.material.button.MaterialButton
                android:id="@+id/showStatsButton"
                style="@style/BoideloButton"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginStart="8dp"
                android:layout_weight="1"
                android:text="📊 Voir\nstatistiques"
                android:textColor="@color/text_primary"
                android:textSize="14sp"
                app:backgroundTint="@android:color/white"
                app:cornerRadius="20dp"
                app:strokeColor="@color/primary"
                app:strokeWidth="2dp"
                android:elevation="2dp" />

        </LinearLayout>

        <!-- Info Card -->
        <com.google.android.material.card.MaterialCardView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="16dp"
            app:cardBackgroundColor="@android:color/white"
            app:cardCornerRadius="16dp"
            app:cardElevation="4dp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/actionButtons">

            <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:text="💡 Rappel des règles"
                    android:textColor="@color/text_primary"
                    android:textSize="16sp"
                    android:textStyle="bold" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="8dp"
                    android:text="• Valet = -10\n• Dame = Change sens\n• Roi = Choisissez la valeur\n• Dizaine (10, 20...) = distribuez des gorgées\n• 70 = DOUBLE (14 gorgées!)"
                    android:textColor="@color/text_hint"
                    android:textSize="14sp" />

            </LinearLayout>

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

    </androidx.constraintlayout.widget.ConstraintLayout>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
