/*
 * 국립낙동강생물자원관 AI 챗봇 — 답변 안 실시간 조회 표 (```html 블록) 스타일
 * 기준: AIOP 관리자 화면 실시간 조회 카드 (answerLiveData.css) · 화면설계서 SC-06 실시간 조회 박스
 * 작성: AIOP 2026-11-06 · v1.0
 *
 * 적용 방법
 *   1) 챗봇 화면에서 답변 본문의 ```html … ``` 블록을 꺼내 sanitize 한 뒤
 *      <div class="nnibr-live"> … </div> 안에 넣어 주세요. (블록 하나에 div 하나)
 *   2) 이 파일을 챗봇 CSS 뒤에 불러 주세요.  <link rel="stylesheet" href="/…/nnibr-chatbot-live.css">
 *   AIOP 서버는 블록 안에 class·style 을 넣지 않습니다(거르기에서 지움). 모든 꾸밈은 이 파일이 .nnibr-live 아래 태그로 합니다.
 *
 * 블록 안에 오는 태그 (AIOP 허용 목록): table caption thead tbody tr th td p ul ol li strong br a figure figcaption img
 *   - <caption>  = 「잔여 객실 (17:33 기준)」 처럼 조회 이름 + 기준 시각
 *   - <p><a …>   = 「통합예약시스템에서 예약하기」 링크 (p 안에 a 하나만 있으면 버튼 모양)
 *   - 날짜 안내(「날짜를 알려 주시면 …」)는 블록 밖 본문 한 줄로 옵니다.
 *   - <figure>   = 종 사진 카드 (아래 「종 사진 카드」). img src 는 /cms_images/… 와 /icms/file/getImage.do 만 옵니다.
 *
 * 색 (관리자 화면과 같음)
 *   테두리 #2e9e5b · 배지 #e7f6ed / #1f7a45 · 머리칸 글자 #5b6573 · 선 #dde5f2 / #eef1f6 · 버튼 #336BCC
 */

.nnibr-live {
  --nl-border: #2e9e5b;
  --nl-badge-bg: #e7f6ed;
  --nl-badge-fg: #1f7a45;
  --nl-head-fg: #5b6573;
  --nl-line: #dde5f2;
  --nl-line-soft: #eef1f6;
  --nl-text: #1f2937;
  --nl-btn: #336bcc;
  --nl-btn-hover: #2a5ab0;

  box-sizing: border-box;
  margin: 10px 0 6px;
  padding: 12px 14px;
  border: 2px solid var(--nl-border);
  border-radius: 12px;
  background: #fff;
  color: var(--nl-text);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: auto;                     /* 열이 많으면 박스 안에서 가로로 넘김 */
  -webkit-overflow-scrolling: touch;
}
.nnibr-live *,
.nnibr-live *::before,
.nnibr-live *::after { box-sizing: border-box; }

/* 표 두 개 이상이면 사이 간격 */
.nnibr-live table + table { margin-top: 14px; }

/* ---- 표 ---- */
.nnibr-live table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: #fff;
}

/* caption = 머리줄: [실시간 조회] 잔여 객실 (17:33 기준) */
.nnibr-live caption {
  caption-side: top;
  padding: 0 0 8px;
  text-align: left;
  font-size: 14px;
  font-weight: 700;
  color: var(--nl-text);
}
.nnibr-live caption::before {
  content: "실시간 조회";
  display: inline-block;
  margin-right: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--nl-badge-bg);
  color: var(--nl-badge-fg);
  font-size: 11px;
  font-weight: 700;
  vertical-align: 1px;
}

.nnibr-live th,
.nnibr-live td {
  padding: 7px 10px;
  text-align: left;
  vertical-align: top;
  word-break: keep-all;                 /* 한글 낱말 중간에서 줄이 바뀌지 않게 (「2인/실」 방지) */
}
.nnibr-live thead th {
  font-size: 12px;
  font-weight: 600;
  color: var(--nl-head-fg);
  border-bottom: 1px solid var(--nl-line);
  white-space: nowrap;
}
.nnibr-live tbody td {
  border-bottom: 1px solid var(--nl-line-soft);
}
.nnibr-live tbody tr:last-child td { border-bottom: 0; }
/* 머리칸 없이 2열(항목 | 내용)로 오면 첫 칸 굵게 — 화면설계서 Ⅲ-5 「표 첫 열 Bold」 */
.nnibr-live tbody th {
  font-weight: 700;
  color: var(--nl-text);
  border-bottom: 1px solid var(--nl-line-soft);
  white-space: nowrap;
}

