/*
 * alignvu UI v2.1: Connect > Templates: the templates list and the create-extract steps (mappings.php,
 * extract_mappings_out_grid.php, create_extract_*.php; js/align_from/configure/mappings.js, extract_settings.js,
 * js/align_from/configure.js).
 * Shared Connect parts are in css/v21_connect.css.
 */

/* ---------- Extracts list (mappings.php, mappings.js) and the import step's files (create_extract_import.php) ---------- */

/* the template's (or file's) name leads the row */
.app-connect-extracts tbody th.app-connect-extracts__name,
.app-connect-extracts-files tbody th.app-connect-extracts__name {
    font-weight: 600;
    color: var(--heading-ink);
    text-align: left;
    background: var(--surface);
}

/* the action buttons take only the room they need */
.app-connect-extracts td:last-child,
.app-connect-extracts-files td:last-child {
    width: 1%;
}

/* ---------- Create-extract steps (create_extract_*.php): a Panel of fields, 16px apart ---------- */

.app-connect-extracts-step > .av-panel,
.app-connect-extracts__file {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.app-connect-extracts-step .av-panel__head {
    margin-bottom: 0;
}

/* text inputs and selects keep a readable width rather than spanning the panel */
.app-connect-extracts-step__fields {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: min(480px, 100%);
}

/* a follow-up group (step 6: how to split, shown when the files are split) */
.app-connect-extracts-step__group {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* step 7: the Other delimiter's input, under its radio */
.app-connect-extracts-step__other {
    max-width: min(240px, 100%);
    margin-left: 24px;
}

/* ---------- Step 5: one Panel per file of a multi-file extract (generateExtractTypeFileInput) ---------- */

/* (scripts hide and show these with an inline display, which wins over the display set here) */
.app-connect-extracts__files {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.app-connect-extracts__file-title {
    margin: 0;
    font: 600 15px/22px var(--font-display);
    color: var(--heading-ink);
}

.app-connect-extracts__file .av-field {
    max-width: min(480px, 100%);
}

/* a split's filter: its suffix and checkboxes, indented under the chosen radio */
.app-connect-extracts__filter {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 4px 0 8px 24px;
}

.app-connect-extracts__filter .av-field {
    max-width: min(480px, 100%);
}

.app-connect-extracts__checks {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr));
    gap: 8px 16px;
}

/* the Add another file button sits under the files, at its own width */
.app-connect-extracts-step > #create-extract-multi-file-add {
    align-self: flex-start;
}

/* ---------- Dialogs (delete template, tips, map across entity types) ---------- */

/* the old shared rules size paragraphs at 16px and tip titles at 21px (css/application.css): back to v2.1 type */
.align-from .app-connect-extracts-dialog .modal-body p {
    margin: 0 0 12px;
    font: 400 14px/21px var(--font-display);
    color: var(--body-ink);
}

.align-from .app-connect-extracts-dialog .modal-body p:last-child {
    margin-bottom: 0;
}

.align-from .tutorial-modal .app-connect-extracts-dialog {
    width: min(480px, calc(100vw - 32px));
    min-width: 0;
}

.align-from .tutorial-modal .app-connect-extracts-dialog .app-dialog__title {
    margin: 0 !important;
    font-size: 17px !important;
}

/* Templates list: the description wraps in the room left by the name and the icon buttons */
.app-connect-extracts td.app-connect-extracts__description {
    color: var(--body-ink);
    white-space: normal;
    overflow-wrap: anywhere;
}

/* Details step: the description runs the full width of the panel; the name keeps the usual field width */
.create-extract-name-desc .app-connect-extracts-step__fields {
    max-width: none;
}

.create-extract-name-desc .app-connect-extracts-step__fields > .av-field:first-child {
    max-width: min(480px, 100%);
}

/* the name lines up with the rest of its row */
.app-connect-extracts tbody th.app-connect-extracts__name {
    vertical-align: middle;
}

/* Templates list, as the Schedules list (css/v21_connect_schedules.css): the name is a link to the template's
   read-only view, underlined on hover or focus; Edit and Delete are icon buttons side by side */
.app-connect-extracts .app-connect-extracts__link {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    color: var(--heading-ink);
    text-align: left;
    cursor: pointer;
}

