/* ============================================================
   TFChat 帮助手册 / Central de Ajuda / Help Center
   复用 ../styles.css 的设计变量与 .nav/.btn/.container 基础件，
   这里只补帮助中心自己的版式（顶栏、搜索条、目录、正文块）。
   ============================================================ */

:root {
  --help-side-w: 268px;
  --help-bar-h: 64px;
}

body {
  background: var(--surface-2);
}

/* ---------- Nav ---------- */
.help-nav {
  background: rgba(255, 255, 255, 0.86);
  border-bottom-color: var(--line);
}
.help-nav .container { justify-content: space-between; }
.help-nav-btn { padding: 9px 17px; font-size: 14px; }

/* ---------- 语言切换（下拉，与官网导航同款） ----------
   ⚠ 别再改回 ../styles.css 的 .lang-switch：那套是官网 <details> + <a> 专用的，
     帮助中心这边是 help.js 渲染的 <button>，套上去只拿到一个 position:relative，
     按钮全是浏览器默认灰框——线上「中文 PT EN」挤成一坨就是这么来的。
   ⚠ 语种是接口下发的（运营后台勾选，最多六种），并排平铺一定会把顶栏撑爆，
     所以跟官网一样收进下拉里。 */
.help-lang { position: relative; flex: none; }
.help-lang details { position: relative; }
.help-lang summary {
  list-style: none; cursor: pointer; user-select: none;
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px;
  font-size: 13px; font-weight: 650; color: var(--text-muted); padding: 7px 13px;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}
