<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="16dp">

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

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="🔌 Интерфейсы: UDP и BLE"
            android:textSize="22sp"
            android:textStyle="bold"
            android:textColor="@android:color/black"
            android:gravity="center"
            android:layout_marginBottom="24dp" />

        <!-- UDP -->
        <com.google.android.material.card.MaterialCardView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="16dp"
            app:cardCornerRadius="8dp"
            app:cardElevation="4dp">

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

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="📡 UDP"
                    android:textSize="18sp"
                    android:textStyle="bold"
                    android:textColor="@android:color/black"
                    android:layout_marginBottom="12dp" />

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="8dp"
                    android:hint="UDP Порт"
                    app:helperText="Порт для прослушивания AIS данных">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/et_udp_port"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:inputType="number"
                        android:text="10110" />

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

                <com.google.android.material.switchmaterial.SwitchMaterial
                    android:id="@+id/switch_udp_enabled"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Включить UDP слушатель"
                    android:textSize="16sp"
                    android:checked="true" />

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

        <!-- BLE -->
        <com.google.android.material.card.MaterialCardView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="16dp"
            app:cardCornerRadius="8dp"
            app:cardElevation="4dp">

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

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="📶 BLE"
                    android:textSize="18sp"
                    android:textStyle="bold"
                    android:textColor="@android:color/black"
                    android:layout_marginBottom="12dp" />

                <com.google.android.material.switchmaterial.SwitchMaterial
                    android:id="@+id/switch_ble_enabled"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Включить BLE источник NMEA"
                    android:textSize="16sp"
                    android:layout_marginBottom="8dp" />

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="8dp"
                    android:hint="MAC адрес BLE устройства"
                    app:helperText="Например: 01:23:45:67:89:AB">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/et_ble_mac"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:inputType="text"
                        android:text="" />

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

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

                    <Button
                        android:id="@+id/btn_ble_scan"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Сканировать BLE"
                        style="@style/Widget.Material3.Button" />

                    <Button
                        android:id="@+id/btn_ble_stop_scan"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Стоп"
                        android:layout_marginStart="8dp"
                        style="@style/Widget.Material3.Button.OutlinedButton" />
                </LinearLayout>

                <androidx.recyclerview.widget.RecyclerView
                    android:id="@+id/rv_ble_devices"
                    android:layout_width="match_parent"
                    android:layout_height="200dp"
                    android:layout_marginTop="8dp" />

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

        <!-- BLE UDP Bridge -->
        <com.google.android.material.card.MaterialCardView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="16dp"
            app:cardCornerRadius="8dp"
            app:cardElevation="4dp">

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

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="🔁 BLE UDP Bridge"
                    android:textSize="18sp"
                    android:textStyle="bold"
                    android:textColor="@android:color/black"
                    android:layout_marginBottom="12dp" />

                <com.google.android.material.switchmaterial.SwitchMaterial
                    android:id="@+id/switch_ble_udp_bridge_enabled"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Включить UDP-bridge (пересылать NMEA)"
                    android:textSize="16sp"
                    android:layout_marginBottom="8dp" />

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="8dp"
                    android:hint="UDP Host (назначение)">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/et_ble_udp_host"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:inputType="text"
                        android:text="255.255.255.255" />

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

                <com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="8dp"
                    android:hint="UDP Port (назначение)">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/et_ble_udp_port"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:inputType="number"
                        android:text="10110" />

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

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

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:gravity="end">

            <Button
                android:id="@+id/btn_cancel"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Отмена"
                android:layout_marginEnd="8dp"
                style="@style/Widget.Material3.Button.OutlinedButton" />

            <Button
                android:id="@+id/btn_save"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Сохранить"
                style="@style/Widget.Material3.Button" />
        </LinearLayout>

    </LinearLayout>
</ScrollView>
