@extends('layouts.app')

@section('title', '신용평가 개발문서')

@section('content')
<div class="max-w-5xl mx-auto">

    {{-- 페이지 헤더 --}}
    <div class="mb-8">
        <div class="flex items-center gap-2 text-sm text-gray-500 mb-2">
            <a href="{{ route('credit.inquiry.index') }}" class="hover:text-blue-600">신용평가</a>
            <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="M9 5l7 7-7 7"/>
            </svg>
            <span class="text-gray-800 font-medium">개발문서</span>
        </div>
        <h1 class="text-2xl font-bold text-gray-800">신용평가 연동 개발문서</h1>
        <p class="text-sm text-gray-500 mt-1">쿠콘(KooCon/나이스평가정보) API를 통한 기업 신용정보 조회 시스템 가이드</p>
    </div>

    {{-- 목차 --}}
    <div class="bg-emerald-50 border border-emerald-200 rounded-xl p-6 mb-8">
        <h2 class="font-semibold text-emerald-800 mb-3">📋 목차</h2>
        <nav class="grid gap-1 text-sm" style="grid-template-columns: repeat(2, 1fr);">
            <a href="#section1" class="text-emerald-700 hover:text-emerald-900 hover:underline py-0.5">1. 쿠콘(KooCon)이란?</a>
            <a href="#section6" class="text-emerald-700 hover:text-emerald-900 hover:underline py-0.5">6. 과금 정책</a>
            <a href="#section2" class="text-emerald-700 hover:text-emerald-900 hover:underline py-0.5">2. 시스템 구조</a>
            <a href="#section7" class="text-emerald-700 hover:text-emerald-900 hover:underline py-0.5">7. 환경 설정 (테스트/운영)</a>
            <a href="#section3" class="text-emerald-700 hover:text-emerald-900 hover:underline py-0.5">3. 조회 가능한 신용정보</a>
            <a href="#section8" class="text-emerald-700 hover:text-emerald-900 hover:underline py-0.5">8. 주요 테이블</a>
            <a href="#section4" class="text-emerald-700 hover:text-emerald-900 hover:underline py-0.5">4. 국세청 사업자 조회</a>
            <a href="#section9" class="text-emerald-700 hover:text-emerald-900 hover:underline py-0.5">9. 에러 코드</a>
            <a href="#section5" class="text-emerald-700 hover:text-emerald-900 hover:underline py-0.5">5. 신용조회 실행 흐름</a>
            <a href="#section10" class="text-emerald-700 hover:text-emerald-900 hover:underline py-0.5">10. 관련 파일 경로</a>
        </nav>
    </div>

    {{-- 본문 --}}
    <div class="space-y-10">

        {{-- 섹션 1: 쿠콘이란? --}}
        <section id="section1" class="scroll-mt-20">
            <div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
                <div class="flex items-center gap-3 mb-4">
                    <div class="w-8 h-8 bg-emerald-500 text-white rounded-lg flex items-center justify-center text-sm font-bold shrink-0">1</div>
                    <h2 class="text-xl font-bold text-gray-800">쿠콘(KooCon)이란?</h2>
                </div>

                <div class="space-y-4 text-sm text-gray-700 leading-relaxed">
                    <p><strong>쿠콘(KooCon)</strong>은 나이스평가정보가 운영하는 금융 데이터 API 플랫폼입니다. 기업의 신용정보, 재무정보, 연체정보 등을 API로 조회할 수 있습니다.</p>

                    <div class="bg-gray-50 rounded-lg p-4">
                        <p class="font-semibold text-gray-800 mb-2">파트너 구조</p>
                        <div class="flex items-center gap-3 flex-wrap text-xs mb-3">
                            <div class="px-3 py-2 bg-emerald-100 border border-emerald-300 rounded-lg text-center">
                                <p class="font-bold text-emerald-800">쿠콘 (나이스평가정보)</p>
                                <p class="text-emerald-600">API 플랫폼</p>
                            </div>
                            <span class="text-gray-400 text-lg">→</span>
                            <div class="px-3 py-2 bg-indigo-100 border border-indigo-300 rounded-lg text-center">
                                <p class="font-bold text-indigo-800">(주)코드브릿지엑스</p>
                                <p class="text-indigo-600">파트너사 (API 키 보유)</p>
                            </div>
                            <span class="text-gray-400 text-lg">→</span>
                            <div class="px-3 py-2 bg-blue-100 border border-blue-300 rounded-lg text-center">
                                <p class="font-bold text-blue-800">각 테넌트</p>
                                <p class="text-blue-600">SAM을 통해 조회</p>
                            </div>
                        </div>
                    </div>

                    <div class="bg-gray-50 rounded-lg p-4">
                        <p class="font-semibold text-gray-800 mb-2">SAM에서 쿠콘을 쓰는 이유</p>
                        <ul class="space-y-1 text-xs text-gray-600">
                            <li>• 거래처/협력업체의 <strong>신용 안전성</strong>을 사전에 파악</li>
                            <li>• 단기연체, 당좌거래정지, 법정관리 등 <strong>위험 신호</strong>를 한눈에 확인</li>
                            <li>• 국세청 사업자등록 상태(영업/휴업/폐업)를 동시에 조회</li>
                            <li>• 모든 조회 결과를 DB에 기록하여 <strong>이력 관리</strong> 및 감사 추적</li>
                        </ul>
                    </div>
                </div>
            </div>
        </section>

        {{-- 섹션 2: 시스템 구조 --}}
        <section id="section2" class="scroll-mt-20">
            <div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
                <div class="flex items-center gap-3 mb-4">
                    <div class="w-8 h-8 bg-emerald-500 text-white rounded-lg flex items-center justify-center text-sm font-bold shrink-0">2</div>
                    <h2 class="text-xl font-bold text-gray-800">시스템 구조</h2>
                </div>

                <div class="bg-gray-50 rounded-lg p-4 mb-4 overflow-x-auto">
                    <pre class="text-xs text-gray-700 font-mono leading-relaxed whitespace-pre">
