{{--
    연차유급휴가 사용촉진 통지서 (1차) 읽기전용
    Props:
        $content (array) - approvals.content JSON
--}}
<div class="space-y-4">
    {{-- 미리보기 버튼 --}}
    <div class="flex justify-end gap-2">
        <button type="button" onclick="openLp1ShowPreview()"
                class="px-3 py-1.5 bg-indigo-50 text-indigo-600 hover:bg-indigo-100 border border-indigo-200 rounded-lg text-sm font-medium transition inline-flex items-center gap-1">
            <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/>
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"/>
            </svg>
            통지서 미리보기
        </button>
    </div>

    {{-- 수신자 정보 --}}
    <div class="border border-gray-200 rounded-lg overflow-hidden">
        <div class="bg-gray-50 px-4 py-2 border-b border-gray-200">
            <h3 class="text-sm font-semibold text-gray-700">수신자 정보</h3>
        </div>
        <div class="p-4">
            <div class="grid gap-3" style="grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));">
                <div>
                    <span class="text-xs text-gray-500">직원명</span>
                    <div class="text-sm font-medium mt-0.5">{{ $content['employee_name'] ?? '-' }}</div>
                </div>
                <div>
                    <span class="text-xs text-gray-500">부서</span>
                    <div class="text-sm font-medium mt-0.5">{{ $content['department'] ?? '-' }}</div>
                </div>
                <div>
                    <span class="text-xs text-gray-500">직급</span>
                    <div class="text-sm font-medium mt-0.5">{{ $content['position'] ?? '-' }}</div>
                </div>
            </div>
        </div>
    </div>

    {{-- 연차 현황 --}}
    <div class="border border-gray-200 rounded-lg overflow-hidden">
        <div class="bg-gray-50 px-4 py-2 border-b border-gray-200">
            <h3 class="text-sm font-semibold text-gray-700">연차 현황</h3>
        </div>
        <div class="p-4">
            <div class="grid gap-3" style="grid-template-columns: repeat(3, 1fr);">
                <div class="text-center p-3 bg-blue-50 rounded-lg">
                    <div class="text-xs text-blue-600">발생연차</div>
                    <div class="text-lg font-bold text-blue-800 mt-1">{{ $content['total_days'] ?? 0 }}일</div>
                </div>
                <div class="text-center p-3 bg-green-50 rounded-lg">
                    <div class="text-xs text-green-600">사용연차</div>
                    <div class="text-lg font-bold text-green-800 mt-1">{{ $content['used_days'] ?? 0 }}일</div>
                </div>
                <div class="text-center p-3 bg-amber-50 rounded-lg">
                    <div class="text-xs text-amber-600">잔여연차</div>
                    <div class="text-lg font-bold text-amber-800 mt-1">{{ $content['remaining_days'] ?? 0 }}일</div>
                </div>
            </div>
        </div>
    </div>

    {{-- 사용계획 제출기한 --}}
    <div class="border border-amber-200 rounded-lg overflow-hidden">
        <div class="bg-amber-50 px-4 py-2 border-b border-amber-200">
            <h3 class="text-sm font-semibold text-amber-700">사용계획 제출기한</h3>
        </div>
        <div class="p-4">
            <div class="text-base font-semibold text-amber-800">{{ $content['deadline'] ?? '-' }}</div>
        </div>
    </div>

    {{-- 법적 문구 --}}
    <div class="border border-blue-200 rounded-lg overflow-hidden">
        <div class="bg-blue-50 px-4 py-2 border-b border-blue-200">
            <h3 class="text-sm font-semibold text-blue-700">법적 통지 문구</h3>
        </div>
        <div class="p-4 text-xs text-gray-600 leading-relaxed space-y-1">
            <p>근로기준법 제61조에 따라 귀하의 미사용 연차유급휴가 사용을 촉진하고자 통지합니다.</p>
            <p class="text-red-600 font-medium">기한 내 사용 시기를 제출하지 않을 경우 회사는 연차휴가 사용 시기를 지정할 수 있습니다.</p>
        </div>
    </div>
</div>

{{-- 미리보기 모달 --}}
<div id="lp1-show-preview-modal" style="display: none;" class="fixed inset-0 z-50">
    <div class="absolute inset-0 bg-black/50" onclick="closeLp1ShowPreview()"></div>
    <div class="relative flex items-center justify-center min-h-full p-4">
        <div class="bg-white rounded-xl shadow-2xl w-full overflow-hidden relative" style="max-width: 780px;">
            <div class="flex items-center justify-between px-5 py-3 border-b border-gray-200 bg-gray-50">
                <h3 class="text-base font-semibold text-gray-800">1차 통지서 미리보기</h3>
                <div class="flex items-center gap-2">
                    <button type="button" onclick="printLp1ShowPreview()"
                            class="px-3 py-1.5 bg-white border border-gray-300 hover:bg-gray-50 rounded-lg text-xs font-medium transition inline-flex items-center gap-1">
                        <svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 17h2a2 2 0 002-2v-4a2 2 0 00-2-2H5a2 2 0 00-2 2v4a2 2 0 002 2h2m2 4h6a2 2 0 002-2v-4a2 2 0 00-2-2H9a2 2 0 00-2 2v4a2 2 0 002 2zm8-12V5a2 2 0 00-2-2H9a2 2 0 00-2 2v4h10z"/>
                        </svg>
                        인쇄
                    </button>
                    <button type="button" onclick="closeLp1ShowPreview()"
                            class="p-1 text-gray-400 hover:text-gray-600 transition">
                        <svg class="w-5 h-5" 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>
            </div>
            <div class="overflow-y-auto" style="max-height: 80vh;">
                <div id="lp1-show-preview-content" style="padding: 40px 48px; font-family: 'Pretendard', 'Malgun Gothic', sans-serif;"></div>
            </div>
        </div>
    </div>