.app-connect-extracts .app-connect-extracts__link:hover,
.app-connect-extracts .app-connect-extracts__link:focus-visible {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.app-connect-extracts .app-connect-extracts__link:focus-visible {
    outline: 2px solid var(--heading-ink);
    outline-offset: 2px;
}

.app-connect-extracts .app-connect__actions {
    gap: 0;
}

/* ---------- Template Overview (template_summary.php, template_summary.js): read-only ---------- */

.app-connect-template-summary {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

.app-connect-template-summary__page {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.app-connect-template-summary__page[hidden] {
    display: none;
}

/* Details: one Panel. The description, then a field and its value per line, then the file structure on one line */
.app-connect-template-summary__details {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.align-from .app-connect-template-summary__description {
    margin: 0;
    font: 400 14px/21px var(--font-display);
    color: var(--body-ink);
    white-space: pre-wrap;
}

.app-connect-template-summary__list.av-details {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 0;
}

.app-connect-template-summary__list > div {
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr);
    align-items: baseline;
    gap: var(--space-4);
}

.app-connect-template-summary__file-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.app-connect-template-summary__structure.av-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px var(--space-5);
    margin: 0;
    padding-top: var(--space-4);
    border-top: 1px solid var(--border);
}

/* the pen in the template's name pill in the page head: a small quiet icon button after the name */
.app-connect-title-pill--overview {
    gap: 4px;
}

.app-connect-title-pill--overview .extract-template-summary-edit {
    width: 20px;
    height: 20px;
    min-width: 0;
    margin-right: -6px;
    padding: 0;
    border-radius: var(--radius-pill);
}

.app-connect-title-pill--overview .extract-template-summary-edit .av-icon {
    width: 13px;
    height: 13px;
}

/* Field Mapping: an internal field (its name starts with "*") is shaded */
.app-connect-template-summary__canvas .app-connect-fields__chip.app-connect-template-summary__chip--internal {
    background: var(--fill);
}

/* the loading / failure message in place of the canvas */
.align-from .app-connect-template-summary__status {
    margin: 0;
    font: 400 14px/21px var(--font-display);
    color: var(--muted);
}

/* value mappings in a mapping's box: a disclosure opening their table */
.app-connect-template-summary__value-mappings summary {
    cursor: pointer;
    font: 600 12px/16px var(--font-display);
    color: var(--heading-ink);
}

.app-connect-template-summary__value-mappings .av-table {
    margin-top: 6px;
}

/* the note above the entity type tabs */
.align-from .app-connect-template-summary__note {
    margin: 0;
    font: 400 12px/18px var(--font-display);
    color: var(--muted);
}

/* Field Mapping: the edit screen's canvas (css/v21_connect_fields.css sizes it; css/align_from.css lays it out only
   under .template-table, which this page can't use because legacy scripts show every .template-table) */
.app-connect-template-summary__canvas .align-from-header-sticky .extract-mapping-headers,
.app-connect-template-summary__canvas .align-from-header-sticky .extract-mapping-headers-wrapper,
.app-connect-template-summary__canvas .align-from-header-sticky .extract-mapping-headers-model,
.app-connect-template-summary__canvas .extract-template-file-fields-grid-container,
.app-connect-template-summary__canvas .extract-file-field-grid-container,
.app-connect-template-summary__canvas .extract-file-model-mappings {
    display: grid;
}

.app-connect-template-summary__canvas .template-table-field-container,
.app-connect-template-summary__canvas .extract-template-file-columns {
    display: flex;
    flex-direction: column;
}

.app-connect-template-summary__canvas .template-table-field-container .extract-file-model-mapping {
    display: grid;
    align-items: center;
    position: relative;
    z-index: 1;
}

.app-connect-template-summary__canvas .extract-model-field,
.app-connect-template-summary__canvas .extract-enrichment-value { grid-column: 2; }

.app-connect-template-summary__canvas .extract-file-model-mappings .extract-file-mapping-summary {
    grid-column: 2 / -1;
    position: relative;
    z-index: 1;
}

.app-connect-template-summary__canvas .extract-file-mapping-summary-elements dt {
    font: 600 11px/14px var(--font-display);
    color: var(--muted);
}

.app-connect-template-summary__canvas .extract-file-mapping-summary-elements dd {
    margin: 0;
}
