/*
 * CardRowList layout modes (Blazor + ResizeObserver on container width):
 *   .card-row-list--table   per-list TableMinWidth (default 1000px; evaluations 960px)
 *   .card-row-list--medium  700–(TableMinWidth-1)  multi-column card grid
 *   .card-row-list--mobile  < 700px    single-column cards
 *
 * Initial render uses table mode; ResizeObserver downgrades to cards when the
 * container is narrower than TableMinWidth.
 *
 * Table mode: outer scroll wrapper (.card-row-list-table-scroll) contains a shared
 * grid container (.card-row-list-table-inner) whose columns are reused by header
 * and rows via subgrid so column widths stay aligned during horizontal scroll.
 *
 * Header cells (.card-row-list-header-cell) and data cells (.card-row-list-row > .card-row-list-cell)
 * share --card-row-list-cell-padding for identical horizontal alignment.
 */

.card-row-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    --card-row-list-columns: 1fr;
    --card-row-grid-template: var(--card-row-list-columns);
    --card-row-list-cell-padding: 12px 14px;
    --card-row-list-row-min-height: 52px;
}

.card-row-list-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
    width: 100%;
}

.card-row-list-body > .report-inline-detail {
    width: 100%;
    min-width: 0;
}

/* ── Table mode ───────────────────────────────────────── */

.card-row-list--table {
    gap: 0;
}

.card-row-list--table .card-row-list-table-scroll {
    overflow-x: auto;
    overscroll-behavior-x: contain;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    /* Small right inset so the last column is not flush with the scroll edge. */
    padding-inline-end: 3px;
}

