/* ───────────────────────────────────────────────────────────────────────────
   jindo chatbot — high-end SaaS support chat UI
   Inherits design tokens from home.css (Notion warm-light palette).
   No backend, no model — pure frontend with JSON FAQ + fuzzy match.
   ─────────────────────────────────────────────────────────────────────────── */

/* Local accent — sky-blue, matches the rest of the site's info pill */
:root {
  --jindo-accent: #0369a1;
  --jindo-accent-deep: #075985;
  --jindo-accent-tint: rgba(3, 105, 161, 0.06);
  --jindo-accent-tint-strong: rgba(3, 105, 161, 0.12);
  --jindo-bot-bg: #f7f6f3;
  --jindo-user-bg: linear-gradient(180deg, #1f1e1b 0%, #2a2926 100%);
  --jindo-radius-bubble: 14px;
  --jindo-radius-card: 16px;
  --jindo-shadow-card: 0 24px 64px rgba(31, 30, 27, 0.06), 0 4px 16px rgba(31, 30, 27, 0.04);
}

body {
  background: var(--surface-alt);
  min-height: 100vh;
}

/* ───────── Page shell ───────── */
.chat-shell {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 24px 80px;
  min-height: calc(100vh - 64px);
}

.chat-card {
  width: 100%;
  max-width: 760px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--jindo-radius-card);
  box-shadow: var(--jindo-shadow-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: calc(100vh - 200px);
  max-height: calc(100vh - 100px);
  position: relative;
}

/* ───────── Chat header ───────── */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  background: linear-gradient(180deg, #fff 0%, #fafaf8 100%);
  border-bottom: 1px solid var(--border);
}
.chat-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}
.chat-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1f1e1b 0%, #3a3935 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(31, 30, 27, 0.18);
}
.chat-header-text { line-height: 1.3; }
.chat-header-name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text-strong);
}
.chat-header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18); }
  50% { box-shadow: 0 0 0 5px rgba(34, 197, 94, 0.28); }
}
.chat-header-meta {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-alt);
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

/* ───────── Chat log ───────── */
.chat-log {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 24px 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}
.chat-log::-webkit-scrollbar { width: 8px; }
.chat-log::-webkit-scrollbar-track { background: transparent; }
.chat-log::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
.chat-log::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ───────── Message rows ───────── */
.msg {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  max-width: 100%;
  animation: msg-in 0.32s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg-bot { justify-content: flex-start; }
.msg-user { justify-content: flex-end; }

.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1f1e1b 0%, #3a3935 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 2px;
}

.msg-bubble {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: var(--jindo-radius-bubble);
  font-size: 14.5px;
  line-height: 1.55;
  word-wrap: break-word;
  position: relative;
}
.msg-bubble p { margin: 0 0 8px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble strong { color: var(--text-strong); font-weight: 600; }
.msg-bubble code {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 12.5px;
  background: rgba(0, 0, 0, 0.05);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--text-strong);
}

/* Bot bubble */
.msg-bot .msg-bubble {
  background: var(--jindo-bot-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

/* User bubble */
.msg-user .msg-bubble {
  background: var(--jindo-user-bg);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(31, 30, 27, 0.12);
}
.msg-user .msg-bubble strong { color: #fff; }

/* ───────── Suggested chips inside welcome ───────── */
.suggested-block { margin-top: 14px; }
.suggested-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.suggested-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  background: #fff;
  border: 1px solid var(--border-strong);
  color: var(--text-strong);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .12s ease;
  font-family: inherit;
}
.chip:hover {
  background: var(--jindo-accent-tint);
  border-color: var(--jindo-accent);
  color: var(--jindo-accent-deep);
}
.chip:active { transform: scale(0.97); }

/* ───────── Live suggestion popup (above input) ───────── */
.chat-suggest-pop {
  position: absolute;
  bottom: 86px;
  left: 16px;
  right: 16px;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.08);
  max-height: 220px;
  overflow-y: auto;
  z-index: 5;
  padding: 6px;
  animation: pop-in 0.18s ease-out;
}
@keyframes pop-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.suggest-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  transition: background .12s ease;
}
.suggest-item:hover, .suggest-item.active {
  background: var(--jindo-accent-tint);
  color: var(--jindo-accent-deep);
}
.suggest-item-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--text-muted);
}
.suggest-item.active .suggest-item-icon { color: var(--jindo-accent); }
.suggest-item-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.suggest-item-text mark {
  background: var(--jindo-accent-tint-strong);
  color: var(--jindo-accent-deep);
  padding: 0 2px;
  border-radius: 3px;
  font-weight: 600;
}

/* ───────── Composer ───────── */
.chat-composer {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 14px 16px;
  background: #fff;
  border-top: 1px solid var(--border);
  position: relative;
}
.chat-composer input {
  flex: 1;
  height: 46px;
  padding: 0 16px;
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  font-family: inherit;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.chat-composer input::placeholder { color: var(--text-muted); }
.chat-composer input:focus {
  outline: none;
  background: #fff;
  border-color: var(--jindo-accent);
  box-shadow: 0 0 0 3px rgba(3, 105, 161, 0.12);
}

.chat-send {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  background: var(--text-strong);
  color: #fff;
  border: 1px solid var(--text-strong);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s ease, transform .12s ease;
}
.chat-send:hover {
  background: #000;
  border-color: #000;
}
.chat-send:active { transform: scale(0.95); }
.chat-send:disabled {
  background: var(--border-strong);
  border-color: var(--border-strong);
  cursor: not-allowed;
  opacity: 0.6;
}

/* ───────── Footer ───────── */
.chat-foot {
  padding: 10px 20px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  color: var(--text-muted);
  background: #fff;
  border-top: 1px solid var(--border);
}
.chat-foot a {
  color: var(--jindo-accent);
  font-weight: 500;
}
.chat-foot a:hover {
  color: var(--jindo-accent-deep);
  text-decoration: underline;
}
.chat-foot-meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-feature-settings: "tnum";
}

/* ───────── Typing indicator ───────── */
.typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}
.typing-dot {
  width: 7px;
  height: 7px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typing-bounce 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.30s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ───────── Mobile ───────── */
@media (max-width: 720px) {
  .chat-shell {
    padding: 0;
    min-height: calc(100vh - 64px);
  }
  .chat-card {
    border-radius: 0;
    border-left: none;
    border-right: none;
    box-shadow: none;
    min-height: calc(100vh - 64px);
    max-height: calc(100vh - 64px);
  }
  .chat-header { padding: 16px 18px; }
  .chat-avatar { width: 38px; height: 38px; }
  .chat-header-name { font-size: 15px; }
  .chat-header-meta { display: none; }
  .chat-log { padding: 16px 14px 8px; }
  .msg-bubble { max-width: 85%; font-size: 14px; }
  .chat-composer { padding: 10px 12px; }
  .chat-foot { padding: 8px 14px 10px; font-size: 11px; }
  .chat-foot-meta { display: none; }
}
