/*
 * chat.css — 사내 지원 챗봇 챗 화면. 380×600 팝업·iframe 이 기준, 모바일·독립 페이지는 가득 채운다.
 * 메신저 상담 창: 옅은 회색 바탕 위 흰 말풍선, 차례마다 보낸 시각, 답 아래 바로가기 버튼.
 * 문서·대시보드처럼 보이게 하던 것(라임 윗줄·왼쪽 강조선·라임 번호 배지·「자주 묻는 질문」 표)은 뺐다(10-03).
 * 라임은 보내기 버튼·선택된 피드백에만.
 * 카드 모양은 card.css 가 맡는다.
 */
:root {
  --bg: #f3f4f0;
  --surface: #ffffff;
  --ink: #161b12;
  --text: #2a2f26;
  --muted: #586152;
  --line: #dfe2d9;
  --line-2: #c3c9bb;
  --hover: #f3f6e9;
  --lime: #acc90e;
  --lime-ink: #12200a;
  --lime-hover: #9fba0c;
  --user: #2b3125;
  --focus: #3e4a05;
  --danger: #b42318;
  --font: Pretendard, "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
button, input, textarea { font-family: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ---------- 틀 ---------- */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
}

/* ---------- 머리 ---------- */
.top {
  flex: none;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.top-in {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 680px;
  height: 56px;
  margin: 0 auto;
  padding: 0 8px 0 14px;
}
.mark {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--lime);
  color: var(--lime-ink);
}
.mark svg { width: 19px; height: 19px; }
.who { flex: 1; min-width: 0; }
.who-name {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.who-sub {
  margin: 1px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.3;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.top-act { display: flex; flex: none; gap: 2px; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.icon-btn svg { width: 21px; height: 21px; }
.icon-btn:hover { background: #eef0ea; }
.icon-btn:focus-visible { outline-offset: -2px; }
.preview-strip {
  margin: 0;
  padding: 5px 14px;
  border-top: 1px solid #ecd9a0;
  background: #fff3cf;
  color: #5a4300;
  font-size: 12.5px;
  font-weight: 700;
  text-align: center;
}

/* ---------- 대화 ---------- */
.log {
  position: relative; /* 차례(.turn)의 offsetTop 기준 */
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.log-in {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px 14px 20px;
}

.turn { display: flex; flex-direction: column; animation: turn-in 0.18s ease-out both; }
.turn + .turn { margin-top: 16px; }
.turn-user { align-items: flex-end; }
.turn-user + .turn-bot { margin-top: 14px; }

.turn-head { display: flex; align-items: center; gap: 7px; margin-bottom: 6px; }
.av {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--lime);
  color: var(--lime-ink);
}
.av svg { width: 16px; height: 16px; }
.turn-name { color: var(--ink); font-size: 13px; font-weight: 700; }
.turn-time {
  margin-top: 5px;
  color: #7a8273;
  font-size: 11.5px;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

.turn-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}
.turn-body > .ac-card,
.turn-body > .ac-dept,
.turn-body > .qlist,
.turn-body > .dept-list,
.turn-body > .chips,
.turn-body > .fb { align-self: stretch; }

.bubble {
  max-width: 88%;
  margin: 0;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 4px 16px 16px 16px;
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-line;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.bubble-user {
  max-width: 82%;
  border-color: var(--user);
  border-radius: 16px 4px 16px 16px;
  background: var(--user);
  color: #fff;
  white-space: pre-wrap;
}
.bubble .ac-autolink { color: #3e4a05; }

.sec-label {
  margin: 4px 0 -2px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 700;
}

/* 점 3개 */
.typing { display: inline-flex; align-items: center; gap: 5px; padding: 14px 16px; }
.typing .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #7d8676;
  animation: dot 1.1s ease-in-out infinite;
}
.typing .dot:nth-of-type(3) { animation-delay: 0.15s; } /* 1번째 span 은 화면낭독기용 글자 */
.typing .dot:nth-of-type(4) { animation-delay: 0.3s; }

/* 질문 목록 (자주 묻는 질문·선택지·관련 질문) */
.qlist {
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  list-style: none;
}
.qlist li + li { border-top: 1px solid var(--line); }
.qitem {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  margin: 0;
  padding: 10px 12px 10px 14px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.qitem:hover { background: var(--hover); }
.qitem:focus-visible { outline-offset: -3px; border-radius: 10px; }
.qitem-txt { display: flex; flex: 1; flex-direction: column; min-width: 0; word-break: keep-all; overflow-wrap: anywhere; }
.qitem-t { color: var(--ink); }
.qitem-d { margin-top: 1px; color: var(--muted); font-size: 12.5px; }
.qitem-i {
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--muted);
  transition: transform 0.15s ease, color 0.15s ease;
}
.qitem:hover .qitem-i { color: var(--ink); transform: translateX(2px); }
/* 관련 질문 — 표가 아니라 따로 떨어진 버튼(신한·하나 챗봇의 「추가 안내 보기」 버튼처럼) */
.qlist-sm { display: flex; flex-direction: column; gap: 6px; overflow: visible; border: 0; background: none; }
.qlist-sm li + li { border-top: 0; }
.qlist-sm .qitem {
  min-height: 40px;
  padding-top: 8px;
  padding-bottom: 8px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--surface);
  font-size: 14px;
}

/* 부서 칩 */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 36px;
  margin: 0;
  padding: 6px 14px;
  border: 1px solid var(--line-2);
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.chip:hover { border-color: #9fa78f; background: var(--hover); }
.chip-all { border-color: transparent; background: #e7eae1; color: var(--text); }
.chip-all:hover { border-color: transparent; background: #dde1d5; }
.chip-i { width: 15px; height: 15px; }

.dept-list { display: flex; flex-direction: column; gap: 6px; }

/* 부서 창구 카드도 챗봇의 말처럼 — 왼쪽 라임 막대 대신 말풍선 모서리 */
.turn-body .ac-dept { border-radius: 4px 16px 16px 16px; }
.turn-body .ac-dept-head::before { content: none; }

/* ---------- 피드백 ---------- */
.fb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 0 2px;
}
.fb-q { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.fb-btns { display: flex; gap: 2px; }
.fb-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 30px;
  margin: 0;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.3;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.fb-btn:hover { background: #e9ece4; color: var(--ink); }
.fb-btn:disabled { opacity: 0.55; cursor: default; }
.fb-i { width: 14px; height: 14px; }
.fb-err { flex-basis: 100%; margin: 0; color: var(--danger); font-size: 12.5px; }
.fb-err:empty { display: none; }

.fb-open {
  display: block;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}
.fb-form .fb-q { display: block; margin: 0 0 8px; color: var(--ink); font-size: 13.5px; font-weight: 700; }
.fb-reasons { display: flex; flex-wrap: wrap; gap: 6px; }
.fb-reason {
  min-height: 32px;
  margin: 0;
  padding: 4px 10px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  line-height: 1.3;
  cursor: pointer;
}
.fb-reason:hover { border-color: #9fa78f; background: var(--hover); }
.fb-reason[aria-pressed="true"] {
  border-color: var(--lime);
  background: var(--lime);
  color: var(--lime-ink);
  font-weight: 700;
}
.fb-row { display: flex; gap: 6px; margin-top: 8px; }
.fb-input {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
}
.fb-input::placeholder { color: #6b7465; }
.fb-input:focus { border-color: var(--focus); outline: 0; box-shadow: 0 0 0 3px rgba(172, 201, 14, 0.3); }
.fb-send {
  flex: none;
  height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: var(--lime);
  color: var(--lime-ink);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
}
.fb-send:hover { background: var(--lime-hover); }
.fb-skip {
  flex: none;
  height: 36px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.fb-done .fb-thanks { margin: 0; color: var(--muted); font-size: 13px; }
.fb-thanks:focus { outline: 0; }

/* ---------- 입력창 ---------- */
.composer {
  flex: none;
  padding: 10px 12px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.composer-in { max-width: 652px; margin: 0 auto; }
.field {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 5px 5px 5px 14px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(172, 201, 14, 0.3); }
.menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 38px;
  height: 38px;
  margin-left: -9px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.menu-btn svg { width: 21px; height: 21px; }
.menu-btn:hover { background: #eef0ea; color: var(--ink); }
.field textarea {
  flex: 1;
  min-width: 0;
  height: 38px;
  max-height: 120px;
  margin: 0;
  padding: 8px 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  resize: none;
}
.field textarea::placeholder { color: #6b7465; }
.send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: var(--lime);
  color: var(--lime-ink);
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.send svg { width: 20px; height: 20px; }
.send:not(:disabled):hover { background: var(--lime-hover); }
.send:disabled { background: #e8ebe2; color: #8a9282; cursor: default; }
.meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}
.count { flex: none; font-variant-numeric: tabular-nums; visibility: hidden; } /* 거의 찼을 때만 보인다 */
.count.near { visibility: visible; }
.count.near { color: var(--danger); font-weight: 700; }

/* ---------- embed(그룹웨어 iframe) ---------- */
.is-embed .top-in { height: 50px; padding-left: 12px; }
.is-embed .mark { width: 30px; height: 30px; }
.is-embed .mark svg { width: 18px; height: 18px; }
.is-embed .who-name { font-size: 15px; }
.is-embed .who-sub { font-size: 12px; }

/* ---------- 넓은 화면(독립 페이지) ---------- */
@media (min-width: 900px) {
  .log-in { padding: 24px 14px 28px; }
  .bubble { max-width: 80%; }
  .bubble-user { max-width: 70%; }
}

/* ---------- 넓은 화면: 왼쪽 「업무별로 찾기」 (그룹웨어 메뉴 링크로 본문 전체에 열 때) ---------- */
@media (min-width: 1000px) {
  html:not(.is-embed) .app.has-side {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
  }
  html:not(.is-embed) .app.has-side .top { grid-column: 1 / -1; }
  html:not(.is-embed) .app.has-side .top-in { max-width: none; padding-left: 20px; padding-right: 16px; }
  html:not(.is-embed) .app.has-side .side { display: flex !important; grid-column: 1; grid-row: 2 / 4; }
  html:not(.is-embed) .app.has-side .log { grid-column: 2; grid-row: 2; }
  html:not(.is-embed) .app.has-side .composer { grid-column: 2; grid-row: 3; }
  html:not(.is-embed) .app.has-side .log-in { max-width: 760px; }
  html:not(.is-embed) .app.has-side .composer-in { max-width: 732px; }
  html:not(.is-embed) .app.has-side .menu-btn,
  html:not(.is-embed) .app.has-side .side-close { display: none; }
}

/* ---------- 좁은 창(팝업·가젯·모바일): 「전체 업무 보기」 = 아래에서 올라오는 시트 ---------- */
.sheet-shade {
  position: fixed;
  inset: 0;
  z-index: 19;
  background: rgba(22, 27, 18, 0.34);
}
.app.sheet-open .side {
  display: flex;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  height: min(82vh, 600px);
  height: min(82dvh, 600px);
  border-right: 0;
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -6px 24px rgba(22, 27, 18, 0.16);
  animation: sheet-in 0.2s ease-out both;
}
.side-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.side-top .side-title { margin: 0; }
.side-close { width: 34px; height: 34px; margin-right: -8px; }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.side {
  display: none;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--surface);
}
.side-head { flex: none; padding: 18px 18px 12px; border-bottom: 1px solid var(--line); }
.side-title { margin: 0 0 10px; color: var(--ink); font-size: 14px; font-weight: 700; letter-spacing: -0.01em; }
.side-filter {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
}
.side-filter:focus { border-color: var(--focus); outline: 0; box-shadow: 0 0 0 3px rgba(172, 201, 14, 0.3); }
.side-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 6px 0 18px; }
.side-dept { padding: 12px 10px 4px; }
.side-dept + .side-dept { border-top: 1px solid var(--line); }
.side-dh { display: flex; align-items: baseline; gap: 6px; margin: 0 8px 6px; }
.side-dn { color: var(--ink); font-size: 13.5px; font-weight: 700; }
.side-do { color: var(--muted); font-size: 12px; }
.side-n { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.side-contact-top { margin: 0 0 0 4px; font-size: 12px; font-weight: 600; }
.side-q { list-style: none; margin: 0; padding: 0; }
.side-qb {
  display: block;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.side-qb:hover { background: var(--hover); color: var(--ink); }
.side-qb.is-on { background: #e9eedb; color: var(--ink); font-weight: 700; }
.side-prep { margin: 0 8px 6px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.side-contact {
  margin: 0 8px 4px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--focus);
  font-size: 13px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.side-empty { margin: 0; padding: 0 18px 18px; color: var(--muted); font-size: 13px; }

/* 터치 기기: 입력 글자 16px(확대 방지), 누르기 쉬운 높이 */
@media (pointer: coarse) {
  .field textarea, .fb-input { font-size: 16px; }
  .qitem { min-height: 48px; }
}

@keyframes turn-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
@keyframes dot {
  0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}
@media (prefers-reduced-motion: reduce) {
  .turn, .app.sheet-open .side { animation: none; }
  .typing .dot { animation: none; opacity: 0.7; }
  .icon-btn, .qitem, .qitem-i, .chip, .fb-btn, .send, .field { transition: none; }
}
