/* =========================================================================
 * SkinsFlow support — Help Center (skinsflow.com/help), ticket pages
 * (/help/tickets, dashboard /support, admin /tickets) and the KB editor.
 * Loaded by every view in .inc/views/help/**, support/**, admin/support/**
 * and admin/kb/** via View::push('head', …). Builds on theme.css tokens.
 *
 *   .help-hero .help-search          search hero on /help
 *   .help-cats .help-cat              category cards
 *   .help-list .help-list__item       article lists (title + excerpt)
 *   .help-article .help-toc           article page layout + "on this page"
 *   .help-vote                        "Was this helpful?"
 *   .help-cta                         "Still need help?" band
 *   .help-tips                        short tip list in side cards
 *   .suggest .suggest__item           live article suggestions on ticket forms
 *   .thread .msg .msg--staff|--internal|--system   ticket conversation
 *   .msg__files .file-chip            attachment links
 *   .ticket-side .side-links          ticket side panel (compact datalist, link rows)
 *   .ticket-meta .sla .sla--late      SLA markers
 *   .status-tabs                      tabs with counts
 *   .kb-preview .kb-help              editor preview and syntax hints
 * ========================================================================= */

/* ---------- Help Center hero + search ---------------------------------- */

.help-hero { padding-block: clamp(48px, 8vw, 88px) clamp(36px, 6vw, 64px); border-bottom: 1px solid var(--line);
    background: radial-gradient(90% 120% at 50% -20%, rgba(139, 108, 255, .13), transparent 60%), radial-gradient(60% 80% at 100% 0%, rgba(46, 230, 166, .07), transparent 60%); }
.help-hero__inner { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 16px; }
.help-hero h1 { font-size: clamp(32px, 5vw, 52px); letter-spacing: -0.035em; }
.help-hero .lead { margin: 0 auto; }
.help-hero--compact { padding-block: clamp(28px, 5vw, 48px); }
.help-hero--compact .help-hero__inner { align-items: flex-start; text-align: left; }
.help-hero--compact h1 { font-size: clamp(26px, 3.4vw, 36px); }
.help-hero--compact .lead { margin: 0; }
.help-tips { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; font-size: 14px; color: var(--muted); }
.help-tips li { position: relative; padding-left: 16px; }
.help-tips li::before { content: ""; position: absolute; left: 0; top: .6em; width: 6px; height: 6px; border-radius: 50%; background: var(--mint); }

.help-search { position: relative; width: 100%; max-width: 640px; display: flex; gap: 8px; margin-top: 8px; }
.help-search__icon { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; display: inline-flex; }
.help-search__icon svg { width: 20px; height: 20px; }
.help-search input[type=search] { flex: 1; min-width: 0; min-height: 56px; padding: 14px 18px 14px 50px; border-radius: 999px; background: var(--ink); color: var(--fg); border: 1px solid var(--line-2); font: 500 16px/1.3 var(--f-body); box-shadow: var(--shadow); }
.help-search input[type=search]:focus { outline: none; border-color: var(--mint); box-shadow: 0 0 0 3px color-mix(in srgb, var(--mint) 18%, transparent), var(--shadow); }
.help-search .btn { min-height: 56px; padding-inline: 24px; }
@media (max-width: 560px) { .help-search .btn { padding-inline: 16px; } .help-search .btn span { display: none; } }
.help-hero__popular { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; font-size: 13px; color: var(--muted); }
.help-hero__popular a { color: var(--fg); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; background: var(--panel); }
.help-hero__popular a:hover { border-color: var(--line-2); color: var(--mint); }

.help-section { padding-block: clamp(36px, 6vw, 64px); }
.help-section + .help-section { border-top: 1px solid var(--line); }
.help-head { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: baseline; justify-content: space-between; margin-bottom: 20px; }
.help-head p { color: var(--muted); }

/* ---------- Category cards --------------------------------------------- */

