{{-- 컬러풀/캐주얼 견적서 템플릿 --}}
<style>
    .colorful { font-family: 'Pretendard', sans-serif; color: #1f2937; }
    .colorful .doc-table { width: 100%; border-collapse: separate; border-spacing: 0; border-radius: 12px; overflow: hidden; border: 1px solid #e5e7eb; }
    .colorful .doc-table th, .colorful .doc-table td { padding: 8px 12px; font-size: 13px; border-bottom: 1px solid #f3e8ff; }
    .colorful .doc-table thead th { background: linear-gradient(135deg, #7c3aed, #a855f7); color: #fff; font-weight: 600; border-bottom: none; }
    .colorful .doc-table tbody tr:nth-child(even) { background-color: #faf5ff; }
    .colorful .doc-table tbody tr:hover { background-color: #f3e8ff; }
    .colorful .doc-table tfoot td, .colorful .doc-table tfoot th { border-bottom: none; }
    .colorful .seal-box { display: inline-block; width: 60px; height: 60px; border: 2px solid #a855f7; border-radius: 50%; text-align: center; line-height: 56px; color: #a855f7; font-weight: 700; font-size: 16px; }
    .colorful .card { border-radius: 12px; overflow: hidden; }

    @media print {
        .colorful .doc-table thead th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
        .colorful .doc-table tbody tr:nth-child(even) { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    }
</style>

<div class="colorful document-page max-w-[210mm] mx-auto my-8 bg-white shadow-lg" style="padding: 18mm 22mm;">

    {{-- 그라데이션 헤더 --}}
    <div class="card" style="background: linear-gradient(135deg, #f59e0b, #ef4444); padding: 24px 28px; margin-bottom: 28px; -webkit-print-color-adjust: exact; print-color-adjust: exact;">
        <div style="display: flex; justify-content: space-between; align-items: center;">
            <div>
                <h1 style="font-size: 28px; font-weight: 700; letter-spacing: 0.4em; color: #fff; margin: 0;">견 적 서</h1>
                <p style="font-size: 11px; color: rgba(255,255,255,0.8); margin-top: 4px;">QUOTATION</p>
            </div>
            <div style="text-align: right; color: rgba(255,255,255,0.9); font-size: 12px;">
                <p style="font-weight: 600;">{{ $quotationNo }}</p>
                <p>{{ $quotation->created_at->format('Y. m. d') }}</p>
            </div>
        </div>
    </div>

    {{-- 수신 / 공급자 카드 --}}
    <div style="display: flex; gap: 16px; margin-bottom: 24px;">
        <div class="card" style="flex: 1; padding: 16px 20px; background: linear-gradient(135deg, #fef3c7, #fde68a); -webkit-print-color-adjust: exact; print-color-adjust: exact;">
            <p style="font-size: 11px; color: #92400e; font-weight: 700; margin-bottom: 8px;">수 신</p>
            <p style="font-size: 15px; font-weight: 700; color: #78350f; margin-bottom: 4px;">{{ $quotation->title }}</p>
            <p style="font-size: 12px; color: #92400e;">{{ $company['industry'] ?? '-' }} · {{ $company['scale'] ?? '-' }}</p>
            @if(!empty($company['current_systems']))
                <p style="font-size: 11px; color: #a16207; margin-top: 4px;">현재: {{ implode(', ', $company['current_systems']) }}</p>
            @endif
        </div>
        <div class="card" style="flex: 1; padding: 16px 20px; background: linear-gradient(135deg, #ede9fe, #ddd6fe); -webkit-print-color-adjust: exact; print-color-adjust: exact;">
            <p style="font-size: 11px; color: #5b21b6; font-weight: 700; margin-bottom: 8px;">공 급 자</p>
            <p style="font-size: 15px; font-weight: 700; color: #4c1d95; margin-bottom: 4px;">(주)코드브릿지엑스</p>
            <p style="font-size: 12px; color: #6d28d9;">대표 이의찬</p>
            <p style="font-size: 11px; color: #7c3aed; margin-top: 4px;">인천 남동구 남동대로 215번길 30 · 032-123-4567</p>
        </div>
    </div>

    {{-- 합계 카드 --}}
    <div class="card" style="margin-bottom: 24px; padding: 20px; background: linear-gradient(135deg, #fef3c7, #fff7ed); border: 2px solid #f59e0b; text-align: center; -webkit-print-color-adjust: exact; print-color-adjust: exact;">
        <p style="font-size: 12px; color: #92400e; margin-bottom: 8px;">아래와 같이 견적합니다.</p>
        <p style="font-size: 22px; font-weight: 700; color: #b45309;">
            합계금액: 금 {{ $devTotalKorean }}원정
            <span style="font-size: 14px; font-weight: 400; color: #78350f;">(&#8361;{{ number_format($devSubtotal) }})</span>
        </p>
        <p style="font-size: 11px; color: #a16207; margin-top: 6px;">※ 부가가치세 별도 / 월 구독료 {{ number_format($monthlySubtotal) }}원 별도</p>
    </div>

    {{-- 품목 --}}
    <table class="doc-table" style="margin-bottom: 24px;">
        <colgroup>
            <col style="width: 5%;"><col style="width: 7%;"><col style="width: 20%;"><col style="width: 33%;"><col style="width: 17.5%;"><col style="width: 17.5%;">
        </colgroup>
        <thead>
            <tr>
                <th class="text-center">No</th><th class="text-center">구분</th><th class="text-center">품 목</th>
                <th class="text-center">설 명</th><th class="text-center">개발비 (원)</th><th class="text-center">월 구독료 (원)</th>
            </tr>
        </thead>
        <tbody>
            @foreach($sortedItems as $index => $item)
                <tr>
                    <td class="text-center" style="color: #9ca3af;">{{ $index + 1 }}</td>
                    <td class="text-center">
                        <span style="font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 600; {{ $item->is_required ? 'background:linear-gradient(135deg,#fbbf24,#f59e0b);color:#78350f;' : 'background:#f3f4f6;color:#6b7280;' }} -webkit-print-color-adjust: exact; print-color-adjust: exact;">
                            {{ $item->is_required ? '필수' : '선택' }}
                        </span>
                    </td>
                    <td style="font-weight: 600;">{{ $item->module_name }}</td>
                    <td style="font-size: 12px; color: #6b7280;">{{ Str::limit($item->reason, 80) }}</td>
                    <td class="text-right">{{ number_format((int) $item->dev_cost) }}</td>
                    <td class="text-right">{{ number_format((int) $item->monthly_fee) }}</td>
                </tr>
            @endforeach
        </tbody>
        <tfoot>
            <tr style="background: #faf5ff; -webkit-print-color-adjust: exact; print-color-adjust: exact;">
                <th colspan="4" class="text-right" style="color: #7c3aed;">소 계</th>
                <td class="text-right" style="font-weight: 700; color: #7c3aed;">{{ number_format($devSubtotal) }}</td>
                <td class="text-right" style="font-weight: 700; color: #7c3aed;">{{ number_format($monthlySubtotal) }}</td>
            </tr>
            <tr>
                <th colspan="4" class="text-right" style="color: #9ca3af;">부가세 (10%)</th>
                <td class="text-right" style="color: #9ca3af;">{{ number_format($devVat) }}</td>
                <td class="text-right" style="color: #9ca3af;">{{ number_format($monthlyVat) }}</td>
            </tr>
            <tr style="background: linear-gradient(135deg, #ede9fe, #ddd6fe); -webkit-print-color-adjust: exact; print-color-adjust: exact;">
                <th colspan="4" class="text-right" style="font-size: 15px; color: #5b21b6;">합 계</th>
                <td class="text-right" style="font-size: 15px; font-weight: 700; color: #5b21b6;">{{ number_format($devTotal) }}</td>
                <td class="text-right" style="font-size: 15px; font-weight: 700; color: #5b21b6;">{{ number_format($monthlyTotal) }}</td>
            </tr>
        </tfoot>
    </table>

    {{-- 비고 --}}
    <div class="card" style="margin-bottom: 28px; padding: 16px 20px; background: #faf5ff; border: 1px solid #e9d5ff; -webkit-print-color-adjust: exact; print-color-adjust: exact;">
        <p style="font-size: 11px; color: #7c3aed; font-weight: 700; margin-bottom: 8px;">비 고</p>
        <ol style="list-style: decimal; padding-left: 18px; font-size: 12px; color: #6b7280; line-height: 1.8;">
            <li>상기 금액은 부가가치세 별도입니다.</li>
            <li>개발비 납부 조건: 계약 시 50%, 완료 시 50% 분할 납부</li>
            <li>월 구독료: 서비스 오픈일부터 과금 (월 {{ number_format($monthlyTotal) }}원, VAT 포함)</li>
            @if($estimatedMonths)
                <li>예상 구축 기간: {{ $estimatedMonths }}개월</li>
            @endif
            <li>본 견적서의 유효기간은 견적일로부터 30일입니다.</li>
            <li>세부 사항은 별도 협의를 통해 조정될 수 있습니다.</li>
        </ol>
    </div>

    {{-- 서명 --}}
    <div style="display: flex; justify-content: flex-end; align-items: center; gap: 24px; margin-top: 48px;">
        <div style="text-align: right;">
            <p style="font-size: 16px; font-weight: 700; color: #5b21b6;">(주)코드브릿지엑스</p>
            <p style="font-size: 12px; color: #7c3aed; margin-top: 4px;">대표이사 이 의 찬</p>
        </div>
        <div class="seal-box">(인)</div>
    </div>

</div>
