/* Compact list rows, same visual language as the address TreeView (Endereçamento): one line per item,
   fixed-width code chip, bold title with ellipsis and short chips. Reused by list panels of the cadastro screens. */
.compact-list {
    margin-top: 12px;
    max-height: 620px;
    overflow-y: auto;
    overflow-x: hidden;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
    margin-left: -6px;
    margin-right: -6px;
    padding: 0 6px
}

.compact-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-width: 0;
    padding: 7px 6px;
    border: 0;
    border-radius: var(--radius);
    background: none;
    text-align: left;
    color: var(--text-2);
    cursor: pointer
}

.compact-row:hover:not(:disabled) {
    background: var(--hover)
}

.compact-row:disabled {
    cursor: default
}

/* Selected row: tinted background and a chevron icon at the end (no colored bar on the side). */
.compact-row.selected {
    background: var(--primary-faint)
}

.compact-row.selected::after {
    content: "";
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    margin-left: 2px;
    background: var(--blue);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 18 6-6-6-6'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 18 6-6-6-6'/%3E%3C/svg%3E") center / contain no-repeat
}

.compact-row.inactive .compact-title {
    color: var(--text-faint)
}

.compact-row.is-locked {
    cursor: default
}

/* Wide enough for 9 characters, so 1-8 and 1002-5 get the same chip size. */
.compact-code {
    flex-shrink: 0;
    width: calc(9ch + 12px);
    box-sizing: border-box;
    padding: 3px 6px;
    border-radius: var(--radius-sm);
    text-align: center;
    font: 700 9px 'Manrope', sans-serif;
    font-variant-numeric: tabular-nums;
    letter-spacing: .2px;
    background: var(--accent-soft);
    color: var(--accent-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
}

/* Label variant (J8 validation r1, B7; the queues and decisions of the box checks): the code is the label of a box (CX-000000-0, 11 characters or more), shown whole, never cut by the ellipsis of the chip. */
.compact-code.is-label {
    width: auto;
    padding: 3px 8px;
    overflow: visible;
    text-overflow: clip
}

/* Initials variant (Usuários): two letters, blue; Admin profile in purple. */
.compact-code.is-initials {
    width: 30px;
    padding: 3px 0;
    background: var(--primary-faint);
    color: var(--primary-text)
}

.compact-code.is-admin {
    background: var(--purple-soft);
    color: var(--purple-text)
}

.compact-title {
    flex: 1;
    min-width: 0;
    font-size: 11px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap
}

.compact-chip {
    flex-shrink: 0;
    padding: 3px 6px;
    border-radius: var(--radius-sm);
    font-size: 8px;
    letter-spacing: .3px;
    text-transform: uppercase;
    white-space: nowrap;
    background: var(--chip-bg);
    color: var(--chip-text)
}

.compact-chip.is-plain {
    text-transform: none;
    letter-spacing: 0;
    background: var(--chip-neutral-bg);
    color: var(--chip-neutral-text)
}

.compact-chip.is-count {
    display: inline-flex;
    align-items: center;
    gap: 3px
}

.compact-status {
    flex-shrink: 0;
    padding: 3px 6px;
    border-radius: var(--radius-sm);
    font-size: 8px;
    white-space: nowrap;
    background: var(--success-soft);
    color: var(--success-text)
}

.compact-status.is-inactive {
    background: var(--surface-2);
    color: var(--text-muted)
}

/* Tree variant (Produtos): toggle + row, children indented with the dashed guide used by Endereçamento. */
.compact-node {
    display: flex;
    align-items: center;
    gap: 2px;
    min-width: 0
}

.compact-node .compact-row {
    width: auto;
    flex: 1
}

.compact-toggle {
    border: 0;
    background: none;
    color: var(--text-muted);
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    cursor: pointer
}

.compact-toggle:hover:not(:disabled) {
    background: var(--hover);
    color: var(--blue)
}

.compact-children {
    margin-left: 12px;
    padding-left: 18px;
    border-left: 1px dashed var(--border);
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 2px
}

.compact-list>* {
    min-width: 0
}

.compact-group {
    display: flex;
    align-items: center;
    gap: 5px;
    margin: 8px 0 2px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .3px;
    text-transform: uppercase;
    color: var(--primary-text)
}

.compact-empty {
    font-size: 9px;
    color: var(--text-faint);
    margin: 6px 0
}

/* Two-line list row (wms-ui "Linha de lista em duas linhas", user decision 2026-10-08; first use: divergences of Devoluções ao fornecedor). A fixed
   grid so every row lines up whatever the length of the description: the selection box (optional) and the code balloon span both lines, centered
   on the vertical; line 1 = title (+ <small> second text), breaking its own text, never ellipsis; line 2 = .compact-meta, under the title: the chips
   from the left and the status at the right end. Markup: <label|button class="compact-row is-two-line"> [<input>] <span class="compact-code">
   <span class="compact-title">…<small>…</small></span> <span class="compact-meta"><chips…><span class="compact-status">…</span></span>. */
.compact-row.is-two-line {
    display: grid;
    grid-template-columns: auto 64px minmax(0, 1fr) auto;
    grid-template-areas: "select code title mark" "select code meta mark";
    column-gap: 8px;
    row-gap: 4px;
    align-items: center
}

.compact-row.is-two-line:not(:has(> input)) {
    grid-template-columns: 64px minmax(0, 1fr) auto;
    grid-template-areas: "code title mark" "code meta mark"
}

/* Without a code balloon (rows named by an address: the stock picker of Reservas e bloqueios), the title and the meta start at the left. */
.compact-row.is-two-line:not(:has(> input)):not(:has(> .compact-code)) {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "title mark" "meta mark"
}

/* The column of the code of a row with a label variant takes the width of the label (the fixed 64px of the other lists would cut it). */
.compact-row.is-two-line:has(> .compact-code.is-label) {
    grid-template-columns: auto max-content minmax(0, 1fr) auto
}

.compact-row.is-two-line:has(> .compact-code.is-label):not(:has(> input)) {
    grid-template-columns: max-content minmax(0, 1fr) auto
}

/* The chevron of the selected row (.compact-row.selected::after) has its own column spanning both lines, at the right end, centered. */
.compact-row.is-two-line.selected::after {
    grid-area: mark;
    align-self: center;
    margin-left: 0
}

.compact-row.is-two-line > input {
    grid-area: select;
    align-self: center;
    margin: 0
}

.compact-row.is-two-line > .compact-code {
    grid-area: code;
    align-self: center;
    justify-self: stretch;
    text-align: center
}

.compact-row.is-two-line > .compact-title {
    grid-area: title;
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    text-overflow: clip
}

/* Default look of the second text (zero specificity: a screen rule, as .compact-detail of Produtos, wins). */
:where(.compact-row.is-two-line > .compact-title) small {
    margin-top: 2px;
    font-size: 9px;
    font-weight: 500;
    color: var(--text-muted)
}

.compact-row.is-two-line > .compact-title small {
    display: block;
    white-space: normal;
    overflow-wrap: anywhere
}

.compact-row.is-two-line > .compact-meta {
    grid-area: meta;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-width: 0
}

.compact-row.is-two-line > .compact-meta > .compact-status {
    margin-left: auto
}

@media(max-width:850px) {
    .compact-list {
        max-height: 260px
    }
}