/* =====================================================================
   Help Center (/help) — Components/Pages/Help/HelpCenter.razor.
   Article bodies are Markdown rendered to HTML (MarkupString), which CSS
   isolation cannot reach, so everything lives in this global sheet.
   Logical properties (inline-start/end) keep it correct in RTL.
   ===================================================================== */

:root {
    --help-sticky-top: calc(var(--mud-appbar-height, 64px) + 16px);
    --help-border: var(--mud-palette-lines-default, rgba(0, 0, 0, 0.12));
    --help-muted: var(--mud-palette-text-secondary);
    --help-accent: var(--mud-palette-secondary);
    --help-soft: color-mix(in srgb, var(--mud-palette-secondary) 8%, transparent);
    --help-code-bg: color-mix(in srgb, var(--mud-palette-text-primary) 6%, transparent);
}

/* ----- Home ----- */
.help-hero {
    text-align: center;
    padding: 40px 16px 32px;
    margin: -16px -16px 32px;
    background:
        radial-gradient(ellipse at top, color-mix(in srgb, var(--help-accent) 14%, transparent), transparent 70%);
    border-bottom: 1px solid var(--help-border);
}
.help-hero-icon { font-size: 48px !important; width: 48px; height: 48px; color: var(--help-accent); }
.help-hero-title { font-weight: 600 !important; margin-top: 8px !important; }
.help-hero-subtitle { color: var(--help-muted); margin-top: 4px !important; }
.help-hero-search { max-width: 640px; margin: 24px auto 0; }
.help-search-large .mud-input { background: var(--mud-palette-surface); }

.help-section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    max-width: 1280px;
    margin: 0 auto;
}
.help-section-card { padding: 20px; border-radius: 12px !important; display: flex; flex-direction: column; gap: 8px; }
.help-section-card-head { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.help-section-card-head:hover .help-section-card-title { color: var(--help-accent); }
.help-section-card-icon {
    flex: none;
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; border-radius: 10px;
    background: var(--help-soft); color: var(--help-accent);
}
.help-section-card-title { display: block; font-weight: 600; font-size: 1.05rem; }
.help-section-card-count { display: block; font-size: 0.8rem; color: var(--help-muted); }
.help-section-card-desc { color: var(--help-muted); }
.help-section-card-links { list-style: none; margin: 4px 0 0; padding: 0; }
.help-section-card-links li { padding: 3px 0; }
.help-section-card-links a, .help-more-link { color: var(--mud-palette-text-primary); text-decoration: none; font-size: 0.9rem; }
.help-section-card-links a:hover, .help-more-link:hover { color: var(--help-accent); text-decoration: underline; }
.help-more-link { color: var(--help-accent); font-weight: 500; margin-top: auto; }

/* ----- Shell: topics | content | on this page ----- */
.help-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 40px;
    max-width: 1440px;
    margin: 0 auto;
}
@media (min-width: 1280px) {
    .help-shell-article { grid-template-columns: 260px minmax(0, 1fr) 220px; }
}
.help-main { min-width: 0; max-width: 860px; }
.help-nav-sticky, .help-toc-sticky {
    position: sticky;
    top: var(--help-sticky-top);
    max-height: calc(100vh - var(--help-sticky-top) - 16px);
    overflow-y: auto;
    scrollbar-width: thin;
}
.help-nav .help-search { margin-bottom: 16px; }
.help-topics-mobile { display: none; margin-bottom: 16px; }

@media (max-width: 959.98px) {
    .help-shell, .help-shell-article { grid-template-columns: minmax(0, 1fr); gap: 0; }
    .help-nav, .help-toc { display: none; }
    .help-topics-mobile { display: block; }
}
@media (max-width: 1279.98px) {
    .help-toc { display: none; }
}

/* ----- Topic tree ----- */
.help-tree-group { margin-bottom: 14px; }
.help-tree-section {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 8px; border-radius: 8px;
    font-weight: 600; font-size: 0.875rem;
    color: var(--mud-palette-text-primary); text-decoration: none;
}
.help-tree-section .mud-icon-root { color: var(--help-muted); }
.help-tree-section:hover, .help-tree-section.active { background: var(--help-soft); }
.help-tree-group ul { list-style: none; margin: 2px 0 0; padding: 0; }
.help-tree-link {
    display: block;
    padding-block: 5px;
    padding-inline: 16px 8px;
    margin-inline-start: 18px;
    border-inline-start: 2px solid transparent;
    font-size: 0.875rem; line-height: 1.4;
    color: var(--help-muted); text-decoration: none;
}
.help-tree-link:hover { color: var(--mud-palette-text-primary); border-inline-start-color: var(--help-border); }
.help-tree-link.active { color: var(--help-accent); font-weight: 600; border-inline-start-color: var(--help-accent); }

