/* ==========================================================================
   New job (workloads/new_job): the cluster options, the script step, the
   settings and the review.
   The progress, stages and actions are the shared submit-flow rules in
   shell.css.
   ========================================================================== */

.infra-jobs__cluster-option-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

/* Why the step can't go on, beside its buttons. */
.submit-flow__reason {
  flex: 1 1 12rem;
  min-width: 0;
  margin: 0;
  color: var(--danger);
  font-size: var(--text-13);
  line-height: var(--leading-snug);
  text-align: right;
}

.submit-flow__reason:empty {
  display: none;
}

/* ── Script step: where it starts from, beside the editor ─────────────── */
.job-script {
  container: job-script / inline-size;
}

.job-script__panes {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-6);
}

/* Two panes once the step is wide enough for fields beside a script. */
@container job-script (min-width: 1024px) {
  .job-script__panes {
    /* A fixed source pane keeps the editor on whole pixels, where its two
       layers anti-alias alike. */
    grid-template-columns: 28rem minmax(0, 1fr);
    align-items: start;
  }

  .job-script__editor {
    position: sticky;
    top: calc(var(--header-h) + var(--space-4));
  }
}

.job-script__source,
.job-script__editor {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

.job-script__editor {
  gap: var(--space-2);
}

.job-script__source > .ui-segmented {
  align-self: flex-start;
}

.job-script__save {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-top: var(--space-2);
}

.job-script__save .ui-field__hint {
  margin: 0;
  padding-left: calc(32px + var(--space-2));
}

/* ── Template: a searchable list, then the picked one and its fields ──── */
.job-templates {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.job-templates__search {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.job-templates__search .ui-input {
  flex: 1 1 auto;
  min-width: 0;
}

.job-templates__group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.job-templates__list {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  list-style: none;
}

.job-templates__list > li + li {
  border-top: 1px solid var(--line);
}

.job-template {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 0;
  background: var(--bg-raised);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out);
}

.job-template:hover {
  background: var(--bg-hover);
}

.job-template:focus-visible {
  position: relative;
  outline: none;
  box-shadow: inset 0 0 0 2px var(--focus);
}

.job-template[aria-pressed="true"] {
  background: var(--accent-soft);
}

/* Every mark (or monogram) in one 20px slot, so the names line up. */
.job-template > .ui-brand,
.job-template > .ui-brand-monogram {
  flex: none;
  justify-content: center;
  width: 20px;
  margin-top: 1px;
  text-align: center;
}

.job-template__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.job-template__name {
  font-size: var(--text-14);
  font-weight: var(--weight-medium);
}

.job-template__description {
  overflow: hidden;
  color: var(--text-dim);
  font-size: var(--text-13);
  line-height: var(--leading-snug);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-template-picked {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.job-template-picked__head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.job-template-picked__text {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.job-template-picked__text h4 {
  margin: 0;
  font-size: var(--text-16);
  font-weight: var(--weight-semibold);
}

.job-template-picked__text p,
.job-template-picked__details {
  margin: 0;
  color: var(--text-dim);
  font-size: var(--text-13);
  line-height: var(--leading-normal);
}

.job-template-picked__details {
  margin-top: var(--space-2);
}

:is(.job-template__description, .job-template-picked__text p, .job-template-picked__details) code {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

/* ── Saved in Drive ───────────────────────────────────────────────────── */
.job-saved {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.job-saved__list {
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  list-style: none;
}

.job-saved__row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: calc(var(--control-md) + var(--space-4));
  padding: var(--space-2) var(--space-4);
  background: var(--bg-raised);
}

.job-saved__row + .job-saved__row {
  border-top: 1px solid var(--line);
}

.job-saved__name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  font-size: var(--text-13);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-saved__when {
  flex: none;
  color: var(--text-dim);
  font-size: var(--text-12);
}

.job-saved__row > :last-child {
  flex: none;
}

/* ── Blank ────────────────────────────────────────────────────────────── */
.job-blank {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
}

.job-blank .ui-field__hint {
  margin: 0;
}

/* ── Settings: essentials and resources beside what the nodes have free ── */
.job-settings {
  container: job-settings / inline-size;
}

.job-settings__columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-6);
}

@container job-settings (min-width: 1024px) {
  .job-settings__columns {
    grid-template-columns: minmax(0, 1fr) minmax(0, 26rem);
    align-items: start;
  }

  .job-settings__capacity {
    position: sticky;
    top: calc(var(--header-h) + var(--space-4));
  }
}

.job-settings__main,
.job-settings__capacity {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

.job-settings__title {
  margin: 0;
  font-size: var(--text-14);
  font-weight: var(--weight-semibold);
}

.job-settings__note {
  margin: 0;
  color: var(--text-dim);
  font-size: var(--text-13);
  line-height: var(--leading-normal);
}

/* ── The sections below: one row each until opened ────────────────────── */
.job-sections {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.job-section + .job-section {
  border-top: 1px solid var(--line);
}

.job-section > summary.job-section__row {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  width: 100%;
  min-height: var(--control-lg);
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border-radius: 0;
  color: var(--text);
}

.job-section > summary.job-section__row::before {
  flex: none;
  align-self: center;
}

.job-section > summary.job-section__row:hover {
  background: var(--bg-hover);
}

.job-section > summary.job-section__row:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--focus);
}

.job-section__title {
  flex: none;
  font-size: var(--text-14);
  font-weight: var(--weight-medium);
}

.job-section__summary {
  min-width: 0;
  overflow: hidden;
  color: var(--text-dim);
  font-size: var(--text-13);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-section__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-1) var(--space-4) var(--space-5);
}

.job-section__switches {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-6);
}

.job-section__checks {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  border: 0;
}

/* Environment: six lines of the editor, scrolling beyond. */
.job-section__body > .ui-tty {
  height: auto;
}

.job-section__body > .ui-tty .ui-tty__screen {
  height: calc(6 * var(--tty-row) + 2 * var(--space-3));
  flex: none;
}

.job-section__body > .ui-field__hint {
  margin: calc(-1 * var(--space-2)) 0 0;
}

/* ── Review: one block per step ───────────────────────────────────────── */
.job-review__block {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--line);
}

.job-review__block:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.job-review__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.job-review__head h4 {
  margin: 0;
  font-size: var(--text-14);
  font-weight: var(--weight-semibold);
}

/* One key column for every block, so the values line up down the page. */
.job-review .ui-kv {
  grid-template-columns: minmax(0, 10rem) minmax(0, 1fr);
}

.job-review__cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.job-review__none {
  margin: 0;
  color: var(--text-dim);
  font-size: var(--text-13);
}

/* Submit: both labels in one cell, so "Submitting…" doesn't resize it. */
.submit-flow__submit {
  display: inline-grid;
}

.submit-flow__submit > span {
  grid-area: 1 / 1;
}

.submit-flow__submit > span[aria-hidden="true"] {
  visibility: hidden;
}
