/* =============================================================================
   Assistant — the floating panel (Components/Shared/AskAssistant.razor) and its
   transcript vocabulary.

   The WebForms copy of this feature was split across two sheets: AskWidget.css held the chrome and
   AskBot.css held the conversation, because a launcher and a full-page transcript shared one
   renderer. The Razor port has one surface, so the two halves live together here and nothing else
   has to be loaded on every page for the panel to look finished. Those two vendored sheets are now
   deleted rather than linked-but-unused: their only surviving rules were `.askw-composer` and
   `.askw-send`, and both name a class the WebForms widget wrote — this panel writes `.ask-composer`
   and `.ask-send`, styled below — so every other rule in them had already been overtaken by this
   sheet, which loads last.

   Every colour comes from the theme's own tokens — --card, --line, --ink, --ink-2, --muted, --gold*,
   --blue, --input-bg. It used to ask MasterPage.css for --card-bg, --text-primary, --accent and the
   rest of the legacy JPSC palette, and that sheet is gone: where the two palettes disagreed, the theme
   won, because the theme is the design this app is built to. The WebForms sheets reached for --surface,
   --border and --primary, which are declared per module page over there and do not exist in this
   application at all; a panel that used them would render as transparent text on a transparent
   background, which is the one failure mode a floating overlay cannot be allowed to have.

   The module badge is not repeated here. `.mod-badge` with its `.m-*` tints already lives in
   app.css and is what the Archive and the Activity Log wear, so an answer's badge is the same pill
   as the row it came from.
   ========================================================================== */

/* The panel's own names for the shell tokens, so the rules below read the way the WebForms ones did
   and a future reader can see at a glance which of them is real. */
.askw {
    --ask-surface: var(--card);
    --ask-surface-2: var(--input-bg);
    --ask-border: var(--line);
    --ask-text: var(--ink);
    --ask-muted: var(--muted);
    --ask-secondary: var(--ink-2);
    --ask-me-bg: var(--gold-soft);
    --ask-me-line: #F3E3B8;
    --ask-me-text: #6B4E05;
    --ask-blue: #1d4ed8;
    --ask-blue-light: #eff6ff;
    --ask-blue-border: #bfdbfe;
    --ask-red: #e11d48;
    --ask-red-light: #fff1f2;
    --ask-red-border: #fecdd3;

    position: fixed;
    right: 22px;
    bottom: 22px;
    /* Above the topbar (1000) and the sidebar (1001), below the slide-over panels (1400) and the
       toast rail (1600): a person opening a record's inspector is reading something more important
       than a chat launcher. */
    z-index: 1040;
    font-family: inherit;
}

/* ─── The launcher ──────────────────────────────────────────────────────── */
.askw-fab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 50px;
    padding: 0 18px 0 15px;
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 25px;
    background: linear-gradient(135deg, var(--blue) 0%, var(--blue) 100%);
    color: #fff;
    font-size: .84rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(15, 28, 46, .28);
    transition: transform .14s ease, box-shadow .14s ease;
}

/* The launcher's mark is an <Ico> now — an inline SVG wrapped in `.ico-wrap` — so the colour has to
   reach the wrapper rather than a `<i>` font glyph. `stroke="currentColor"` means painting the wrapper
   paints the drawing, and the size lives in the component (Size="17") instead of a font-size here. */
.askw-fab .ico-wrap {
    color: var(--gold-2);
}

.askw-fab:hover,
.askw-fab:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 12px 26px rgba(15, 28, 46, .34);
    color: #fff;
    outline: none;
}

.askw-fab:focus-visible {
    box-shadow: 0 0 0 3px var(--gold), 0 12px 26px rgba(15, 28, 46, .34);
}

.askw-fab-label {
    line-height: 1;
}

/* ─── The panel ─────────────────────────────────────────────────────────── */
.askw-panel {
    position: absolute;
    right: 0;
    bottom: 62px;
    width: 392px;
    max-width: calc(100vw - 44px);
    height: min(580px, calc(100vh - 130px));
    display: flex;
    flex-direction: column;
    background: var(--ask-surface);
    border: 1px solid var(--ask-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 18px 46px rgba(15, 28, 46, .24);
    overflow: hidden;
    /* Hidden rather than unmounted, so the transcript and whatever has been typed are still there
       when the panel comes back. Visibility also takes the panel out of the tab order while it is
       closed, which opacity alone would not have done. */
    opacity: 0;
    visibility: hidden;
    transform: scale(.97) translateY(10px);
    transform-origin: bottom right;
    pointer-events: none;
    transition: opacity .15s ease, transform .15s ease, visibility .15s ease;
}

.askw.is-open .askw-panel {
    opacity: 1;
    visibility: visible;
    transform: none;
    pointer-events: auto;
}

.askw-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    background: linear-gradient(135deg, var(--navy) 0%, #17304f 100%);
    color: #fff;
    flex: 0 0 auto;
}

.askw-head-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, .10);
    border: 1px solid rgba(255, 255, 255, .16);
    font-size: 1.02rem;
    color: var(--gold-2);
    flex: 0 0 auto;
}

