/*
 * alignvu UI v2.1: Align > datafeed wizard review steps (reference_group_codes/*): Review Field Mappings (a canvas of
 * chips joined by lines), Datafeed IDs (Checkboxes), Reference Group Codes, Program Codes and Lists (FeedTables with
 * an edit Dialog). Markup: application/views/configuration/configure/reference_group_codes/; scripts:
 * js/align_to/configure/feed_configures/ (feed_mapping.js, configure_source_ids.js, feed_code_table.js,
 * feed_code_dialog.js). List parts (.app-admin*) come from css/v21_admin.css.
 */

/* ---------- Step page: a Panel with the step buttons under it ---------- */

.app-review-screen .app-review__panel {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    min-width: 0;
}

.app-review .app-review__head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-2) var(--space-4);
    margin: 0;
}

.app-review .app-review__head h2 {
    margin: 0;
}

.app-review .app-review__intro,
.app-review .app-review__count {
    margin: 4px 0 0;
    color: var(--body-ink);
}

.app-review .app-review__count {
    color: var(--muted);
    white-space: nowrap;
}

.app-review .app-review__filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
}

/* Back and Cancel on the left, Next / Finish on the right (datafeedStepNav() in datafeed_step_parts.php) */
.app-review .app-datafeed-step__nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border);
}

.app-review .app-datafeed-step__nav .av-actions {
    margin: 0;
}

/* ---------- Code tables: Reference Group Codes, Program Codes, Lists ---------- */

/* cells wrap so the columns share the width; the code column stays readable */
.app-review-table th,
.app-review-table td {
    white-space: normal;
    overflow-wrap: anywhere;
}

.app-review-table thead th {
    overflow-wrap: normal;
}

/* the code (first) column gets a fifth of the width; headings wrap rather than widen the table */
.app-review-table thead th:first-child {
    width: 20%;
    min-width: 140px;
}

.app-review-table td .av-badge + .av-badge {
    margin-left: 4px;
}

.app-review-table .app-review-table__unmapped th {
    color: var(--heading-ink);
}

/* css/align_to.css styles tables in the legacy screens' modals; keep the Dialog's form plain */
.app-review-dialog .review-code-form {
    align-items: start;
}

.app-review-dialog .app-review-dialog__wide {
    grid-column: 1 / -1;
}

.app-review-dialog .app-review-dialog__switches {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3) var(--space-5);
}

.app-review-dialog textarea.app-review-dialog__textarea {
    height: auto;
    min-height: 72px;
    padding: 8px 12px;
    resize: vertical;
}

.app-review-dialog .app-review-dialog__checklist {
    max-height: 180px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.app-review-dialog .app-review-dialog__checklist .av-check[hidden] {
    display: none;
}

.app-review-dialog .review-code-checklist-filter {
    border: 1px solid var(--muted);
}

/* ---------- Datafeed IDs ---------- */

/* one ID type per row */
.app-review-ids .app-review-ids__list {
    grid-template-columns: minmax(0, 1fr);
    max-height: none;
}

.app-review-ids .av-fieldset[hidden],
.app-review-screen .av-table__frame[hidden],
.app-review-screen .app-review-map[hidden],
.app-review-screen .app-review-map__toolbar[hidden] {
    display: none;
}

/* ---------- Review Field Mappings canvas ---------- */

.app-review-map__toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-3);
}

.app-review-map__table-filter {
    flex: 0 1 360px;
}

/* seven columns sharing the width (the field and table a little wider), gaps wide enough for the lines */
.app-review-map {
    --app-review-map-cols: minmax(0, 1.15fr) minmax(0, 1.15fr) repeat(5, minmax(0, 1fr));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
}

.app-review-map__head,
.app-review-map__table {
    display: grid;
    grid-template-columns: var(--app-review-map-cols);
    column-gap: 18px;
    padding: 0 var(--space-4);
}

.app-review-map__head {
    padding-top: 10px;
    padding-bottom: 10px;
    background: var(--day-band);
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    font: 600 12.5px/16px var(--font-display);
    color: var(--heading-ink);
    hyphens: auto;
}

.app-review-map__table {
    row-gap: 8px;
    align-items: start;
    padding-top: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--row-rule);
}

.app-review-map__table:last-child {
    border-bottom: 0;
}

/* each chip in its column (classes the chips have always had) */
.app-review-map__table .nativeTable { grid-column: 1; }
.app-review-map__table .nativeField { grid-column: 2; }
.app-review-map__table .entityType { grid-column: 3; }
.app-review-map__table .gscName { grid-column: 4; }
.app-review-map__table .scName { grid-column: 5; }
.app-review-map__table .ftName { grid-column: 6; }
.app-review-map__table .fieldName { grid-column: 7; }

/* chips sit above the connecting lines */
.app-review-map__chip {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    min-width: 0;
    min-height: 28px;
    padding: 4px 8px;
    color: var(--heading-ink);
    background: var(--fill);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.app-review-map__chip p {
    min-width: 0;
    margin: 0;
    font: 400 12.5px/18px var(--font-display);
    color: inherit;
    overflow-wrap: break-word;
    hyphens: auto;
}

.app-review-map__chip--table,
.app-review-map__chip--native,
.app-review-map__chip--static {
    background: var(--surface);
    border-color: var(--muted);
}

.app-review-map__chip--table p {
    font-weight: 600;
}

.app-review-map__chip--static {
    border-style: dashed;
}

.app-review-map__chip--dead-end {
    border-color: var(--status-removed);
    box-shadow: inset 0 0 0 1px var(--status-removed);
}

.app-review-map__legend {
    align-self: center;
}

/* a narrow window: tighter chips so the seven columns keep whole words */
@media (max-width: 1279px) {
    .app-review-map__head,
    .app-review-map__table {
        column-gap: 14px;
        padding-left: var(--space-3);
        padding-right: var(--space-3);
    }

    .app-review-map__chip {
        padding: 3px 5px;
    }

    .app-review-map__chip p {
        font-size: 12px;
    }
}
