/* ============================================================
   Help center (search engine) + support chat — shared styles
   Fully client-side features; no server processing involved.
   Uses existing design tokens from variables.css.
   ============================================================ */

/* ---------- Help search page ---------- */
.help-hero {
  background: linear-gradient(135deg, var(--color-orange-tint) 0%, var(--color-gray-200) 100%);
  border-bottom: 1px solid var(--color-gray-300);
  padding: 3.2rem 0 2.6rem;
  text-align: center;
}
.help-hero h1 {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: .4rem;
}
.help-hero p.help-sub {
  color: var(--text-soft);
  font-size: .95rem;
  margin-bottom: 1.4rem;
}
.help-search-box {
  max-width: 680px;
  margin: 0 auto;
  position: relative;
}
.help-search-box .search-icon {
  position: absolute;
  top: 50%;
  inset-inline-start: 1.1rem;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  display: inline-flex;
}
.help-search-input {
  width: 100%;
  border: 2px solid var(--color-gray-300);
  border-radius: 999px;
  padding: 1rem 3.4rem 1rem 3.2rem;
  font-size: 1.05rem;
  font-family: inherit;
  background: var(--color-white);
  box-shadow: 0 6px 24px var(--shadow-sm);
  transition: border-color .2s, box-shadow .2s;
}
.help-search-input:focus {
  outline: none;
  border-color: var(--main);
  box-shadow: 0 6px 28px var(--shadow-md);
}
.help-search-clear {
  position: absolute;
  top: 50%;
  inset-inline-end: .9rem;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  padding: .3rem;
  display: none;
}
.help-search-clear.visible { display: inline-block; }
.help-search-hint {
  margin-top: .7rem;
  font-size: .8rem;
  color: var(--muted);
}

.kb-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  justify-content: center;
  margin: 1.2rem auto 0;
  max-width: 760px;
}
.kb-chip {
  border: 1px solid var(--color-gray-300);
  background: var(--color-white);
  color: var(--text-soft);
  border-radius: 999px;
  padding: .35rem .9rem;
  font-size: .82rem;
  cursor: pointer;
  transition: all .18s;
  font-family: inherit;
}
.kb-chip:hover { border-color: var(--main); color: var(--main); }
.kb-chip.active {
  background: var(--main);
  border-color: var(--main);
  color: var(--color-white);
}

.kb-results { max-width: 760px; margin: 1.6rem auto 3rem; }
.kb-result-card {
  display: block;
  background: var(--color-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: .7rem;
  text-decoration: none;
  transition: transform .18s, box-shadow .18s, border-color .18s;
}
.kb-result-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px var(--shadow-md);
  border-color: var(--main);
  text-decoration: none;
}
.kb-result-title {
  font-weight: 700;
  color: var(--ink);
  font-size: 1rem;
  margin-bottom: .3rem;
  display: flex;
  align-items: center;
  gap: .45rem;
}
.kb-result-title .kb-cat-badge {
  font-size: .68rem;
  font-weight: 600;
  background: var(--color-orange-tint);
  color: var(--color-accent-orange-deep);
  border-radius: 999px;
  padding: .1rem .55rem;
  white-space: nowrap;
}
.kb-result-body {
  color: var(--text-soft);
  font-size: .88rem;
  line-height: 1.8;
  margin: 0;
}
.kb-result-url {
  font-size: .72rem;
  color: var(--muted);
  direction: ltr;
  text-align: start;
  margin-top: .35rem;
  word-break: break-all;
}
.kb-highlight { background: rgba(255, 136, 0, .22); border-radius: 3px; padding: 0 2px; }

.kb-empty {
  text-align: center;
  padding: 2.2rem 1rem;
  color: var(--text-soft);
}
.kb-empty .kb-empty-icon { font-size: 2rem; margin-bottom: .6rem; }
.kb-empty a { color: var(--main); font-weight: 700; }

