/* Functions as a tree table (4.6): page "Funktionen" and the tab "Funktionen" of a function
   structure. Same header, zebra rows and row height as the other SCS tables; the function
   text is edited in its cell without a frame until it gets the focus. */

html:root .function-tree {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: var(--scs-text-m);
}

html:root .function-tree th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 9px 8px;
  border-bottom: 1px solid var(--scs-line);
  background: var(--scs-surface-2);
  color: var(--scs-ink-3);
  font-size: var(--scs-text-s);
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

html:root .function-tree td {
  height: 38px;
  padding: 2px 8px;
  border-bottom: 1px solid var(--scs-line-2);
  vertical-align: middle;
}

html:root .function-tree :is(th, td).function-check {
  width: 36px;
  padding: 0;
  text-align: center;
}

html:root .function-tree :is(th, td).function-check input {
  margin: 0;
}

html:root .function-tree th.function-name {
  width: auto;
  min-width: 260px;
}

html:root .function-tree .function-text-cell {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  padding-left: calc(var(--function-depth, 0) * 18px);
}

html:root .function-tree .function-text-cell input {
  flex: 1;
  min-width: 0;
  height: 30px;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-radius: var(--scs-radius-s);
  background: transparent;
  color: var(--scs-ink);
  font: inherit;
  text-overflow: ellipsis;
}

html:root .function-tree .function-text-cell input:not([readonly]):hover {
  border-color: var(--scs-line);
}

html:root .function-tree .function-text-cell input:focus {
  border-color: var(--scs-focus);
  outline: none;
  background: var(--scs-surface);
}

html:root .function-tree .function-fold,
html:root .function-tree .function-fold-placeholder {
  display: inline-grid;
  flex: 0 0 22px;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: var(--scs-radius-s);
  background: transparent;
  color: var(--scs-ink-3);
}

html:root .function-tree .function-fold:hover {
  background: var(--scs-surface-3);
  color: var(--scs-ink);
}

html:root .function-tree .function-fold svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

html:root .function-tree .function-id {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
}

html:root .function-tree .function-number {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

html:root .function-tree .function-id code {
  overflow: hidden;
  padding: 0;
  background: none;
  color: var(--scs-ink-3);
  font-size: var(--scs-text-s);
  text-overflow: ellipsis;
}

html:root .function-tree select.function-parent {
  width: 100%;
  height: 30px;
  padding: 2px 4px;
  border-color: transparent;
  background-color: transparent;
  color: var(--scs-ink-2);
  font-size: var(--scs-text-s);
  text-overflow: ellipsis;
}

html:root .function-tree select.function-parent:not(:disabled):hover {
  border-color: var(--scs-line);
}

html:root .function-tree .function-count {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  height: auto;
  min-height: 0;
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--scs-accent);
  font-size: var(--scs-text-s);
}

html:root .function-tree .function-count:hover {
  text-decoration: underline;
}

html:root .function-tree .unused-label {
  color: var(--scs-ink-3);
  font-size: var(--scs-text-s);
}

html:root .function-tree .function-row-actions {
  display: flex;
  gap: 2px;
  justify-content: flex-end;
}

html:root .function-tree .function-row-actions button {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: var(--scs-radius-s);
  font-size: 14px;
}

html:root .function-tree .function-row-actions svg {
  width: 15px;
  height: 15px;
}

html:root .function-tree tr.function-context .function-text-cell input,
html:root .function-tree tr.function-outside .function-text-cell input {
  color: var(--scs-ink-3);
}

html:root .function-tree tbody tr:has(> td > .row-check:checked:not(:disabled)) > td {
  background-color: var(--scs-accent-soft);
}

/* Status in a function structure: chosen, through a subtree, context or outside. */
html:root .function-status {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: var(--scs-text-xs);
  font-weight: 600;
  white-space: nowrap;
}

html:root .function-status-chosen {
  background: var(--scs-accent-soft);
  color: var(--scs-accent);
}

html:root .function-status-subtree {
  background: var(--scs-surface-3);
  color: var(--scs-ink-2);
}

html:root .function-status-context {
  border: 1px dashed var(--scs-line-strong);
  color: var(--scs-ink-3);
}

html:root .function-status-out {
  color: var(--scs-ink-3);
  font-weight: 400;
}

html:root .function-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--scs-text-s);
  color: var(--scs-ink-2);
  white-space: nowrap;
}

html:root #dialog-body .function-switch {
  margin: 4px 0 8px;
  font-size: var(--scs-text-m);
}

html:root .function-catalog-summary > span:nth-child(2) {
  color: var(--scs-ink-3);
}

/* Function object page: editable text and parent, the tree below the function. */
html:root .function-attributes {
  display: grid;
  gap: 12px;
}

html:root .function-attributes textarea {
  min-height: 64px;
  resize: vertical;
}

html:root .function-sub-cell {
  padding-left: calc(var(--function-depth, 0) * 18px);
}

@media (max-width: 900px) {
  html:root .function-tree {
    min-width: 860px;
  }
}

/* Row actions that do not apply stay in place without a frame. */
html:root .function-tree .function-row-actions button:disabled {
  border-color: transparent;
  background: transparent;
}

/* Catalog group of a function (4.13): the select stays inside its column. */
.function-group-cell select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
.function-group-cell select.function-group-logical,
.function-group-cell select.function-group-physical {
  border-left: 3px solid var(--scs-accent);
}
.function-group-cell select.function-group-physical {
  border-left-color: var(--scs-warn);
}

/* Function of the other level: refused allocation or marked older allocation (5.4). */
.function-group-warning {
  margin: 0 0 12px;
  padding: 8px 10px;
  border: 1px solid var(--scs-warn-line);
  border-left: 3px solid var(--scs-warn);
  border-radius: var(--scs-radius-m);
  background: var(--scs-warn-soft);
  color: var(--scs-ink);
}

