/* v8.21: presentation-only control and layout corrections.
   Loaded after the existing theme files. Colours, data, permissions and native
   control semantics stay with the existing application. */

/* Keep text controls on one usable baseline without enlarging check/radio,
   range sliders, colour wells or the hidden canonical geography selects. */
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="range"]):not([type="color"]),
select,
textarea {
  box-sizing: border-box;
  min-block-size: 46px;
  min-inline-size: 0;
  max-inline-size: 100%;
  font-family: inherit;
  line-height: 1.5;
}

/* Safari's compact native menu appearance can ignore the shared padded-input
   silhouette. Keep the native select and keyboard behaviour, but draw its field
   and chevron with the current theme's own colour tokens. */
select:not([multiple]):not([size]),
select[size="1"]:not([multiple]) {
  -webkit-appearance: none;
  appearance: none;
  block-size: auto;
  min-block-size: 46px;
  padding-block: 10px;
  padding-inline: 12px 38px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--yx-muted) 50%),
    linear-gradient(135deg, var(--yx-muted) 50%, transparent 50%);
  background-position:
    right 18px center,
    right 13px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

select[multiple],
select[size]:not([size="1"]) {
  block-size: auto;
  min-block-size: 92px;
  background-image: none;
}

textarea {
  min-block-size: 104px;
  resize: vertical;
}

.form-grid > *,
.form-grid label,
.filters,
.toolbar,
.toolbar > *,
.overview-filters > label {
  min-inline-size: 0;
}

.overview-workspace .overview-filters {
  align-items: start;
}

.overview-workspace .overview-filters > label {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.overview-workspace .overview-filters select,
.overview-workspace .region-picker > input {
  inline-size: 100%;
  min-block-size: 46px;
  margin-block-start: 0;
}

/* Only tool areas receive spacing; the surface itself keeps its existing
   padding and overflow behaviour, including geography suggestion popovers. */
.toolbar {
  flex-wrap: wrap;
  gap: 12px;
}

.toolbar .search {
  flex: 1 1 260px;
  inline-size: auto;
  min-inline-size: 0;
}

.toolbar .filters {
  display: flex;
  flex: 1 1 280px;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.toolbar .filters > select {
  flex: 1 1 140px;
  min-inline-size: 0;
}

/* Some existing narrow-screen rules hide this entire hint, including its
   clear-filter button. Keep the count and action available by wrapping them. */
.toolbar > .hint {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  line-height: 1.6;
}

.toolbar > .btn,
.toolbar > .actions {
  max-inline-size: 100%;
}

.toolbar .btn,
.table-foot .btn,
.form-actions .btn {
  min-block-size: 44px;
  max-inline-size: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: center;
}

.tabs,
.queue-tabs,
.record-tabs,
.term-tabs,
.software-tabs {
  min-inline-size: 0;
  max-inline-size: 100%;
  scroll-padding-inline: 16px;
}

.tabs > .tab,
.queue-tabs > .queue-tab {
  flex-shrink: 0;
  min-block-size: 44px;
}

.table-wrap {
  max-inline-size: 100%;
}

.table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 24px;
}

.pager {
  flex-wrap: wrap;
  gap: 8px;
}

/* 分页字段带标签，按钮对齐控件底部；窄屏整组换行，不挤压或截断。 */
.list-pagination .list-pagination-controls {
  align-items: flex-end;
  flex-wrap: wrap;
  width: auto;
  max-width: 100%;
  margin-left: auto;
  gap: 12px;
}
.list-pagination-controls label { gap: 6px; }
.list-pagination-controls select,
.list-pagination .pager button {
  box-sizing: border-box;
  height: 46px;
  min-height: 46px;
  margin: 0;
}
.list-pagination .pager button {
  padding: 0 14px;
  white-space: nowrap;
}

.table-foot .pager button,
.pager button,
.icon-btn {
  min-inline-size: 44px;
  min-block-size: 44px;
}

/* Long dialog titles and actions wrap within their own area. No content or
   action is hidden, and the existing sticky footer/safe-area rules remain. */
dialog .dialog-title,
dialog .dialog-title h2,
dialog .dialog-tools,
dialog .modal-body,
dialog .form-actions {
  min-inline-size: 0;
}

dialog .dialog-title h2 {
  overflow-wrap: anywhere;
}

dialog .dialog-tools {
  flex-wrap: wrap;
}

dialog :is(.dialog-title, .dialog-tools) .btn,
dialog .form-actions .btn {
  min-block-size: 44px;
  max-inline-size: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

dialog .form-actions {
  flex-wrap: wrap;
  gap: 10px 12px;
}

/* Align buttons to their body's existing gutter. Earlier negative margins use
   several different historical gutter widths and can overrun the dialog. */
dialog:is(.modal, .drawer) .form-actions {
  margin-inline: 0;
  padding-inline: 0;
  max-inline-size: 100%;
}

@media (max-width: 680px) {
  .toolbar .search,
  .toolbar .filters {
    flex-basis: 100%;
    max-inline-size: 100%;
  }

  .toolbar .filters > select {
    max-inline-size: 100%;
  }

  .toolbar > .hint {
    flex-basis: 100%;
  }

  .table-foot {
    padding: 16px;
    gap: 12px 16px;
  }

  .overview-workspace .overview-filter-footer {
    gap: 10px;
    padding-block-end: 16px;
  }

  .overview-filters select,
  .filters select,
  .overview-search-row input {
    font-size: 16px;
  }

  dialog .modal-head {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 10px 12px;
  }

  dialog .dialog-tools {
    margin-inline-start: auto;
    gap: 8px;
  }

  dialog:not(.unsaved-dialog) .form-actions .btn {
    flex: 1 1 140px;
  }

  dialog:not(.unsaved-dialog) .form-actions .btn.primary {
    flex-basis: 100%;
  }
}

@media (forced-colors: active) {
  select:not([multiple]):not([size]),
  select[size="1"]:not([multiple]) {
    -webkit-appearance: auto;
    appearance: auto;
    background-image: none;
  }
}

/* Office task filters stay grouped and align above the results table. */
.toolbar.workflow-toolbar {
  display: grid;
  grid-template-columns: minmax(16rem, 2fr) minmax(8rem, 1fr) minmax(8rem, 1fr) auto;
  align-items: end;
  gap: 12px 16px;
}

.workflow-toolbar > label,
.workflow-search-field {
  display: grid;
  gap: 6px;
  min-inline-size: 0;
  font-size: 13px;
}

.workflow-toolbar .search,
.workflow-toolbar select {
  inline-size: 100%;
  max-inline-size: none;
}

.workflow-toolbar input,
.workflow-toolbar select {
  min-block-size: 44px;
}

.workflow-toolbar .search svg {
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

.workflow-filter-summary,
.workflow-batch-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.workflow-filter-summary {
  min-block-size: 44px;
  justify-content: flex-end;
}

.workflow-batch-controls {
  grid-column: 1 / -1;
}

@media (max-width: 1100px) {
  .toolbar.workflow-toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workflow-search-field, .workflow-filter-summary { grid-column: 1 / -1; }
  .workflow-filter-summary { min-block-size: 0; justify-content: flex-start; }
}
