/*
 * PZ-Med: единая геометрия строк «поле/селект/чекбокс + действие».
 *
 * Не меняем глобально все кнопки: в приложении есть намеренно компактные
 * и icon-only controls. Здесь нормализуются только типовые строки форм,
 * где действие должно совпадать по верхней и нижней границе с соседним
 * однострочным control.
 */

:root {
  --pz-control-height: 44px;
  --pz-control-gap: 12px;
}

/*
 * Полноразмерные рабочие строки. Большинство этих контейнеров уже flex/grid;
 * column-gap гарантирует, что кнопка не прилипнет к соседнему полю, а
 * row-gap остаётся за конкретной адаптивной раскладкой страницы.
 */
:where(
  .ui-control-group,
  .inline-form,
  .employee-add-grid,
  .duty-settings-form,
  .slot-edit-form,
  .vacation-form,
  .vacation-admin-filter,
  .vacation-manual-form,
  .vacation-public-filter,
  .table-report-item-form,
  .table-report-period-create,
  .table-report-archive-filters,
  .table-report-copy-form,
  .duty-type-search,
  .who-is-receiving-filters,
  .timesheet-filters,
  .timesheet-draft-actions
) {
  --pz-row-control-height: var(--pz-control-height);
  column-gap: var(--pz-control-gap);
}

/* Старый global label имеет внешние margin; у label-контейнера поля это
 * сдвигает нижнюю границу относительно соседней кнопки. */
:where(
  .ui-control-group,
  .inline-form,
  .employee-add-grid,
  .duty-settings-form,
  .slot-edit-form,
  .vacation-form,
  .vacation-admin-filter,
  .vacation-manual-form,
  .vacation-public-filter,
  .table-report-item-form,
  .table-report-period-create,
  .table-report-archive-filters,
  .table-report-copy-form,
  .duty-type-search,
  .who-is-receiving-filters,
  .timesheet-filters
) > label {
  margin-block: 0;
}

/* Однострочные поля внутри нормализованных строк. */
:where(
  .ui-control-group,
  .inline-form,
  .employee-add-grid,
  .duty-settings-form,
  .slot-edit-form,
  .vacation-form,
  .vacation-admin-filter,
  .vacation-manual-form,
  .vacation-public-filter,
  .table-report-item-form,
  .table-report-period-create,
  .table-report-archive-filters,
  .table-report-copy-form,
  .duty-type-search,
  .who-is-receiving-filters,
  .timesheet-filters
) :is(
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]):not([type="range"]):not([type="color"]),
  select
) {
  box-sizing: border-box;
  height: var(--pz-row-control-height);
  min-height: var(--pz-row-control-height);
}

/* Кнопка/ссылка-действие, стоящая непосредственно в строке. */
:where(
  .ui-control-group,
  .inline-form,
  .employee-add-grid,
  .duty-settings-form,
  .slot-edit-form,
  .vacation-form,
  .vacation-admin-filter,
  .vacation-manual-form,
  .vacation-public-filter,
  .table-report-item-form,
  .table-report-period-create,
  .table-report-archive-filters,
  .table-report-copy-form,
  .duty-type-search,
  .who-is-receiving-filters,
  .timesheet-filters,
  .timesheet-draft-actions
) > :is(button, .btn, .button),
:where(
  .ui-control-group,
  .inline-form,
  .employee-add-grid,
  .duty-settings-form,
  .slot-edit-form,
  .vacation-form,
  .vacation-admin-filter,
  .vacation-manual-form,
  .vacation-public-filter,
  .table-report-item-form,
  .table-report-period-create,
  .table-report-archive-filters,
  .table-report-copy-form,
  .duty-type-search,
  .who-is-receiving-filters,
  .timesheet-filters,
  .timesheet-draft-actions
) > form > :is(button, .btn, .button),
:where(
  .ui-control-group,
  .employee-add-grid,
  .vacation-admin-filter,
  .vacation-manual-form,
  .vacation-public-filter,
  .table-report-period-create,
  .table-report-archive-filters
) > .form-actions > :is(button, .btn, .button),
:where(
  .ui-control-group,
  .employee-add-grid,
  .vacation-admin-filter,
  .vacation-manual-form,
  .vacation-public-filter,
  .table-report-period-create,
  .table-report-archive-filters
) > .form-actions > form > :is(button, .btn, .button) {
  box-sizing: border-box;
  height: var(--pz-row-control-height);
  min-height: var(--pz-row-control-height);
  margin-block: 0;
}

/* Внутренние action-контейнеры тоже не должны склеивать соседние кнопки. */
:where(
  .ui-control-group,
  .employee-add-grid,
  .vacation-admin-filter,
  .vacation-manual-form,
  .vacation-public-filter,
  .table-report-period-create,
  .table-report-archive-filters
) > .form-actions {
  gap: var(--pz-control-gap);
}

