/* =====================================================================================================================
   An area's Intelligence page (Components/Shared/Ai/AiAreaIntelligence.razor: Investments > Intelligence and
   Liabilities > Intelligence) and the Pin / Delete actions on every briefing history (those two pages and Reports >
   Intelligence). Neutral cards on the Reports tokens (--rp-card, --rp-tile, --rp-text...); color only in the AI
   gradient (buttons, pills, the thinking orb, css/ai-theme.css) and in the findings' tones. Selected chips take a
   slight gradient of the text color, never a colored border. Light and dark.
   ===================================================================================================================== */

.ai-intel { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.ai-intel-card {
    min-width: 0;
    padding: 18px 20px 20px;
    border: 1px solid var(--rp-card-border, #DCDFF8);
    border-radius: 18px;
    background: var(--rp-card, #FFFFFF);
    color: var(--rp-text, #0B0F19);
}

.ai-intel-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px 14px; }
.ai-intel-chip {
    display: inline-grid; place-items: center; flex: 0 0 auto; width: 38px; height: 38px; border-radius: 12px;
    background: var(--rp-tile, #F6F7FD); color: var(--rp-text, #0B0F19); font-size: 15px;
}
.ai-intel-titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ai-intel-eyebrow { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--rp-muted, #565973); }
.ai-intel-title { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.3; color: var(--rp-text, #0B0F19); }
.ai-intel-caption { margin: 0; font-size: 12.5px; color: var(--rp-muted, #565973); }
.ai-intel-actions { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.ai-intel-depth { min-width: 220px; }

.ai-intel-body { margin-top: 16px; min-width: 0; }
.ai-intel-wait { display: flex; flex-direction: column; gap: 10px; padding: 6px 0; }

/* Start: the still orb, what it reads, the AI button. */
.ai-intel-start { display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 620px; margin: 0 auto; padding: 18px 8px 8px; text-align: center; }
.ai-intel-start-title { font-size: 16px; font-weight: 600; }
.ai-intel-start-pitch { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--rp-muted, #565973); }
.ai-intel-start .ci-ai-btn { margin-top: 4px; }
.ai-intel-model { display: block; margin: 6px 0 0; font-size: 11.5px; color: var(--rp-light, #9397AD); }
.ai-intel-start .ai-intel-model { margin: 0; }

/* Thinking: the orb with its ring, the status, the shimmering lines. */
.ai-intel-thinking { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px 16px; align-items: center; padding: 8px 2px; }
.ai-intel-thinking > .ci-ai-orb { margin: 7px; }
.ai-intel-thinking-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ai-intel-thinking-text strong { font-size: 14.5px; font-weight: 600; }
.ai-intel-thinking-text span { font-size: 12.5px; color: var(--rp-muted, #565973); }
.ai-intel-thinking-lines { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 9px; }
.ai-intel-dialog-scroll > .ai-intel-thinking { display: flex; flex-direction: column; gap: 10px; padding: 20px; }

.ai-intel-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-bottom: 14px; font-size: 12px; color: var(--rp-muted, #565973); }
.ai-intel-meta > span { display: inline-flex; align-items: center; gap: 6px; }
.ai-intel-meta-tools { margin-left: auto; gap: 4px !important; }
.ai-intel-limit { margin-bottom: 12px; }
.ai-intel-error { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; color: var(--rp-negative, #DC2626); }
.ai-intel-empty { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-radius: 14px; background: var(--rp-tile, #F6F7FD); font-size: 13px; color: var(--rp-muted, #565973); }
.ai-intel-empty > .tx-glyph, .ai-intel-empty > i { flex: 0 0 auto; font-size: 15px; color: var(--rp-text, #0B0F19); opacity: .7; }

/* All Access card (Free viewers): neutral, gold only on the crown and the button. */
.ai-intel-locked { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 14px; background: var(--rp-tile, #F6F7FD); }
.ai-intel-locked strong { display: block; font-size: 14px; }
.ai-intel-locked p { margin: 2px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--rp-muted, #565973); }
.ai-intel-locked-crown { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: var(--rp-gold-soft, #FEF3C7); color: var(--rp-gold, #B7791F); }
.ai-intel-unlock {
    display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border: 0; border-radius: 12px; cursor: pointer;
    background: var(--rp-gold-grad, linear-gradient(135deg, #F6C453 0%, #E59E2D 55%, #C27A1A 100%)); color: #FFFFFF; font: inherit; font-size: 13px; font-weight: 600;
}
@media (max-width: 640px) {
    .ai-intel-head { grid-template-columns: auto minmax(0, 1fr); }
    .ai-intel-actions { grid-column: 1 / -1; justify-content: flex-start; }
    .ai-intel-locked { grid-template-columns: auto minmax(0, 1fr); }
    .ai-intel-locked .ai-intel-unlock { grid-column: 1 / -1; justify-self: start; }
}

/* ---- History: search, chips, rows with Pin and Delete --------------------------------------------------------------- */
.ai-hist-tools { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.ai-hist-search { position: relative; max-width: 460px; }
.ai-hist-search-glyph { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--rp-muted, #565973); pointer-events: none; }
.ai-hist-search-input { width: 100%; padding-left: 34px !important; }
.ai-hist-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ai-hist-sep { width: 1px; height: 18px; margin: 0 4px; background: var(--rp-card-border, #DCDFF8); }
.ai-hist-chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border: 1px solid var(--rp-tile-border, #E5E7F5); border-radius: 999px;
    background: var(--rp-tile, #F6F7FD); color: var(--rp-muted, #565973); font: inherit; font-size: 12px; font-weight: 500; cursor: pointer;
    transition: background .15s ease, color .15s ease;
}
.ai-hist-chip:hover { color: var(--rp-text, #0B0F19); }
.ai-hist-chip.is-on {
    border-color: transparent; color: var(--rp-text, #0B0F19);
    background: linear-gradient(180deg, color-mix(in srgb, var(--rp-text, #0B0F19) 12%, transparent), color-mix(in srgb, var(--rp-text, #0B0F19) 5%, transparent));
}
.ai-hist-count { font-size: 11px; font-weight: 600; opacity: .7; }

.ai-hist-list { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.ai-hist-list.is-stale { opacity: .6; transition: opacity .2s ease; }
.ai-hist-skel { display: flex; flex-direction: column; gap: 8px; padding: 14px; border-radius: 14px; background: var(--rp-tile, #F6F7FD); }
.ai-hist-item { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ai-hist-row {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; flex: 1 1 auto; min-width: 0;
    padding: 12px 14px; border: 1px solid var(--rp-tile-border, #E5E7F5); border-radius: 14px; background: var(--rp-tile, #F6F7FD);
    color: inherit; font: inherit; text-align: left; cursor: pointer; transition: background .15s ease;
}
.ai-hist-row:hover { background: color-mix(in srgb, var(--rp-text, #0B0F19) 4%, var(--rp-tile, #F6F7FD)); }
.ai-hist-row:focus-visible { outline: 2px solid var(--ci-ai-ring, #7C3AED); outline-offset: 2px; }
.ai-hist-item.is-pinned .ai-hist-row { background: linear-gradient(180deg, color-mix(in srgb, var(--rp-text, #0B0F19) 6%, var(--rp-tile, #F6F7FD)), var(--rp-tile, #F6F7FD)); }
.ai-hist-depth { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--rp-card, #FFFFFF); color: var(--rp-text, #0B0F19); font-size: 13px; }
.ai-hist-depth.is-deep { background: var(--ci-ai-grad); color: #FFFFFF; }
.ai-hist-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ai-hist-headline { font-size: 13.5px; font-weight: 600; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ai-hist-summary { font-size: 12.5px; line-height: 1.45; color: var(--rp-muted, #565973); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ai-hist-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11.5px; color: var(--rp-light, #9397AD); }
.ai-hist-meta > span { display: inline-flex; align-items: center; gap: 5px; }
.ai-hist-pinmark { font-size: 12px; color: var(--rp-text, #0B0F19); opacity: .7; }

/* The small neutral icon buttons: Pin, Delete, Helpful, Refresh (history rows, the viewer, the briefing's meta). */
.ai-hist-actions { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 4px; }
.ai-hist-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 32px; height: 32px; padding: 0 9px;
    border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--rp-muted, #565973);
    font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; transition: background .15s ease, color .15s ease;
}
.ai-hist-btn:hover:not(:disabled) { background: color-mix(in srgb, var(--rp-text, #0B0F19) 7%, transparent); color: var(--rp-text, #0B0F19); }
.ai-hist-btn:disabled { opacity: .45; cursor: default; }
.ai-hist-btn:focus-visible { outline: 2px solid var(--ci-ai-ring, #7C3AED); outline-offset: 1px; }
.ai-hist-btn.is-on { color: var(--rp-text, #0B0F19); background: linear-gradient(180deg, color-mix(in srgb, var(--rp-text, #0B0F19) 12%, transparent), color-mix(in srgb, var(--rp-text, #0B0F19) 5%, transparent)); }
.ai-hist-btn.is-danger:hover:not(:disabled) { color: var(--rp-negative, #DC2626); background: color-mix(in srgb, var(--rp-negative, #DC2626) 10%, transparent); }
.ai-hist-btn.is-confirm { color: var(--rp-negative, #DC2626); background: color-mix(in srgb, var(--rp-negative, #DC2626) 12%, transparent); }
.ai-hist-actions .ai-hist-btn:not(.is-on):not(.is-confirm) { opacity: .55; }
.ai-hist-item:hover .ai-hist-actions .ai-hist-btn, .ai-hist-actions .ai-hist-btn:focus-visible,
.rp-bh-item:hover .ai-hist-actions .ai-hist-btn { opacity: 1; }

.ai-hist-pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; font-size: 12px; color: var(--rp-muted, #565973); }
.ai-hist-pages { display: inline-flex; gap: 4px; }

/* Reports > Intelligence > Your briefings: Pin and Delete sit beside each row. */
.rp-bh-item:has(> .ai-hist-actions) { display: flex; align-items: center; gap: 8px; }
.rp-bh-item > .rp-bh-row { flex: 1 1 auto; min-width: 0; }
.ai-hist-delete:hover:not(:disabled), .ai-hist-delete.is-confirm { color: var(--rp-negative, #DC2626); }

/* The Credit Briefing card's way to Liabilities > Intelligence (all briefings, history). */
.lb-cb-launch .lb-cb-intel-link { margin-top: 10px; align-self: flex-end; }

/* The viewer. */
.ai-intel-dialog .ai-intel-dialog-head .rc-dialog-actions { gap: 4px; }
.ai-intel-dialog-scroll { padding: 18px 22px 24px; }
.ai-intel-dialog .ai-intel { gap: 0; }

/* The briefing in the Investments area (2026-11-19): the shared briefing view (lb-cb-*) was drawn in the Credit
   Journey's rose, so a plain value chart, every section, tile and subhead icon and the numbered actions read red on
   Investments without anything being wrong. Every hue the view takes from the Liabilities tokens is restated here in
   the Investments green, and good news reads green (the paid-off steel is for debt). Red and amber stay only where the
   server or the briefing marks something negative or caution, so red on this page always means a real problem. The
   --iv-* tokens sit on :root and the dark theme, so one rule serves both themes and the body-appended viewer. */
.ai-intel-investments {
    --lb-rose: var(--iv-green);
    --lb-rose-strong: var(--iv-green-strong);
    --lb-rose-soft: var(--iv-green-soft);
    --lb-icon: var(--iv-icon);
    --lb-icon-bg: var(--iv-icon-bg);
    --lb-positive: var(--iv-positive);
    --lb-positive-soft: var(--iv-positive-soft);
    --lb-negative: var(--iv-negative);
    --lb-negative-soft: var(--iv-negative-soft);
    --lb-caution: var(--iv-caution);
    --lb-caution-soft: var(--iv-caution-soft);
    --lb-track: var(--iv-track);
    /* The donut slices (asset mix, sectors) are categories, not severities: greens, blues, slate and teal, never the
       amber or red that mean caution and a problem. Same six, same order as the mobile sheet (AiBriefingHue.Investments). */
    --lb-cb-c0: #16A34A;
    --lb-cb-c1: #4AA8F0;
    --lb-cb-c2: #475569;
    --lb-cb-c3: #0D9488;
    --lb-cb-c4: #0EA5E9;
    --lb-cb-c5: #0B6E4F;
    --lb-cb-panel: #F6FBF7;
}
[data-bs-theme="dark"] .ai-intel-investments {
    --lb-cb-c0: #34D399;
    --lb-cb-c1: #7CC4FA;
    --lb-cb-c2: #CBD5E1;
    --lb-cb-c3: #2DD4BF;
    --lb-cb-c4: #38BDF8;
    --lb-cb-c5: #2EAD78;
    --lb-cb-panel: rgba(52, 211, 153, .06);
}


/* Investments briefing bars (2026-11-19): the value/positive greens read loud on the bars. Dark takes a deeper,
   quieter forest green; light takes a softer, lighter sage-green. Only the bar and column fills change: icons, tiles
   and good-news text keep the area green. */
.ai-intel-investments { --iv-cb-bar-green: #4FA97A; }
[data-bs-theme="dark"] .ai-intel-investments { --iv-cb-bar-green: #237A55; }
.ai-intel-investments .lb-cb-bar-fill.lb-cb-fill-positive,
.ai-intel-investments .lb-cb-bar-fill.lb-cb-fill-accent,
.ai-intel-investments .lb-cb-column-bar.lb-cb-fill-positive,
.ai-intel-investments .lb-cb-column-bar.lb-cb-fill-accent { background: var(--iv-cb-bar-green); }

@media (max-width: 640px) {
    .ai-hist-item { flex-direction: column; align-items: stretch; }
    .ai-hist-actions { justify-content: flex-end; }
    .ai-hist-actions .ai-hist-btn { opacity: 1; }
    .rp-bh-item:has(> .ai-hist-actions) { flex-direction: column; align-items: stretch; }
}