.help-lang summary::-webkit-details-marker { display: none; }
.help-lang summary::after {
  content: ""; width: 5px; height: 5px; margin-left: 1px;
  border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor;
  transform: rotate(45deg) translate(-1px, -1px);
}
.help-lang summary:hover { color: var(--brand-700); }
.help-lang details[open] summary { background: #fff; color: var(--brand-700); box-shadow: var(--shadow-sm); }
.help-lang-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 70;
  min-width: 132px; padding: 5px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.help-lang-menu button {
  font-family: inherit; font-size: 13px; font-weight: 600; color: var(--text-muted);
  text-align: left; white-space: nowrap; cursor: pointer;
  padding: 8px 11px; border: none; border-radius: 8px; background: none;
  transition: color 0.15s, background 0.15s;
}
.help-lang-menu button:hover { background: var(--surface-2); color: var(--brand-700); }
.help-lang-menu button.active { background: var(--surface-2); color: var(--brand-700); }

/* ---------- Hero ---------- */
.help-hero {
  padding: calc(var(--nav-h) + 46px) 0 34px;
  background: var(--gradient-hero);
  color: #fff;
  position: relative;
  overflow: hidden;
}
.help-hero::after {
  content: "";
  position: absolute; width: 460px; height: 460px; border-radius: 50%;
  background: radial-gradient(circle, rgba(31, 211, 197, 0.28), transparent 70%);
  filter: blur(60px); top: -220px; right: -120px; pointer-events: none;
}
.help-hero .container { position: relative; }
.help-hero .eyebrow { background: rgba(255, 255, 255, 0.12); color: #cfe4ff; }
.help-hero h1 { color: #fff; font-size: clamp(28px, 4.4vw, 42px); margin-bottom: 12px; }
.help-hero-sub { color: #c7d7ec; font-size: clamp(15px, 2vw, 17px); max-width: 640px; }

/* ---------- Sticky search bar ---------- */
.help-searchbar {
  position: sticky; top: var(--nav-h); z-index: 60;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.help-searchbar-inner {
  display: flex; align-items: center; gap: 12px;
  min-height: var(--help-bar-h);
}
.help-search {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  height: 44px;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.help-search:focus-within {
  border-color: var(--brand-400);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(74, 144, 217, 0.14);
}
.help-search .s-ic { width: 18px; height: 18px; flex: none; color: var(--text-muted); }
.help-search input {
  flex: 1; min-width: 0;
  border: none; background: transparent; outline: none;
  font-family: inherit; font-size: 15px; color: var(--text);
  height: 100%;
}
.help-search input::placeholder { color: var(--text-muted); }
/* 去掉 Safari/Chrome search 输入框自带的清除叉，我们自己画 */
.help-search input::-webkit-search-decoration,
.help-search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.help-kbd {
  flex: none; font-family: inherit; font-size: 11px; font-weight: 650; color: var(--text-muted);
  background: #fff; border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 6px; padding: 2px 7px; letter-spacing: 0.02em;
}
.help-search-clear {
  flex: none; width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
  border: none; background: var(--surface-3); color: var(--text-soft);
  display: grid; place-items: center; padding: 0;
}
.help-search-clear svg { width: 13px; height: 13px; }
.help-search-clear:hover { background: var(--line); color: var(--ink); }

.help-toc-toggle {
  display: none; align-items: center; gap: 7px;
  font-family: inherit; font-size: 14px; font-weight: 650; color: var(--brand-700);
  background: #fff; border: 1.5px solid var(--line); border-radius: 12px;
  height: 44px; padding: 0 14px; cursor: pointer; flex: none;
}
.help-toc-toggle svg { width: 17px; height: 17px; }

/* ---------- Layout ---------- */
.help-main {
  display: grid;
  grid-template-columns: var(--help-side-w) minmax(0, 1fr);
  gap: 40px;
  align-items: start;
  padding-top: 30px;
  padding-bottom: 72px;
}
.help-side {
  position: sticky;
  top: calc(var(--nav-h) + var(--help-bar-h) + 18px);
  max-height: calc(100vh - var(--nav-h) - var(--help-bar-h) - 36px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 6px;
}

/* ---------- TOC ---------- */
.toc-group + .toc-group { margin-top: 20px; }
.toc-cat {
  display: flex; align-items: center; gap: 8px;
  font-size: 11.5px; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 8px; padding: 0 12px;
}
.toc-cat::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent-500); flex: none; }
.toc-link {
  display: block; width: 100%; text-align: left;
  font-family: inherit; font-size: 14.5px; font-weight: 550; color: var(--text-soft);
  background: transparent; border: none; cursor: pointer;
  padding: 8px 12px; border-radius: 9px; line-height: 1.4;
  transition: color 0.15s, background 0.15s;
}
.toc-link:hover { background: var(--surface-3); color: var(--brand-700); }
.toc-link.active { background: var(--gradient-brand); color: #fff; font-weight: 650; box-shadow: var(--shadow-sm); }

/* ---------- Article ---------- */
.help-article {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 38px 42px 46px;
}
.help-article[hidden] { display: none; }
.art-crumb { font-size: 13px; font-weight: 650; color: var(--brand-600); margin-bottom: 10px; }
.art-title { font-size: clamp(24px, 3.2vw, 32px); margin-bottom: 12px; }
.art-lead { font-size: 16.5px; color: var(--text-soft); margin-bottom: 30px; }

/* 正文：运营后台存的是一整段富文本 HTML（不再是按 section 分块的结构化数据），
   所以版式规则挂在 .art-body 的后代选择器上。这一段与工作台侧的
   tfchat-web/src/components/helpArticle.css 是同一套版式的两份实现，改动要一起改。 */
.art-body { font-size: 15.5px; color: var(--text-soft); line-height: 1.75; }
.art-body > :first-child { margin-top: 0; }
.art-body h2 {
  font-size: 19px; color: var(--ink); margin: 34px 0 14px;
  padding-bottom: 9px; border-bottom: 1px solid var(--line-soft);
  scroll-margin-top: calc(var(--nav-h) + var(--help-bar-h) + 16px);
}
.art-body h3 { font-size: 16px; color: var(--ink); margin: 22px 0 10px; }
.art-body p { margin: 0 0 13px; }
.art-body p:last-child { margin-bottom: 0; }
.art-body blockquote {
  margin: 0 0 14px; padding: 4px 0 4px 14px;
  border-left: 3px solid var(--brand-400); color: var(--text-muted);
}
.art-body pre {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; overflow-x: auto; margin: 0 0 14px;
}
.art-body pre code { background: none; padding: 0; }
.art-body hr { border: none; border-top: 1px solid var(--line); margin: 24px 0; }
/* 正文配图：后台上传后以 /api/help/assets/{id} 引用 */
.art-body img, .art-img {
  display: block; max-width: 100%; height: auto;
  border: 1px solid var(--line); border-radius: 10px; margin: 4px 0 16px;
}
.help-article strong { color: var(--ink); font-weight: 700; }
.help-article code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em; background: var(--surface-3); color: var(--brand-700);
  padding: 2px 6px; border-radius: 5px; word-break: break-word;
}
.help-article a.inline { color: var(--brand-600); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.help-article a.inline:hover { color: var(--brand-700); }

/* bullets（.art-ul 是正常情况；裸 ul 是源码模式下手写正文时的兜底，样式取齐） */
.art-ul, .art-body ul { display: grid; gap: 9px; margin: 0 0 14px; padding: 0; list-style: none; }
.art-ul li, .art-body ul > li {
  position: relative; padding-left: 20px;
  font-size: 15.5px; color: var(--text-soft);
}
.art-ul li::before, .art-body ul > li::before {
  content: ""; position: absolute; left: 3px; top: 9px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--brand-400);
}

/* numbered steps（同上，.art-steps 之外再给裸 ol 兜一份） */
.art-steps, .art-body ol {
  display: grid; gap: 12px; margin: 0 0 14px; padding: 0; list-style: none; counter-reset: s;
}
.art-steps li, .art-body ol > li {
  position: relative; padding-left: 38px; min-height: 26px;
  font-size: 15.5px; color: var(--text-soft);
}
.art-steps li::before, .art-body ol > li::before {
  counter-increment: s; content: counter(s);
  position: absolute; left: 0; top: 0;
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--surface-3); color: var(--brand-700);
  font-size: 13px; font-weight: 750;
  display: grid; place-items: center;
}

/* callouts —— 图标走 CSS 背景图而不是把 SVG 存进正文：
   库里只留语义（div.art-note.tip），以后换图标不用回头改历史内容，编辑器里也不必渲染 SVG */
.art-note {
  position: relative;
  border-radius: 12px; padding: 14px 16px 14px 46px; margin-bottom: 14px;
  font-size: 15px; line-height: 1.6;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text-soft);
}
.art-note > p:last-child { margin-bottom: 0; }
.art-note::before {
  content: ""; position: absolute; left: 16px; top: 16px;
  width: 19px; height: 19px; background-repeat: no-repeat; background-size: contain;
}
.art-note.tip { background: rgba(18, 181, 172, 0.08); border-color: rgba(18, 181, 172, 0.28); }
.art-note.tip::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230a857e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 18h6M10 22h4M12 2a7 7 0 00-4 12.7V17h8v-2.3A7 7 0 0012 2z'/%3E%3C/svg%3E");
}
.art-note.warn { background: rgba(245, 158, 92, 0.1); border-color: rgba(245, 158, 92, 0.35); }
.art-note.warn::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b96a1e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3l9.5 16.5H2.5L12 3zM12 9v5M12 17.5v.5'/%3E%3C/svg%3E");
}
.art-note.info { background: var(--surface-3); border-color: rgba(74, 144, 217, 0.28); }
.art-note.info::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232c6fb2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v5M12 7.5v.5'/%3E%3C/svg%3E");
}
/* 离线兜底提示：顶在正文最前面，与正文里的提示框区分开 */
.art-offline { margin-bottom: 22px; }