.kb-popular { max-width: 760px; margin: 0 auto 3rem; }
.kb-popular h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 1rem; color: var(--ink); }
.kb-popular-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: .7rem;
}
.kb-popular-link {
  background: var(--color-white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .8rem .95rem;
  font-size: .86rem;
  color: var(--text);
  text-decoration: none;
  transition: all .18s;
}
.kb-popular-link:hover {
  border-color: var(--main);
  color: var(--main);
  text-decoration: none;
  transform: translateY(-2px);
}

/* ---------- Chat page ---------- */
.chat-wrap { max-width: 760px; margin: 0 auto 3rem; }
.chat-card {
  background: var(--color-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: min(72vh, 640px);
  min-height: 420px;
}
.chat-head {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .9rem 1.1rem;
  background: linear-gradient(135deg, var(--main) 0%, var(--main-2) 100%);
  color: var(--color-white);
}
.chat-head-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-head-titles { flex: 1; min-width: 0; }
.chat-head-titles .chat-name { font-weight: 800; font-size: .98rem; line-height: 1.3; }
.chat-head-titles .chat-status { font-size: .72rem; opacity: .92; }
.chat-lang-toggle {
  border: 1px solid rgba(255,255,255,.55);
  background: transparent;
  color: var(--color-white);
  border-radius: 999px;
  font-size: .74rem;
  padding: .28rem .7rem;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.chat-lang-toggle:hover { background: rgba(255,255,255,.15); }

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.1rem;
  background: var(--surface-2);
  scroll-behavior: smooth;
}
.chat-msg { display: flex; margin-bottom: .8rem; }
.chat-msg.user { justify-content: flex-start; flex-direction: row-reverse; }
.chat-bubble {
  max-width: 84%;
  border-radius: 14px;
  padding: .7rem .95rem;
  font-size: .9rem;
  line-height: 1.9;
  white-space: pre-line;
}
.chat-msg.bot .chat-bubble {
  background: var(--color-white);
  border: 1px solid var(--border);
  color: var(--text);
  border-start-start-radius: 4px;
}
.chat-msg.user .chat-bubble {
  background: var(--main);
  color: var(--color-white);
  border-start-end-radius: 4px;
}
.chat-bubble a { color: var(--main-2); font-weight: 700; }
.chat-msg.user .chat-bubble a { color: var(--color-white); text-decoration: underline; }

.chat-links { margin-top: .55rem; display: flex; flex-wrap: wrap; gap: .4rem; }
.chat-link-chip {
  display: inline-block;
  border: 1px solid var(--main);
  color: var(--main-2);
  background: var(--color-orange-tint);
  border-radius: 999px;
  padding: .22rem .7rem;
  font-size: .78rem;
  font-weight: 700;
  text-decoration: none;
}
.chat-link-chip:hover { background: var(--main); color: var(--color-white); text-decoration: none; }
.chat-result-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .55rem .75rem;
  margin-top: .45rem;
  text-decoration: none;
  color: var(--text);
}
.chat-result-card:hover { border-color: var(--main); text-decoration: none; }
.chat-result-card .cr-title { font-weight: 700; font-size: .84rem; }
.chat-result-card .cr-body { font-size: .78rem; color: var(--text-soft); line-height: 1.7; margin: .15rem 0 0; }

.chat-typing { display: inline-flex; gap: .25rem; align-items: center; padding: .35rem 0; }
.chat-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted);
  animation: chatBlink 1.1s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: .18s; }
.chat-typing span:nth-child(3) { animation-delay: .36s; }
@keyframes chatBlink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.chat-quick {
  display: flex; flex-wrap: wrap; gap: .45rem;
  padding: .7rem 1.1rem 0;
  background: var(--color-white);
  border-top: 1px solid var(--border);
}
.chat-quick-btn {
  border: 1px solid var(--color-gray-300);
  background: var(--color-white);
  color: var(--text-soft);
  border-radius: 999px;
  padding: .3rem .8rem;
  font-size: .78rem;
  cursor: pointer;
  font-family: inherit;
  transition: all .18s;
}
.chat-quick-btn:hover { border-color: var(--main); color: var(--main); }

.chat-input-row {
  display: flex;
  gap: .5rem;
  padding: .8rem 1.1rem .9rem;
  background: var(--color-white);
}
.chat-input {
  flex: 1;
  border: 1.5px solid var(--color-gray-300);
  border-radius: 999px;
  padding: .65rem 1.1rem;
  font-size: .92rem;
  font-family: inherit;
  background: var(--surface-2);
  transition: border-color .2s;
}
.chat-input:focus { outline: none; border-color: var(--main); background: var(--color-white); }
.chat-send {
  border: none;
  border-radius: 999px;
  background: var(--main);
  color: var(--color-white);
  width: 46px; height: 46px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .2s, transform .15s;
}
.chat-send:hover { background: var(--main-2); transform: translateY(-1px); }
.chat-send:disabled { opacity: .6; cursor: default; transform: none; }

.chat-foot-note {
  text-align: center;
  font-size: .74rem;
  color: var(--muted);
  margin-top: .7rem;
}

/* LTR mode (English UI) flips chat alignment */
.chat-wrap[dir="ltr"] .chat-msg.user { justify-content: flex-end; flex-direction: row; }
[dir="ltr"] .chat-result-card { text-align: left; }

@media (max-width: 575.98px) {
  .help-hero { padding: 2.2rem 0 1.8rem; }
  .help-hero h1 { font-size: 1.35rem; }
  .chat-bubble { max-width: 92%; }
  .chat-card { height: min(78vh, 620px); }
}

/* LTR chat: send arrow points right (default), RTL uses flipped arrow */
.chat-wrap[dir="ltr"] .chat-send svg { transform: none; }
