/* =====================================================================
   รอบ 44: ศูนย์ช่วยเหลือ / คู่มือการใช้งาน (Components/Pages/Help.razor, route /help)
   รอบ 104: ใช้กับ <HelpCenter> — ตัวเดียวของคู่มือร้านค้า /help และคู่มือโรงเรียน /school/help
   - ทุกกฎของหน้าอยู่ใต้ .help-page ; ยกเว้นลิงก์ "คู่มือ" ในแถบล่างของเมนู (.who-tools .help-link)
   - จอคอม (≥1025px): สารบัญซ้ายติดอยู่กับที่ (sticky ภายใน .main ที่เลื่อน), เนื้อหาเป็นการ์ดต่อกัน
   - มือถือ/แท็บเล็ต: สารบัญพับได้ (ปุ่ม), งานแต่ละเรื่องเรียงคอลัมน์เดียว
   - ใช้ตัวแปรสีของระบบ → โหมดมืด (dark.css) ปรับให้เอง ; สีเตือนใช้ --warn-soft / --warn-text
   ===================================================================== */

/* ---------- ลิงก์ "คู่มือ" ที่แถบผู้ใช้ด้านล่างเมนู (แถวเต็มความกว้างใต้ปุ่มภาษา/โหมดมืด) ---------- */
.who-tools:has(.help-link) { flex-wrap: wrap; row-gap: 8px; }
.who-tools .help-link {
  order: 3; flex: 1 0 100%; display: flex; align-items: center; gap: 8px;
  min-height: 36px; padding: 0 12px; border-radius: 10px;
  background: rgba(255,255,255,.06); color: #D8CCC2; text-decoration: none;
  font-size: .88rem; font-weight: 600; white-space: nowrap;
}
.who-tools .help-link:hover { background: rgba(255,255,255,.12); color: #fff; }
.who-tools .help-link.active { background: rgba(255,255,255,.16); color: #fff; }
.who-tools .help-link svg { flex: none; }

/* ---------- โครงหน้า ---------- */
.help-page { display: flex; flex-direction: column; gap: 18px; min-width: 0; max-width: 1360px; margin: 0 auto; width: 100%; }
.help-page > * { min-width: 0; }
.help-page h1, .help-page h2, .help-page h3 { margin: 0; }

/* หัวหน้า + ช่องค้นหา */
.help-hero {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 520px); gap: 18px 28px; align-items: center;
  padding: 22px 26px; border-radius: var(--radius-lg);
  background:
    radial-gradient(120% 140% at 100% 0%, var(--brand-soft) 0%, transparent 60%),
    var(--surface);
  box-shadow: var(--shadow);
}
.help-hero .context { margin: 0 0 2px; }
.help-hero h1 { font-size: 1.7rem; }
.help-lead { margin: 6px 0 0; color: var(--muted); max-width: 52ch; }

.help-search-wrap { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.help-search {
  display: flex; align-items: center; gap: 10px; min-height: 50px; padding: 0 8px 0 14px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--muted);
  box-shadow: 0 1px 0 rgba(0,0,0,.02);
}
.help-search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.help-search svg { flex: none; }
.help-search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: none; padding: 10px 0;
  font: inherit; font-size: 16px; color: var(--ink);
}
.help-search input::-webkit-search-cancel-button { display: none; }
.help-search-x {
  flex: none; display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0;
  border: 0; border-radius: 999px; background: var(--chip); color: var(--muted); cursor: pointer;
}
.help-search-x:hover { color: var(--ink); background: var(--line); }

.help-quick { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.help-quick-label { color: var(--muted); font-size: .82rem; margin-right: 2px; }
.help-chip {
  display: inline-flex; align-items: center; min-height: 30px; padding: 0 12px; border-radius: 999px;
  background: var(--chip); color: var(--ink); text-decoration: none; font-size: .85rem; font-weight: 600;
}
.help-chip:hover { background: var(--brand-soft); color: var(--brand-text, var(--brand-strong)); }

/* สองคอลัมน์: สารบัญ | เนื้อหา */
.help-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 20px; align-items: start; }

