/* ─────────────────────────────────────────────────────────────
   Help assistant (Components/Layout/HelpAssistant.razor) and
   User manual page (Components/Pages/Help/Index.razor).
   Colours come from the MudBlazor theme variables, so light/dark follow the app.
   ───────────────────────────────────────────────────────────── */
.hx-fab, .hx-panel {
    --hx-accent: var(--mud-palette-primary, #1E3A70);
    --hx-surface: var(--mud-palette-surface, #fff);
    --hx-bg: var(--mud-palette-background, #f5f5f6);
    --hx-line: var(--mud-palette-lines-default, rgba(0,0,0,.12));
    --hx-ink: var(--mud-palette-text-primary, #1F2937);
    --hx-ink-2: var(--mud-palette-text-secondary, #5B6475);
}

/* Floating button */
.hx-fab {
    position: fixed; right: 20px; bottom: 20px; z-index: 1350;   /* above the app bar (1300), below dialogs (1400) */
    display: inline-flex; align-items: center; gap: 8px;
    height: 48px; padding: 0 18px 0 14px; border: 0; border-radius: 999px;
    background: var(--hx-accent); color: #fff;
    font-family: inherit; font-size: .9rem; font-weight: 600; line-height: 1; cursor: pointer;
    box-shadow: 0 6px 20px rgba(16,24,40,.22);
    transition: transform .15s, box-shadow .15s, bottom .2s;
}
.hx-fab:hover { transform: translateY(-1px); box-shadow: 0 10px 26px rgba(16,24,40,.28); }
.hx-fab:focus-visible { outline: 3px solid color-mix(in srgb, var(--hx-accent) 45%, transparent); outline-offset: 3px; }
.hx-fab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hx-fab.is-open { width: 48px; padding: 0; justify-content: center; }

/* Keep clear of the sticky bulk-action bar (Orders, Products) */
body:has(.vx-bulkbar) .hx-fab { bottom: 104px; }
/* The chat page's composer sits bottom-right: use the round button there */
body:has(.vx-composer) .hx-fab:not(.is-open) { width: 48px; padding: 0; justify-content: center; bottom: 96px; }
body:has(.vx-composer) .hx-fab:not(.is-open) span { display: none; }

/* Panel */
.hx-panel {
    position: fixed; right: 20px; bottom: 80px; z-index: 1350;
    width: min(400px, calc(100vw - 40px));
    height: min(620px, calc(100vh - 160px));
    display: flex; flex-direction: column;
    background: var(--hx-surface); color: var(--hx-ink);
    border: 1px solid var(--hx-line); border-radius: 16px;
    box-shadow: 0 18px 48px rgba(16,24,40,.24);
    overflow: hidden;
    animation: hx-in .16s ease-out;
}
body:has(.vx-bulkbar) .hx-panel { bottom: 164px; height: min(620px, calc(100vh - 244px)); }
@keyframes hx-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.hx-head { display: flex; align-items: center; gap: 4px; padding: 12px 10px 12px 16px; border-bottom: 1px solid var(--hx-line); }
.hx-title { flex: 1; min-width: 0; display: grid; }
.hx-title strong { font-size: .98rem; }
.hx-title span { font-size: .76rem; color: var(--hx-ink-2); }
.hx-icon {
    display: inline-grid; place-items: center; width: 34px; height: 34px;
    border: 0; border-radius: 8px; background: transparent; color: var(--hx-ink-2) !important; cursor: pointer;
}
.hx-icon:hover { background: var(--hx-bg); color: var(--hx-ink) !important; }
.hx-icon:disabled { opacity: .4; cursor: default; background: transparent; }
.hx-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.hx-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: var(--hx-bg); }
.hx-welcome p { margin: 0 0 6px; font-size: .9rem; color: var(--hx-ink-2); }
.hx-welcome p strong { color: var(--hx-ink); font-size: .98rem; }
.hx-suggest { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-top: 4px; }
.hx-chip {
    text-align: left; padding: 8px 12px; border-radius: 12px; cursor: pointer;
    border: 1px solid color-mix(in srgb, var(--hx-accent) 30%, var(--hx-line));
    background: var(--hx-surface); color: var(--hx-accent);
    font-family: inherit; font-size: .86rem; font-weight: 500; line-height: 1.35;
}
.hx-chip:hover { background: color-mix(in srgb, var(--hx-accent) 8%, var(--hx-surface)); }

.hx-msg { max-width: 88%; padding: 9px 13px; border-radius: 14px; font-size: .9rem; line-height: 1.5; overflow-wrap: anywhere; }
.hx-msg.mine { align-self: flex-end; background: var(--hx-accent); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.hx-msg.theirs { align-self: flex-start; background: var(--hx-surface); border: 1px solid var(--hx-line); border-bottom-left-radius: 4px; }

.hx-typing { display: inline-flex; gap: 4px; padding: 13px 14px; }
.hx-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--hx-ink-2); opacity: .4; animation: hx-dot 1s infinite; }
.hx-typing i:nth-child(2) { animation-delay: .15s; }
.hx-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes hx-dot { 0%, 80%, 100% { opacity: .25; transform: none; } 40% { opacity: .9; transform: translateY(-2px); } }

.hx-composer { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--hx-line); background: var(--hx-surface); }
.hx-input {
    flex: 1; min-height: 42px; max-height: 140px; resize: none;
    padding: 10px 12px; border-radius: 12px; border: 1px solid var(--hx-line);
    background: var(--hx-surface); color: var(--hx-ink); font: inherit; font-size: .9rem; line-height: 1.4;
}
.hx-input:focus { outline: none; border-color: var(--hx-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--hx-accent) 18%, transparent); }
.hx-send { flex: 0 0 42px; height: 42px; display: grid; place-items: center; border: 0; border-radius: 12px; background: var(--hx-accent); color: #fff; cursor: pointer; }
.hx-send:disabled { opacity: .45; cursor: default; }
.hx-send svg { width: 19px; height: 19px; fill: currentColor; }
.hx-note { padding: 0 14px 10px; font-size: .72rem; color: var(--hx-ink-2); background: var(--hx-surface); }
.hx-note a, .hx-md a { color: var(--hx-accent, var(--mud-palette-primary)); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }

/* Rendered markdown (assistant answers and the manual page) */
.hx-md > :first-child { margin-top: 0; }
.hx-md > :last-child { margin-bottom: 0; }
.hx-md p { margin: 0 0 .6em; }
.hx-md ol, .hx-md ul { margin: 0 0 .6em; padding-left: 1.35em; }
.hx-md li { margin: .2em 0; }
.hx-md li > ol, .hx-md li > ul { margin: .2em 0 .3em; }
.hx-md strong { font-weight: 650; }
.hx-md code { font-size: .86em; padding: 1px 5px; border-radius: 5px; background: color-mix(in srgb, currentColor 9%, transparent); }
.hx-md h1, .hx-md h2, .hx-md h3, .hx-md h4 { font-weight: 650; line-height: 1.3; margin: 1em 0 .45em; scroll-margin-top: 80px; }
.hx-msg.hx-md h1, .hx-msg.hx-md h2, .hx-msg.hx-md h3, .hx-msg.hx-md h4 { font-size: .95rem; }
.hx-table { overflow-x: auto; margin: 0 0 .8em; }
.hx-md table { border-collapse: collapse; width: 100%; font-size: .88em; }
.hx-md th, .hx-md td { text-align: left; vertical-align: top; padding: 7px 10px; border-bottom: 1px solid var(--line, var(--mud-palette-lines-default)); }
.hx-md th { font-weight: 600; white-space: nowrap; }

/* User manual page */
.hx-manual { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; align-items: start; }
.hx-toc { position: sticky; top: 80px; max-height: calc(100vh - 100px); overflow-y: auto; padding: 16px; }
.hx-toc .hx-search { width: 100%; margin-bottom: 12px; }
.hx-toc ol { list-style: none; margin: 0; padding: 0; }
.hx-toc ol > li { margin: 0 0 10px; }
.hx-toc ol > li > a { font-weight: 600; font-size: .9rem; color: var(--ink); }
.hx-toc ul { list-style: none; margin: 4px 0 0; padding: 0 0 0 10px; border-left: 2px solid var(--line); }
.hx-toc ul a { display: block; padding: 3px 0 3px 8px; font-size: .84rem; color: var(--ink-2); }
.hx-toc a:hover { color: var(--accent); }
.hx-toc-foot { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.hx-doc { padding: 24px 28px; color: var(--ink); font-size: .95rem; line-height: 1.6; max-width: 860px; }
.hx-doc h2 { font-size: 1.3rem; padding-top: .6em; margin-top: 1.4em; border-top: 1px solid var(--line); }
.hx-doc h2:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.hx-doc h3 { font-size: 1.05rem; }
.hx-doc a { color: var(--accent); }
.hx-hit { padding: 12px 0; border-bottom: 1px solid var(--line); }
.hx-hit:last-child { border-bottom: 0; }
.hx-flash { animation: hx-flash 1.6s ease-out; border-radius: 6px; }
@keyframes hx-flash { 0%, 40% { background: color-mix(in srgb, var(--accent, #1E3A70) 16%, transparent); } 100% { background: transparent; } }

@media (max-width: 900px) {
    .hx-manual { grid-template-columns: minmax(0, 1fr); }
    .hx-toc { position: static; max-height: none; }
    .hx-doc { padding: 18px; }
}
@media (max-width: 600px) {
    .hx-fab:not(.is-open) { width: 52px; height: 52px; padding: 0; justify-content: center; }
    .hx-fab:not(.is-open) span { display: none; }
    .hx-panel, body:has(.vx-bulkbar) .hx-panel { inset: 0; width: auto; height: auto; border-radius: 0; border: 0; }
    .hx-fab.is-open { top: 10px; bottom: auto; right: 10px; width: 34px; height: 34px; opacity: 0; pointer-events: none; }
}
@media (prefers-reduced-motion: reduce) {
    .hx-panel, .hx-typing i, .hx-flash { animation: none; }
}
