/* =====================================================================================================================
   Chip In Intelligence: one look for every AI button, pill and "thinking" mark on the web (the mobile twin is
   Resources/Styles/AiTheme.xaml with the AiGradientBrush / AiThinkingOrbView keys).

   The AI gradient (--ci-ai-grad) is its own fixed iris, indigo into violet, tuned per theme and no longer read from
   the accent slider (the slider's slate default turned it into a muddy grey-to-violet). Light: indigo #4338CA into
   violet #7444E4. Dark: a deeper indigo #3F3DB8 into violet #7357E8, so it sits quietly on the dark cards. The middle
   stop is the OKLab midpoint, so the blend never passes through grey. White text holds 4.9:1 or better on every stop.
   Buttons and pills add --ci-ai-sheen, a faint top highlight, over the gradient. --ci-ai-ink is the AI colour for text
   and glyphs on a neutral surface; --ci-ai-wash is the faint iris tint behind the All Access pill (ai-all-access.css).

   The thinking orb (.ci-ai-orb, Components/Shared/Ai/AiThinkingOrb.razor) is the Budgets Rebalance loader made
   shared: the AI-gradient disc, the glyph twinkling, and a progress ring sweeping around it while .is-thinking.

   Loaded after every area sheet (App.razor), so these tokens and overrides win over the per-area copies (the Reports,
   Quick categorize, Liabilities, Connection health and paywall AI colours all route here).
   ===================================================================================================================== */

:root {
    --ci-ai-grad: linear-gradient(135deg, #4338CA 0%, #5C3ED7 50%, #7444E4 100%);
    --ci-ai-sheen: linear-gradient(180deg, rgba(255, 255, 255, .16) 0%, rgba(255, 255, 255, 0) 58%);
    --ci-ai-ink: #4338CA;
    --ci-ai-wash: #E9E8FB;
    --ci-ai-violet: #7444E4;
    --ci-ai-ring: #6A45E0;
    --ci-ai-glow: rgba(67, 56, 202, .26);
    --ci-ai-text: #FFFFFF;
    --rp-ai-grad: var(--ci-ai-grad);

    /* The per-area AI tokens, routed to the one gradient. */
    --qc-ai-a: #4338CA;
    --qc-ai-b: #5C3ED7;
    --qc-ai-c: #7444E4;
    --qc-ai-soft: linear-gradient(135deg, rgba(67, 56, 202, .08) 0%, rgba(116, 68, 228, .06) 100%);
    --qc-ai-text: #4338CA;
    --lb-ai: #5C3ED7;
    --sub-gradient: var(--ci-ai-grad);
    --sub-gradient-soft: linear-gradient(135deg, rgba(67, 56, 202, .12) 0%, rgba(116, 68, 228, .08) 100%);
    --chx-upgrade: var(--ci-ai-grad);
}

[data-bs-theme="dark"] {
    --ci-ai-grad: linear-gradient(135deg, #3F3DB8 0%, #594AD0 50%, #7357E8 100%);
    --ci-ai-sheen: linear-gradient(180deg, rgba(255, 255, 255, .12) 0%, rgba(255, 255, 255, 0) 58%);
    --ci-ai-ink: #B2AAFF;
    --ci-ai-wash: rgba(115, 87, 232, .2);
    --ci-ai-violet: #7357E8;
    --ci-ai-ring: #A99BFF;
    --ci-ai-glow: rgba(115, 87, 232, .32);
    --rp-ai-grad: var(--ci-ai-grad);

    --qc-ai-a: #3F3DB8;
    --qc-ai-b: #594AD0;
    --qc-ai-c: #7357E8;
    --qc-ai-soft: linear-gradient(135deg, rgba(115, 87, 232, .16) 0%, rgba(115, 87, 232, .07) 100%);
    --qc-ai-text: #B2AAFF;
    --lb-ai: #8F80F0;
    --sub-gradient: var(--ci-ai-grad);
    --sub-gradient-soft: linear-gradient(135deg, rgba(115, 87, 232, .22) 0%, rgba(115, 87, 232, .1) 100%);
    --chx-upgrade: var(--ci-ai-grad);
}

/* ---- Every AI button and pill takes the one gradient, with the faint top sheen ------------------------------------- */
.rp-btn-ai, [data-bs-theme="dark"] .rp-btn-ai,
.rp-pill-ai,
.bg-pill-ai,
.rt-btn-ai,
.sd-tool-ai,
.qc-chip-ai,
.rpx-mode-tag.is-deep,
.rp-models-chip.is-deep,
.rp-bh-chip.is-deep,
.ai-hist-depth.is-deep,
.settle-intel-btn,
.lb-cb-run.is-deep .lb-cb-run-btn.is-open,
.ai-editor-send,
.ci-ai-btn {
    background: var(--ci-ai-sheen), var(--ci-ai-grad);
    color: var(--ci-ai-text);
    border-color: transparent;
}

.settle-intel-btn { border: 0; }
.ai-editor-send { box-shadow: none; }
.ai-editor-send:hover:not(:disabled) { opacity: 1; filter: brightness(1.07); box-shadow: 0 6px 18px var(--ci-ai-glow); }

/* AI glyphs, ink and faint washes on neutral surfaces (Import Assist and its AI-category band) take the AI ink. */
.imc-assist, .imc-cats-ai { --ai: var(--ci-ai-ink); }

.rp-btn-ai:hover:not(:disabled), .rt-btn-ai:hover:not(:disabled), .ci-ai-btn:hover:not(:disabled), .settle-intel-btn:hover:not(:disabled) {
    filter: brightness(1.07);
    box-shadow: 0 6px 18px var(--ci-ai-glow);
}

.ci-ai-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 9px 16px; border: 0; border-radius: 12px;
    font: inherit; font-size: 13.5px; font-weight: 600; line-height: 1.2; cursor: pointer;
    transition: filter .15s ease, box-shadow .15s ease, transform .12s ease;
}
.ci-ai-btn:active:not(:disabled) { transform: translateY(1px); }
.ci-ai-btn:disabled { opacity: .55; cursor: default; }
.ci-ai-btn:focus-visible { outline: 2px solid var(--ci-ai-ring); outline-offset: 2px; }
.ci-ai-btn.is-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 10px; }