/* ----- Search results ----- */
.help-search-item { padding: 4px 0; max-width: 560px; white-space: normal; }
.help-search-item-title { font-weight: 600; }
.help-search-item-section { font-size: 0.75rem; color: var(--help-accent); text-transform: uppercase; letter-spacing: 0.03em; }
.help-search-item-snippet { font-size: 0.8125rem; color: var(--help-muted); line-height: 1.45; margin-top: 2px; }

/* ----- Section page ----- */
.help-breadcrumbs { padding: 0 0 8px !important; }
.help-breadcrumbs a { color: var(--help-accent); }
.help-section-head { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 24px; }
.help-lead { color: var(--help-muted); font-size: 1.05rem !important; line-height: 1.6 !important; margin-top: 6px !important; }
.help-article-list { display: grid; gap: 12px; }
.help-article-card {
    display: block; padding: 16px 20px;
    border: 1px solid var(--help-border); border-radius: 10px;
    color: inherit; text-decoration: none;
    transition: border-color .15s, background-color .15s;
}
.help-article-card:hover { border-color: var(--help-accent); background: var(--help-soft); }
.help-article-card-title { display: block; font-weight: 600; }
.help-article-card-summary { display: block; color: var(--help-muted); font-size: 0.9rem; margin-top: 4px; }

/* ----- Article ----- */
.help-article-head { margin-bottom: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--help-border); }
.help-article-head h1 { font-weight: 600 !important; }

.help-article { font-size: 1rem; line-height: 1.75; color: var(--mud-palette-text-primary); }
.help-article > :first-child { margin-top: 0; }
.help-article h2, .help-article h3, .help-article h4 { scroll-margin-top: var(--help-sticky-top); line-height: 1.3; }
.help-article h2 { font-size: 1.5rem; font-weight: 600; margin: 2.2em 0 0.6em; padding-top: 0.2em; }
.help-article h3 { font-size: 1.15rem; font-weight: 600; margin: 1.8em 0 0.5em; }
.help-article h4 { font-size: 1rem; font-weight: 600; margin: 1.5em 0 0.4em; }
.help-article p { margin: 0 0 1em; }
.help-article a { color: var(--help-accent); text-decoration: underline; text-underline-offset: 2px; }
.help-article ul, .help-article ol { margin: 0 0 1em; padding-inline-start: 1.6em; }
.help-article li { margin: 0.3em 0; }
.help-article li > p { margin: 0.3em 0; }
.help-article hr { border: 0; border-top: 1px solid var(--help-border); margin: 2em 0; }
.help-article code {
    font-size: 0.875em; padding: 0.1em 0.4em; border-radius: 4px;
    background: var(--help-code-bg);
}
.help-article kbd {
    font: inherit; font-size: 0.8em; padding: 0.1em 0.45em;
    border: 1px solid var(--help-border); border-bottom-width: 2px; border-radius: 4px;
    background: var(--mud-palette-surface);
}

/* Numbered steps: an ordered list becomes a vertical stepper */
.help-article ol {
    list-style: none; counter-reset: help-step; padding-inline-start: 0;
}
.help-article ol > li {
    counter-increment: help-step; position: relative;
    padding-inline-start: 44px; margin: 0 0 14px; min-height: 28px;
}
.help-article ol > li::before {
    content: counter(help-step);
    position: absolute; inset-inline-start: 0; top: 0.1em;
    width: 28px; height: 28px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.85rem; font-weight: 600;
    background: var(--help-accent); color: #fff;
}

/* UI labels ({{ui:Key}}), statuses and icons */
.help-ui {
    font-weight: 600; white-space: nowrap;
    padding: 0.05em 0.3em; border-radius: 4px;
    background: var(--help-code-bg);
}
.help-status {
    display: inline-block; font-size: 0.8em; font-weight: 600; line-height: 1.6;
    padding: 0 0.7em; border-radius: 999px; white-space: nowrap;
    background: color-mix(in srgb, var(--mud-palette-warning) 18%, transparent);
    color: color-mix(in srgb, var(--mud-palette-warning) 60%, var(--mud-palette-text-primary));
}
.help-status-confirmed, .help-status-completed, .help-status-fullyhanded, .help-status-fullyreceived,
.help-status-paid, .help-status-cleared, .help-status-posted, .help-status-approved, .help-status-active,
.help-status-settled, .help-status-received {
    background: color-mix(in srgb, var(--mud-palette-success) 16%, transparent);
    color: color-mix(in srgb, var(--mud-palette-success) 70%, var(--mud-palette-text-primary));
}
.help-status-cancelled, .help-status-rejected, .help-status-bounced, .help-status-returnedbounced {
    background: color-mix(in srgb, var(--mud-palette-error) 14%, transparent);
    color: color-mix(in srgb, var(--mud-palette-error) 70%, var(--mud-palette-text-primary));
}
.help-status-notissued, .help-status-none, .help-status-unknown {
    background: var(--help-code-bg); color: var(--help-muted);
}
.help-icon {
    width: 1.25em; height: 1.25em; vertical-align: -0.28em;
    fill: currentColor; color: var(--help-accent);
}
.help-missing { color: var(--mud-palette-error); font-family: monospace; text-decoration: wavy underline; }

