<?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="@drawable/gradient_background_dark"
    android:fitsSystemWindows="true">

    <!-- Header con animación -->
    <LinearLayout
        android:id="@+id/headerSection"
        android:layout_width="360dp"
        android:layout_height="376dp"
        android:layout_marginHorizontal="32dp"
        android:layout_marginTop="60dp"
        android:gravity="center"
        android:orientation="vertical"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <!-- Icono de carga animado -->
        <com.google.android.material.card.MaterialCardView
            android:layout_width="120dp"
            android:layout_height="120dp"
            android:layout_marginBottom="24dp"
            app:cardBackgroundColor="@android:color/white"
            app:cardCornerRadius="60dp"
            app:cardElevation="20dp">

            <ImageView
                android:id="@+id/loadingIcon"
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:layout_gravity="center"
                android:src="@drawable/ic_fitness_center"
                app:tint="@color/primary" />

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

        <!-- Título principal -->
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            android:text="Generando tu plan"
            android:textColor="@android:color/white"
            android:textSize="32sp"
            android:textStyle="bold" />

        <!-- Subtítulo -->
        <TextView
            android:id="@+id/statusText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="32dp"
            android:alpha="0.8"
            android:gravity="center"
            android:text="Analizando tu perfil fitness..."
            android:textColor="@android:color/white"
            android:textSize="16sp" />

        <!-- Progress Bar -->
        <com.google.android.material.card.MaterialCardView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginHorizontal="16dp"
            app:cardBackgroundColor="@android:color/white"
            app:cardCornerRadius="20dp"
            app:cardElevation="8dp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent">

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

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

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:text="Progreso"
                        android:textColor="@color/primary"
                        android:textSize="16sp"
                        android:textStyle="bold" />

                    <TextView
                        android:id="@+id/progressText"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="0%"
                        android:textColor="@color/primary"
                        android:textSize="16sp"
                        android:textStyle="bold" />

                </LinearLayout>

                <ProgressBar
                    android:id="@+id/progressBar"
                    style="?android:attr/progressBarStyleHorizontal"
                    android:layout_width="match_parent"
                    android:layout_height="12dp"
                    android:background="@drawable/progress_bar_background"
                    android:max="100"
                    android:progress="0"
                    android:progressBackgroundTint="#E9ECEF"
                    android:progressTint="@color/primary" />

            </LinearLayout>

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

    </LinearLayout>

    <!-- Log Section -->
    <com.google.android.material.card.MaterialCardView
        android:id="@+id/logCard"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginTop="32dp"
        android:layout_marginHorizontal="16dp"
        android:layout_marginBottom="32dp"
        app:cardCornerRadius="20dp"
        app:cardElevation="12dp"
        app:cardBackgroundColor="@android:color/white"
        app:layout_constraintTop_toBottomOf="@id/headerSection"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintBottom_toBottomOf="parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <!-- Header del log -->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:gravity="center_vertical"
                android:padding="20dp"
                android:background="@drawable/log_header_background">

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

                <TextView
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:text="Proceso de Generación"
                    android:textSize="18sp"
                    android:textStyle="bold"
                    android:textColor="@color/primary" />

                <com.google.android.material.chip.Chip
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="EN VIVO"
                    android:textSize="10sp"
                    app:chipBackgroundColor="@color/success"
                    app:chipMinHeight="24dp"
                    android:textColor="@android:color/white" />

            </LinearLayout>

            <!-- Divider -->
            <View
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:background="#E9ECEF" />

            <!-- RecyclerView para el log -->
            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/logRecyclerView"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:padding="16dp"
                android:scrollbars="vertical"
                android:fadeScrollbars="true"
                tools:listitem="@layout/item_log" />

        </LinearLayout>

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

</androidx.constraintlayout.widget.ConstraintLayout>