<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:background="?attr/itemBackground"
    android:fitsSystemWindows="true">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/rule_toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:minHeight="?attr/actionBarSize"
        android:background="?attr/colorPrimary" />

    <androidx.core.widget.NestedScrollView
        android:id="@+id/ruleScrollView"
        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="8dp">

            <!-- Rules Section -->
            <androidx.cardview.widget.CardView
                android:id="@+id/rules_card"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:cardCornerRadius="12dp"
                app:cardElevation="4dp"
                app:cardBackgroundColor="?attr/itemBackground"
                android:layout_marginBottom="8dp"
                android:layout_marginHorizontal="2dp">

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

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

                        <ImageView
                            android:layout_width="24dp"
                            android:layout_height="24dp"
                            android:src="@drawable/ic_rules"
                            app:tint="?attr/colorPrimary" />

                        <TextView
                            android:id="@+id/rules_title"
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:text="@string/showrules_title"
                            android:textAppearance="?android:attr/textAppearanceLarge"
                            android:textStyle="bold"
                            android:textColor="?attr/colorPrimary"
                            android:layout_marginStart="12dp" />

                        <TextView
                            android:id="@+id/rules_status"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@string/loading_data_title"
                            android:textAppearance="?android:attr/textAppearanceSmall"
                            android:textColor="?android:attr/textColorSecondary" />
                    </LinearLayout>

                    <TextView
                        android:id="@+id/rules_content"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:typeface="monospace"
                        android:textAppearance="?android:attr/textAppearanceSmall"
                        android:textColor="?android:attr/textColorPrimary"
                        android:background="@drawable/text_background_rounded"
                        android:padding="12dp"
                        android:scrollHorizontally="true"
                        android:text="@string/loading_iptables_rules" />

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

            <!-- Network Interfaces Section -->
            <androidx.cardview.widget.CardView
                android:id="@+id/interfaces_card"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:cardCornerRadius="12dp"
                app:cardElevation="4dp"
                app:cardBackgroundColor="?attr/itemBackground"
                android:layout_marginBottom="8dp"
                android:layout_marginHorizontal="2dp"
                android:visibility="gone">

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

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

                        <ImageView
                            android:layout_width="24dp"
                            android:layout_height="24dp"
                            android:src="@drawable/ic_wifi"
                            app:tint="?attr/colorAccent" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@string/network_interfaces"
                            android:textAppearance="?android:attr/textAppearanceLarge"
                            android:textStyle="bold"
                            android:textColor="?attr/colorAccent"
                            android:layout_marginStart="12dp" />
                    </LinearLayout>

                    <TextView
                        android:id="@+id/interfaces_content"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:typeface="monospace"
                        android:textAppearance="?android:attr/textAppearanceSmall"
                        android:textColor="?android:attr/textColorPrimary"
                        android:background="@drawable/text_background_rounded"
                        android:padding="12dp"
                        android:scrollHorizontally="true" />

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

            <!-- System Info Section -->
            <androidx.cardview.widget.CardView
                android:id="@+id/system_card"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:cardCornerRadius="12dp"
                app:cardElevation="4dp"
                app:cardBackgroundColor="?attr/itemBackground"
                android:layout_marginBottom="8dp"
                android:layout_marginHorizontal="2dp"
                android:visibility="gone">

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

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

                        <ImageView
                            android:layout_width="24dp"
                            android:layout_height="24dp"
                            android:src="@android:drawable/ic_menu_info_details"
                            app:tint="?android:attr/textColorSecondary" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@string/system_information"
                            android:textAppearance="?android:attr/textAppearanceLarge"
                            android:textStyle="bold"
                            android:textColor="?android:attr/textColorSecondary"
                            android:layout_marginStart="12dp" />
                    </LinearLayout>

                    <TextView
                        android:id="@+id/system_content"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:typeface="monospace"
                        android:textAppearance="?android:attr/textAppearanceSmall"
                        android:textColor="?android:attr/textColorPrimary"
                        android:background="@drawable/text_background_rounded"
                        android:padding="12dp"
                        android:scrollHorizontally="true" />

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

            <!-- Preferences Section -->
            <androidx.cardview.widget.CardView
                android:id="@+id/preferences_card"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:cardCornerRadius="12dp"
                app:cardElevation="4dp"
                app:cardBackgroundColor="?attr/itemBackground"
                android:layout_marginBottom="8dp"
                android:layout_marginHorizontal="2dp"
                android:visibility="gone">

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

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

                        <ImageView
                            android:layout_width="24dp"
                            android:layout_height="24dp"
                            android:src="@android:drawable/ic_menu_preferences"
                            app:tint="?android:attr/textColorSecondary" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@string/preferences_amp_status"
                            android:textAppearance="?android:attr/textAppearanceLarge"
                            android:textStyle="bold"
                            android:textColor="?android:attr/textColorSecondary"
                            android:layout_marginStart="12dp" />
                    </LinearLayout>

                    <TextView
                        android:id="@+id/preferences_content"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:typeface="monospace"
                        android:textAppearance="?android:attr/textAppearanceSmall"
                        android:textColor="?android:attr/textColorPrimary"
                        android:background="@drawable/text_background_rounded"
                        android:padding="12dp"
                        android:scrollHorizontally="true" />

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

            <!-- Logcat Section -->
            <androidx.cardview.widget.CardView
                android:id="@+id/logcat_card"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:cardCornerRadius="12dp"
                app:cardElevation="4dp"
                app:cardBackgroundColor="?attr/itemBackground"
                android:layout_marginBottom="8dp"
                android:layout_marginStart="4dp"
                android:layout_marginEnd="4dp"
                android:visibility="gone">

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

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

                        <ImageView
                            android:layout_width="24dp"
                            android:layout_height="24dp"
                            android:src="@android:drawable/ic_menu_view"
                            app:tint="?android:attr/textColorSecondary" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@string/logcat_title"
                            android:textAppearance="?android:attr/textAppearanceLarge"
                            android:textStyle="bold"
                            android:textColor="?android:attr/textColorSecondary"
                            android:layout_marginStart="12dp" />
                    </LinearLayout>

                    <TextView
                        android:id="@+id/logcat_content"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:typeface="monospace"
                        android:textAppearance="?android:attr/textAppearanceSmall"
                        android:textColor="?android:attr/textColorPrimary"
                        android:background="@drawable/text_background_rounded"
                        android:padding="12dp"
                        android:scrollHorizontally="true" />

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

            <!-- Hidden TextView for backward compatibility -->
            <TextView
                android:id="@+id/rules"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:typeface="monospace"
                android:visibility="gone" />

        </LinearLayout>
    </androidx.core.widget.NestedScrollView>
</LinearLayout>