<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <data>

        <variable
            name="tire1"
            type="com.example.tyre.maintenance.been.BaseTyre" />

        <variable
            name="tire2"
            type="com.example.tyre.maintenance.been.BaseTyre" />

        <variable
            name="tire3"
            type="com.example.tyre.maintenance.been.BaseTyre" />

        <variable
            name="tire4"
            type="com.example.tyre.maintenance.been.BaseTyre" />

        <variable
            name="tire5"
            type="com.example.tyre.maintenance.been.BaseTyre" />

        <variable
            name="tire6"
            type="com.example.tyre.maintenance.been.BaseTyre" />

        <variable
            name="adapter"
            type="com.example.tyre.adapter.CarRecordAdapter" />

    </data>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#F0F4F8"
        android:fillViewport="true"> <!-- 浅灰色背景提升质感 -->

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

            <!-- 顶部：搜索卡片 -->
            <com.google.android.material.card.MaterialCardView
                android:id="@+id/card_search"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:cardCornerRadius="16dp"
                app:cardElevation="4dp"
                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:orientation="vertical"
                    android:padding="24dp">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center_horizontal"
                        android:layout_marginBottom="20dp"
                        android:text="公交车轮胎管理"
                        android:textColor="#202020"
                        android:textSize="18sp"
                        android:textStyle="bold" />

                    <!-- 车牌号输入 -->
                    <com.google.android.material.textfield.TextInputLayout
                        android:id="@+id/til_plate_number"
                        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginBottom="16dp"
                        android:hint="请输入车牌号"
                        app:endIconDrawable="@mipmap/search_icon"
                        app:endIconMode="custom">

                        <com.google.android.material.textfield.TextInputEditText
                            android:id="@+id/et_plate_number"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:inputType="number"
                            android:maxLines="1" />
                    </com.google.android.material.textfield.TextInputLayout>

                    <Button
                        android:id="@+id/btn_retrieve"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="立即检索"
                        android:textSize="16sp"
                        app:cornerRadius="8dp" />
                </LinearLayout>
            </com.google.android.material.card.MaterialCardView>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:layout_marginTop="12dp"
                android:background="@drawable/card_bg"
                android:padding="12dp">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:gravity="center"
                    android:text="车辆最新里程："
                    android:textColor="#202020"
                    android:textSize="16sp"
                    android:textStyle="bold" />

                <TextView
                    android:id="@+id/select_info_mileage"
                    android:layout_width="100dp"
                    android:layout_height="match_parent"
                    android:gravity="center"
                    android:text="0"
                    android:textColor="#202020"
                    android:textSize="16sp"
                    android:textStyle="bold" />

            </LinearLayout>
            <!-- 底部：三轴轮位图展示区 -->
            <com.google.android.material.card.MaterialCardView
                android:id="@+id/card_visual"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginTop="16dp"
                android:visibility="gone"
                app:cardCornerRadius="16dp"
                app:cardElevation="2dp"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/card_search">

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:padding="16dp">

                    <!-- 辅助线：垂直中心线 (分隔左右轮胎) -->
                    <androidx.constraintlayout.widget.Guideline
                        android:id="@+id/guideline_vertical_center"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:orientation="vertical"
                        app:layout_constraintGuide_percent="0.5" />

                    <!-- 辅助线：水平线 1 (第1轴位置) -->
                    <androidx.constraintlayout.widget.Guideline
                        android:id="@+id/guideline_axis_1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal"
                        app:layout_constraintGuide_begin="96dp" />

                    <!-- 辅助线：水平线 2 (第2轴位置) -->
                    <androidx.constraintlayout.widget.Guideline
                        android:id="@+id/guideline_axis_2"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal"
                        app:layout_constraintGuide_end="235dp" />

                    <!-- 辅助线：水平线 3 (第3轴位置) -->
                    <androidx.constraintlayout.widget.Guideline
                        android:id="@+id/guideline_axis_3"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal"
                        app:layout_constraintGuide_begin="399dp" />

                    <!-- 车头指示 -->
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="🚗 车头方向"
                        android:textColor="#999999"
                        android:textSize="10sp"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />

                    <!-- ================= 第1轴 (前轴) ================= -->
                    <!-- 左侧轮胎 (1轴) -->
                    <include
                        android:id="@+id/tire_left_front"
                        layout="@layout/item_tire"
                        android:layout_width="0dp"
                        android:layout_height="120dp"
                        app:layout_constraintBottom_toBottomOf="@id/guideline_axis_1"
                        app:layout_constraintEnd_toStartOf="@id/guideline_vertical_center"
                        app:layout_constraintHorizontal_bias="0.5"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="@id/guideline_axis_1" />

                    <!-- 右侧轮胎 (1轴) -->

                    <!-- ================= 第2轴 (中轴) ================= -->
                    <!-- 左侧轮胎 (2轴) -->

                    <include
                        android:id="@+id/tire_right_front"
                        layout="@layout/item_tire"
                        android:layout_width="0dp"
                        android:layout_height="120dp"
                        app:layout_constraintBottom_toBottomOf="@id/guideline_axis_1"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintHorizontal_bias="0.0"
                        app:layout_constraintStart_toEndOf="@id/guideline_vertical_center"
                        app:layout_constraintTop_toTopOf="@id/guideline_axis_1" />

                    <include
                        android:id="@+id/tire_middle_left"
                        layout="@layout/item_tire"
                        android:layout_width="0dp"
                        android:layout_height="120dp"
                        app:layout_constraintBottom_toBottomOf="@id/guideline_axis_2"
                        app:layout_constraintEnd_toStartOf="@id/guideline_vertical_center"
                        app:layout_constraintHorizontal_bias="0.5"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="@id/guideline_axis_2" />

                    <!-- 右侧轮胎 (2轴) -->
                    <include
                        android:id="@+id/tire_middle_right"
                        layout="@layout/item_tire"
                        android:layout_width="0dp"
                        android:layout_height="120dp"
                        app:layout_constraintBottom_toBottomOf="@id/guideline_axis_2"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintHorizontal_bias="0.5"
                        app:layout_constraintStart_toEndOf="@id/guideline_vertical_center"
                        app:layout_constraintTop_toTopOf="@id/guideline_axis_2" />

                    <!-- ================= 第3轴 (后轴) ================= -->
                    <!-- 左侧轮胎 (3轴) -->
                    <include
                        android:id="@+id/tire_bottom_left"
                        layout="@layout/item_tire"
                        android:layout_width="0dp"
                        android:layout_height="120dp"
                        app:layout_constraintBottom_toBottomOf="@id/guideline_axis_3"
                        app:layout_constraintEnd_toStartOf="@id/guideline_vertical_center"
                        app:layout_constraintHorizontal_bias="0.5"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="@id/guideline_axis_3" />

                    <!-- 右侧轮胎 (3轴) -->
                    <include
                        android:id="@+id/tire_bottom_right"
                        layout="@layout/item_tire"
                        android:layout_width="0dp"
                        android:layout_height="120dp"
                        app:layout_constraintBottom_toBottomOf="@id/guideline_axis_3"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintHorizontal_bias="0.5"
                        app:layout_constraintStart_toEndOf="@id/guideline_vertical_center"
                        app:layout_constraintTop_toTopOf="@id/guideline_axis_3" />

                </androidx.constraintlayout.widget.ConstraintLayout>
            </com.google.android.material.card.MaterialCardView>

            <LinearLayout
                style="@style/layout_card_style"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="12dp"
                android:orientation="vertical">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center">

                    <include
                        android:id="@+id/tireClick1"
                        layout="@layout/layout_trae_info"
                        android:layout_width="80dp"
                        android:layout_height="wrap_content"
                        app:data="@{tire1}"
                        app:locationOld='@{"左前轮"}' />

                    <View
                        android:layout_width="match_parent"
                        android:layout_height="3dp"
                        android:layout_weight="1"
                        android:background="#E3E6EC" />

                    <TextView
                        android:layout_width="30dp"
                        android:layout_height="30dp"
                        android:background="@drawable/bg_grey"
                        android:gravity="center"
                        android:text="1"
                        android:textStyle="bold" />

                    <View
                        android:layout_width="match_parent"
                        android:layout_height="3dp"
                        android:layout_weight="1"
                        android:background="#E3E6EC" />


                    <include
                        android:id="@+id/tireClick2"
                        layout="@layout/layout_trae_info"
                        android:layout_width="80dp"
                        android:layout_height="wrap_content"
                        app:data="@{tire2}"
                        app:locationOld='@{"右前轮"}' />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="8dp"
                    android:gravity="center">

                    <include
                        android:id="@+id/tireClick3"
                        layout="@layout/layout_trae_info"
                        android:layout_width="80dp"
                        android:layout_height="wrap_content"
                        app:data="@{tire3}"
                        app:locationOld='@{"左外轮"}' />

                    <include
                        android:id="@+id/tireClick4"
                        layout="@layout/layout_trae_info"
                        android:layout_width="80dp"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="4dp"
                        app:data="@{tire4}"
                        app:locationOld='@{"左内轮"}' />

                    <View
                        android:layout_width="match_parent"
                        android:layout_height="3dp"
                        android:layout_weight="1"
                        android:background="#E3E6EC" />

                    <TextView
                        android:layout_width="30dp"
                        android:layout_height="30dp"
                        android:background="@drawable/bg_grey"
                        android:gravity="center"
                        android:text="2"
                        android:textStyle="bold" />

                    <View
                        android:layout_width="match_parent"
                        android:layout_height="3dp"
                        android:layout_weight="1"
                        android:background="#E3E6EC" />


                    <include
                        android:id="@+id/tireClick5"
                        layout="@layout/layout_trae_info"
                        android:layout_width="80dp"
                        android:layout_height="wrap_content"
                        app:data="@{tire5}"
                        app:locationOld='@{"右内轮"}' />

                    <include
                        android:id="@+id/tireClick6"
                        layout="@layout/layout_trae_info"
                        android:layout_width="80dp"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="4dp"
                        app:data="@{tire6}"
                        app:locationOld='@{"右外轮"}' />
                </LinearLayout>

            </LinearLayout>

            <androidx.recyclerview.widget.RecyclerView
                android:layout_width="match_parent"
                android:layout_height="400dp"
                android:layout_marginTop="12dp"
                android:adapter="@{adapter}"
                android:background="@drawable/card_bg"
                android:padding="8dp"
                app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
        </LinearLayout>
    </ScrollView>
</layout>