/* Современный реестр отсутствий использует собственный 42px control. */
.absence-modern-filter {
  --pz-row-control-height: 42px;
  column-gap: var(--pz-control-gap);
}

.absence-modern-filter :is(
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
  select
),
.absence-modern-filter__actions > :is(button, .btn, .button) {
  box-sizing: border-box;
  height: var(--pz-row-control-height);
  min-height: var(--pz-row-control-height);
  margin-block: 0;
}

.absence-modern-filter__actions {
  gap: var(--pz-control-gap);
}

/* Поиск в управлении алгоритмами: поле уже 42px, поднимаем до него действия. */
.algorithm-admin-search {
  --pz-row-control-height: 42px;
  column-gap: var(--pz-control-gap);
}

.algorithm-admin-search > input,
.algorithm-admin-search__actions > :is(button, .btn, .button) {
  box-sizing: border-box;
  height: var(--pz-row-control-height);
  min-height: var(--pz-row-control-height);
  margin-block: 0;
}

.algorithm-admin-search__actions {
  gap: 8px;
}

/* Публичный список алгоритмов: действия должны стоять на одной линии с input,
 * а не центрироваться относительно блока «label + input». */
.algorithm-list-search > :is(button, .btn, .button) {
  box-sizing: border-box;
  height: 42px;
  min-height: 42px;
  margin-block: 0;
}

@media (min-width: 761px) {
  .ui-toolbar.algorithm-list-search {
    align-items: flex-end;
  }
}

/* Учёт пациентов использует более крупные 48px controls. Формы уже выравнивают
 * grid-элементы по нижней границе, поэтому здесь синхронизируем именно высоту
 * однострочных полей и соседних действий. Это покрывает список, делегирование,
 * карточку пациента и быстрые формы внутри неё. */
:where(
  .patient-accounting-filter,
  .patient-accounting-observation-form,
  .patient-accounting-add-form,
  .patient-accounting-compact-form,
  .patient-passport-subcategory-row__form,
  .patient-passport-statistics-filter
) {
  --pz-row-control-height: 48px;
}

:where(
  .patient-accounting-filter,
  .patient-accounting-observation-form,
  .patient-accounting-add-form,
  .patient-accounting-compact-form,
  .patient-passport-subcategory-row__form,
  .patient-passport-statistics-filter
) :is(
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]):not([type="range"]):not([type="color"]),
  select
) {
  box-sizing: border-box;
  height: var(--pz-row-control-height);
  min-height: var(--pz-row-control-height);
}

.patient-accounting-form-actions > :is(button, .btn, .button),
:where(
  .patient-accounting-observation-form,
  .patient-accounting-add-form,
  .patient-accounting-compact-form,
  .patient-passport-subcategory-row__form
) > :is(button, .btn, .button),
.patient-passport-statistics-filter > div > :is(button, .btn, .button) {
  box-sizing: border-box;
  height: var(--pz-row-control-height);
  min-height: var(--pz-row-control-height);
  margin-block: 0;
}

.patient-accounting-form-actions {
  gap: var(--pz-control-gap);
}

/* «Кто принимает»: точное совпадение поля даты и кнопки «Показать». */
.who-is-receiving-submit {
  height: var(--pz-row-control-height);
  min-height: var(--pz-row-control-height);
  align-self: end;
}

/* Табель: фильтр сверху и рамочный checkbox в панели черновика. */
.timesheet-filter-submit {
  height: var(--pz-row-control-height);
  min-height: var(--pz-row-control-height);
  align-self: end;
}

.timesheet-worked-toggle {
  box-sizing: border-box;
  height: var(--pz-row-control-height);
  min-height: var(--pz-row-control-height);
  margin: 0;
}

.timesheet-draft-actions > form {
  display: inline-flex !important;
  margin: 0 !important;
  padding: 0 !important;
  align-items: stretch;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

/* Счётчик и шеврон сохранённых табелей имеют одну базовую геометрию. */
.timesheet-count,
.timesheet-chevron {
  box-sizing: border-box;
  min-height: 34px;
  height: 34px;
  line-height: 1;
  flex: 0 0 auto;
}

.timesheet-chevron {
  width: 34px;
  min-width: 34px;
  padding-inline: 0;
}

/*
 * Намеренно не включены компактные специализированные строки:
 * .duty-print-form (38px), .task-archive-search (38px),
 * .messages-compose (48px) и icon-only controls — у них уже согласованные
 * собственные размеры и их нельзя растягивать общим правилом.
 */