.askw-head-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    min-width: 0;
    flex: 1 1 auto;
}

.askw-head-title {
    font-size: .9rem;
    font-weight: 700;
}

.askw-head-sub {
    font-size: .7rem;
    color: rgba(255, 255, 255, .62);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.askw-head-btn {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: rgba(255, 255, 255, .72);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .86rem;
    cursor: pointer;
    flex: 0 0 auto;
    transition: background .12s ease, color .12s ease;
}

.askw-head-btn:hover,
.askw-head-btn:focus-visible {
    background: rgba(255, 255, 255, .12);
    color: #fff;
    outline: none;
}

/* ─── The transcript ────────────────────────────────────────────────────── */
.ask-thread {
    padding: 14px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.askw-body {
    flex: 1 1 auto;
    min-height: 0;
    background: var(--ask-surface-2);
}

.ask-msg {
    display: flex;
    gap: 10px;
}

.ask-msg.is-me {
    justify-content: flex-end;
}

.ask-bubble {
    max-width: 90%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: .82rem;
    line-height: 1.5;
    background: var(--ask-surface);
    border: 1px solid var(--ask-border);
    color: var(--ask-text);
}

.ask-msg.is-me .ask-bubble {
    background: var(--ask-me-bg);
    border-color: var(--ask-me-line);
    color: var(--ask-me-text);
    max-width: 78%;
}

.ask-bubble.is-answer {
    max-width: 100%;
    width: 100%;
    background: var(--ask-surface);
}

.ask-bubble.is-error {
    background: var(--ask-red-light);
    border-color: var(--ask-red-border);
    color: var(--ask-red);
}

.ask-bubble p {
    margin: 0 0 6px;
}

.ask-bubble p:last-child,
.ask-bubble p.mb-0 {
    margin-bottom: 0;
}

.ask-bubble-note {
    font-size: .74rem;
    color: var(--ask-muted);
}

/* ─── While the read runs ───────────────────────────────────────────────── */
.ask-thinking .ask-bubble {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ask-secondary);
}

.ask-thinking-text {
    font-size: .8rem;
}

/* The assistant's own ring, on purpose not `.spinner-border`. Bootstrap does ship that component and
   the register's Trash.aspx writes it for the archive's read, so the class is spoken for; this circle
   is 14px of the assistant's brand blues and shares its size with nothing else on the screen. */
.ask-spin {
    width: 14px;
    height: 14px;
    flex: 0 0 auto;
    border: 2px solid var(--blue-soft);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: askSpin .8s linear infinite;
}

@keyframes askSpin {
    to { transform: rotate(360deg); }
}

/* ─── An answer ─────────────────────────────────────────────────────────── */
.ask-answer-top {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.ask-intent {
    font-size: .7rem;
    color: var(--ask-muted);
    font-style: italic;
}

/* The answer's group badge is the shell's pill at the panel's scale, so it matches the Archive row
   it describes without a second palette. */
.ask-module.mod-badge {
    font-size: .7rem;
    padding: 2px 8px;
}

.ask-headline {
    font-size: .84rem;
    font-weight: 600;
    color: var(--ask-text);
    margin-bottom: 10px;
}

/* ─── The result table ──────────────────────────────────────────────────── */
.ask-table-scroll {
    overflow-x: auto;
    border: 1px solid var(--ask-border);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    background: var(--ask-surface);
}

.ask-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .74rem;
}

.ask-table th {
    text-align: left;
    padding: 7px 10px;
    background: var(--ask-surface-2);
    color: var(--ask-secondary);
    font-weight: 700;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    white-space: nowrap;
    border-bottom: 1px solid var(--ask-border);
}

.ask-table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--ask-border);
    color: var(--ask-text);
    vertical-align: top;
}

.ask-table tbody tr:last-child td {
    border-bottom: 0;
}

/* ─── What the assistant understood ─────────────────────────────────────── */
.ask-filter-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.ask-filter-label {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--ask-muted);
    font-weight: 700;
}

.ask-chip {
    border: 1px solid var(--ask-border);
    background: var(--ask-surface-2);
    color: var(--ask-secondary);
    border-radius: 20px;
    padding: 3px 10px;
    font: inherit;
    font-size: .72rem;
    font-weight: 600;
    text-align: left;
    cursor: default;
    transition: background .12s ease, border-color .12s ease, color .12s ease;
}

.ask-chip.is-read {
    background: var(--ask-blue-light);
    border-color: var(--ask-blue-border);
    color: var(--ask-blue);
}

.ask-chip.is-skipped {
    color: var(--ask-muted);
    text-decoration: line-through;
}

