/* NILI chat — global (non-scoped) styles. Loaded via _content/ETuteApp.UI.Shared/css/nili.css.
   v1 minimal skin; the NILI sub-brand identity + two personality profiles land in step 28.
   Palette reuses the ETute sky-blue (#00A2FF) / navy family; the trademarked logo is untouched. */

.nili-launcher-root {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1200;
}

.nili-launcher-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: #00A2FF;
    color: #fff;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nili-launcher-btn:hover {
    background: #0090e6;
}

.nili-launcher-btn.nili-open {
    background: #0b2545;
}

/* Desktop: right slide-in panel. */
.nili-panel-wrap {
    position: fixed;
    right: 20px;
    bottom: 84px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 560px;
    max-height: calc(100vh - 120px);
    z-index: 1200;
}

.nili-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

/* Desktop "expand" — a large centered overlay so charts/tables are comfortable to read.
   The panel breaks out of the corner sizer via fixed positioning; the backdrop dims behind it. */
.nili-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(11, 37, 69, 0.45);
    z-index: 1250;
}

.nili-panel.nili-expanded {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(960px, 92vw);
    height: 85vh;
    max-height: 85vh;
    z-index: 1260;
    border-radius: 14px;
}

/* The wrap's entry animation uses fill-mode:both, which leaves a transform on it — that would make the
   wrap (not the viewport) the containing block for the fixed expanded panel, pushing it off-centre.
   Clear the wrap's transform/animation while a panel is expanded so it centres on the viewport. */
.nili-panel-wrap:has(.nili-panel.nili-expanded) {
    animation: none;
    transform: none;
}

.nili-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #0b2545;
    color: #fff;
}

.nili-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.nili-icon-btn {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.nili-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f7fafd;
}

.nili-welcome {
    margin: auto;
    text-align: center;
    color: #5a6b7b;
    padding: 20px;
}

.nili-msg {
    display: flex;
}

.nili-msg-user {
    justify-content: flex-end;
}

.nili-msg-nili {
    justify-content: flex-start;
}

.nili-msg-body {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
}

.nili-msg-user .nili-msg-body {
    background: #00A2FF;
    color: #fff;
    border-bottom-right-radius: 3px;
}

.nili-msg-nili .nili-msg-body {
    background: #fff;
    color: #16232f;
    border: 1px solid #e2e9f0;
    border-bottom-left-radius: 3px;
}

.nili-msg-error .nili-msg-body {
    background: #fff3f3;
    border-color: #f0c2c2;
    color: #a12a2a;
}

/* C13 — quota notice. Deliberately NOT styled like .nili-msg-error: the turn succeeded, and dressing an
   informational "you are near your allowance" message as a failure would misread as NILI being broken.
   Shared by both surfaces (the ask sheet's answer card and the chat panel's message). */
.nili-notice {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin: 0 0 10px;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.85rem;
    line-height: 1.35;
    background: #eef5fd;
    border: 1px solid #cfe0f5;
    color: #1c4a7a;
}

.nili-notice--warning {
    background: #fff8ec;
    border-color: #f2ddb4;
    color: #8a5a12;
}

.nili-notice__icon {
    flex: 0 0 auto;
    line-height: 1.35;
}

/* Rendered markdown (NILI answers only) — the bubble's pre-wrap is for plain user text;
   Markdig emits real block HTML, so normalise whitespace and keep block margins tight. */
.nili-msg-md { white-space: normal; }
.nili-msg-md > :first-child { margin-top: 0; }
.nili-msg-md > :last-child { margin-bottom: 0; }
.nili-msg-md p { margin: 0 0 0.5em; }
.nili-msg-md ul,
.nili-msg-md ol { margin: 0 0 0.5em; padding-left: 1.25em; }
.nili-msg-md li { margin: 0.1em 0; }
.nili-msg-md strong { font-weight: 600; }
.nili-msg-md code {
    background: rgba(0, 0, 0, 0.06);
    padding: 0.05em 0.3em;
    border-radius: 4px;
    font-size: 0.85em;
}
.nili-msg-md pre {
    background: rgba(0, 0, 0, 0.06);
    padding: 8px 10px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 0 0 0.5em;
}
.nili-msg-md pre code { background: none; padding: 0; }
.nili-msg-md table {
    border-collapse: collapse;
    margin: 0.25em 0 0.5em;
    font-size: 0.85em;
}
.nili-msg-md th,
.nili-msg-md td {
    border: 1px solid #e2e9f0;
    padding: 2px 6px;
    text-align: left;
}