/* Tables (field references) */
.help-article table {
    width: 100%; border-collapse: collapse; margin: 0 0 1.4em;
    font-size: 0.925rem; line-height: 1.55;
    display: block; overflow-x: auto;
}
.help-article th, .help-article td {
    text-align: start; vertical-align: top;
    padding: 10px 14px; border-bottom: 1px solid var(--help-border);
}
.help-article thead th {
    font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em;
    color: var(--help-muted); border-bottom-width: 2px; white-space: nowrap;
}
.help-article tbody tr:hover { background: var(--help-soft); }

/* Callouts (:::tip etc.) */
.help-callout {
    margin: 0 0 1.4em; padding: 14px 18px;
    border-radius: 10px; border-inline-start: 4px solid var(--help-callout-color);
    background: color-mix(in srgb, var(--help-callout-color) 9%, transparent);
    --help-callout-color: var(--mud-palette-info);
}
.help-callout::before {
    content: attr(data-label);
    display: block; margin-bottom: 4px;
    font-weight: 700; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em;
    color: color-mix(in srgb, var(--help-callout-color) 75%, var(--mud-palette-text-primary));
}
.help-callout > :last-child { margin-bottom: 0; }
.help-callout-tip { --help-callout-color: var(--mud-palette-success); }
.help-callout-note { --help-callout-color: var(--mud-palette-info); }
.help-callout-warning { --help-callout-color: var(--mud-palette-warning); }
.help-callout-important { --help-callout-color: var(--mud-palette-error); }

/* Screenshots */
.help-figure { text-align: center; margin: 1.2em 0 1.8em; }
.help-article img.help-shot {
    max-width: 100%; height: auto;
    border: 1px solid var(--help-border); border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
    cursor: zoom-in;
}
.help-caption { display: block; margin-top: 10px; font-size: 0.85rem; color: var(--help-muted); }
.help-shot-missing {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    min-height: 180px; padding: 16px;
    border: 2px dashed var(--help-border); border-radius: 10px;
    color: var(--help-muted); background: var(--help-soft);
}
.help-shot-missing-label { font-weight: 600; }
.help-shot-missing code { font-size: 0.8rem; }

.help-lightbox {
    position: fixed; inset: 0; z-index: 3000;
    display: flex; align-items: center; justify-content: center; padding: 24px;
    background: rgba(0, 0, 0, 0.8); cursor: zoom-out;
}
.help-lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5); }

/* Previous / next */
.help-pager {
    display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
    margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--help-border);
}
.help-pager-link {
    display: flex; flex-direction: column; gap: 4px; padding: 14px 18px;
    border: 1px solid var(--help-border); border-radius: 10px;
    color: inherit; text-decoration: none;
}
.help-pager-link:hover { border-color: var(--help-accent); }
.help-pager-next { text-align: end; align-items: flex-end; }
.help-pager-label { display: inline-flex; align-items: center; gap: 4px; font-size: 0.8rem; color: var(--help-muted); }
.help-pager-title { font-weight: 600; color: var(--help-accent); }
@media (max-width: 599.98px) {
    .help-pager { grid-template-columns: 1fr; }
}

/* On this page */
.help-toc-title {
    font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--help-muted); margin-bottom: 10px;
}
.help-toc ul { list-style: none; margin: 0; padding: 0; border-inline-start: 1px solid var(--help-border); }
.help-toc a {
    display: block; padding: 4px 12px; margin-inline-start: -1px;
    border-inline-start: 2px solid transparent;
    font-size: 0.825rem; line-height: 1.4;
    color: var(--help-muted); text-decoration: none;
}
.help-toc .help-toc-level-3 a { padding-inline-start: 24px; }
.help-toc a:hover { color: var(--mud-palette-text-primary); }
.help-toc a.active { color: var(--help-accent); border-inline-start-color: var(--help-accent); font-weight: 600; }
