<div th:fragment="result">
  <div class="alert alert-danger" th:if="${errorMessage}" th:text="${errorMessage}"></div>
  <div th:if="${searchResult}">
    <div class="result-metrics">
      <div><span>임베딩</span><strong th:text="${searchResult.embeddingModel() == 'DEMO-4D' ? '로컬 임베딩(개발용)' : searchResult.embeddingModel()}">로컬 임베딩(개발용)</strong></div>
      <div><span>검색 결과</span><strong th:text="${searchResult.probe().rowCount() + '건 · ' + searchResult.probe().status()}">0건</strong></div>
    </div>
    <div class="next-action-card mt-3">
      <h3 th:text="${searchResult.probe().title()}">권한 결과</h3>
      <p th:text="${searchResult.probe().plainSummary()}">결과 요약</p>
      <small th:text="${'질문: ' + searchResult.query() + ' · 방식: ' + searchResult.embeddingMode()}">검색 정보</small>
    </div>
    <div class="table-responsive mt-3" th:if="${!#lists.isEmpty(searchResult.probe().rows())}">
      <table class="table table-sm align-middle">
        <thead>
        <tr>
          <th>검색 단위 ID</th>
          <th>자료 ID</th>
          <th>제목</th>
          <th>기술 태그</th>
          <th>관련도</th>
          <th>본문</th>
        </tr>
        </thead>
        <tbody>
        <tr th:each="row : ${searchResult.probe().rows()}">
          <td th:text="${row['CHUNK_ID'] ?: row['chunk_id']}">28001</td>
          <td th:text="${row['DOCUMENT_ID'] ?: row['document_id']}">knowledge-001</td>
          <td th:text="${row['TITLE'] ?: row['title']}">제목</td>
          <td><code th:text="${row['TECH_TAG'] ?: row['tech_tag']}">ORDS</code></td>
          <td th:text="${row['SCORE'] ?: row['score']}">0.01</td>
          <td class="matrix-list" th:text="${row['CHUNK_TEXT'] ?: row['chunk_text']}">본문</td>
        </tr>
        </tbody>
      </table>
    </div>
    <details class="technical-details mt-3">
      <summary>검색 기술 상세 보기</summary>
      <pre class="table-pre" th:text="${searchResult.probe().responseBody()}">response</pre>
    </details>
  </div>
</div>