/* ---- The thinking orb (AiThinkingOrb): the Rebalance loader, shared -------------------------------------------------- */
.ci-ai-orb {
    --ci-ai-orb-size: 40px;
    position: relative;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    width: var(--ci-ai-orb-size);
    height: var(--ci-ai-orb-size);
    border-radius: 50%;
    background: var(--ci-ai-sheen), var(--ci-ai-grad);
    color: var(--ci-ai-text);
    font-size: calc(var(--ci-ai-orb-size) * .36);
    line-height: 1;
    isolation: isolate;
}
.ci-ai-orb > i, .ci-ai-orb > svg, .ci-ai-orb > .tx-glyph { color: inherit !important; fill: currentColor; }
/* A touch smaller everywhere (2026-11-19, web only): ~10% under the old 26/32/40/56/72 and 44 default. */
.ci-ai-orb.is-xs { --ci-ai-orb-size: 24px; }
.ci-ai-orb.is-sm { --ci-ai-orb-size: 29px; }
.ci-ai-orb.is-md { --ci-ai-orb-size: 36px; }
.ci-ai-orb.is-lg { --ci-ai-orb-size: 50px; }
.ci-ai-orb.is-xl { --ci-ai-orb-size: 65px; }
/* Financial Intelligence's pending-answer line: smaller still, to sit with the 13px stage text. */
.ai-progress > .ci-ai-orb.is-md { --ci-ai-orb-size: 30px; }

.ci-ai-orb.is-thinking::before {
    content: "";
    position: absolute;
    inset: calc(var(--ci-ai-orb-size) * -.115);
    border-radius: 50%;
    background: conic-gradient(from 0deg, transparent 0 55%, color-mix(in srgb, var(--ci-ai-ring) 35%, transparent) 72%, var(--ci-ai-ring) 92%, transparent 100%);
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), #000 calc(100% - 2px));
    mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), #000 calc(100% - 2px));
    animation: ci-ai-spin 1.1s linear infinite;
    pointer-events: none;
}
.ci-ai-orb.is-thinking > i, .ci-ai-orb.is-thinking > svg, .ci-ai-orb.is-thinking .tx-glyph { animation: ci-ai-twinkle 1.8s ease-in-out infinite; }

@keyframes ci-ai-spin { to { transform: rotate(360deg); } }
@keyframes ci-ai-twinkle { 0%, 100% { transform: scale(1) rotate(0deg); opacity: 1; } 50% { transform: scale(.86) rotate(-10deg); opacity: .78; } }

/* The thinking rows that hold an orb: room for the ring so it never clips. */
.rp-ai-thinking > .ci-ai-orb, .lb-cb-thinking > .ci-ai-orb, .qc-ai > .ci-ai-orb, .rp-ask-a > .ci-ai-orb, .rb-loading > .ci-ai-orb { margin: 5px; }
.ai-progress > .ci-ai-orb { justify-self: center; }
.ai-progress > canvas[hidden] { display: none; }
.imc-assist-thinking > .ci-ai-orb, .rt-thinking > .ci-ai-orb { margin: 8px; }
.bg-ai-status > .ci-ai-orb { margin: 3px; }

@media (prefers-reduced-motion: reduce) {
    .ci-ai-orb.is-thinking::before { animation-duration: 2.4s; }
    .ci-ai-orb.is-thinking > i, .ci-ai-orb.is-thinking > svg, .ci-ai-orb.is-thinking .tx-glyph { animation: none; }
}