.nili-typing {
    color: #9aa7b3;
}

.nili-table {
    margin-top: 8px;
    font-size: 0.8rem;
}

.nili-table summary {
    cursor: pointer;
    color: #0b6bb0;
}

.nili-table-scroll {
    overflow-x: auto;
    margin-top: 6px;
}

.nili-table table {
    border-collapse: collapse;
    width: 100%;
}

.nili-table th,
.nili-table td {
    border: 1px solid #e2e9f0;
    padding: 4px 8px;
    text-align: left;
    white-space: nowrap;
}

.nili-table-note {
    color: #8a97a3;
    margin-top: 4px;
}

.nili-input {
    padding: 10px 12px 12px;
    border-top: 1px solid #e2e9f0;
    background: #fff;
}

/* The composer is one rounded pill grouping mic + input + send, with a brand-blue focus ring. */
.nili-composer {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    border: 1px solid #cfd9e2;
    border-radius: 14px;
    padding: 3px 4px 3px 8px;
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.nili-composer:focus-within {
    border-color: #00A2FF;
    box-shadow: 0 0 0 3px rgba(0, 162, 255, 0.15);
}

.nili-textbox {
    flex: 1 1 auto;
    resize: none;
    border: none;
    outline: none;
    background: transparent;
    padding: 8px 4px;
    font-size: 0.92rem;
    line-height: 1.4;
    font-family: inherit;
    /* Auto-grow with content (Chrome/Edge) up to ~6 lines, then scroll. Older browsers keep one line. */
    field-sizing: content;
    min-height: 22px;
    max-height: 140px;
    overflow-y: auto;
}

/* Mic + send sit inside the pill: mic is a bare glyph, send is a filled brand circle. */
.nili-composer .nili-mic-btn {
    border: none;
    background: transparent;
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
}

.nili-composer .nili-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex: 0 0 auto;
}

.nili-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: none;
    background: #00A2FF;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.nili-send-btn:disabled {
    background: #b9d9ee;
    cursor: default;
}

/* Header actions (new chat / history / close). */
.nili-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nili-icon-btn.nili-active {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 6px;
}

/* Chart card (answer → chart → collapsed table). */
.nili-chart-card {
    margin-top: 8px;
    background: #fff;
    border: 1px solid #e2e9f0;
    border-radius: 10px;
    padding: 8px;
}

.nili-chart-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: #16232f;
    margin-bottom: 4px;
}

/* Session list / resume. */
.nili-sessions {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 10px;
    background: #f7fafd;
}

.nili-newchat-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 10px;
    border: 1px solid #cfe4f5;
    border-radius: 10px;
    background: #fff;
    color: #0b6bb0;
    cursor: pointer;
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.nili-newchat-btn:hover {
    background: #eef7fe;
}

.nili-sessions-empty {
    color: #8a97a3;
    text-align: center;
    padding: 20px;
    font-size: 0.85rem;
}