┌──────────────┐     ┌─────────────────────┐     ┌──────────────────┐
│  SAM 관리자    │────▶│  CreditController    │────▶│  CooconService   │
│  신용조회 요청  │     │  search()            │     │  7개 API 순차 호출 │
└──────────────┘     └─────────┬───────────┘     └────────┬─────────┘
                               │                          │
                               │                          ▼
                               │                 ┌──────────────────┐
                               │                 │  쿠콘 서버         │
                               │                 │  (나이스평가정보)    │
                               │                 └──────────────────┘
                               │
                               ├────▶ NtsBusinessService
                               │        └──▶ 국세청 공공데이터포털
                               │
                               └────▶ CreditInquiry::create()
                                        └──▶ DB 저장 (이력 기록)</pre>
                </div>

                <div class="overflow-x-auto">
                    <table class="w-full text-xs border-collapse">
                        <thead>
                            <tr class="bg-gray-50">
                                <th class="border border-gray-200 px-3 py-2 text-left">프로젝트</th>
                                <th class="border border-gray-200 px-3 py-2 text-left">프로토콜</th>
                                <th class="border border-gray-200 px-3 py-2 text-left">대상</th>
                                <th class="border border-gray-200 px-3 py-2 text-left">용도</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td class="border border-gray-200 px-3 py-2 font-medium">MNG</td>
                                <td class="border border-gray-200 px-3 py-2"><span class="px-1.5 py-0.5 bg-emerald-100 text-emerald-700 rounded text-xs">REST/JSON</span></td>
                                <td class="border border-gray-200 px-3 py-2">쿠콘 API</td>
                                <td class="border border-gray-200 px-3 py-2">기업 신용정보 7개 항목 조회</td>
                            </tr>
                            <tr>
                                <td class="border border-gray-200 px-3 py-2 font-medium">MNG</td>
                                <td class="border border-gray-200 px-3 py-2"><span class="px-1.5 py-0.5 bg-blue-100 text-blue-700 rounded text-xs">REST/JSON</span></td>
                                <td class="border border-gray-200 px-3 py-2">국세청 API</td>
                                <td class="border border-gray-200 px-3 py-2">사업자등록 상태(영업/휴업/폐업) 확인</td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </section>

        {{-- 섹션 3: 조회 가능한 신용정보 --}}
        <section id="section3" class="scroll-mt-20">
            <div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
                <div class="flex items-center gap-3 mb-4">
                    <div class="w-8 h-8 bg-emerald-500 text-white rounded-lg flex items-center justify-center text-sm font-bold shrink-0">3</div>
                    <h2 class="text-xl font-bold text-gray-800">조회 가능한 신용정보</h2>
                </div>

                <p class="text-sm text-gray-600 mb-4">사업자번호 1개를 입력하면 아래 <strong>7개 API를 순차 호출</strong>하여 한 번에 결과를 수집합니다.</p>

                <div class="overflow-x-auto">
                    <table class="w-full text-xs border-collapse">
                        <thead>
                            <tr class="bg-gray-50">
                                <th class="border border-gray-200 px-3 py-2 text-left">API ID</th>
                                <th class="border border-gray-200 px-3 py-2 text-left">조회 항목</th>
                                <th class="border border-gray-200 px-3 py-2 text-left">데이터 출처</th>
                                <th class="border border-gray-200 px-3 py-2 text-left">비개발자 설명</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td class="border border-gray-200 px-3 py-2 font-mono font-bold">OA08</td>
                                <td class="border border-gray-200 px-3 py-2 font-medium">기업 기본정보</td>
                                <td class="border border-gray-200 px-3 py-2">나이스평가정보</td>
                                <td class="border border-gray-200 px-3 py-2">회사명, 대표자, 주소, 업종, 설립일</td>
                            </tr>
                            <tr class="bg-emerald-50">
                                <td class="border border-gray-200 px-3 py-2 font-mono font-bold">OA12</td>
                                <td class="border border-gray-200 px-3 py-2 font-medium">신용요약정보</td>
                                <td class="border border-gray-200 px-3 py-2">나이스평가정보</td>
                                <td class="border border-gray-200 px-3 py-2">각종 이슈 건수를 한눈에 요약한 데이터</td>
                            </tr>
                            <tr>
                                <td class="border border-gray-200 px-3 py-2 font-mono font-bold">OA13</td>
                                <td class="border border-gray-200 px-3 py-2 font-medium">단기연체정보</td>
                                <td class="border border-gray-200 px-3 py-2">한국신용정보원</td>
                                <td class="border border-gray-200 px-3 py-2">대출금, 카드 등 <strong>단기 연체</strong> 발생 여부</td>
                            </tr>
                            <tr>
                                <td class="border border-gray-200 px-3 py-2 font-mono font-bold">OA14</td>
                                <td class="border border-gray-200 px-3 py-2 font-medium">신용도판단정보 (KCI)</td>
                                <td class="border border-gray-200 px-3 py-2">한국신용정보원 + 공공정보</td>
                                <td class="border border-gray-200 px-3 py-2">부도, 세금체납, 가압류 등 <strong>공적 기록</strong></td>
                            </tr>
                            <tr>
                                <td class="border border-gray-200 px-3 py-2 font-mono font-bold">OA15</td>
                                <td class="border border-gray-200 px-3 py-2 font-medium">신용도판단정보 (CB)</td>
                                <td class="border border-gray-200 px-3 py-2">신용정보사</td>
                                <td class="border border-gray-200 px-3 py-2">민간 신용정보사가 수집한 <strong>부정적 정보</strong></td>
                            </tr>
                            <tr>
                                <td class="border border-gray-200 px-3 py-2 font-mono font-bold">OA16</td>
                                <td class="border border-gray-200 px-3 py-2 font-medium">당좌거래정지정보</td>
                                <td class="border border-gray-200 px-3 py-2">금융결제원</td>
                                <td class="border border-gray-200 px-3 py-2">수표 부도로 인한 <strong>은행 거래 정지</strong> 여부</td>
                            </tr>
                            <tr>
                                <td class="border border-gray-200 px-3 py-2 font-mono font-bold">OA17</td>
                                <td class="border border-gray-200 px-3 py-2 font-medium">법정관리/워크아웃</td>
                                <td class="border border-gray-200 px-3 py-2">법원</td>
                                <td class="border border-gray-200 px-3 py-2"><strong>회생절차/파산</strong> 진행 여부</td>
                            </tr>
                        </tbody>
                    </table>
                </div>

                <div class="bg-red-50 border border-red-200 rounded-lg p-3 mt-4 text-xs text-red-700">
                    <strong>이슈 판단 기준:</strong> OA13~OA17 중 1건이라도 건수가 있으면 "이슈 있음"으로 표시됩니다. 이슈가 있는 업체와의 거래 시 주의가 필요합니다.
                </div>
            </div>
        </section>

        {{-- 섹션 4: 국세청 사업자 조회 --}}
        <section id="section4" class="scroll-mt-20">
            <div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
                <div class="flex items-center gap-3 mb-4">
                    <div class="w-8 h-8 bg-emerald-500 text-white rounded-lg flex items-center justify-center text-sm font-bold shrink-0">4</div>
                    <h2 class="text-xl font-bold text-gray-800">국세청 사업자등록 조회</h2>
                </div>

                <div class="space-y-4 text-sm text-gray-700">
                    <p>신용정보와 별도로, <strong>국세청 공공데이터포털 API</strong>를 통해 사업자등록 상태를 동시에 확인합니다.</p>

                    <div class="overflow-x-auto">
                        <table class="w-full text-xs border-collapse">
                            <thead>
                                <tr class="bg-gray-50">
                                    <th class="border border-gray-200 px-3 py-2 text-left">상태코드</th>
                                    <th class="border border-gray-200 px-3 py-2 text-left">상태</th>
                                    <th class="border border-gray-200 px-3 py-2 text-left">의미</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td class="border border-gray-200 px-3 py-2 font-mono">01</td>
                                    <td class="border border-gray-200 px-3 py-2"><span class="px-2 py-0.5 bg-green-100 text-green-700 rounded-full text-xs font-medium">계속사업자</span></td>
                                    <td class="border border-gray-200 px-3 py-2">정상 영업 중</td>
                                </tr>
                                <tr>
                                    <td class="border border-gray-200 px-3 py-2 font-mono">02</td>
                                    <td class="border border-gray-200 px-3 py-2"><span class="px-2 py-0.5 bg-yellow-100 text-yellow-700 rounded-full text-xs font-medium">휴업자</span></td>
                                    <td class="border border-gray-200 px-3 py-2">영업 일시 중지</td>
                                </tr>
                                <tr>
                                    <td class="border border-gray-200 px-3 py-2 font-mono">03</td>
                                    <td class="border border-gray-200 px-3 py-2"><span class="px-2 py-0.5 bg-red-100 text-red-700 rounded-full text-xs font-medium">폐업자</span></td>
                                    <td class="border border-gray-200 px-3 py-2">사업 종료 (폐업일 포함)</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>

                    <div class="bg-blue-50 border border-blue-100 rounded-lg p-3 text-xs text-blue-700">
                        <strong>API 출처:</strong> 공공데이터포털 (<code>api.odcloud.kr</code>) — 사업자등록정보 진위확인 및 상태조회 서비스
                    </div>
                </div>
            </div>
        </section>

        {{-- 섹션 5: 신용조회 실행 흐름 --}}
        <section id="section5" class="scroll-mt-20">
            <div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
                <div class="flex items-center gap-3 mb-4">
                    <div class="w-8 h-8 bg-emerald-500 text-white rounded-lg flex items-center justify-center text-sm font-bold shrink-0">5</div>
                    <h2 class="text-xl font-bold text-gray-800">신용조회 실행 흐름</h2>
                </div>

                <div class="space-y-4">
                    {{-- 단계별 흐름 --}}
                    <div class="flex flex-col gap-3">
                        <div class="flex items-start gap-3">
                            <span class="w-6 h-6 bg-emerald-500 text-white rounded-full flex items-center justify-center text-xs font-bold shrink-0 mt-0.5">1</span>
                            <div class="text-sm">
                                <p class="font-medium text-gray-800">사업자번호 입력</p>
                                <p class="text-xs text-gray-500">SAM 신용평가 조회 페이지에서 사업자번호(10자리) 또는 법인번호(13자리) 입력</p>
                            </div>
                        </div>
                        <div class="flex items-start gap-3">
                            <span class="w-6 h-6 bg-emerald-500 text-white rounded-full flex items-center justify-center text-xs font-bold shrink-0 mt-0.5">2</span>
                            <div class="text-sm">
                                <p class="font-medium text-gray-800">쿠콘 API 7개 순차 호출 (OA08 ~ OA17)</p>
                                <p class="text-xs text-gray-500">기업정보, 신용요약, 연체, KCI, CB, 당좌정지, 법정관리 — 일부 실패해도 나머지는 저장 (status='partial')</p>
                            </div>
                        </div>
                        <div class="flex items-start gap-3">
                            <span class="w-6 h-6 bg-blue-500 text-white rounded-full flex items-center justify-center text-xs font-bold shrink-0 mt-0.5">3</span>
                            <div class="text-sm">
                                <p class="font-medium text-gray-800">국세청 API 동시 호출</p>
                                <p class="text-xs text-gray-500">사업자등록 상태(영업/휴업/폐업) 확인 — 쿠콘과 별도 API</p>
                            </div>
                        </div>
                        <div class="flex items-start gap-3">
                            <span class="w-6 h-6 bg-gray-500 text-white rounded-full flex items-center justify-center text-xs font-bold shrink-0 mt-0.5">4</span>
                            <div class="text-sm">
                                <p class="font-medium text-gray-800">DB 저장 및 결과 표시</p>
                                <p class="text-xs text-gray-500">모든 원본 응답을 JSON으로 저장, 이슈 건수 요약 표시, 조회 이력에 기록</p>
                            </div>
                        </div>
                    </div>

                    <div class="bg-amber-50 border border-amber-200 rounded-lg p-3 text-xs text-amber-800">
                        <strong>참고:</strong> 1회 조회 시 쿠콘 API 7개 + 국세청 API 1개 = 총 8개 API를 호출합니다. 타임아웃은 API당 30초이며, 전체 소요시간은 보통 3~10초입니다.
                    </div>
                </div>
            </div>
        </section>

        {{-- 섹션 6: 과금 정책 --}}
        <section id="section6" class="scroll-mt-20">
            <div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
                <div class="flex items-center gap-3 mb-4">
                    <div class="w-8 h-8 bg-emerald-500 text-white rounded-lg flex items-center justify-center text-sm font-bold shrink-0">6</div>
                    <h2 class="text-xl font-bold text-gray-800">과금 정책</h2>
                </div>

                <div class="space-y-4 text-sm text-gray-700">
                    <div class="grid gap-4" style="grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));">
                        <div class="border border-gray-200 rounded-lg p-4 text-center">
                            <p class="text-2xl font-bold text-emerald-600">5건</p>
                            <p class="text-xs text-gray-500 mt-1">월 무료 할당량</p>
                        </div>
                        <div class="border border-gray-200 rounded-lg p-4 text-center">
                            <p class="text-2xl font-bold text-orange-600">2,000원</p>
                            <p class="text-xs text-gray-500 mt-1">초과 건당 요금</p>
                        </div>
                        <div class="border border-gray-200 rounded-lg p-4 text-center bg-gray-50">
                            <p class="text-sm font-mono font-bold text-gray-700">max(0, N-5) × 2,000</p>
                            <p class="text-xs text-gray-500 mt-1">계산 공식</p>
                        </div>
                    </div>

                    <div class="overflow-x-auto">
                        <table class="w-full text-xs border-collapse">
                            <thead>
                                <tr class="bg-gray-50">
                                    <th class="border border-gray-200 px-3 py-2 text-left">월 조회 건수</th>
                                    <th class="border border-gray-200 px-3 py-2 text-left">무료</th>
                                    <th class="border border-gray-200 px-3 py-2 text-left">유료</th>
                                    <th class="border border-gray-200 px-3 py-2 text-left">요금</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td class="border border-gray-200 px-3 py-2">3건</td>
                                    <td class="border border-gray-200 px-3 py-2">3</td>
                                    <td class="border border-gray-200 px-3 py-2">0</td>
                                    <td class="border border-gray-200 px-3 py-2 font-medium text-green-600">0원</td>
                                </tr>
                                <tr>
                                    <td class="border border-gray-200 px-3 py-2">5건</td>
                                    <td class="border border-gray-200 px-3 py-2">5</td>
                                    <td class="border border-gray-200 px-3 py-2">0</td>
                                    <td class="border border-gray-200 px-3 py-2 font-medium text-green-600">0원</td>
                                </tr>
                                <tr>
                                    <td class="border border-gray-200 px-3 py-2">10건</td>
                                    <td class="border border-gray-200 px-3 py-2">5</td>
                                    <td class="border border-gray-200 px-3 py-2">5</td>
                                    <td class="border border-gray-200 px-3 py-2 font-medium text-orange-600">10,000원</td>
                                </tr>
                                <tr>
                                    <td class="border border-gray-200 px-3 py-2">20건</td>
                                    <td class="border border-gray-200 px-3 py-2">5</td>
                                    <td class="border border-gray-200 px-3 py-2">15</td>
                                    <td class="border border-gray-200 px-3 py-2 font-medium text-red-600">30,000원</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>

                    <div class="bg-blue-50 border border-blue-100 rounded-lg p-3 text-xs text-blue-700">
                        <strong>집계 확인:</strong> SAM → 신용평가 → 조회회수 집계에서 테넌트별/월별 사용량과 요금을 확인할 수 있습니다. 본사(tenant_id=1)는 전체 테넌트 현황을 조회합니다.
                    </div>
                </div>
            </div>
        </section>

        {{-- 섹션 7: 환경 설정 --}}
        <section id="section7" class="scroll-mt-20">
            <div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
                <div class="flex items-center gap-3 mb-4">
                    <div class="w-8 h-8 bg-emerald-500 text-white rounded-lg flex items-center justify-center text-sm font-bold shrink-0">7</div>
                    <h2 class="text-xl font-bold text-gray-800">환경 설정 <span class="text-sm font-normal text-gray-500">(테스트/운영)</span></h2>
                </div>

                <div class="space-y-4">
                    <div class="overflow-x-auto">
                        <table class="w-full text-xs border-collapse">
                            <thead>
                                <tr class="bg-gray-50">
                                    <th class="border border-gray-200 px-3 py-2 text-left">환경</th>
                                    <th class="border border-gray-200 px-3 py-2 text-left">API URL</th>
                                    <th class="border border-gray-200 px-3 py-2 text-left">과금</th>
                                    <th class="border border-gray-200 px-3 py-2 text-left">용도</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td class="border border-gray-200 px-3 py-2"><span class="px-1.5 py-0.5 bg-amber-100 text-amber-700 rounded text-xs">테스트</span></td>
                                    <td class="border border-gray-200 px-3 py-2"><code>dev2.coocon.co.kr:8443</code></td>
                                    <td class="border border-gray-200 px-3 py-2 text-green-600 font-medium">무료</td>
                                    <td class="border border-gray-200 px-3 py-2">개발/검증</td>
                                </tr>
                                <tr>
                                    <td class="border border-gray-200 px-3 py-2"><span class="px-1.5 py-0.5 bg-green-100 text-green-700 rounded text-xs">운영</span></td>
                                    <td class="border border-gray-200 px-3 py-2"><code>sgw.coocon.co.kr</code></td>
                                    <td class="border border-gray-200 px-3 py-2 text-red-600 font-medium">유료</td>
                                    <td class="border border-gray-200 px-3 py-2">실 서비스</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>

                    <div class="bg-gray-50 rounded-lg p-4 text-xs text-gray-700">
                        <p class="font-medium text-gray-800 mb-2">설정 관리 방법</p>
                        <ol class="list-decimal ml-4 space-y-1">
                            <li>SAM MNG → 신용평가 → 설정 관리</li>
                            <li>환경(테스트/운영)별로 API 키와 URL 설정</li>
                            <li><strong>활성화</strong> 토글로 사용할 설정 선택 (환경당 1개만 활성화 가능)</li>
                            <li>"연결 테스트" 버튼으로 API 정상 연결 확인</li>
                        </ol>
                    </div>

                    <div class="bg-red-50 border border-red-200 rounded-lg p-3 text-xs text-red-700">
                        <strong>⚠️ 주의:</strong> 운영 환경 설정으로 전환하면 실제 과금이 발생합니다. 개발/테스트 중에는 반드시 테스트 환경을 사용하세요.
                    </div>
                </div>
            </div>
        </section>

        {{-- 섹션 8: 주요 테이블 --}}
        <section id="section8" class="scroll-mt-20">
            <div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
                <div class="flex items-center gap-3 mb-4">
                    <div class="w-8 h-8 bg-emerald-500 text-white rounded-lg flex items-center justify-center text-sm font-bold shrink-0">8</div>
                    <h2 class="text-xl font-bold text-gray-800">주요 테이블</h2>
                </div>

                <div class="overflow-x-auto">
                    <table class="w-full text-xs border-collapse">
                        <thead>
                            <tr class="bg-gray-50">
                                <th class="border border-gray-200 px-3 py-2 text-left">테이블</th>
                                <th class="border border-gray-200 px-3 py-2 text-left">모델</th>
                                <th class="border border-gray-200 px-3 py-2 text-left">역할</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td class="border border-gray-200 px-3 py-2 font-medium"><code>coocon_configs</code></td>
                                <td class="border border-gray-200 px-3 py-2">CooconConfig</td>
                                <td class="border border-gray-200 px-3 py-2">쿠콘 API 설정 (키, URL, 환경, 활성화)</td>
                            </tr>
                            <tr>
                                <td class="border border-gray-200 px-3 py-2 font-medium"><code>credit_inquiries</code></td>
                                <td class="border border-gray-200 px-3 py-2">CreditInquiry</td>
                                <td class="border border-gray-200 px-3 py-2">조회 이력 (기업정보, 이슈건수, 원본 JSON, 국세청 상태)</td>
                            </tr>
                        </tbody>
                    </table>
                </div>

                <div class="bg-gray-50 rounded-lg p-4 mt-4 text-xs text-gray-700">
                    <p class="font-medium text-gray-800 mb-1">credit_inquiries 주요 컬럼</p>
                    <div class="grid gap-1" style="grid-template-columns: repeat(2, 1fr);">
                        <span><code>inquiry_key</code> — 조회 고유키 (32자)</span>
                        <span><code>raw_summary</code> — OA12 원본 JSON</span>
                        <span><code>company_key</code> — 사업자/법인번호</span>
                        <span><code>raw_short_term_overdue</code> — OA13 원본</span>
                        <span><code>nts_status_code</code> — 국세청 상태</span>
                        <span><code>raw_negative_info_kci</code> — OA14 원본</span>
                        <span><code>short_term_overdue_cnt</code> — 연체 건수</span>
                        <span><code>raw_negative_info_cb</code> — OA15 원본</span>
                        <span><code>suspension_info_cnt</code> — 당좌정지 건수</span>
                        <span><code>status</code> — success/partial/failed</span>
                    </div>
                </div>
            </div>
        </section>

        {{-- 섹션 9: 에러 코드 --}}
        <section id="section9" class="scroll-mt-20">
            <div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
                <div class="flex items-center gap-3 mb-4">
                    <div class="w-8 h-8 bg-emerald-500 text-white rounded-lg flex items-center justify-center text-sm font-bold shrink-0">9</div>
                    <h2 class="text-xl font-bold text-gray-800">에러 코드</h2>
                </div>

                <div class="space-y-4">
                    <div>
                        <p class="font-semibold text-gray-800 text-sm mb-2">쿠콘 API</p>
                        <div class="overflow-x-auto">
                            <table class="w-full text-xs border-collapse">
                                <thead>
                                    <tr class="bg-gray-50">
                                        <th class="border border-gray-200 px-3 py-2 text-left">코드</th>
                                        <th class="border border-gray-200 px-3 py-2 text-left">설명</th>
                                        <th class="border border-gray-200 px-3 py-2 text-left">대응</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr>
                                        <td class="border border-gray-200 px-3 py-2 font-mono">NO_CONFIG</td>
                                        <td class="border border-gray-200 px-3 py-2">API 설정 없음</td>
                                        <td class="border border-gray-200 px-3 py-2">설정 관리에서 활성화된 설정 확인</td>
                                    </tr>
                                    <tr>
                                        <td class="border border-gray-200 px-3 py-2 font-mono">HTTP_ERROR</td>
                                        <td class="border border-gray-200 px-3 py-2">HTTP 통신 오류</td>
                                        <td class="border border-gray-200 px-3 py-2">쿠콘 서버 상태 확인, 네트워크 확인</td>
                                    </tr>
                                    <tr>
                                        <td class="border border-gray-200 px-3 py-2 font-mono">00000000</td>
                                        <td class="border border-gray-200 px-3 py-2 text-green-600">정상 처리</td>
                                        <td class="border border-gray-200 px-3 py-2">—</td>
                                    </tr>
                                    <tr>
                                        <td class="border border-gray-200 px-3 py-2 font-mono">(기타)</td>
                                        <td class="border border-gray-200 px-3 py-2">쿠콘 API 에러</td>
                                        <td class="border border-gray-200 px-3 py-2">RSLT_MSG 에러 메시지 참조</td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>

                    <div>
                        <p class="font-semibold text-gray-800 text-sm mb-2">국세청 API</p>
                        <div class="overflow-x-auto">
                            <table class="w-full text-xs border-collapse">
                                <thead>
                                    <tr class="bg-gray-50">
                                        <th class="border border-gray-200 px-3 py-2 text-left">코드</th>
                                        <th class="border border-gray-200 px-3 py-2 text-left">설명</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr>
                                        <td class="border border-gray-200 px-3 py-2 font-mono">INVALID_FORMAT</td>
                                        <td class="border border-gray-200 px-3 py-2">사업자번호 형식 오류 (10자리 숫자)</td>
                                    </tr>
                                    <tr>
                                        <td class="border border-gray-200 px-3 py-2 font-mono">NOT_FOUND</td>
                                        <td class="border border-gray-200 px-3 py-2">등록되지 않은 사업자번호</td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        {{-- 섹션 10: 관련 파일 경로 --}}
        <section id="section10" class="scroll-mt-20">
            <div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
                <div class="flex items-center gap-3 mb-4">
                    <div class="w-8 h-8 bg-emerald-500 text-white rounded-lg flex items-center justify-center text-sm font-bold shrink-0">10</div>
                    <h2 class="text-xl font-bold text-gray-800">관련 파일 경로</h2>
                </div>

                <div class="space-y-4">
                    <div>
                        <p class="font-semibold text-gray-800 text-sm mb-2">MNG 프로젝트</p>
                        <div class="bg-gray-50 rounded-lg p-3 text-xs space-y-1 font-mono text-gray-700">
                            <p><span class="text-gray-400">컨트롤러</span> app/Http/Controllers/Credit/CreditController.php</p>
                            <p><span class="text-gray-400">컨트롤러</span> app/Http/Controllers/Credit/CreditUsageController.php</p>
                            <p><span class="text-gray-400">서비스  </span> app/Services/Coocon/CooconService.php <span class="text-gray-400">← 쿠콘 API 클라이언트</span></p>
                            <p><span class="text-gray-400">서비스  </span> app/Services/Nts/NtsBusinessService.php <span class="text-gray-400">← 국세청 API</span></p>
                            <p><span class="text-gray-400">모델   </span> app/Models/Coocon/CooconConfig.php</p>
                            <p><span class="text-gray-400">모델   </span> app/Models/Credit/CreditInquiry.php</p>
                            <p><span class="text-gray-400">뷰    </span> resources/views/credit/**/*.blade.php</p>
                        </div>
                    </div>

                    <div>
                        <p class="font-semibold text-gray-800 text-sm mb-2">문서</p>
                        <div class="bg-gray-50 rounded-lg p-3 text-xs space-y-1 font-mono text-gray-700">
                            <p><span class="text-gray-400">가이드</span> docs/features/credit-evaluation/README.md</p>
                        </div>
                    </div>
                </div>
            </div>
        </section>

    </div>

    {{-- 하단 바로가기 --}}
    <div class="bg-emerald-50 border border-emerald-200 rounded-xl p-6 text-center mt-10 mb-8">
        <h3 class="font-semibold text-emerald-800 mb-3">바로 이동하기</h3>
        <div class="flex flex-wrap justify-center gap-3">
            <a href="{{ route('credit.inquiry.index') }}" class="px-4 py-2 bg-white border border-emerald-300 text-emerald-700 rounded-lg text-sm hover:bg-emerald-100 transition-colors">신용평가 조회</a>
            <a href="{{ route('credit.usage.index') }}" class="px-4 py-2 bg-white border border-emerald-300 text-emerald-700 rounded-lg text-sm hover:bg-emerald-100 transition-colors">조회회수 집계</a>
            <a href="{{ route('credit.settings.index') }}" class="px-4 py-2 bg-white border border-emerald-300 text-emerald-700 rounded-lg text-sm hover:bg-emerald-100 transition-colors">설정 관리</a>
        </div>
    </div>

</div>
@endsection
