<!-- 일일 로그 생성/수정 모달 -->
<div id="logModal" class="hidden fixed inset-0 z-50 overflow-y-auto">
    <!-- 배경 -->
    <div class="fixed inset-0 bg-black bg-opacity-50 transition-opacity" onclick="closeModal()"></div>

    <!-- 모달 컨텐츠 -->
    <div class="flex min-h-full items-center justify-center p-4">
        <div class="relative transform overflow-hidden rounded-lg bg-white shadow-xl transition-all w-full max-w-2xl">
            <!-- 헤더 -->
            <div class="bg-gray-50 px-6 py-4 border-b">
                <h3 id="modalTitle" class="text-lg font-semibold text-gray-900">새 일일 로그</h3>
                <button type="button" onclick="closeModal()" class="absolute top-4 right-4 text-gray-400 hover:text-gray-600">
                    <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
                    </svg>
                </button>
            </div>

            <!-- 폼 -->
            <form id="logForm" class="p-6">
                <input type="hidden" id="logId" name="id">

                <!-- 기본 정보 -->
                <div class="grid grid-cols-2 gap-4 mb-6">
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">날짜 <span class="text-red-500">*</span></label>
                        <input type="date"
                               id="logDate"
                               name="log_date"
                               required
                               class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
                    </div>
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">프로젝트</label>
                        <select id="projectId"
                                name="project_id"
                                class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
                            <option value="">전체 (프로젝트 미지정)</option>
                            @foreach($projects as $project)
                                <option value="{{ $project->id }}">{{ $project->name }}</option>
                            @endforeach
                        </select>
                    </div>
                </div>

                <div class="mb-6">
                    <label class="block text-sm font-medium text-gray-700 mb-1">일일 요약</label>
                    <textarea id="summary"
                              name="summary"
                              rows="8"
                              placeholder="오늘의 주요 활동 요약..."
                              class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"></textarea>
                </div>

                <!-- 항목 목록 -->
                <div class="mb-6">
                    <div class="flex justify-between items-center mb-2">
                        <label class="block text-sm font-medium text-gray-700">업무 항목</label>
                        <button type="button"
                                onclick="addEntry()"
                                class="text-sm text-blue-600 hover:text-blue-800">
                            + 항목 추가
                        </button>
                    </div>

                    <div id="entriesContainer" class="space-y-3">
                        <!-- 항목들이 여기에 동적으로 추가됨 -->
                    </div>

                    <div class="mt-3 text-center">
                        <button type="button"
                                onclick="addEntry()"
                                class="text-sm text-gray-500 hover:text-gray-700 py-2">
                            + 새 항목 추가
                        </button>
                    </div>
                </div>

                <!-- 버튼 -->
                <div class="flex justify-end space-x-3 pt-4 border-t">
                    <button type="button"
                            onclick="closeModal()"
                            class="px-4 py-2 text-gray-700 bg-gray-200 rounded-lg hover:bg-gray-300 transition">
                        취소
                    </button>
                    <button type="submit"
                            class="px-4 py-2 text-white bg-blue-600 rounded-lg hover:bg-blue-700 transition">
                        저장
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
