/*
 * Inquiry Tree styles.
 *
 * Classes:
 *   details.inquiry-step    Level 1 message step
 *   details.inquiry-child   Level 2 child (toSummary sub-item)
 */


/* ── History page wrapper ── */

.inquiry-page {
    font-family: var(--app-font-primary, "Geist", sans-serif);
    color: var(--app-text-primary, rgba(17, 24, 39, 0.87));
    font-size: 16px;
    line-height: 24px;
    max-width: 1800px;
}

.inquiry-page h1 {
    font-size: 20px;
    font-weight: 600;
    line-height: 28px;
    margin: 0 0 16px 0;
}

.inquiry-page h2 {
    font-size: 16px;
    font-weight: 600;
    line-height: 24px;
    margin: 0 0 12px 0;
}


/* ── Level 1: message steps ── */

details.inquiry-step {
    border: 1px solid var(--app-stroke-primary, hsla(0, 0%, 40%, 0.15));
    border-radius: 6px;
    margin-bottom: 6px;
    background: var(--app-bg-primary, #fff);
    overflow: hidden;
}

details.inquiry-step > summary {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    cursor: pointer;
    background: var(--app-bg-secondary, #f9f9f9);
    list-style: none;
    transition: background 0.15s;
}

details.inquiry-step > summary::-webkit-details-marker {
    display: none;
}

details.inquiry-step > summary::before {
    content: "\25B6";
    font-size: 10px;
    color: var(--app-text-secondary, #878787);
    margin-right: 10px;
    transition: transform 0.2s;
    display: inline-block;
}

details.inquiry-step[open] > summary::before {
    transform: rotate(90deg);
}

details.inquiry-step > summary:hover {
    background: var(--app-color-border-light, #e9ecef);
}

details.inquiry-step > summary {
    font-size: 16px;
}

details.inquiry-step > summary b {
    font-weight: 600;
    color: var(--app-text-primary, #2d3748);
}

/* Indent all content inside a step (everything except the summary) */
details.inquiry-step > :not(summary) {
    margin-left: 20px;
}

details.inquiry-step > p,
details.inquiry-step > pre {
    padding: 4px 16px;
    margin-top: 0;
    margin-bottom: 0;
    font-size: 16px;
    line-height: 1.5;
    color: var(--app-text-primary, #4a5568);
    word-break: break-word;
}

details.inquiry-step > pre {
    white-space: pre-wrap;
}


/* ── Level 2: a spawned inquiry rendered inside the message that caused it ──
 * It has no header of its own — the spawn's tag is on the owner's summary line —
 * so the indent is what shows the steps belong to that call. */

.inquiry-nested {
    margin: 4px 0 4px 16px;
}

/* ── Level 2: children (toSummary sub-items) ── */

details.inquiry-child {
    margin: 0;
}

/* A step demoted to child level — the live view nests a spawn by reusing the
 * element already rendered for it, and that summary carries a <b>. Match the
 * weight of the sibling panes it now sits among. */
details.inquiry-child > summary b {
    font-weight: normal;
}

details.inquiry-child > summary {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 4px 16px;
    font-size: 16px;
    color: var(--app-text-primary, #4a5568);
    list-style: none;
}

details.inquiry-child > summary::-webkit-details-marker {
    display: none;
}

details.inquiry-child > summary::before {
    content: "\25B6";
    font-size: 10px;
    color: var(--app-text-secondary, #878787);
    margin-right: 8px;
    transition: transform 0.2s;
    display: inline-block;
}

details.inquiry-child[open] > summary::before {
    transform: rotate(90deg);
}

details.inquiry-child > p,
details.inquiry-child > pre {
    padding: 2px 16px 2px 36px;
    margin: 0;
    font-size: 16px;
    line-height: 1.5;
    color: var(--app-text-primary, #4a5568);
    word-break: break-word;
}

details.inquiry-child > pre {
    white-space: pre-wrap;
}


/* ── Search result entries (ul.wrap from SearchResultSnippet) ── */

details.inquiry-step ul.wrap {
    color: var(--app-text-primary, #4a5568);
    font-size: 16px;
}

details.inquiry-step ul.wrap li {
    color: var(--app-text-primary, #4a5568);
}

details.inquiry-step ul.wrap a {
    color: var(--app-color-primary, #0066cc);
}


/* ── Chat ask box ── */

.chat-ask {
    margin-top: 24px;
}

.chat-ask form {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--app-bg-secondary, #f9f9f9);
    border: 1px solid rgba(20, 27, 155, 0.2);
    border-radius: 8px;
    padding: 4px 6px 4px 12px;
    transition: border-color 0.15s;
}

.chat-ask form:focus-within {
    border-color: rgba(20, 27, 155, 0.4);
}

.dlg-page .chat-ask input.field,
.chat-ask input.field {
    flex: 1;
    width: 0;
    min-width: 0;
    max-width: none;
    border: none;
    outline: none;
    background: transparent;
    font-family: var(--app-font-primary, "Geist", sans-serif);
    font-size: 16px;
    line-height: 22px;
    color: var(--app-action-primary, #212121);
    padding: 9px 0;
    border-radius: 0;
}

.dlg-page .chat-ask input.field:hover,
.dlg-page .chat-ask input.field:focus,
.chat-ask input.field:hover,
.chat-ask input.field:focus {
    border: none;
    outline: none;
}

.chat-ask input.field::placeholder {
    color: var(--app-text-placeholder, rgba(17, 24, 39, 0.35));
}

.dlg-page .chat-ask input.submit,
.chat-ask input.submit {
    flex-shrink: 0;
    background: rgba(20, 27, 155, 0.87);
    color: var(--app-text-white, #f5f5f5);
    border: none;
    border-radius: 6px;
    padding: 9px 16px;
    font-family: var(--app-font-primary, "Geist", sans-serif);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.dlg-page .chat-ask input.submit:hover,
.chat-ask input.submit:hover {
    background: rgba(20, 27, 155, 1);
    border: none;
}


/* ── Chat usage stats ── */

.chat-stats {
    background: var(--app-bg-secondary, #f9f9f9);
    border: 1px solid var(--app-stroke-primary, hsla(0, 0%, 40%, 0.15));
    border-radius: 8px;
    padding: 16px 20px;
    margin-top: 24px;
}

.chat-stats h2 {
    font-size: 16px;
    font-weight: 600;
    line-height: 24px;
    margin: 0 0 8px 0;
    color: var(--app-text-primary, rgba(17, 24, 39, 0.87));
}

.chat-stat {
    padding: 2px 0;
}

.chat-stat-label {
    font-size: 14px;
    color: var(--app-text-secondary, #6c757d);
}

.chat-stat-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--app-text-primary, rgba(17, 24, 39, 0.87));
    margin-left: 8px;
}


/* ── Eval: Test Results page ── */

.eval-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.eval-subtitle {
    font-size: 14px;
    color: var(--app-text-secondary, #6c757d);
    margin-top: 4px;
}

/* Empty state shown on the Test Results page when there are no runs yet. */
.eval-empty {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}
.eval-empty p {
    margin: 0;
    font-size: 14px;
    color: var(--app-text-secondary, #6c757d);
}
.eval-empty a {
    font-size: 14px;
    color: var(--app-brand-color, #141b9b);
    text-decoration: none;
}
.eval-empty a:hover {
    text-decoration: underline;
}

.eval-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* Scoped to .inquiry-page so it doesn't collide with the unrelated
   .eval-btn rules in eval-page.css (Setup & Run page). */
.inquiry-page .eval-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    border: 1px solid var(--app-stroke-primary, hsla(0, 0%, 40%, 0.15));
    border-radius: 8px;
    background: var(--app-bg-primary, #fff);
    color: var(--app-text-primary, rgba(17, 24, 39, 0.87));
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: border-color 0.15s;
}

.inquiry-page .eval-btn:hover {
    border-color: var(--app-action-hover, #141b9b);
}

/* Test Summary card: grey panel wrapping the summary, metrics and runs tables */
.eval-summary-card {
    background: var(--app-bg-secondary, #f9f9f9);
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 24px;
}

.eval-summary-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.eval-summary-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--app-text-primary, rgba(17, 24, 39, 0.87));
}

.eval-summary-filter {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}

/* Summary row: three side-by-side boxes inside the Test Summary card */
.eval-summary-row {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

/* The three summary columns share the row width equally */
.eval-summary-row > .eval-col,
.eval-summary-row > .eval-box {
    flex: 1;
    min-width: 0;
}

/* Each table sits in its own bordered, rounded box on the grey card.
   overflow:hidden clips the striped rows to the rounded corners. */
.eval-box {
    border: 1px solid var(--app-stroke-primary, hsla(0, 0%, 40%, 0.15));
    border-radius: 8px;
    overflow: hidden;
}

/* Chat id caption under the first column's box */
.eval-summary-chat-id {
    margin-top: 8px;
    font-size: 13px;
    color: var(--app-text-secondary, #6c757d);
}

/* Alternating row striping; even rows show the card's grey through */
.eval-summary-card table tbody tr:nth-child(odd) {
    background: var(--app-bg-primary, #ffffff);
}

/* Key-value table in summary box */
table.eval-kv {
    border-collapse: collapse;
    font-size: 14px;
    width: 100%;
}

table.eval-kv td {
    padding: 8px 12px;
    color: var(--app-text-primary, rgba(17, 24, 39, 0.87));
}

table.eval-kv td:first-child {
    font-weight: 500;
    color: var(--app-text-secondary, #6c757d);
    white-space: nowrap;
}

/* Metrics table */
table.eval-metrics {
    border-collapse: collapse;
    font-size: 14px;
    width: 100%;
}

table.eval-metrics th,
table.eval-metrics td {
    padding: 8px 12px;
    text-align: left;
}

table.eval-metrics thead th {
    font-weight: 600;
    color: var(--app-text-primary, rgba(17, 24, 39, 0.87));
}

table.eval-metrics tbody td {
    color: var(--app-text-primary, rgba(17, 24, 39, 0.87));
}

table.eval-metrics tbody td:first-child {
    font-weight: 500;
}

/* Modified settings */
.eval-settings {
    margin-bottom: 24px;
}

.eval-settings ul {
    margin: 8px 0 0;
    padding-left: 20px;
    font-size: 14px;
    color: var(--app-text-secondary, #6c757d);
}

/* Per-inquiry test case.
 *
 * `contain: layout style` tells the browser that style/layout effects
 * inside one case can't escape into siblings — so toggling a `<details>`,
 * switching the search-results mode, or hovering a button only triggers
 * style recalc and reflow within this one case's subtree, not across all
 * ~9 cases / ~20,000 elements on the page. No visual change, just lets
 * the engine scope its work tighter. */
.eval-case {
    margin-bottom: 16px;
    contain: layout style;
}

.eval-case-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
}

.eval-case-header h2 {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
}

.eval-case-actions {
    display: flex;
    gap: 16px;
    font-size: 14px;
    flex-shrink: 0;
}

.eval-case-actions a {
    color: var(--app-text-secondary, #6c757d);
    text-decoration: none;
}

.eval-case-actions a:hover {
    color: var(--app-text-primary, rgba(17, 24, 39, 0.87));
}

/* Two-column body. Each column stacks its sections vertically.
   On screens narrower than 1440 the columns collapse so the whole
   left column appears above the whole right column. */
.eval-case-body {
    display: flex;
    gap: 16px;
}

.eval-case-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Gray rounded box wrapping each of the four content sections. */
.eval-section {
    background: var(--app-bg-secondary, #f9f9f9);
    border-radius: 8px;
    padding: 16px 20px;
}

@media (max-width: 1399px) {
    .eval-case-body {
        flex-direction: column;
    }
    .eval-summary-row {
        flex-direction: column;
    }
}

.eval-field {
    margin-bottom: 12px;
}

.eval-field-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--app-text-secondary, #6c757d);
    margin-bottom: 4px;
}

.eval-field p {
    margin: 4px 0;
    font-size: 16px;
    color: var(--app-text-primary, rgba(17, 24, 39, 0.87));
}

/* All Test Runs table */
table.eval-runs {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

table.eval-runs th {
    text-align: left;
    font-weight: 600;
    padding: 8px 12px;
    color: var(--app-text-primary, rgba(17, 24, 39, 0.87));
}

table.eval-runs td {
    padding: 8px 12px;
    color: var(--app-text-primary, rgba(17, 24, 39, 0.87));
}

table.eval-runs a {
    color: var(--app-action-hover, #141b9b);
    text-decoration: none;
}

table.eval-runs a:hover {
    text-decoration: underline;
}

.eval-runs-collapsible:not(.eval-runs-expanded) .eval-runs-extra {
    display: none;
}

.eval-runs-toggle {
    display: inline-block;
    margin: 8px 0 16px 12px;
    font-family: var(--app-font-primary, "Geist", sans-serif);
    font-size: 14px;
    font-weight: normal;
    font-style: normal;
    color: var(--app-text-primary, rgba(17, 24, 39, 0.87));
    text-decoration: none;
    cursor: pointer;
}

.eval-runs-toggle:hover {
    text-decoration: underline;
}

/* Per-case Score column: each row is a single score+comment line.
   Sits inside .eval-field on the right side of an eval-case. */
.eval-score-row {
    margin: 6px 0;
    font-size: 14px;
    line-height: 1.4;
    color: var(--app-text-primary, rgba(17, 24, 39, 0.87));
}

/* Compact metric trio (Average Score / Time Spent / Cost) on the right side
   of an eval-case, sitting under the Score block. */
.eval-metric-trio {
    margin: 12px 0;
    border-top: 1px solid var(--app-stroke-primary, hsla(0, 0%, 40%, 0.15));
    border-bottom: 1px solid var(--app-stroke-primary, hsla(0, 0%, 40%, 0.15));
}

.eval-metric-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 8px 0;
    font-size: 14px;
}

.eval-metric-row + .eval-metric-row {
    border-top: 1px solid var(--app-color-border-light, #e9ecef);
}

.eval-metric-label {
    color: var(--app-text-secondary, #6c757d);
}

.eval-metric-value {
    color: var(--app-text-primary, rgba(17, 24, 39, 0.87));
    font-weight: 500;
}

/* Per-case Metrics Table (collapsible).
   Sits directly inside an .eval-section, so no outer border/background here. */
.eval-case-metrics-accordion > summary {
    list-style: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--app-text-secondary, #6c757d);
    user-select: none;
}

.eval-case-metrics-accordion[open] > summary {
    margin-bottom: 8px;
}

.eval-case-metrics-accordion > summary::-webkit-details-marker {
    display: none;
}

.eval-case-metrics-accordion > summary::after {
    content: "\25BE"; /* ▾ */
    float: right;
    color: var(--app-text-secondary, #6c757d);
}

.eval-case-metrics-accordion[open] > summary::after {
    content: "\25B4"; /* ▴ */
}

table.eval-case-metrics {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

table.eval-case-metrics th,
table.eval-case-metrics td {
    padding: 6px 12px;
    text-align: left;
}

table.eval-case-metrics thead th {
    font-weight: 600;
    color: var(--app-text-primary, rgba(17, 24, 39, 0.87));
    border-bottom: 1px solid var(--app-stroke-primary, hsla(0, 0%, 40%, 0.15));
}

table.eval-case-metrics tbody tr:nth-child(odd) td {
    background: var(--app-bg-secondary, #f9f9f9);
}

table.eval-case-metrics tbody td:first-child {
    font-weight: 500;
    color: var(--app-text-secondary, #6c757d);
}



/* Eval: search panel with mode switcher */
.eval-search-panel {
    font-size: 14px;
}

.eval-search-modes {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.eval-search-mode-label {
    font-weight: 600;
    color: var(--app-text-primary, rgba(17, 24, 39, 0.87));
    margin-right: 8px;
}

.eval-search-mode {
    padding: 4px 10px;
    border: 1px solid var(--app-stroke-primary, hsla(0, 0%, 40%, 0.15));
    border-radius: 6px;
    font-size: 13px;
    color: var(--app-text-secondary, #6c757d);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s;
}

.eval-search-mode:hover {
    border-color: var(--app-action-hover, #141b9b);
    color: var(--app-text-primary, rgba(17, 24, 39, 0.87));
}

.eval-search-panel[data-mode="Sources"] .eval-search-mode[data-mode="Sources"],
.eval-search-panel[data-mode="All"] .eval-search-mode[data-mode="All"],
.eval-search-panel[data-mode="Omitted"] .eval-search-mode[data-mode="Omitted"] {
    background: var(--app-action-hover, #141b9b);
    color: var(--app-text-white, #f5f5f5);
    border-color: var(--app-action-hover, #141b9b);
}

/* Mode-driven entry visibility: panel data-mode × entry data-is-source. */
.eval-search-panel[data-mode="Sources"] .eval-search-entry[data-is-source="false"],
.eval-search-panel[data-mode="Omitted"] .eval-search-entry[data-is-source="true"] {
    display: none;
}

/* Eval: search entry view link */
.eval-search-entry-actions {
    padding: 4px 16px;
}

/* Indent the expanded entry's field list so it sits under the summary
 * text instead of aligning with the disclosure triangle. Matches the
 * 36px content indent used by details.inquiry-child > p / > pre. */
.eval-search-entry > .dlg-result-entry {
    margin-left: 20px;
    margin-right: 16px;
}

.eval-search-entry-actions a {
    font-size: 14px;
    color: var(--app-action-hover, #141b9b);
    text-decoration: none;
}

.eval-search-entry-actions a:hover {
    text-decoration: underline;
}


/* ── JS tree container ── */

.inquiry-tree {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    color: var(--app-text-primary, #2d3748);
}


/* ── Modal wrapper ── */

.inquiry-tree-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--app-stroke-primary, hsla(0, 0%, 40%, 0.15));
}

.inquiry-tree-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.inquiry-tree-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--app-text-secondary, #878787);
    padding: 4px 8px;
}

.inquiry-tree-close:hover {
    color: var(--app-text-primary, #2d3748);
}

.inquiry-tree-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.inquiry-tree-modal {
    background: var(--app-bg-primary, #fff);
    border-radius: 8px;
    width: 90%;
    max-width: 1000px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.inquiry-tree-modal-body {
    padding: 16px 20px 20px;
}


/* ── Copy button (inside both inquiry-step and inquiry-child summaries) ── */

.inquiry-copy-btn {
    margin-left: auto;
    padding: 2px 8px;
    border: 1px solid var(--app-stroke-primary, hsla(0, 0%, 40%, 0.15));
    border-radius: 4px;
    background: var(--app-bg-primary, #fff);
    color: var(--app-text-secondary, #6c757d);
    font-family: inherit;
    font-size: 12px;
    line-height: 1.4;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, border-color 0.15s, background 0.15s;
}

details.inquiry-step > summary:hover .inquiry-copy-btn,
details.inquiry-child > summary:hover .inquiry-copy-btn,
.inquiry-copy-btn:focus,
.inquiry-copy-btn--ok {
    opacity: 1;
}

.inquiry-copy-btn:hover {
    border-color: var(--app-action-hover, #141b9b);
    color: var(--app-text-primary, rgba(17, 24, 39, 0.87));
}

.inquiry-copy-btn--ok {
    color: #2f855a;
    border-color: #c6f6d5;
    background: #f0fff4;
}
