<!doctype html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org">
<body>
<div th:fragment="explanation">
  <section class="alert alert-warning mb-3" th:if="${errorMessage}" th:text="${errorMessage}">설명을 생성할 수 없습니다.</section>
  <section th:if="${explanation}" class="ai-answer">
    <div class="section-heading mb-2">
      <div>
        <h2>LLM 스크립트 설명</h2>
        <p class="section-subtitle" th:text="${explanation.script().fileName() + ' · 토큰 처리와 행 접근/ASO 적용 흐름 포함'}">script.sql</p>
      </div>
      <div class="action-stack">
        <span class="badge text-bg-secondary" th:text="${explanation.modelName()} ?: 'model not configured'">model</span>
        <span class="badge" th:classappend="${explanation.status() == 'SUCCESS'} ? ' text-bg-success' : ' text-bg-warning'" th:text="${explanation.status()}">SUCCESS</span>
      </div>
    </div>
    <div class="markdown-view" data-markdown-view th:text="${explanation.answer()}">설명</div>
    <details class="explanation-details mt-3">
      <summary>LLM에 전달한 근거 Prompt 보기</summary>
      <pre th:text="${explanation.prompt()}">prompt</pre>
    </details>
  </section>
</div>
</body>
</html>