/* ---- 문단·목록 (LLM 이 쓴 블록에 올 수 있음) ---- */
.nnibr-live p { margin: 8px 0 0; }
.nnibr-live ul,
.nnibr-live ol { margin: 8px 0 0; padding-left: 20px; }
.nnibr-live li + li { margin-top: 2px; }
.nnibr-live strong { font-weight: 700; }

/* ---- 링크 ---- */
.nnibr-live a { color: var(--nl-btn); text-decoration: underline; }

/* p 안에 링크 하나만 있으면 = 예약 버튼 (전체 폭, 화면설계서 「주 행동 버튼 1개 전체 폭」) */
.nnibr-live p > a:only-child {
  display: block;
  margin-top: 4px;
  padding: 10px;
  border-radius: 8px;
  background: var(--nl-btn);
  color: #fff;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}
.nnibr-live p > a:only-child::after { content: " ↗"; }
.nnibr-live p > a:only-child:hover { background: var(--nl-btn-hover); }
.nnibr-live p > a:only-child:focus-visible { outline: 3px solid #9cc0ff; outline-offset: 2px; }

/* ---- 이미지 ---- */
.nnibr-live img { display: block; max-width: 100%; height: auto; }

/* ---- 종 사진 카드 (TPL-02 종 답변, 대표홈페이지 예시 2 이미지 카드와 같은 배치) ----
 *   <figure>
 *     <p><img …><img …></p>                 사진 (여러 장이면 옆으로 넘겨 보기)
 *     <p>사진 제공: … · 사진 n장, 옆으로 넘겨 보기</p>
 *     <figcaption><table><caption>국명</caption><tbody><tr><th>학명</th><td>…</td></tr>…</tbody></table></figcaption>
 *   </figure>
 *   <p>저작권 안내</p>
 * 실시간 조회 박스(초록 테두리·배지)는 쓰지 않고, 사진이 있으면 카드 폭 520px 이상에서 사진 | 표 두 칸.
 * 사진 없이 <figure><figcaption><table>…</table></figcaption></figure> 로 오는 표(정보포털·자원은행 조회 등)도 배지 없이 그린다. */
.nnibr-live:has(> figure) { margin: 12px 0 6px; padding: 0; border: 0; border-radius: 0; overflow: visible; }
.nnibr-live figure { display: grid; grid-template-columns: 1fr; gap: 8px 14px; margin: 0; }
.nnibr-live figure > p { margin: 0; min-width: 0; }
.nnibr-live figure > p:first-child {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
  border-radius: 10px;
  background: #e9eef3;
}
.nnibr-live figure > p:first-child img {
  flex: 0 0 100%;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  scroll-snap-align: start;
}
.nnibr-live figure > p + p { font-size: 13px; color: #3f4a54; }
.nnibr-live figcaption { min-width: 0; }
.nnibr-live figcaption caption { padding-bottom: 6px; font-size: 15px; }
.nnibr-live figcaption caption::before { content: none; }
.nnibr-live figure:has(> p > img) figcaption caption { font-size: 17px; }
.nnibr-live figcaption td { word-break: keep-all; overflow-wrap: break-word; }   /* 낱말 단위로 줄바꿈, 칸보다 긴 낱말만 끊음 */
.nnibr-live * + figure { margin-top: 14px; }
.nnibr-live figure:has(> p > img) + p { margin-top: 10px; font-size: 13px; color: #55636f; }   /* 저작권 안내 */
@container (min-width: 520px) {
  .nnibr-live figure:has(> p > img) { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; }
  .nnibr-live figure:has(> p > img) > figcaption { grid-column: 2; grid-row: 1 / span 2; }
}

/* ---- 좁은 화면 (모바일 전체 화면) ---- */
@media (max-width: 480px) {
  .nnibr-live { padding: 10px 10px; border-radius: 10px; }
  .nnibr-live table { font-size: 12px; width: max-content; min-width: 100%; }
  .nnibr-live caption { position: sticky; left: 0; }        /* 표를 옆으로 밀어도 머리줄은 그 자리 */
  .nnibr-live th,
  .nnibr-live td { padding: 6px 8px; white-space: nowrap; } /* 칸은 한 줄로, 넓으면 박스 안에서 가로 넘김 */
  .nnibr-live p > a:only-child { position: sticky; left: 0; }
  .nnibr-live figcaption table { width: 100%; }                  /* 종 정보 표는 가로로 넘기지 않고 줄바꿈 */
  .nnibr-live figcaption td { white-space: normal; }
}

/* ---- 인쇄 ---- */
@media print {
  .nnibr-live { border-color: #999; overflow: visible; }
  .nnibr-live p > a:only-child { background: none; color: #000; border: 1px solid #999; }
}