</div>

@push('scripts')
<script>
function buildLp1ShowPreviewHtml(data) {
    return '<div style="text-align:center;margin-bottom:32px;">' +
        '<h1 style="font-size:20px;font-weight:800;margin:0;letter-spacing:4px;">연차유급휴가 사용촉진 통지서 (1차)</h1>' +
        '</div>' +
        '<div style="border-bottom:2px solid #333;padding-bottom:12px;margin-bottom:24px;font-size:13px;line-height:2;">' +
        '<div><span style="display:inline-block;width:60px;font-weight:600;">수신</span> : ' + (data.employee_name || '') + '</div>' +
        '<div><span style="display:inline-block;width:60px;font-weight:600;">부서</span> : ' + (data.department || '') + '</div>' +
        '<div><span style="display:inline-block;width:60px;font-weight:600;">직급</span> : ' + (data.position || '') + '</div>' +
        '</div>' +
        '<div style="font-size:13px;line-height:1.8;margin-bottom:24px;">' +
        '<p>근로기준법 제61조에 따라 귀하의 미사용 연차유급휴가 사용을 촉진하고자 아래와 같이 통지합니다.</p>' +
        '</div>' +
        '<div style="margin:24px 0;padding:16px 20px;border:1px solid #ddd;border-radius:4px;">' +
        '<div style="font-size:13px;font-weight:700;margin-bottom:8px;">■ 연차 현황</div>' +
        '<table style="width:100%;border-collapse:collapse;font-size:13px;">' +
        '<tr><td style="padding:6px 12px;border:1px solid #ddd;background:#f8f9fa;font-weight:600;width:100px;">발생연차</td>' +
        '<td style="padding:6px 12px;border:1px solid #ddd;text-align:center;">' + (data.total_days || 0) + '일</td>' +
        '<td style="padding:6px 12px;border:1px solid #ddd;background:#f8f9fa;font-weight:600;width:100px;">사용연차</td>' +
        '<td style="padding:6px 12px;border:1px solid #ddd;text-align:center;">' + (data.used_days || 0) + '일</td>' +
        '<td style="padding:6px 12px;border:1px solid #ddd;background:#f8f9fa;font-weight:600;width:100px;">잔여연차</td>' +
        '<td style="padding:6px 12px;border:1px solid #ddd;text-align:center;color:#dc2626;font-weight:700;">' + (data.remaining_days || 0) + '일</td></tr>' +
        '</table>' +
        '</div>' +
        '<div style="font-size:13px;line-height:1.8;margin-bottom:16px;">' +
        '<p>위 잔여 연차휴가에 대하여 아래 기한까지 사용 시기를 지정하여 제출하여 주시기 바랍니다.</p>' +
        '</div>' +
        '<div style="margin:16px 0;padding:12px 20px;border:1px solid #ddd;border-radius:4px;background:#fffbeb;">' +
        '<div style="font-size:13px;font-weight:700;">■ 사용계획 제출기한 : ' + (data.deadline || '') + '</div>' +
        '</div>' +
        '<div style="font-size:12px;line-height:1.8;margin:24px 0;padding:12px 16px;background:#f8f9fa;border-radius:4px;color:#666;">' +
        '<p>기한 내 사용 시기를 제출하지 않을 경우 회사는 근로기준법 제61조에 따라 연차휴가 사용 시기를 지정할 수 있습니다.</p>' +
        '<p>본 통지서는 연차 사용 촉진 절차에 따른 법적 통보 문서이며, 확인 시 수신 확인으로 간주됩니다.</p>' +
        '</div>' +
        '<div style="text-align:center;margin:40px 0 16px;font-size:14px;">' +
        '<span>' + (data.company_name || '') + '</span>&nbsp;&nbsp;&nbsp;&nbsp;' +
        '<span>대표이사&nbsp;&nbsp;&nbsp;' + (data.ceo_name || '') + '</span>&nbsp;&nbsp;' +
        '<span style="color:#999;">[직인날인]</span>' +
        '</div>' +
        '<div style="border-top:2px solid #333;padding-top:12px;margin-top:24px;">' +
        '<div style="font-size:12px;color:#666;text-align:center;">□ 본인은 위 내용을 확인하였으며 연차 사용 시기를 제출하겠습니다.</div>' +
        '<div style="text-align:right;margin-top:12px;font-size:12px;color:#999;">서명: ________________________&nbsp;&nbsp;&nbsp;일자: ____년 ____월 ____일</div>' +
        '</div>';
}
function openLp1ShowPreview() {
    const data = @json($content);
    document.getElementById('lp1-show-preview-content').innerHTML = buildLp1ShowPreviewHtml(data);
    document.getElementById('lp1-show-preview-modal').style.display = '';
}
function closeLp1ShowPreview() { document.getElementById('lp1-show-preview-modal').style.display = 'none'; }
function printLp1ShowPreview() {
    const content = document.getElementById('lp1-show-preview-content').innerHTML;
    const win = window.open('', '_blank');
    win.document.write('<html><head><title>연차사용촉진 1차 통지서</title><style>body{font-family:"Pretendard","Malgun Gothic",sans-serif;padding:40px 48px;}@media print{body{padding:20px 30px;}}</style></head><body>' + content + '</body></html>');
    win.document.close();
    win.print();
}
</script>
@endpush
