/* Data requests (2026-10-25), /agents/data: the tables to pick, the view's drawing, its rows.
   The page's two columns are the planner's (.planner-layout in planner-module.css). Colours
   come from the shell's --shell-* tokens, so light, dark and the accent follow by construction. */

.data-picker {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.data-picker-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 14rem;
    overflow-y: auto;
    padding: 4px 0;
}

.data-picker-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 2px 10px;
    border: 1px solid var(--shell-border);
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.9em;
}

.data-picker-on {
    border-color: var(--shell-accent);
    color: var(--shell-accent);
}

.data-picked { margin: 0; font-size: 0.9em; }

.data-view-title { flex: 1 1 auto; }

.data-name {
    font-family: var(--shell-font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
    font-size: 0.85em;
}

.data-description { white-space: pre-wrap; }

.data-subtitle {
    margin: 16px 0 6px;
    font-size: 0.95em;
}

/* The drawing scrolls sideways on a narrow screen rather than shrinking its text. */
.data-diagram {
    margin-top: 12px;
    overflow-x: auto;
    max-width: 100%;
}

.data-diagram svg { display: block; }

.data-box {
    fill: var(--shell-surface);
    stroke: var(--shell-border);
    stroke-width: 1;
}

.data-box-head {
    fill: var(--shell-surface-muted);
    stroke: var(--shell-border);
    stroke-width: 1;
}

.data-box-name {
    fill: var(--shell-content);
    font-size: 13px;
    font-weight: 600;
}

.data-box-column {
    fill: var(--shell-content-secondary);
    font-size: 12px;
}

.data-join {
    stroke: var(--shell-accent);
    stroke-width: 1.5;
}

.data-join-left { stroke-dasharray: 6 4; }
.data-join-exists { stroke-dasharray: 2 4; }
.data-join-not-exists { stroke: var(--shell-danger); stroke-dasharray: 2 4; }

.data-join-label {
    fill: var(--shell-content);
    font-size: 11px;
    paint-order: stroke;
    stroke: var(--shell-surface);
    stroke-width: 4px;
}

.data-rows {
    overflow-x: auto;
    max-width: 100%;
    border: 1px solid var(--shell-border);
    border-radius: 6px;
}

.data-rows table {
    border-collapse: collapse;
    font-size: 0.85em;
    width: max-content;
    min-width: 100%;
}

.data-rows th,
.data-rows td {
    padding: 4px 8px;
    border-bottom: 1px solid var(--shell-border);
    text-align: left;
    white-space: nowrap;
}

.data-rows th {
    background: var(--shell-surface-muted);
    font-weight: 600;
}

.data-null { color: var(--shell-content-secondary); font-style: italic; }

.data-sql { margin-top: 12px; }

.data-sql summary {
    cursor: pointer;
    color: var(--shell-accent);
}

.data-sql pre {
    margin: 8px 0 0;
    padding: 8px 12px;
    border-radius: 6px;
    background: var(--shell-surface-muted);
    white-space: pre-wrap;
    font-size: 0.85em;
}

/* An elaboration's fields, in the new elaboration's dialog and on its Request tab (2026-10-25). */
.data-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.data-task-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    margin-bottom: 0.75rem;
}

/* An elaboration the person and the model are working on: nothing proposed yet. */
.data-status-progress {
    color: var(--shell-warning-fg);
    border-color: var(--shell-warning-fg);
}

/* The list of elaborations: one table per area, the same columns in each. */
.data-elaborations { table-layout: fixed; }
.data-elaborations-state { width: 9rem; }
.data-elaborations-percent { width: 5rem; }
.data-elaborations-cost { width: 6rem; }
.data-elaborations-action { width: 2.5rem; }

/* On a phone the title keeps its room: the percentage goes (the state says enough), the rest narrows. */
@media (max-width: 600px) {
    .data-elaborations-state { width: 6.5rem; }
    .data-elaborations-percent { width: 0; }
    .data-elaborations-percent-cell { visibility: hidden; padding: 0 !important; overflow: hidden; }
    .data-elaborations-cost { width: 4.5rem; }
}
.data-elaborations-number { text-align: right; }

/* The list's heading, with what the project's elaborations cost so far beside it. */
.data-elaborations-head { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; }

/* AI Reports Settings: the connections' list, their actions, the check boxes of the popup. */
.reports-list td { vertical-align: top; }
.reports-actions { white-space: nowrap; text-align: right; width: 12rem; }
.reports-check { display: flex; align-items: center; gap: 0.5rem; }
.reports-sources { margin: 0.25rem 0 0; padding-left: 1.25rem; }
.reports-sources li { margin: 0.25rem 0; }

/* The fields of the chosen tables (Data source tab, 2026-10-26): one folding block per table. */
.data-fields-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 16px;
}

.data-fields-head .data-subtitle { margin: 0; }

.data-fields-filter { width: 16rem; max-width: 100%; }

.data-fields {
    margin-top: 8px;
    border: 1px solid var(--shell-border);
    border-radius: 8px;
    background: var(--shell-surface);
}

.data-fields > summary {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    background: var(--shell-surface-muted);
    border-radius: 8px;
}

.data-fields[open] > summary {
    border-bottom: 1px solid var(--shell-border);
    border-radius: 8px 8px 0 0;
}

.data-fields > p { margin: 8px 12px; }

.data-fields-scroll { overflow-x: auto; }

.data-fields-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.data-fields-table th,
.data-fields-table td {
    padding: 4px 12px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--shell-border);
}

.data-fields-table tbody tr:last-child td { border-bottom: none; }

.data-fields-table th {
    font-weight: 600;
    white-space: nowrap;
}

.data-fields-action {
    text-align: right;
    white-space: nowrap;
    width: 1%;
}

.data-field-key { margin-left: 6px; }

.data-field-relation {
    font-size: 0.85em;
    overflow-wrap: anywhere;
}

/* On a phone the four columns fit without sliding: tighter cells, headings that wrap. */
@media (max-width: 600px) {
    .data-fields-table th,
    .data-fields-table td { padding: 4px 6px; }

    .data-fields-table th { white-space: normal; }

    .data-fields-table td:first-child .data-name { word-break: break-word; }

    .data-fields-table td.data-name { white-space: nowrap; }
}

/* The Data source tab (2026-10-27): only the chosen tables, each with its remove; the choice in a popup. */
.data-sources-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.data-sources-head p { margin: 0; }

.data-sources-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 12px;
    padding: 0;
    list-style: none;
}

.data-sources-list .data-picker-item { cursor: default; padding-right: 4px; }

.data-sources-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.data-sources-remove:hover,
.data-sources-remove:focus-visible { background: var(--shell-surface-muted); }

/* In the popup the list scrolls inside it, so the footer stays in reach on a phone. */
.data-sources-popup { max-height: min(50vh, 24rem); }

.data-sources-count { margin: 0; }
