/* ==========================================================================
   components/app-data-list.css — Label / value pairs
   --------------------------------------------------------------------------
   Read-only key–value display: summary blocks, totals, KPI rows, record
   detail panes. Not for editable fields — use layouts/app-form.css there.

   Markup contract:
     .app-data-list                     (stacked label above value)
     .app-data-list--inline             (label left, value right)
     .app-data-list--divided            (rule between rows)
     .app-data-list--stats              (rows side by side as summary figures)
       .app-data-list__row
         .app-data-list__label
         .app-data-list__value          (+ --num / --muted / --strong / --pos / --neg)
         .app-data-list__sub            (secondary line under the value, e.g. a count)
   ========================================================================== */

/* ========== CONTAINER ========== */

.app-data-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    margin: 0;
}

/* Body copy directly above a list needs separating. The `margin: 0` above defeats the
   app-mt--* utilities, which load earlier in the bundle, so the spacing lives here. */
p + .app-data-list {
    margin-top: var(--spacing-lg);
}

/* Same reason in reverse: a table straight after a list has no gap of its own and reads as one
   block with the rows above it. */
.app-data-list + .app-table {
    margin-top: var(--spacing-lg);
}

/* A record summary heading a dense dialog, where the value sitting a step above the label is too
   much next to 12px table cells. Levels the value with the label and keeps the weight difference. */
.app-data-list--compact .app-data-list__value {
    font-size: var(--font-body-sm-size);
    line-height: var(--font-body-sm-line-height);
}

/* ========== ROWS ========== */
/* Several callers render every field of a record and leave the ones with no data blank. A row whose
   values are all empty still contributes a flex gap, so the list reads as a band of whitespace —
   addevent's Information panel had 40px of it above its first heading, from a contact block with
   nothing in it. */
.app-data-list__row:not(:has(> :not(:empty))) {
    display: none;
}


.app-data-list__row {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    min-width: 0;
}

.app-data-list--inline .app-data-list__row {
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--spacing-lg);
}

/* Label in a fixed column with the value right after it, not pushed to the far edge — a short list of
   links (the trace dialogs), where space-between strands each link away from its label. Centred, since
   an icon + text link sits off the label's baseline. */
.app-data-list--aligned .app-data-list__row {
    display: grid;
    grid-template-columns: 12rem minmax(0, 1fr);
    align-items: center;
    column-gap: var(--spacing-lg);
}

.app-data-list--divided .app-data-list__row {
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--color-border-subtle);
}

.app-data-list--divided .app-data-list__row:last-child {
    padding-bottom: 0;
    border-bottom: none;
}

/* ========== LABEL ========== */

.app-data-list__label {
    font-size: var(--font-body-sm-size);
    font-weight: var(--font-weight-regular);
    line-height: var(--font-body-sm-line-height);
    color: var(--color-text-muted);
}

/* ========== VALUE ========== */

.app-data-list__value {
    font-size: var(--font-body-md-size);
    font-weight: var(--font-weight-medium);
    line-height: var(--font-body-md-line-height);
    color: var(--color-text-default);
    min-width: 0;
    overflow-wrap: anywhere;
}

/* Numeric — tabular figures, right aligned so decimal points line up */
.app-data-list__value--num {
    font-variant-numeric: tabular-nums;
    font-feature-settings: 'tnum';
    text-align: right;
    overflow-wrap: normal;
    white-space: nowrap;
}

.app-data-list__value--muted {
    color: var(--color-text-muted);
    font-weight: var(--font-weight-regular);
}

.app-data-list__value--strong {
    font-size: var(--font-body-lg-size);
    font-weight: var(--font-weight-semibold);
}

.app-data-list__value--pos {
    color: var(--color-success);
}

.app-data-list__value--neg {
    color: var(--color-error);
}

/* ========== STATS STRIP ========== */

/* Summary figures side by side: caption label, large number, optional secondary line (.app-data-list__sub). */
/* Every row carries its divider; pulling the list left and clipping hides the one on whichever row
   starts a line, so wrapped rows line up flush instead of only the first. */
/* A figure the page script updates through .value (kf/modal/modal_pay.htm totals): the read-only input reads as the value text. */
.app-data-list__value input[readonly] {
    border: 0;
    background: transparent;
    padding: 0;
    font: inherit;
    color: inherit;
    vertical-align: baseline;
}
/* The edit views' totals are size="12" inputs, which cut a large amount off; let the figure set the width. */
.app-data-list__value--num input[readonly] {
    field-sizing: content;
    min-width: 8ch;
}

.app-data-list--stats {
    flex-direction: row;
    flex-wrap: wrap;
    row-gap: var(--spacing-lg);
    padding: var(--spacing-md) 0;
    margin-left: calc(-1 * var(--spacing-2xl));
    overflow: hidden;
}

.app-data-list--stats .app-data-list__row {
    padding: 0 var(--spacing-2xl);
    margin-left: -1px;
    border-left: 1px solid var(--color-border-subtle);
}

.app-data-list--stats .app-data-list__label {
    font-size: var(--font-caption-md-size);
    font-weight: var(--font-weight-medium);
    line-height: var(--font-caption-md-line-height);
    letter-spacing: var(--font-caption-md-letter-spacing);
    text-transform: uppercase;
}

.app-data-list--stats .app-data-list__value {
    font-size: var(--font-display-sm-size);
    font-weight: var(--font-weight-semibold);
    line-height: var(--font-display-sm-line-height);
}

/* A figure starts under its caption, not at the far edge of a column the caption may be wider than. */
.app-data-list--stats .app-data-list__value--num {
    text-align: left;
}

.app-data-list__sub {
    margin: 0;
    font-size: var(--font-body-sm-size);
    line-height: var(--font-body-sm-line-height);
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
}

/* ========== TOTALS CLUSTER ========== */

/* Figure groups set side by side under an edit view's rows table: equal widths, an empty group takes no room.
   Rows sit on the --sm input rhythm (28px + 8px gap) so they line up with a column of inline fields beside them. */
.app-data-list--totals {
    min-width: 13rem;
    gap: var(--spacing-sm);
}

.app-data-list--totals .app-data-list__row {
    min-height: 28px;
    align-items: center;
}

.app-data-list--totals .app-data-list__row--total {
    padding-top: 0;
}

.app-data-list--totals:not(:has(.app-data-list__row)) {
    display: none;
}

/* A stats figure closing the cluster: its caption sits on the first totals row's line. */
.app-data-list--totals ~ .app-data-list--stats {
    padding-top: 0;
}

.app-data-list--totals ~ .app-data-list--stats .app-data-list__label {
    line-height: 28px;
}

/* ========== TOTAL ROW ========== */

/* Emphasised closing row — sums, balances, results */
.app-data-list__row--total {
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--color-border-default);
}

.app-data-list__row--total .app-data-list__label {
    color: var(--color-text-default);
    font-weight: var(--font-weight-semibold);
}

.app-data-list__row--total .app-data-list__value {
    font-weight: var(--font-weight-semibold);
}

/* ========== RESPONSIVE ========== */

@media (max-width: 640px) {
    .app-data-list--inline .app-data-list__row {
        flex-direction: column;
        gap: var(--spacing-xs);
    }

    .app-data-list--inline .app-data-list__value--num {
        text-align: left;
    }
}
