<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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/bg_dashboard_gradient"
    android:fitsSystemWindows="true"
    android:orientation="vertical"
    tools:context=".ui.SettingsFragment">

    <!-- Header -->
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="56dp"
        android:background="#1A1F2B"
        android:paddingHorizontal="16dp">

        <ImageButton
            android:id="@+id/btn_back"
            android:layout_width="48dp"
            android:layout_height="48dp"
            android:layout_centerVertical="true"
            android:background="?attr/selectableItemBackgroundBorderless"
            android:src="@drawable/abc_ic_ab_back_material"
            android:contentDescription="Go Back"
            app:tint="#FFFFFF" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_marginStart="8dp"
            android:layout_toEndOf="@id/btn_back"
            android:text="Settings"
            android:textColor="#FFFFFF"
            android:textSize="18sp"
            android:textStyle="bold" />
    </RelativeLayout>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true">

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

            <!-- Heartbeat Settings Card -->
            <androidx.cardview.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                app:cardBackgroundColor="@color/card_bg"
                app:cardCornerRadius="16dp"
                app:cardElevation="0dp">

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

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Heartbeat Settings"
                        android:textColor="@color/text_primary"
                        android:textSize="16sp"
                        android:textStyle="bold" />

                    <View
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:layout_marginTop="12dp"
                        android:layout_marginBottom="16dp"
                        android:background="@color/divider" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Heartbeat Interval (in seconds)"
                        android:textColor="@color/text_secondary"
                        android:textSize="13sp" />

                    <EditText
                        android:id="@+id/edit_heartbeat_interval"
                        android:layout_width="match_parent"
                        android:layout_height="48dp"
                        android:layout_marginTop="8dp"
                        android:background="@drawable/bg_pill_inactive"
                        android:inputType="number"
                        android:paddingHorizontal="16dp"
                        android:textColor="@color/text_primary"
                        android:textCursorDrawable="@null"
                        android:textSize="14sp"
                        android:hint="Enter interval in seconds (e.g. 30)"
                        android:textColorHint="@color/text_tertiary" />

                    <com.google.android.material.button.MaterialButton
                        android:id="@+id/btn_save"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="24dp"
                        android:text="Save Changes"
                        android:textColor="#FFFFFF"
                        android:textSize="14sp"
                        android:textStyle="bold"
                        app:cornerRadius="8dp"
                        style="@style/Widget.MaterialComponents.Button" />

                </LinearLayout>
            </androidx.cardview.widget.CardView>

            <!-- Wi-Fi Settings Card -->
            <androidx.cardview.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                app:cardBackgroundColor="@color/card_bg"
                app:cardCornerRadius="16dp"
                app:cardElevation="0dp">

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

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Wi-Fi Settings"
                        android:textColor="@color/text_primary"
                        android:textSize="16sp"
                        android:textStyle="bold" />

                    <View
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:layout_marginTop="12dp"
                        android:layout_marginBottom="16dp"
                        android:background="@color/divider" />

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">

                        <LinearLayout
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentStart="true"
                            android:layout_toStartOf="@id/switch_wifi_check"
                            android:layout_centerVertical="true"
                            android:orientation="vertical">

                            <TextView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:text="Disable Wi-Fi Connection"
                                android:textColor="@color/text_primary"
                                android:textSize="14sp"
                                android:textStyle="bold" />

                            <TextView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="4dp"
                                android:text="Forces the application to use mobile network data"
                                android:textColor="@color/text_secondary"
                                android:textSize="12sp" />
                        </LinearLayout>

                        <androidx.appcompat.widget.SwitchCompat
                            android:id="@+id/switch_wifi_check"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentEnd="true"
                            android:layout_centerVertical="true" />
                    </RelativeLayout>

                </LinearLayout>
            </androidx.cardview.widget.CardView>

        </LinearLayout>
    </ScrollView>
</LinearLayout>
