<div class="space-y-4">
    {{-- 选择老师（如果是老师登录，自动选中并隐藏） --}}
    @if(!$this->shouldHideTeacherDropdown())
        <div class="form-control w-full">
            <label class="label">
                <span class="label-text font-medium">
                    {{ $teacherLabel }}
                    @if($required)
                        <span class="text-error">*</span>
                    @endif
                </span>
            </label>
            <select
                wire:model.live="teacherId"
                class="select select-bordered w-full"
                @if($required) required @endif
            >
                <option value="">{{ $teacherPlaceholder }}</option>
                @foreach($teacherOptions as $teacherId => $teacherName)
                    <option value="{{ $teacherId }}">{{ $teacherName }}</option>
                @endforeach
            </select>
            @if($teacherHelperText)
                <label class="label">
                    <span class="label-text-alt text-info">{{ $teacherHelperText }}</span>
                </label>
            @endif
            @if($teacherId)
                <label class="label">
                    <span class="label-text-alt text-success">
                        <svg class="w-3 h-3 inline mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
                        </svg>
                        已选择：{{ $teacherId ? $teacherOptions[$teacherId] ?? '未选择' : '未选择' }}
                    </span>
                </label>
            @endif
        </div>
    @else
        {{-- 显示当前选中的老师信息（不可编辑） --}}
        <div class="form-control w-full">
            <label class="label">
                <span class="label-text font-medium">
                    {{ $teacherLabel }}
                    @if($required)
                        <span class="text-error">*</span>
                    @endif
                </span>
                <span class="label-text-alt text-info">
                    <svg class="w-3 h-3 inline mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
                    </svg>
                    已自动选择
                </span>
            </label>
            <div class="p-3 bg-base-200 rounded-lg">
                <div class="font-medium">
                    {{ $teacherId ? $teacherOptions[$teacherId] ?? '未选择' : '未选择' }}
                </div>
                @if($teacherHelperText)
                    <div class="text-xs text-gray-500 mt-1">{{ $teacherHelperText }}</div>
                @endif
            </div>
            <input type="hidden" wire:model.live="teacherId">
        </div>
    @endif

    {{-- 选择学生 --}}
    <div class="form-control w-full">
        <label class="label">
            <span class="label-text font-medium">
                {{ $studentLabel }}
                @if($required)
                    <span class="text-error">*</span>
                @endif
            </span>
        </label>
        <select
            wire:model.live="studentId"
            wire:change="$refresh"
            class="select select-bordered w-full"
            @if(empty($teacherId)) disabled @endif
            @if($required) required @endif
        >
            <option value="">
                @if(empty($teacherId))
                    请先选择老师
                @else
                    {{ $studentPlaceholder }}
                @endif
            </option>
            @foreach($studentOptions as $studentId => $studentName)
                <option value="{{ $studentId }}">{{ $studentName }}</option>
            @endforeach
        </select>
        @if($studentHelperText)
            <label class="label">
                <span class="label-text-alt text-info">{{ $studentHelperText }}</span>
            </label>
        @endif
        @if($studentId)
            <label class="label">
                <span class="label-text-alt text-success">
                    <svg class="w-3 h-3 inline mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
                    </svg>
                    已选择：{{ $studentId ? $studentOptions[$studentId] ?? '未选择' : '未选择' }}
                </span>
            </label>
        @elseif($teacherId && empty($studentOptions))
            <label class="label">
                <span class="label-text-alt text-warning">
                    <svg class="w-3 h-3 inline mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 15.5c-.77.833.192 2.5 1.732 2.5z"></path>
                    </svg>
                    该老师暂无学生
                </span>
            </label>
        @endif
    </div>
</div>