/* SPDX-FileCopyrightText: 2026 Dieter Bolz <dieter.bolz@t-online.de> */
/* SPDX-License-Identifier: AGPL-3.0-or-later */

/* mcp-ui components and charts in assistant answers (mcpui.js, result.js).
   Shared by the agent app (imported by styles.css) and the contextagent chat. */

.mcp-ui-text {
    margin-top: 6px;
}

.mcp-form {
    display: flex;
    flex-direction: column;
    gap: 1em;
    margin-top: 3em;
    padding: var(--box-padding);
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.mcp-form + .mcp-form {
    margin-top: 1em;
}

.mcp-form-title {
    font-size: 16px;
    overflow-wrap: anywhere;
}

/* Beats `.markdown h4` when the form renders inside a chat bubble. */
.mcp-form .mcp-form-title {
    margin: 0;
}

.mcp-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.8rem;
}

.mcp-field-inline {
    flex-direction: row;
    align-items: center;
}

.mcp-field-label {
    font-weight: 600;
}

.mcp-field input,
.mcp-field select {
    margin-top: 0;
}

.mcp-field input[type="checkbox"] {
    width: auto;
    min-height: 0;
}

.mcp-form-submit,
.mcp-button {
    width: auto;
    min-height: 40px;
    margin-top: 4px;
    align-self: flex-start;
    border-radius: 6px;
    padding: 0.2em 1em;
    line-height: 1;
    min-width: 200px;
    font-size: 0.8rem;
    letter-spacing: 0.01em;
    font-weight: 500;
}

.mcp-button {
    text-align: left;
    min-width: 0;
}

.mcp-link {
    display: inline-block;
    width: auto;
    box-sizing: border-box;
    min-height: 40px;
    margin-top: 4px;
    align-self: flex-start;
    border-radius: 6px;
    padding: 0 1em;
    line-height: 40px;
    min-width: 200px;
    font-size: 0.8rem;
    letter-spacing: 0.01em;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    background: var(--action);
    color: var(--text-inverse);
    cursor: pointer;
    transition: background-color 0.15s ease;
}

@media (hover: hover) {
    .mcp-link:hover {
        background: var(--brand);
        color: var(--text-inverse);
    }
}

.mcp-form-done {
    margin: 0;
    color: var(--success);
    font-size: 14px;
}

/* An action that refused to run: name the fields still to fill. */
.mcp-form-hint {
    margin: 4px 0 0;
    color: var(--danger, #b91c1c);
    font-size: 14px;
}

.mcp-form textarea,
.mcp-form input,
.mcp-form select {
    padding: 0.5em 0.75em;
    border-radius: 6px;
    background-color: var(--surface-page);
}

.mcp-box {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.mcp-box.is-horizontal {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
}

/* REQ-BE-77: Recherche-Karte je Objekt - Paket, Suchbegriffe, alle Treffer.
   Der Text im Verlauf nennt die besten fünf; der Rest ist nur hier klickbar. */
.mcp-research {
    margin-top: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-card);
}

.mcp-research-head {
    display: flex;
    gap: 10px;
    align-items: baseline;
    justify-content: space-between;
    padding: 8px 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

.mcp-research-count {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 400;
    white-space: nowrap;
}

.mcp-research-body {
    padding: 0 10px 10px;
    font-size: 14px;
}

.mcp-research-link {
    display: inline-block;
    margin-bottom: 4px;
    color: var(--brand);
    font-size: 12px;
    overflow-wrap: anywhere;
}

.mcp-research-terms,
.mcp-research-more,
.mcp-research-skipped {
    margin: 6px 0 0;
    color: var(--text-muted);
    font-size: 12px;
    overflow-wrap: anywhere;
}

.mcp-research-empty {
    margin: 6px 0 0;
}

.mcp-research-error {
    margin: 6px 0 0;
    color: var(--danger);
}

.mcp-research-hits {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 8px 0 0;
    padding: 0;
    list-style: none;
}

.mcp-research-hits.is-rest {
    opacity: 0.85;
}

.mcp-research-hit {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: baseline;
}

.mcp-research-key {
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

/* Denselben Baustein wie die Skill-Chips: kleines Etikett für die Quelle. */
.mcp-research-area {
    display: inline-flex;
    align-items: center;
    padding: 1px 7px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-page);
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.6;
}

.mcp-research-hit-title {
    flex: 1 1 200px;
    min-width: 0;
    color: var(--brand);
    overflow-wrap: anywhere;
}

.mcp-research-snippet {
    flex-basis: 100%;
    color: var(--text-muted);
    font-size: 12px;
    overflow-wrap: anywhere;
}

.chart {
    margin-top: 10px;
    padding: var(--box-padding);
    background: var(--surface-card);
    border-radius: 8px;
    width: 100%;
    border: 1px solid var(--border-subtle);
}

.chart-title {
    font-weight: 600;
    margin-bottom: 1em;
}

.chart-row {
    display: flex;
    align-items: center;
    font-size: 0.8rem;
}

/* Label and value stretch to the row height so their borders form continuous
   lines; equal vertical padding keeps the text centred on the bar. */
.chart-label {
    flex: 0 0 40%;
    align-self: stretch;
    padding: 0.5em 0.75em 0.5em 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border-right: 1px solid var(--border);
}

.chart-track {
    flex: 1;
    background: var(--surface-subtle);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    height: 1.4em;
    overflow: hidden;
    margin-bottom: 0.5em;
    margin-top: 0.5em;
}

.chart-bar {
    display: block;
    height: 100%;
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
    background: var(--brand);
}

.chart-value {
    flex: 0 0 auto;
    min-width: 52px;
    align-self: stretch;
    padding: 0.5em 0 0.5em 0.75em;
    text-align: right;
    color: var(--text-muted);
    border-left: 1px solid var(--border);
}

.chart-pie-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    margin-top: 0.5rem;
}

@media (min-width: 480px) {
    .chart-pie-wrapper {
        flex-direction: row;
        justify-content: space-around;
        align-items: center;
    }
}

.chart-pie {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    position: relative;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
}

.chart-pie.is-donut::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70px;
    height: 70px;
    background: var(--surface-card);
    border-radius: 50%;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chart-legend {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    width: 100%;
    font-size: 0.85rem;
}

.chart-legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.2rem 0;
}

.chart-legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

.chart-legend-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}

.chart-legend-pct {
    font-weight: 600;
    color: var(--text);
}

.chart-legend-value {
    color: var(--text-muted);
    font-size: 0.75rem;
}