.nili-session-items {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nili-session-item {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 8px 10px;
    border: 1px solid #e2e9f0;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    text-align: left;
}

.nili-session-item:hover {
    background: #eef7fe;
    border-color: #cfe4f5;
}

.nili-session-title {
    font-size: 0.88rem;
    color: #16232f;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.nili-session-date {
    font-size: 0.72rem;
    color: #8a97a3;
}

/* Mobile: full-screen sheet. */
@media (max-width: 640px) {

    .nili-panel-wrap {
        right: 0;
        bottom: 0;
        left: 0;
        top: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
    }

    .nili-panel {
        border-radius: 0;
    }

    /* On mobile the panel is already full-screen, so hide the expand trigger. */
    .nili-expand-btn {
        display: none;
    }
}

/* ── Action card (amber) — a drafted, human-confirmed mutation. Deliberately unmistakable from the
   informational chart/table cards: warm amber surface, warning glyph, explicit Confirm/Edit/Cancel. ── */
.nili-action-card {
    margin-top: 8px;
    background: #fff8ec;
    border: 1px solid #f0b429;
    border-left: 4px solid #e6a100;
    border-radius: 10px;
    padding: 10px 12px;
}

.nili-action-head {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #8a5a00;
    font-weight: 600;
    font-size: 0.85rem;
}

.nili-action-timer {
    margin-left: auto;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: #b06f00;
    background: #fdeecb;
    border-radius: 6px;
    padding: 1px 6px;
    font-size: 0.78rem;
}

.nili-action-meta {
    margin: 6px 0;
}

.nili-action-badge {
    display: inline-block;
    background: #fdeecb;
    color: #8a5a00;
    border-radius: 10px;
    padding: 1px 8px;
    font-size: 0.75rem;
    font-weight: 600;
}

.nili-action-preview {
    background: #fff;
    border: 1px solid #f2ddb0;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 0.85rem;
    color: #4a3c1e;
    white-space: pre-wrap;
    word-break: break-word;
}

.nili-action-edit {
    width: 100%;
    resize: vertical;
    border: 1px solid #e6a100;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 0.85rem;
    font-family: inherit;
    color: #4a3c1e;
    background: #fff;
}

.nili-action-buttons {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.nili-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
}

.nili-action-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.nili-action-btn.nili-confirm {
    background: #e6a100;
    color: #fff;
}

.nili-action-btn.nili-confirm:hover:not(:disabled) {
    background: #cc8f00;
}

.nili-action-btn.nili-edit {
    background: #fff;
    color: #8a5a00;
    border-color: #e6a100;
}

.nili-action-btn.nili-cancel {
    background: #fff;
    color: #9a4a2a;
    border-color: #e2b7a6;
}

.nili-action-receipt {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.82rem;
}

.nili-action-receipt.nili-ok {
    background: #eaf7ee;
    color: #1c7a3e;
    border: 1px solid #b9e2c6;
}

.nili-action-receipt.nili-fail {
    background: #fff3f3;
    color: #a12a2a;
    border: 1px solid #f0c2c2;
}

.nili-action-receipt.nili-cancelled {
    background: #f2f3f5;
    color: #5a6b7b;
    border: 1px solid #dbe1e7;
}

/* ── Voice (step 29): mic input button + live waveform + per-reply read-aloud. Capability-gated in the
   panel so these only render where the browser supports Web Speech. ── */
.nili-mic-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid #cfd9e2;
    background: #fff;
    color: #0b6bb0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.nili-mic-btn:hover:not(:disabled) {
    background: #eef7fe;
}

.nili-mic-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.nili-mic-btn.nili-listening {
    background: #00A2FF;
    color: #fff;
    border-color: #00A2FF;
}

.nili-wave {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    height: 16px;
}

.nili-wave span {
    width: 3px;
    height: 6px;
    background: currentColor;
    border-radius: 2px;
    animation: nili-wave 0.9s ease-in-out infinite;
}

.nili-wave span:nth-child(2) {
    animation-delay: 0.15s;
}

.nili-wave span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes nili-wave {
    0%, 100% { height: 6px; }
    50% { height: 15px; }
}

.nili-readaloud-btn {
    margin-top: 6px;
    background: transparent;
    border: none;
    color: #8a97a3;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    font-size: 0.85rem;
}

.nili-readaloud-btn:hover {
    color: #0b6bb0;
}

/* ── Follow-up chips (step 30): Supervisor-suggested next steps. Tapping pre-fills the input. ── */
.nili-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.nili-chip {
    border: 1px solid #cfe4f5;
    background: #f3f9ff;
    color: #0b6bb0;
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 0.8rem;
    cursor: pointer;
    line-height: 1.3;
}

.nili-chip:hover {
    background: #e4f2ff;
    border-color: #9fd0f2;
}