.ask-chip.is-suggest {
    cursor: pointer;
}

.ask-chip.is-suggest:hover,
.ask-chip.is-suggest:focus-visible {
    background: var(--gold-soft);
    border-color: #E8CE7A;
    color: #7A5606;
    outline: none;
}

/* ─── What it can answer, before anything has been asked ────────────────── */
.askw-welcome {
    text-align: center;
    padding: 6px 2px 2px;
}

.askw-mascot {
    width: 52px;
    height: 52px;
    margin: 2px auto 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--blue);
    background: var(--blue-soft);
    border: 1px solid var(--ask-border);
}

.askw-hi {
    margin: 0;
    font-size: 1.02rem;
    font-weight: 700;
    color: var(--ask-text);
}

.askw-tagline {
    margin: 3px 0 0;
    font-size: .76rem;
    color: var(--ask-secondary);
}

.askw-tagline strong {
    color: var(--ask-text);
}

.askw-qlist {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 13px;
    text-align: left;
}

.askw-q {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 8px 11px;
    border: 1px solid var(--ask-border);
    border-radius: 11px;
    background: var(--ask-surface);
    color: var(--ask-secondary);
    font: inherit;
    font-size: .78rem;
    font-weight: 600;
    line-height: 1.35;
    text-align: left;
    cursor: pointer;
    transition: border-color .12s ease, background .12s ease, transform .12s ease, color .12s ease;
}

/* The same swap as the launcher: each suggested question carries its module's <Ico> glyph, and the
   gold is the wrapper's colour, not a font glyph's. `flex: 0 0 auto` keeps the 14px square from
   being squeezed by a long question on a narrow panel. */
.askw-q .ico-wrap {
    color: var(--gold);
    flex: 0 0 auto;
}

.askw-q:hover,
.askw-q:focus-visible {
    border-color: #E8CE7A;
    background: var(--gold-soft);
    color: var(--ask-me-text);
    transform: translateX(2px);
    outline: none;
}

.askw-foot {
    margin: 13px 0 0;
    font-size: .7rem;
    color: var(--ask-muted);
    line-height: 1.5;
}

/* ─── Composer ──────────────────────────────────────────────────────────── */
.ask-composer {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--ask-border);
    background: var(--ask-surface-2);
    flex: 0 0 auto;
}

.ask-input {
    flex: 1 1 auto;
    min-width: 0;
    border-radius: 10px;
    border: 1px solid var(--input-border);
    background: var(--ask-surface);
    color: var(--ask-text);
    font: inherit;
    font-size: .86rem;
    padding: 8px 12px;
}

.ask-input::placeholder {
    color: var(--ask-muted);
}

.ask-input:focus {
    border-color: #E0BE55;
    box-shadow: 0 0 0 .2rem var(--gold-glow);
    outline: none;
}

.ask-send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    background: var(--blue);
    border: 0;
    color: #fff;
    border-radius: 10px;
    padding: 0 15px;
    font-size: .82rem;
    font-weight: 700;
    cursor: pointer;
    transition: background .12s ease;
}

.ask-send:hover,
.ask-send:focus-visible {
    background: var(--blue);
    color: #fff;
    outline: none;
}

.ask-send:disabled {
    opacity: .55;
    cursor: progress;
}

/* ─── Mobile: never outrank the navigation drawer ─────────────────────────
   The sidebar and its backdrop exist only under 992px and sit at 1000-1002. The launcher's 1040 is
   right for a desk, where it shares the screen with no drawer, but on a phone it would float above a
   menu the person has just opened and stay clickable behind it. */
@media (max-width: 991px) {
    .askw {
        z-index: 999;
    }
}

/* ─── Small screens: the panel takes the width it can ─────────────────────
   The wrapper is shrink-to-fit — its own width is the launcher's, since only its right and bottom
   edges are pinned. So the panel cannot be stretched by setting left and right against it: that
   asks an absolutely positioned box to be as wide as a parent that is as wide as it is, and the
   browser resolves the circle by making the panel the width of the button. Fixed positioning takes
   the same inset values against the viewport instead, which is what "use the whole screen" means
   here. */
@media (max-width: 640px) {
    .askw {
        right: 14px;
        bottom: 14px;
    }

    .askw-panel {
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: 76px;
        width: auto;
        max-width: none;
        height: calc(100vh - 92px);
    }

    .askw-fab-label {
        display: none;
    }

    .askw-fab {
        padding: 0 15px;
    }
}

/* ─── The corner is shared with the notice rail ───────────────────────
   This launcher lives 22px from the bottom-right corner and never leaves it, so a page's transient
   "Saved" line has to step above it rather than the panel moving under it. The clearance is stated in
   JpscTheme.css on the sheet's own `.notice`, because that is the rule that decides where the corner is;
   an override here would load before it and lose the tie it was written to break. */

@media print {
    .askw {
        display: none;
    }
}