/* 加载中 / 加载失败 / 尚无内容 */
.art-status { padding: 48px 8px; text-align: center; }
.art-status h2 { font-size: 18px; color: var(--ink); margin-bottom: 8px; }
.art-status p { font-size: 15px; color: var(--text-muted); margin-bottom: 18px; }

/* path breadcrumb chip: 告诉用户功能在界面哪个位置 */
.art-path {
  display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px;
  background: var(--surface-3); border: 1px solid rgba(74, 144, 217, 0.22);
  border-radius: 999px; padding: 6px 14px; margin-bottom: 16px;
  font-size: 13.5px; font-weight: 600; color: var(--brand-700);
}
.art-path .sep { color: var(--brand-400); font-weight: 700; }

/* tables */
.art-table-wrap { overflow-x: auto; margin-bottom: 16px; border: 1px solid var(--line); border-radius: 12px; }
.art-table { width: 100%; border-collapse: collapse; font-size: 14.5px; min-width: 420px; }
.art-table th, .art-table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.art-table th { background: var(--surface-2); color: var(--ink); font-weight: 700; font-size: 13.5px; white-space: nowrap; }
.art-table tr:last-child td { border-bottom: none; }
.art-table td { color: var(--text-soft); }

/* related links */
.art-related { margin-top: 38px; padding-top: 24px; border-top: 1px solid var(--line); }
.art-related h2 { font-size: 14px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 14px; }
.art-related-list { display: flex; flex-wrap: wrap; gap: 9px; }
.art-related-list button {
  font-family: inherit; font-size: 14px; font-weight: 600; color: var(--brand-700);
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 15px; cursor: pointer; transition: border-color 0.15s, transform 0.15s;
}
.art-related-list button:hover { border-color: var(--brand-400); transform: translateY(-1px); }