/* ---------- สารบัญ ---------- */
.help-toc {
  position: sticky; top: 80px; display: flex; flex-direction: column; min-width: 0;
  max-height: calc(100vh - 100px); max-height: calc(100dvh - 100px);
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.help-toc-toggle {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 14px 16px 10px;
  border: 0; background: none; color: var(--ink); font: inherit; font-weight: 700; text-align: left; cursor: default;
}
.help-toc-toggle > span:first-of-type { flex: 1; }
.help-toc-n {
  min-width: 26px; height: 22px; padding: 0 7px; border-radius: 999px; display: inline-grid; place-items: center;
  background: var(--chip); color: var(--muted); font-size: .75rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.help-toc-caret { display: none; transition: transform .15s; }
.help-toc-list {
  display: flex; flex-direction: column; gap: 1px; padding: 0 8px 10px; overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin;
}
.help-page .help-toc-list a.help-toc-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px;
  color: var(--ink); text-decoration: none; font-size: .92rem; line-height: 1.35;
}
.help-toc-list a.help-toc-link svg { flex: none; color: var(--muted); }
.help-page .help-toc-list a.help-toc-link:hover { background: var(--brand-tint); }
.help-toc-list a.help-toc-link:hover svg { color: var(--brand-text, var(--brand)); }

/* ---------- เนื้อหา ---------- */
.help-content { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.help-result {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; border-radius: var(--radius); background: var(--brand-tint); font-weight: 600;
}
.help-empty { margin: 0; }

.help-sec {
  scroll-margin-top: 80px;
  display: flex; flex-direction: column; gap: 16px; min-width: 0;
  padding: 22px 24px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
}
.help-sec-head { display: flex; align-items: flex-start; gap: 14px; }
.help-sec-ico {
  flex: none; display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 14px;
  background: var(--brand-soft); color: var(--brand-text, var(--brand));
}
.help-sec-text { min-width: 0; }
.help-sec h2 { font-size: 1.3rem; line-height: 1.3; margin: 0; }
.help-intro { margin: 4px 0 0; color: var(--muted); }
/* รอบ 82: ปุ่มดูวิดีโอ + ป๊อปอัปเล่นวิดีโอ (แบบเดียวกับ .shl-play ของคู่มือโรงเรียน) */
.help-play { display: inline-flex; align-items: center; gap: 5px; margin-top: 8px; white-space: nowrap;
  background: var(--brand-soft); border-color: transparent; color: var(--brand-strong, var(--brand)); font-weight: 700; }
.help-play:hover { background: var(--brand); color: #fff; }
.help-video { display: block; width: 100%; max-height: 72vh; margin: 0 auto; border-radius: 12px; background: #000; object-fit: contain; }
.help-video-note { margin: 8px 0 0; text-align: center; }

/* สิทธิ์/โมดูลที่ต้องใช้ */
.help-needs { display: flex; flex-wrap: wrap; gap: 6px; }
.help-needs.small { margin: -2px 0 2px; }
.help-need {
  display: inline-flex; align-items: center; min-height: 24px; padding: 2px 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 600; line-height: 1.35; background: var(--chip); color: var(--muted);
}
.help-need::before { content: ""; width: 6px; height: 6px; border-radius: 50%; margin-right: 6px; background: currentColor; opacity: .7; flex: none; }
.help-need.module { background: var(--brand-soft); color: var(--brand-text, var(--brand-strong)); }
.help-need.admin { background: var(--warn-soft); color: var(--warn-text, #7A4E00); }
.help-need.perm { background: var(--ok-soft); color: var(--ok); }
.help-needs.small .help-need { font-size: .74rem; min-height: 22px; }

/* รอบ 104: ข้อสั้นทีละข้อ (คู่มือโรงเรียน — HelpTopic.Bullets) */
.help-bullets { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; line-height: 1.55; font-size: .95rem; }
.help-bullets li { overflow-wrap: anywhere; }
.help-bullets li::marker { color: var(--brand); }

/* งานแต่ละเรื่อง */
.help-tasks { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.help-task {
  display: flex; flex-direction: column; gap: 10px; min-width: 0;
  padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
}
.help-task h3 { font-size: 1.02rem; font-weight: 700; line-height: 1.35; }
.help-steps { list-style: none; counter-reset: hstep; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.help-steps li {
  counter-increment: hstep; position: relative; padding-left: 36px; min-height: 26px; line-height: 1.55; font-size: .95rem;
}
.help-steps li::before {
  content: counter(hstep); position: absolute; left: 0; top: 0;
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand); color: var(--brand-ink, #fff); font-size: .78rem; font-weight: 700; font-variant-numeric: tabular-nums;
}

/* เคล็ดลับ / ข้อควรระวัง */
.help-calls { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 10px; }
.help-call {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm);
  border-left: 4px solid var(--brand); background: var(--brand-tint);
}
.help-call svg { flex: none; margin-top: 2px; color: var(--brand-text, var(--brand)); }
.help-call p { margin: 0; font-size: .93rem; line-height: 1.55; }
.help-call strong { margin-right: 4px; }
.help-call.warn { border-left-color: #D18A00; background: var(--warn-soft); }
.help-call.warn svg, .help-call.warn strong { color: var(--warn-text, #8A5600); }

/* FAQ */
.help-faq-list { display: flex; flex-direction: column; gap: 8px; }
.help-faq { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.help-faq summary {
  display: flex; align-items: center; gap: 10px; padding: 13px 16px; cursor: pointer; list-style: none; font-weight: 600;
}
.help-faq summary::-webkit-details-marker { display: none; }
.help-faq summary span { flex: 1; min-width: 0; }
.help-faq-caret { flex: none; color: var(--muted); transition: transform .15s; }
.help-faq[open] .help-faq-caret { transform: rotate(180deg); }
.help-faq[open] summary { color: var(--brand-text, var(--brand-strong)); }
.help-faq p { margin: 0; padding: 0 16px 14px; color: var(--ink); line-height: 1.6; }

/* ไปที่หน้า */
.help-go { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; border-top: 1px dashed var(--line); padding-top: 14px; }
.help-go-label { color: var(--muted); font-size: .85rem; font-weight: 600; margin-right: 2px; }
.help-go-btn { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.help-go-btn svg { flex: none; opacity: .75; }

.help-top { align-self: flex-end; margin-top: -6px; font-size: .82rem; color: var(--muted); text-decoration: none; }
.help-top:hover { color: var(--brand-text, var(--brand)); text-decoration: underline; }
.help-contact { margin: 4px 0 8px; text-align: center; color: var(--muted); font-size: .92rem; }

/* ---------- จอกลาง ---------- */
@media screen and (max-width: 1280px) {
  .help-layout { grid-template-columns: 220px minmax(0, 1fr); }
  .help-tasks { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
}

/* ---------- แท็บเล็ต/มือถือ: สารบัญพับได้ คอลัมน์เดียว ---------- */
@media screen and (max-width: 1024px) {
  .help-hero { grid-template-columns: minmax(0, 1fr); padding: 18px; }
  .help-layout { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .help-toc { position: static; max-height: none; }
  .help-toc-toggle { cursor: pointer; padding: 12px 16px; min-height: 50px; }
  .help-toc-caret { display: block; color: var(--muted); }
  .help-toc.open .help-toc-caret { transform: rotate(180deg); }
  .help-toc-list { display: none; }
  .help-toc.open .help-toc-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 6px; padding: 0 8px 12px; }
  .help-sec { scroll-margin-top: 16px; padding: 18px; }
}

@media screen and (max-width: 760px) {
  .help-page { gap: 14px; }
  .help-hero { padding: 16px; gap: 14px; border-radius: var(--radius); }
  .help-hero h1 { font-size: 1.4rem; }
  .help-lead { font-size: .93rem; }
  .help-quick { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 2px; scrollbar-width: none; }
  .help-quick::-webkit-scrollbar { display: none; }
  .help-quick-label { display: none; }
  .help-chip { flex: none; white-space: nowrap; }
  .help-toc.open .help-toc-list { grid-template-columns: minmax(0, 1fr); }
  .help-sec { padding: 16px 14px; gap: 14px; }
  .help-sec-ico { width: 40px; height: 40px; border-radius: 12px; }
  .help-sec-ico svg { width: 20px; height: 20px; }
  .help-sec h2 { font-size: 1.12rem; }
  .help-intro { font-size: .93rem; }
  .help-tasks { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .help-task { padding: 14px; }
  .help-calls { grid-template-columns: minmax(0, 1fr); }
  .help-go-label { width: 100%; }
  .help-go-btn { flex: 1 1 auto; justify-content: space-between; }
}

/* ---------- พิมพ์คู่มือ: เฉพาะเนื้อหา ---------- */
@media print {
  .help-toc, .help-search-wrap, .help-go, .help-top, .help-play { display: none !important; }
  .help-layout { display: block; }
  .help-sec { box-shadow: none; border: 1px solid #ddd; break-inside: avoid-page; margin-bottom: 12px; }
  .help-faq p { display: block; }
}