.help-cats { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr)); }
.help-cat { display: flex; flex-direction: column; gap: 10px; padding: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); color: var(--fg); transition: border-color .15s, transform .15s, background-color .15s; min-width: 0; }
.help-cat:hover { color: var(--fg); border-color: color-mix(in srgb, var(--mint) 45%, var(--line)); background: color-mix(in srgb, var(--panel-2) 60%, var(--panel)); transform: translateY(-1px); }
.help-cat__icon { width: 40px; height: 40px; border-radius: 12px; background: var(--panel-3); color: var(--mint); display: inline-flex; align-items: center; justify-content: center; }
.help-cat__icon svg { width: 20px; height: 20px; }
.help-cat h3 { font-size: 17px; }
.help-cat p { color: var(--muted); font-size: 14px; line-height: 1.55; }
.help-cat__meta { margin-top: auto; font-family: var(--f-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.help-cat__links { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
.help-cat__links li { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Article lists ---------------------------------------------- */

.help-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); overflow: hidden; }
.help-list__item + .help-list__item { border-top: 1px solid var(--line); }
.help-list__link { display: flex; gap: 14px; align-items: flex-start; padding: 16px 20px; color: var(--fg); }
.help-list__link:hover { background: color-mix(in srgb, var(--panel-2) 60%, transparent); color: var(--fg); }
.help-list__link:hover .help-list__title { color: var(--mint); }
.help-list__marker { flex: none; margin-top: 3px; color: var(--faint); display: inline-flex; }
.help-list__marker svg { width: 16px; height: 16px; }
.help-list__text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.help-list__title { font-weight: 700; font-size: 15px; line-height: 1.35; transition: color .12s; }
.help-list__excerpt { color: var(--muted); font-size: 14px; line-height: 1.55; }
.help-list__meta { font-size: 12px; color: var(--faint); font-family: var(--f-mono); }
.help-list--plain { border: 0; background: none; border-radius: 0; }
.help-list--plain .help-list__link { padding: 10px 0; }
.help-list--plain .help-list__link:hover { background: none; }

/* ---------- Article page ----------------------------------------------- */

.help-article { display: grid; gap: clamp(28px, 5vw, 56px); grid-template-columns: minmax(0, 1fr) minmax(0, 300px); align-items: start; }
@media (max-width: 960px) { .help-article { grid-template-columns: minmax(0, 1fr); } }
.help-article__head { display: flex; flex-direction: column; gap: 12px; margin-bottom: 28px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.help-article__head h1 { font-size: clamp(28px, 4vw, 42px); letter-spacing: -0.03em; }
.help-article__meta { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 13px; color: var(--muted); }
.help-article .prose { max-width: 70ch; }
.help-article .prose h2 { scroll-margin-top: 90px; }
.help-article .prose ol { counter-reset: none; }
.help-aside { position: sticky; top: 92px; display: flex; flex-direction: column; gap: 16px; }
@media (max-width: 960px) { .help-aside { position: static; } }
.help-toc { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.help-toc a { color: var(--muted); padding: 5px 10px; border-left: 2px solid var(--line); }
.help-toc a:hover { color: var(--fg); border-left-color: var(--mint); }

.help-vote { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; justify-content: space-between; padding: 18px 20px; margin-top: 36px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
.help-vote form { display: flex; gap: 8px; }
.help-vote .btn.is-chosen { border-color: var(--mint); color: var(--mint); }

.help-cta { display: flex; flex-wrap: wrap; gap: 18px 28px; align-items: center; justify-content: space-between; padding: clamp(22px, 4vw, 36px); border-radius: calc(var(--r) * 1.4); border: 1px solid color-mix(in srgb, var(--violet) 35%, var(--line));
    background: radial-gradient(120% 140% at 100% 0%, rgba(139, 108, 255, .12), transparent 55%), var(--panel); }
.help-cta__text { display: flex; flex-direction: column; gap: 6px; max-width: 60ch; }
.help-cta__text p { color: var(--muted); }

.help-crumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--muted); }
.help-crumbs a { color: var(--muted); }
.help-crumbs a:hover { color: var(--fg); }
.help-crumbs span::before { content: "/"; margin-right: 6px; color: var(--faint); }

mark.hl { background: color-mix(in srgb, var(--mint) 22%, transparent); color: var(--fg); border-radius: 3px; padding: 0 2px; }

/* ---------- Suggestions on ticket forms -------------------------------- */

.suggest { border: 1px solid color-mix(in srgb, var(--mint) 35%, var(--line)); border-radius: var(--r); background: color-mix(in srgb, var(--mint) 4%, var(--panel)); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.suggest__head { display: flex; gap: 8px; align-items: center; font-weight: 700; font-size: 14px; }
.suggest__head svg { width: 16px; height: 16px; color: var(--mint); }
.suggest__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.suggest__item { display: flex; flex-direction: column; gap: 3px; padding: 11px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel); color: var(--fg); }
.suggest__item:hover { border-color: var(--mint); color: var(--fg); }
.suggest__item:hover .suggest__title { color: var(--mint); }
.suggest__title { font-weight: 700; font-size: 14px; display: flex; gap: 6px; align-items: center; justify-content: space-between; }
.suggest__title svg { width: 14px; height: 14px; color: var(--faint); flex: none; }
.suggest__excerpt { font-size: 13px; color: var(--muted); line-height: 1.5; }
.suggest__cat { font-family: var(--f-mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.suggest__foot { font-size: 12px; color: var(--faint); }

/* ---------- Ticket thread ---------------------------------------------- */

.thread { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.msg { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); min-width: 0; }
.msg__head { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--line); font-size: 14px; }
.msg__head .avatar { width: 28px; height: 28px; font-size: 12px; }
.msg__who { font-weight: 700; }
.msg__when { margin-left: auto; font-size: 12px; color: var(--faint); font-family: var(--f-mono); }
.msg__body { padding: 16px 18px; font-size: 15px; line-height: 1.65; color: #D3DAE5; overflow-wrap: anywhere; }
.msg__body a { text-decoration: underline; text-underline-offset: 3px; }
.msg__files { list-style: none; margin: 0; padding: 0 18px 16px; display: flex; flex-wrap: wrap; gap: 8px; }
.msg--staff { border-color: color-mix(in srgb, var(--mint) 30%, var(--line)); }
.msg--staff .msg__head { background: color-mix(in srgb, var(--mint) 6%, transparent); }
.msg--staff .avatar { background: var(--mint); color: var(--ink); }
.msg--internal { border-style: dashed; border-color: color-mix(in srgb, var(--warning) 55%, var(--line)); background: color-mix(in srgb, var(--warning) 5%, var(--panel)); }
.msg--internal .msg__head { background: color-mix(in srgb, var(--warning) 9%, transparent); }
.msg--internal .avatar { background: var(--warning); color: var(--ink); }
.msg--system { border: 0; background: none; text-align: center; font-size: 13px; color: var(--muted); padding: 2px 12px; }
.msg--system .msg__when { margin-left: 6px; }

.file-chip { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel-2); color: var(--fg); font-size: 13px; }
.file-chip:hover { border-color: var(--line-2); color: var(--mint); }
.file-chip svg { width: 15px; height: 15px; flex: none; color: var(--muted); }
.file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.file-chip small { color: var(--faint); font-family: var(--f-mono); font-size: 11px; }

.reply-box { display: flex; flex-direction: column; gap: 14px; }
.reply-box textarea { min-height: 150px; }
.reply-box__tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.reply-box__tools select, .reply-box__tools input[type=search] { min-height: 36px; padding: 6px 12px; font: 500 13px/1.3 var(--f-body); background: var(--ink); color: var(--fg); border: 1px solid var(--line); border-radius: 8px; max-width: 100%; }
.reply-box__tools select { appearance: none; padding-right: 28px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239AA5B5' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.kb-insert { position: relative; flex: 1 1 220px; min-width: 0; }
.kb-insert input[type=search] { width: 100%; }
.kb-insert__results { position: absolute; z-index: 15; left: 0; right: 0; top: calc(100% + 4px); list-style: none; margin: 0; padding: 4px; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow); max-height: 280px; overflow-y: auto; }
.kb-insert__results button { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; border-radius: 6px; background: none; color: var(--fg); font: 600 13px/1.35 var(--f-body); cursor: pointer; }
.kb-insert__results button:hover, .kb-insert__results button:focus-visible { background: var(--panel-3); color: var(--mint); }
.kb-insert__results small { display: block; color: var(--muted); font-weight: 500; }

/* ---------- Ticket panels / queue -------------------------------------- */

.ticket-side .datalist { grid-template-columns: minmax(0, 104px) minmax(0, 1fr); }
.side-links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; font-size: 14px; }
.side-links li { display: flex; gap: 10px; align-items: baseline; justify-content: space-between; padding: 8px 0; }
.side-links li + li { border-top: 1px solid var(--line); }
.side-links a { color: var(--fg); min-width: 0; }
.side-links a:hover { color: var(--mint); }
.side-links .btn--link { flex: none; font-size: 13px; }

.ticket-meta { display: flex; flex-direction: column; gap: 6px; }
.ticket-num { font-family: var(--f-mono); color: var(--muted); }
.sla { font-family: var(--f-mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
.sla--late { color: var(--danger); }
.sla--soon { color: var(--warning); }
.unread-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--violet); margin-right: 6px; vertical-align: middle; }
.status-tabs .tabs__link .count { margin-left: 6px; font-family: var(--f-mono); font-size: 11px; color: var(--faint); }
.status-tabs .tabs__link.is-active .count { color: var(--mint); }
.queue-subject { font-weight: 700; color: var(--fg); }
.table td.queue-cell { min-width: 260px; }
.queue-subject:hover { color: var(--mint); }
.table td .queue-sub { font-size: 12px; color: var(--muted); }
.mini-bars { display: flex; flex-direction: column; gap: 10px; }
.mini-bars__row { display: grid; grid-template-columns: minmax(0, 180px) minmax(0, 1fr) 48px; gap: 12px; align-items: center; font-size: 14px; }
.mini-bars__row .progress { height: 8px; }
.mini-bars__row .num { text-align: right; font-family: var(--f-mono); font-size: 13px; }
.funnel { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); }

/* ---------- KB editor --------------------------------------------------- */

.kb-preview { border: 1px dashed var(--line-2); border-radius: var(--r); padding: clamp(18px, 3vw, 28px); background: var(--bg); }
.kb-help { font-size: 13px; color: var(--muted); }
.kb-help code { font-size: 12px; }
.body-input { font-family: var(--f-mono) !important; font-size: 14px !important; line-height: 1.6 !important; min-height: 420px !important; }