.card-row-list--table .card-row-list-table-inner {
    display: grid;
    grid-template-columns: var(--card-row-grid-template);
    grid-auto-rows: auto;
    /* 11px (not 12px): Projekte evaluation grid min width was 916px; 10 gaps × 1px = 10px headroom. */
    column-gap: 11px;
    row-gap: 12px;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.card-row-list--table .card-row-list-body--table {
    display: contents;
}

.card-row-list--table .card-row-list-header,
.card-row-list--table .card-row-list-row {
    display: grid;
    grid-template-columns: subgrid;
    grid-column: 1 / -1;
    column-gap: 0;
    box-sizing: border-box;
    min-width: 0;
}

.card-row-list--table .card-row-list-header {
    align-items: center;
}

.card-row-list--table .card-row-list-row {
    align-items: center;
}

.card-row-list--table .report-inline-detail {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.card-row-list--table .card-row-list-header {
    padding: 0;
    min-height: var(--card-row-list-row-min-height);
    background: #eef2f7;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: var(--font-table-header);
    color: #374151;
}

.card-row-list--table .card-row-list-header-cell,
.card-row-list--table .card-row-list-row > .card-row-list-cell {
    padding: var(--card-row-list-cell-padding);
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    justify-self: stretch;
    overflow-x: clip;
}

.card-row-list--table .card-row-list-header-cell {
    display: block;
    align-self: center;
    white-space: normal;
    overflow-wrap: normal;
    word-break: normal;
    line-height: 1.25;
}

.card-row-list--table .card-row-list-header-cell-actions,
.card-row-list--table.has-actions-column .card-row-list-header-cell:last-child {
    text-align: right;
}

.card-row-list--table .card-row-list-header-cell .sort-button {
    border: none;
    background: transparent;
    padding: 0;
    margin: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
    text-align: inherit;
    width: auto;
    max-width: 100%;
    box-sizing: border-box;
    display: block;
    white-space: normal;
    overflow-wrap: normal;
    word-break: normal;
    line-height: 1.25;
    font-weight: 600;
}

.card-row-list--table .card-row-list-header-cell-actions .sort-button,
.card-row-list--table.has-actions-column .card-row-list-header-cell:last-child .sort-button {
    width: 100%;
}

.card-row-list--table .card-row-list-header-cell .sort-button.sort-asc::after,
.card-row-list--table .card-row-list-header-cell .sort-button.sort-desc::after {
    display: inline;
    margin-left: 4px;
    vertical-align: baseline;
}

.card-row-list--table .card-row-list-row {
    min-height: var(--card-row-list-row-min-height);
    border: 1px solid var(--border-outer);
    border-radius: var(--radius-md);
    background: var(--surface);
}

.card-row-list--table .card-row-list-row:hover {
    border-color: #9aaabe;
    background: #f8fafc;
}

.card-row-list--table .card-row-list-row.card-row-list-footer {
    border: none;
    border-radius: var(--radius-md);
    background: #eef2f7;
    font-weight: 600;
    font-size: var(--font-table-header);
    color: #374151;
}

.card-row-list--table .card-row-list-cell {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    font-size: var(--font-table-body);
    overflow-x: clip;
}

.card-row-list--table .card-row-list-row > .card-row-list-cell > * {
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.card-row-list--table .card-row-list-cell-actions {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    min-width: 0;
    max-width: 100%;
}

.card-row-list--table .card-row-list-cell-actions.table-actions,
.card-row-list--table .card-row-list-cell-actions .table-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    width: 100%;
    min-width: 0;
    max-width: 100%;
}

.card-row-list--table .card-row-list-cell-actions .table-button,
.card-row-list--table .card-row-list-cell-actions.table-actions > .table-button {
    white-space: normal;
    max-width: 100%;
    flex: 0 1 auto;
    min-width: 0;
}

.card-row-list--table .progress-cell {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

/* ── Shared card field styling ────────────────────────── */

.card-row-list--medium .card-row-list-card,
.card-row-list--mobile .card-row-list-card {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    border: 1px solid var(--border-outer);
    border-radius: var(--radius-md);
    background: var(--surface);
    overflow: hidden;
}

.card-row-list--medium .card-row-list-card:hover,
.card-row-list--mobile .card-row-list-card:hover {
    border-color: #9aaabe;
    background: #f8fafc;
}

.card-row-list-field-label {
    display: block;
    font-size: var(--font-table-header);
    font-weight: 600;
    color: #64748b;
    margin-bottom: 3px;
    line-height: 1.3;
    text-transform: none;
    letter-spacing: 0.01em;
}

.card-row-list-field-value {
    display: block;
    min-width: 0;
    word-break: break-word;
    font-size: var(--font-table-body);
    line-height: 1.35;
}

.card-row-list-field--actions {
    border-top: 1px solid #e2e8f0;
    background: #fafbfc;
}

.card-row-list-field--actions .card-row-list-field-label {
    margin-bottom: 8px;
    font-size: var(--font-table-header);
    color: #475569;
}

.card-row-list-field-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
    min-width: 0;
}

.card-row-list-field-actions .table-button {
    max-width: 100%;
    box-sizing: border-box;
}

/* ── Medium card mode ─────────────────────────────────── */

.card-row-list--medium .card-row-list-card {
    display: block;
    padding: 4px 0 0;
}

.card-row-list--medium .card-row-list-medium-grid {
    container-type: inline-size;
    container-name: card-row-list-medium-grid;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    width: 100%;
    min-width: 0;
}

@container card-row-list-medium-grid (min-width: 720px) {
    .card-row-list-medium-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@container card-row-list-medium-grid (min-width: 960px) {
    .card-row-list-medium-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@container card-row-list-medium-grid (min-width: 1080px) {
    .card-row-list-medium-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

.card-row-list--medium .card-row-list-card.card-row-list-footer {
    border: none;
    border-radius: var(--radius-md);
    background: #eef2f7;
    font-weight: 600;
    padding: 10px 12px;
}

.card-row-list--medium .card-row-list-card.card-row-list-footer .card-row-list-medium-grid {
    gap: 8px;
}

.card-row-list--medium .card-row-list-field {
    display: block;
    padding: 10px 14px;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    border-bottom: 1px solid #eef2f7;
    overflow-wrap: anywhere;
}

.card-row-list--medium .card-row-list-field.table-actions {
    display: block;
}

.card-row-list--medium .card-row-list-field--actions {
    grid-column: 1 / -1;
    border-bottom: none;
    margin-top: 2px;
    padding: 12px 14px 14px;
}

.card-row-list--medium .card-row-list-field-value,
.card-row-list--medium .card-row-list-field-actions {
    min-width: 0;
    max-width: 100%;
}

.card-row-list--medium .card-row-list-field-actions {
    justify-content: flex-start;
}

.card-row-list--medium .card-row-list-field-actions .table-button {
    white-space: nowrap;
}

.card-row-list--medium .progress-cell {
    min-width: 0;
    max-width: 100%;
}

/* ── Mobile card mode ─────────────────────────────────── */

.card-row-list--mobile .card-row-list-card {
    display: flex;
    flex-direction: column;
}

.card-row-list--mobile .card-row-list-card.card-row-list-footer {
    border: none;
    border-radius: var(--radius-md);
    background: #eef2f7;
    font-weight: 600;
    padding: 4px 0;
}

.card-row-list--mobile .card-row-list-field {
    padding: 10px 14px;
    border-bottom: 1px solid #eef2f7;
    min-width: 0;
    box-sizing: border-box;
}

.card-row-list--mobile .card-row-list-field--actions {
    border-bottom: none;
    padding-top: 12px;
    padding-bottom: 14px;
}

.card-row-list--mobile .card-row-list-field-actions {
    flex-direction: column;
    align-items: stretch;
}

.card-row-list--mobile .card-row-list-field-actions .table-button {
    width: 100%;
    white-space: normal;
    text-align: center;
    justify-content: center;
}

.report-inline-detail {
    margin: 0 0 4px;
}

.report-inline-detail .active-report-editor {
    margin-top: 0;
}

.report-inline-detail .form-actions {
    margin-top: 12px;
}


/* Sprint 064.3: compact overview lists only (projects, reports, approvals).
 * Header and data retain the same subgrid and padding for aligned columns.
 * Existing container-width layout modes and inline editors remain intact.
 */
.card-row-list.compact-overview-list {
    container-type: inline-size;
    container-name: compact-overview-list;
    --card-row-list-cell-padding: 8px 12px;
    --card-row-list-row-min-height: 44px;
    gap: 8px;
}

.compact-overview-list .card-row-list-body {
    gap: 8px;
}

.compact-overview-list.card-row-list--table {
    gap: 0;
}

.compact-overview-list.card-row-list--table .card-row-list-table-inner {
    row-gap: 8px;
}

.compact-overview-list.card-row-list--table .card-row-list-header {
    min-height: 40px;
}

.compact-overview-list.card-row-list--table .card-row-list-cell-actions,
.compact-overview-list.card-row-list--table .card-row-list-cell-actions.table-actions {
    gap: 6px;
}

.compact-overview-list.card-row-list--medium .card-row-list-field,
.compact-overview-list.card-row-list--mobile .card-row-list-field {
    padding: 8px 12px;
}

.compact-overview-list .card-row-list-field--actions .card-row-list-field-label {
    margin-bottom: 5px;
}

.compact-overview-list.card-row-list--medium .card-row-list-field-actions {
    gap: 6px;
}

/* Wider report action column when all four common actions fit on one line.
 * At narrower widths the existing 260px column wraps actions in order.
 * Both header and rows inherit these columns from the same parent grid.
 */
@container compact-overview-list (min-width: 1400px) {
    .compact-reports-list.card-row-list--table .card-row-list-table-inner {
        grid-template-columns: minmax(150px, 1.4fr) minmax(100px, 1fr) minmax(100px, 0.9fr) minmax(84px, 0.75fr) 440px;
    }

    .compact-reports-list-all.card-row-list--table .card-row-list-table-inner {
        grid-template-columns: minmax(150px, 1.4fr) minmax(100px, 1fr) minmax(100px, 0.9fr) minmax(120px, 1fr) minmax(84px, 0.75fr) 440px;
    }
}


/* Sprint 064.9: package lists follow the same container modes as CardRowList. */
.engineering-package-editor-list.card-row-list--medium .card-row-list-medium-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) 180px;
    gap: 8px;
    padding: 8px;
    box-sizing: border-box;
}

.engineering-package-editor-list.card-row-list--mobile .card-row-list-card {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 8px;
}

.engineering-package-editor-list.card-row-list--medium .card-row-list-card {
    padding: 0;
}

.engineering-package-editor-list .card-row-list-field {
    padding: 0;
    border-bottom: none;
}

.engineering-package-editor-list .card-row-list-field-label {
    margin-bottom: 4px;
}

.engineering-package-editor-list.card-row-list--medium .card-row-list-field--actions {
    grid-column: 2 / -1;
    align-self: end;
}

.engineering-package-editor-list.card-row-list--mobile .card-row-list-field--actions {
    grid-column: 1 / -1;
}

.engineering-package-editor-list.card-row-list--medium .card-row-list-field-actions,
.engineering-package-editor-list.card-row-list--mobile .card-row-list-field-actions {
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
}

.engineering-package-editor-list.card-row-list--mobile .card-row-list-field-actions .table-button {
    width: auto;
    white-space: nowrap;
}

.engineering-package-read-list.card-row-list--mobile .card-row-list-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 100px;
    gap: 8px;
    padding: 8px;
}

.engineering-package-read-list.card-row-list--mobile .card-row-list-field {
    padding: 0;
    border-bottom: none;
}

.engineering-package-read-list.card-row-list--mobile .card-row-list-field:nth-child(2) {
    grid-column: 1 / -1;
    grid-row: 2;
}

.engineering-package-read-list.card-row-list--mobile .card-row-list-field:nth-child(3) {
    grid-column: 2;
    grid-row: 1;
}
