<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="340dp"
    android:layout_height="wrap_content"
    app:cardCornerRadius="32dp"
    app:cardElevation="8dp"
    app:cardBackgroundColor="@android:color/transparent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:background="@drawable/bg_dialog_solid_v4"
        android:padding="20dp">
        
        <!-- Header: Date and Shift -->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:gravity="center"
            android:paddingTop="8dp"
            android:paddingBottom="20dp">

            <TextView
                android:id="@+id/dialogSubtitle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="내일의 근무"
                android:textSize="14sp"
                android:textColor="@color/text_secondary"
                android:layout_marginBottom="4dp"/>

            <TextView
                android:id="@+id/dialogTitle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="2월 12일 (주간)"
                android:textSize="22sp"
                android:textStyle="bold"
                android:textColor="@color/text_primary"
                android:letterSpacing="-0.02"/>
        </LinearLayout>

        <!-- 5-Column Grid Refactored -->
        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <!-- Row 1 -->
            <TextView android:id="@+id/btnJu" style="@style/ShiftCircleButton" android:text="주" android:textColor="@color/shift_ju"/>
            <TextView android:id="@+id/btnSeok" style="@style/ShiftCircleButton" android:text="석" android:textColor="@color/shift_seok"/>
            <TextView android:id="@+id/btnYa" style="@style/ShiftCircleButton" android:text="야" android:textColor="@color/shift_ya"/>
            <TextView android:id="@+id/btnJuMat" style="@style/ShiftCircleButton" android:text="주맞" android:textSize="13sp" android:textColor="@color/shift_jumat"/>
            <TextView android:id="@+id/btnYaMat" style="@style/ShiftCircleButton" android:text="야맞" android:textSize="13sp" android:textColor="@color/shift_yamat"/>

            <!-- Row 2 -->
            <TextView android:id="@+id/btnOff" style="@style/ShiftCircleButton" android:text="휴" android:textColor="@color/shift_off"/>
            <TextView android:id="@+id/btnWolcha" style="@style/ShiftCircleButton" android:text="월차" android:textSize="13sp" android:textColor="@color/secondary"/>
            <TextView android:id="@+id/btnYeoncha" style="@style/ShiftCircleButton" android:text="연차" android:textSize="13sp" android:textColor="@color/secondary"/>
            <TextView android:id="@+id/btnBanwol" style="@style/ShiftCircleButton" android:text="반월" android:textSize="13sp" android:textColor="@color/shift_red"/>
            <TextView android:id="@+id/btnBannyeon" style="@style/ShiftCircleButton" android:text="반년" android:textSize="13sp" android:textColor="@color/shift_red"/>

            <!-- Row 3 -->
            <TextView android:id="@+id/btnEdu" style="@style/ShiftCircleButton" android:text="교육" android:textSize="13sp" android:textColor="@color/primary"/>
            <TextView android:id="@+id/btnReset" style="@style/ShiftCircleButton" android:text="초기" android:textSize="13sp" android:textColor="@color/text_secondary"/>
            <TextView android:id="@+id/btnManual" style="@style/ShiftCircleButton" android:text="직접" android:textSize="14sp" android:textColor="@color/shift_gray"/>

            <androidx.constraintlayout.helper.widget.Flow
                android:id="@+id/gridFlow"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:constraint_referenced_ids="btnJu,btnSeok,btnYa,btnJuMat,btnYaMat, btnOff,btnWolcha,btnYeoncha,btnBanwol,btnBannyeon, btnEdu,btnReset,btnManual"
                app:flow_wrapMode="aligned"
                app:flow_maxElementsWrap="5"
                app:flow_horizontalStyle="packed"
                app:flow_horizontalGap="8dp"
                app:flow_verticalGap="12dp"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintBottom_toBottomOf="parent"/>

        </androidx.constraintlayout.widget.ConstraintLayout>

        <View
            android:id="@+id/memoDivider"
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="@color/grid_divider"
            android:layout_marginTop="20dp"/>

        <!-- Memo Section -->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_marginTop="16dp"
            android:background="@drawable/bg_glass_button_light"
            android:padding="16dp">

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

                <TextView
                    android:id="@+id/memoTitle"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:text="하루 메모"
                    android:textSize="15sp"
                    android:textStyle="bold"
                    android:textColor="@color/text_primary"/>

                <ImageView
                    android:id="@+id/btnClearMemo"
                    android:layout_width="28dp"
                    android:layout_height="28dp"
                    android:src="@drawable/ic_delete"
                    app:tint="@color/shift_red"
                    android:padding="6dp"
                    android:background="?attr/selectableItemBackgroundBorderless"/>
            </LinearLayout>

            <EditText
                android:id="@+id/etMemo"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="여기에 메모를 입력하세요"
                android:inputType="textMultiLine|textNoSuggestions"
                android:minLines="2"
                android:maxLines="4"
                android:gravity="top|start"
                android:textSize="15sp"
                android:textColor="@color/text_primary"
                android:background="@android:color/transparent"
                android:padding="0dp"/>
        </LinearLayout>

        <com.google.android.material.button.MaterialButton
            android:id="@+id/btnClose"
            android:layout_width="match_parent"
            android:layout_height="56dp"
            android:text="저장 및 닫기"
            android:layout_marginTop="24dp"
            android:textSize="16sp"
            android:textStyle="bold"
            android:textColor="#FFFFFF"
            app:cornerRadius="28dp"
            android:backgroundTint="@color/primary"
            android:elevation="2dp"/>

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