/* prev / next */
.art-nav { display: flex; gap: 12px; margin-top: 24px; flex-wrap: wrap; }
.art-nav button {
  flex: 1; min-width: 200px; text-align: left; cursor: pointer;
  font-family: inherit; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; padding: 13px 16px; transition: border-color 0.15s, transform 0.15s;
}
.art-nav button:hover { border-color: var(--brand-400); transform: translateY(-2px); }
.art-nav .an-dir { display: block; font-size: 12px; font-weight: 700; color: var(--text-muted); letter-spacing: 0.04em; text-transform: uppercase; }
.art-nav .an-t { display: block; font-size: 15px; font-weight: 650; color: var(--ink); margin-top: 3px; }
.art-nav .next { text-align: right; }

/* ---------- Search results ---------- */
.help-results[hidden] { display: none; }
.res-head { font-size: 14.5px; color: var(--text-muted); margin-bottom: 16px; }
.res-head strong { color: var(--ink); }
.res-list { display: grid; gap: 12px; }
.res-item {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 18px 20px; font-family: inherit;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.res-item:hover, .res-item.cursor {
  border-color: var(--brand-400); transform: translateY(-2px); box-shadow: var(--shadow-sm);
}
.res-cat { font-size: 12px; font-weight: 700; color: var(--brand-600); letter-spacing: 0.04em; }
.res-title { font-size: 17px; font-weight: 700; color: var(--ink); margin: 4px 0 6px; }
.res-snip { font-size: 14.5px; color: var(--text-soft); line-height: 1.6; }
.res-hit { font-size: 13px; color: var(--text-muted); margin-top: 8px; }
mark {
  background: rgba(255, 214, 102, 0.5); color: inherit;
  border-radius: 3px; padding: 0 2px; font-weight: 650;
}
.res-empty { background: #fff; border: 1px dashed var(--line); border-radius: 14px; padding: 40px 24px; text-align: center; }
.res-empty h3 { font-size: 18px; margin-bottom: 8px; }
.res-empty p { font-size: 15px; color: var(--text-soft); }
.res-sugg { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.res-sugg button {
  font-family: inherit; font-size: 13.5px; font-weight: 600; color: var(--brand-700);
  background: var(--surface-3); border: none; border-radius: 999px; padding: 7px 14px; cursor: pointer;
}
.res-sugg button:hover { background: var(--line); }

/* ---------- Footer ---------- */
.help-footer { background: var(--navy-900); color: #93a9c6; padding: 26px 0; font-size: 13.5px; }
.help-footer-inner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.help-footer-links { display: flex; gap: 18px; flex-wrap: wrap; }
.help-footer-links a:hover { color: #fff; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .help-main { grid-template-columns: 1fr; gap: 0; }
  .help-side {
    position: static; max-height: none; overflow: visible;
    display: none; margin-bottom: 22px;
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    padding: 18px 12px;
  }
  .help-side.open { display: block; }
  .help-toc-toggle { display: inline-flex; }
  .help-article { padding: 28px 22px 34px; }
}
@media (max-width: 720px) {
  .help-nav-btn { display: none; }
  .help-hero { padding-top: calc(var(--nav-h) + 30px); padding-bottom: 26px; }
  .help-kbd { display: none; }
  .art-nav button { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .res-item, .art-nav button, .art-related-list button,
  .help-lang summary, .help-lang-menu button { transition: none; }
}
