/*
 * Sage, the AI assistant. Its own screen (exchange/assistant.html) rather than a tab
 * inside the support widget, which is now the real-support chat and nothing else.
 * Reuses the widget's custom properties so it follows whatever theme is active.
 */

/* Every open/closed state here is driven by the `hidden` attribute, but the rules below set
   `display` on those same elements. An author rule always outranks the UA
   [hidden] { display: none }, so without this guard the pane, menu, footer and closed bar
   would all render at once. */
.ai-pane[hidden],
.ai-view[hidden],
.ai-footer[hidden],
.ai-closed-bar[hidden],
.ai-menu[hidden],
.ai-menu button[hidden],
.ai-modal[hidden],
.ai-row[hidden] { display: none !important; }

.ai-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.ai-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 12px 14px;
}

/* ---------- history list ---------- */

.ai-newchat {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    background: #018a41;
    color: #fff;
    border: none;
    border-radius: var(--standard-radius);
    font-family: 'Roboto', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.ai-newchat:hover { filter: brightness(1.08); }
.ai-newchat:focus-visible { outline: 2px solid #01562a; outline-offset: 2px; }

.ai-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.ai-list::-webkit-scrollbar { display: none; }

.ai-row {
    display: flex;
    align-items: stretch;
    gap: 4px;
    border-radius: var(--standard-radius);
    margin-bottom: 4px;
}
.ai-row:hover { background: rgba(1, 138, 65, .08); }
.ai-row--closed { opacity: .62; }

.ai-row__main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 9px 10px;
    background: none;
    border: none;
    text-align: left;
    color: var(--font-color);
    font-family: 'Roboto', sans-serif;
    cursor: pointer;
}

.ai-row__top { display: flex; align-items: center; gap: 6px; width: 100%; }

.ai-row__title {
    flex: 1;
    min-width: 0;
    font-size: 13.5px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-row__when { flex: none; font-size: 11px; opacity: .5; }

.ai-row__preview {
    font-size: 12px;
    opacity: .6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-chip {
    flex: none;
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 3px;
    background: rgba(0, 0, 0, .1);
}

.ai-row__menu {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    background: none;
    border: none;
    color: var(--font-color);
    opacity: .45;
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
    border-radius: var(--standard-radius);
}
.ai-row__menu:hover { opacity: 1; }
.ai-row__menu:focus-visible { outline: 2px solid #018a41; }

.ai-row__rename {
    flex: 1;
    min-width: 0;
    font-family: 'Roboto', sans-serif;
    font-size: 13.5px;
    padding: 3px 6px;
    border: 1px solid #018a41;
    border-radius: 4px;
    background: #080f16;
    color: var(--font-color);
}
.ai-row__rename:focus { outline: none; }

.ai-empty {
    padding: 26px 12px;
    text-align: center;
    font-size: 13px;
    opacity: .55;
}

/* ---------- row menu ---------- */

/* Absolute against the assistant screen (.msage is position: relative), so the menu is clamped
   inside the pane rather than the viewport. showMenu converts the anchor's viewport rect into
   offsetParent-relative coordinates. */
.ai-menu {
    position: absolute;
    z-index: 999999999999;
    min-width: 148px;
    padding: 4px;
    background: var(--chat-bg-color, #fff);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: var(--standard-radius);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
    display: flex;
    flex-direction: column;
}

.ai-menu button {
    padding: 9px 12px;
    background: none;
    border: none;
    text-align: left;
    color: var(--font-color);
    font-family: 'Roboto', sans-serif;
    font-size: 13px;
    cursor: pointer;
    border-radius: 4px;
}
.ai-menu button:hover { background: rgba(1, 138, 65, .12); }
.ai-menu button:focus-visible { outline: 2px solid #018a41; outline-offset: -2px; }
.ai-menu__danger { color: #c0392b !important; }
.ai-menu__danger:hover { background: rgba(192, 57, 43, .12) !important; }

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

.ai-thread-head {
    flex: none;
    display: flex;
    align-items: center;
    gap: 4px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    margin-bottom: 8px;
}

.ai-back {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: none;
    border: none;
    color: var(--font-color);
    cursor: pointer;
    border-radius: 50%;
}
.ai-back svg { width: 22px; height: 22px; }
.ai-back:hover { background: rgba(0, 0, 0, .07); }
.ai-back:focus-visible { outline: 2px solid #018a41; }

.ai-thread-title {
    flex: 1;
    min-width: 0;
    font-family: 'Roboto', sans-serif;
    font-size: 13.5px;
    font-weight: 600;
    line-height: 28px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Persistent, not a greeting that scrolls away: nobody should have to wonder whether a person
   is reading their message. */
.ai-bot-strip {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 9px;
    margin-bottom: 8px;
    border-radius: var(--standard-radius);
    background: rgba(1, 138, 65, .1);
    font-size: 11px;
    line-height: 1.35;
}

/* Green rather than the browser-blue it used to be: on the dark assistant screen a
   blue link was the only element not from the palette. */
.ai-human-link {
    flex: none;
    background: none;
    border: none;
    padding: 0;
    color: #18BB59;
    font-size: 11px;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
}
.ai-human-link:focus-visible { outline: 2px solid #18BB59; }

.ai-messages {
    flex: 1;
    width: 100%;
    padding: 0 4px;
    margin-top: auto;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    overflow-y: auto;
    min-height: 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.ai-messages::-webkit-scrollbar { display: none; }

.ai-msg {
    display: flex;
    flex-direction: column;
    margin: 4px 0;
    max-width: 90%;
}
.ai-msg--user { align-self: flex-end; align-items: flex-end; }
.ai-msg--bot  { align-self: flex-start; align-items: flex-start; }

.ai-msg__who { font-size: 11px; opacity: .55; margin-bottom: 3px; }

.ai-msg__text {
    padding: var(--standard-padding);
    border-radius: var(--standard-radius);
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.ai-msg--user .ai-msg__text { background-color: #018a41; color: #fff; }
.ai-msg--bot  .ai-msg__text { background-color: #080f16; color: #EAECEF; }
.ai-msg--pending .ai-msg__text { opacity: .6; font-style: italic; }

.ai-disclaimer {
    flex: none;
    font-size: 11px;
    opacity: .5;
    text-align: center;
    padding: 8px 6px 0;
    line-height: 1.4;
}

/* ---------- composer and closed bar ---------- */

.ai-footer {
    width: 100%;
    padding: var(--standard-padding);
    border-top: solid 1px rgba(255, 255, 255, .08);
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
}

#ai_input {
    color: var(--font-color);
    font-family: 'Raleway', sans-serif;
    font-size: var(--font-size);
    background-color: #080f16;
    width: 100%;
    height: 80px;
    max-height: 120px;
    padding: 10px 15px;
    resize: none;
    border: none;
    border-radius: var(--standard-radius);
    transition: .3s background-color;
    overflow: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
#ai_input::-webkit-scrollbar { display: none; }
#ai_input:focus { background-color: #0a101b; outline: none; }

#ai_send {
    background: none;
    border: none;
    margin-left: 10px;
    padding: 5px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
#ai_send:focus-visible { outline: 2px solid #018a41; }
#ai_send[disabled] { opacity: .4; cursor: default; }

.ai-closed-bar {
    width: 100%;
    padding: var(--standard-padding);
    border-top: solid 1px rgba(255, 255, 255, .08);
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 12.5px;
}

.ai-reopen {
    flex: none;
    padding: 7px 14px;
    background: #018a41;
    color: #fff;
    border: none;
    border-radius: var(--standard-radius);
    font-family: 'Roboto', sans-serif;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}
.ai-reopen:hover { filter: brightness(1.08); }
.ai-reopen:focus-visible { outline: 2px solid #01562a; outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
    #ai_input { transition: none; }
}

/* ---------- confirmation cards ---------- */

.ai-card-slot { align-self: flex-start; max-width: 92%; width: 320px; margin: 6px 0; }

.ai-card {
    border: 1px solid #018a4155;
    border-left: 3px solid #018a41;
    border-radius: var(--standard-radius);
    background: rgba(1, 138, 65, .06);
    overflow: hidden;
}

.ai-card--settled { border-left-color: #9a9a9a; background: rgba(0, 0, 0, .04); }
.ai-card--gone { border-left-color: #9a9a9a; background: rgba(0, 0, 0, .04); }

.ai-card__head {
    padding: 9px 12px;
    font-family: 'Roboto', sans-serif;
    font-size: 12.5px;
    font-weight: 600;
    border-bottom: 1px solid #00000018;
}

.ai-card__body {
    margin: 0;
    padding: 10px 12px;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 12px;
    font-size: 12.5px;
}

.ai-card__body dt { opacity: .6; }

.ai-card__body dd {
    margin: 0;
    text-align: right;
    font-family: 'IBM Plex Mono', 'SF Mono', Menlo, Consolas, monospace;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.ai-card__note { padding: 0 12px 8px; font-size: 11px; opacity: .6; line-height: 1.4; }

.ai-card__foot {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px 12px;
}

.ai-card__confirm {
    padding: 8px 16px;
    background: #018a41;
    color: #fff;
    border: none;
    border-radius: var(--standard-radius);
    font-family: 'Roboto', sans-serif;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}
.ai-card__confirm:hover { filter: brightness(1.08); }
.ai-card__confirm:focus-visible { outline: 2px solid #01562a; outline-offset: 2px; }

.ai-card__cancel {
    padding: 8px 14px;
    background: none;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: var(--standard-radius);
    color: var(--font-color);
    font-family: 'Roboto', sans-serif;
    font-size: 12.5px;
    cursor: pointer;
}
.ai-card__cancel:hover { background: rgba(0, 0, 0, .05); }
.ai-card__cancel:focus-visible { outline: 2px solid #018a41; }

.ai-card button[disabled] { opacity: .45; cursor: default; }

.ai-card__expiry {
    margin-left: auto;
    font-family: 'IBM Plex Mono', 'SF Mono', Menlo, Consolas, monospace;
    font-size: 11px;
    opacity: .55;
    font-variant-numeric: tabular-nums;
}

.ai-card__status { padding: 0 12px 12px; font-size: 12px; opacity: .75; }
.ai-card__status--ok { color: #018a41; font-weight: 600; opacity: 1; }
.ai-card__status--bad { color: #c0392b; font-weight: 600; opacity: 1; }

/* ---------- deposit address card ---------- */

/* Shown beneath a reply whenever a tool returned a deposit address, so the user scans or copies
   the address the exchange issued rather than one retyped out of a sentence. */
.ai-addr {
    margin: 4px 4px 10px;
    padding: 12px;
    border-radius: var(--standard-radius);
    background: #080f16;
    border: 1px solid rgba(255, 255, 255, .08);
}

.ai-addr__qr {
    display: flex;
    justify-content: center;
    padding: 10px;
    margin-bottom: 10px;
    background: #fff;
    border-radius: 10px;
}
.ai-addr__qr img, .ai-addr__qr canvas { display: block; }

.ai-addr__label {
    font-size: 11px;
    opacity: .6;
    margin-bottom: 4px;
}

.ai-addr__row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-addr__value {
    flex: 1;
    min-width: 0;
    font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.ai-addr__copy {
    flex: none;
    width: 32px;
    height: 32px;
    padding: 0;
    background: none;
    border: none;
    color: #018a41;
    font-size: 17px;
    cursor: pointer;
    border-radius: 6px;
}
.ai-addr__copy:hover { background: rgba(1, 138, 65, .12); }
.ai-addr__copy:focus-visible { outline: 2px solid #018a41; }

.ai-addr__tag {
    margin-top: 8px;
    font-size: 12px;
    opacity: .75;
}


/* ---------- confirmation dialog ---------- */

/* Absolute like the row menu, so the dim covers the assistant screen rather than the whole
   viewport — the bottom nav and header stay reachable behind it. */
.ai-modal {
    position: absolute;
    inset: 0;
    z-index: 1000000000000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, .55);
    border-radius: var(--standard-radius);
}

.ai-modal__box {
    width: 100%;
    max-width: 300px;
    padding: 18px;
    background: var(--chat-bg-color, #04060a);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: var(--standard-radius);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
}

.ai-modal__title {
    font-family: 'Roboto', sans-serif;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--font-color);
    margin-bottom: 16px;
}

.ai-modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.ai-modal__btn {
    padding: 8px 14px;
    background: none;
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 999px;
    color: var(--font-color);
    font-family: 'Roboto', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}
.ai-modal__btn:hover { background: rgba(255, 255, 255, .06); }
.ai-modal__btn:focus-visible { outline: 2px solid #018a41; outline-offset: 2px; }

.ai-modal__btn--danger {
    background: #c0392b;
    border-color: #c0392b;
    color: #fff;
}
.ai-modal__btn--danger:hover { background: #a93226; }
.ai-modal__btn--danger:focus-visible { outline: 2px solid #c0392b; outline-offset: 2px; }

/* ---------- scam notice ---------- */

/*
 * Red accent on the ordinary surface, not a red fill. A solid red block inside a transcript reads
 * as "something broke" or as a scolding, and this notice is neither — it is the product saying
 * quietly that a person should take over. Same treatment the log-out row in the menu already uses
 * (rgba(235, 69, 54, …) on #F07167), so it looks like part of the app rather than an alert
 * borrowed from somewhere else.
 */
/* .ai-messages is a flex column, so the slot has to claim the width or the notice shrinks to
   its text and stops reading as a banner. */
.ai-warn-slot { align-self: stretch; width: 100%; }

.ai-warn {
    box-sizing: border-box;
    margin: 8px 0;
    padding: 12px 14px;
    border: 1px solid rgba(235, 69, 54, .45);
    border-radius: var(--standard-radius, 13px);
    background: rgba(235, 69, 54, .07);
    color: #F07167;
}

.ai-warn__title {
    font-size: 13.5px;
    font-weight: 700;
    line-height: 1.4;
    margin-bottom: 5px;
}

.ai-warn__body {
    font-size: 13px;
    line-height: 1.55;
}

/* On its own line beneath the copy, so it reads as the way out rather than as a word in a
   sentence someone has to find. */
.ai-warn__link {
    display: inline-block;
    margin-top: 9px;
    color: #F07167;
    font-size: 13px;
    font-weight: 700;
    text-decoration: underline;
}
.ai-warn__link:hover { filter: brightness(1.12); }
.ai-warn__link:focus-visible { outline: 2px solid #F07167; outline-offset: 2px; }

.ai-warn__note {
    margin-top: 9px;
    font-size: 12px;
    line-height: 1.5;
    opacity: .8;
}

/* Replaces the composer in a locked thread. Deliberately has no Reopen button: the whole point
   of the lock is that the conversation continues with a person. */
.ai-locked-bar[hidden] { display: none !important; }
.ai-locked-bar {
    width: 100%;
    padding: var(--standard-padding);
    border-top: solid 1px rgba(235, 69, 54, .28);
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 12.5px;
    color: #F07167;
}

.ai-locked-bar__link {
    flex: none;
    padding: 7px 14px;
    border: 1px solid rgba(235, 69, 54, .45);
    border-radius: var(--standard-radius, 13px);
    color: #F07167;
    font-size: 12.5px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}
.ai-locked-bar__link:hover { background: rgba(235, 69, 54, .12); }

/* The list chip for a thread the filter ended. .ai-chip carries the shape; this recolours it. */
.ai-chip--locked {
    background: rgba(235, 69, 54, .12);
    color: #F07167;
}