.function-level-warning {
  color: var(--scs-warn);
  font-weight: 600;
}
button.function-level-warning {
  margin-left: 6px;
  padding: 1px 6px;
  border: 1px solid var(--scs-warn-line);
  border-radius: var(--scs-radius-s, 4px);
  background: var(--scs-warn-soft);
  color: var(--scs-ink);
  font-weight: 400;
  font-size: 12px;
}
button.function-level-warning > span[aria-hidden] {
  color: var(--scs-warn);
}
.function-level-text {
  display: block;
  color: var(--scs-ink-3);
}
.function-level-note {
  margin: -4px 0 10px;
  font-size: 12px;
}
.grid-flag-cell {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.grid-flag-cell > :last-child {
  flex: 1 1 auto;
  min-width: 0;
}
.grid-flag-cell > .function-level-warning {
  flex: 0 0 auto;
  cursor: help;
}

/* 6.0.1: several project functions in one function box (element dialog and Pro editor). */
.function-more,
.pro-function-more {
  display: grid;
  gap: 6px;
  margin: 4px 0 10px;
}
.function-more[hidden] {
  display: none;
}
.function-more-title,
.pro-function-more > small {
  font-weight: 600;
  color: var(--scs-ink-2);
}
.function-more-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.function-chip,
.pro-function-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 2px 4px 2px 10px;
  border: 1px solid var(--scs-line);
  border-radius: 999px;
  background: var(--scs-accent-soft);
  font-size: 0.9em;
}
.function-chip > span,
.pro-function-chip > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.function-chip button,
.pro-function-chip button {
  min-width: 22px;
  min-height: 22px;
  padding: 0;
  border: 0;
  background: transparent;
  line-height: 1;
}

/* 6.13: model allocation of functions to systems (web/function_allocation.js). */
.function-system-cell {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.function-system-chip {
  max-width: 160px;
  min-height: 24px;
  overflow: hidden;
  padding: 1px 8px;
  border: 1px solid var(--scs-line);
  border-radius: 999px;
  background: var(--scs-surface);
  color: var(--scs-ink);
  font-size: var(--scs-text-s);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.function-system-chip:hover {
  border-color: var(--scs-accent-line);
  background: var(--scs-accent-soft);
}
.function-system-chip.inherited {
  border-style: dashed;
  color: var(--scs-ink-2);
}
.function-system-more {
  min-height: 24px;
  padding: 1px 6px;
  border: 0;
  background: transparent;
  color: var(--scs-accent);
  font-size: var(--scs-text-s);
}
.function-system-add {
  min-width: 26px;
  min-height: 24px;
  padding: 0;
  opacity: 0.55;
}
tr:hover .function-system-add,
.function-system-add:focus-visible {
  opacity: 1;
}
.function-quick {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
  align-items: center;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px dashed var(--scs-line-strong);
  border-radius: var(--scs-radius-m);
  background: var(--scs-surface);
}
.function-quick-place {
  min-width: 0;
  color: var(--scs-ink-2);
  font-size: var(--scs-text-s);
}
.function-quick-place b {
  color: var(--scs-ink);
}
.function-quick input {
  width: 100%;
  min-height: var(--scs-control-h);
}
.function-assign-target {
  margin: 0 0 10px;
}
.function-assign-diagrams {
  display: grid;
  gap: 4px;
  margin: 12px 0 0;
  padding: 8px 12px;
  border: 1px solid var(--scs-line);
  border-radius: var(--scs-radius-m);
}
.function-assign-diagrams label {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: baseline;
  column-gap: 8px;
}
.function-assign-diagrams label small {
  grid-column: 2;
}
.function-assign-diagrams small {
  color: var(--scs-ink-2);
}
#function-assign-picked,
#function-assign-systems {
  margin: 4px 0 10px;
}
.collect-entries label > span {
  display: grid;
}
.collect-entries small {
  color: var(--scs-ink-2);
}
.choice-item.choice-create .choice-label {
  font-weight: 600;
}

/* 7.1: element dialog "Funktion zuweisen" (editElementFunction). */
.function-mode {
  display: inline-flex;
  margin: 0 0 12px;
}
.function-mode label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  cursor: pointer;
}
.function-mode label:has(input:checked) {
  background: var(--scs-accent);
  color: var(--scs-accent-ink);
  font-weight: 600;
}
.function-mode input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.function-mode label:has(input:focus-visible) {
  outline: 2px solid var(--scs-focus);
  outline-offset: -2px;
}
.function-pick-list {
  display: grid;
  justify-items: stretch;
  gap: 2px;
  margin: 0 0 10px;
  padding: 4px;
  border: 1px solid var(--scs-line);
  border-radius: var(--scs-radius-m);
  background: var(--scs-surface);
}
.function-pick-row {
  display: grid;
  grid-template-columns: 2.5em minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
  min-height: 32px;
  padding: 2px 4px 2px 8px;
  border-radius: var(--scs-radius-s);
}
.function-pick-row:hover {
  background: var(--scs-row-hover);
}
.function-pick-row > button.object-link,
.function-pick-row > span[data-no-translate] {
  display: block;
  flex: 1;
  justify-content: flex-start;
  min-width: 0;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.function-pick-row > button.quiet {
  min-width: 28px;
  min-height: 28px;
  padding: 0;
}
.function-pick-number {
  min-width: 2.5em;
  color: var(--scs-ink-2);
  font-family: var(--scs-font-mono);
  font-size: var(--scs-text-s);
}
.function-pick-new {
  color: var(--scs-accent);
}
.function-pick-list > small {
  padding: 6px 8px;
}
#function-free-offer {
  margin: 0 0 8px;
}
