/* UA-ERP GLOBAL MODAL SPACING FIX V2 START */

/*
 * Єдині відступи для модальних вікон складського обліку.
 * Прямі кути збережено: border-radius не використовується.
 */

dialog.wh-v30-modal,
dialog.wh-v31-modal {
  box-sizing: border-box !important;
  width: calc(100vw - 24px) !important;
  max-width: 1680px !important;
  height: calc(100vh - 24px) !important;
  max-height: calc(100vh - 24px) !important;
  margin: auto !important;
  padding: 20px 24px 22px !important;
  border-radius: 0 !important;
  overflow-x: hidden !important;
}

dialog.wh-v30-modal *,
dialog.wh-v31-modal * {
  box-sizing: border-box;
  min-width: 0;
}

dialog.wh-v30-modal > *,
dialog.wh-v31-modal > * {
  max-width: 100%;
}

dialog.wh-v30-modal form,
dialog.wh-v31-modal form {
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

dialog.wh-v30-modal :is(input, select, textarea),
dialog.wh-v31-modal :is(input, select, textarea) {
  box-sizing: border-box !important;
  width: 100% !important;
  max-width: 100% !important;
}

dialog.wh-v30-modal textarea,
dialog.wh-v31-modal textarea {
  resize: vertical;
}

dialog.wh-v30-modal :is(
  .modal-body,
  .dialog-body,
  .wh-modal-body,
  [data-modal-body],
  [class*="modal-body"],
  [class*="dialog-body"]
),
dialog.wh-v31-modal :is(
  .modal-body,
  .dialog-body,
  .wh-modal-body,
  [data-modal-body],
  [class*="modal-body"],
  [class*="dialog-body"]
) {
  box-sizing: border-box !important;
  width: 100% !important;
  max-width: 100% !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  overflow-x: hidden !important;
}

dialog.wh-v30-modal :is(
  .form-grid,
  .fields-grid,
  .modal-grid,
  .dialog-grid,
  .wh-grid,
  [class*="grid"]
),
dialog.wh-v31-modal :is(
  .form-grid,
  .fields-grid,
  .modal-grid,
  .dialog-grid,
  .wh-grid,
  [class*="grid"]
) {
  max-width: 100% !important;
  gap: 16px !important;
}

dialog.wh-v30-modal :is(
  .form-group,
  .field-group,
  .control-group,
  .wh-field,
  [class*="field"]
),
dialog.wh-v31-modal :is(
  .form-group,
  .field-group,
  .control-group,
  .wh-field,
  [class*="field"]
) {
  min-width: 0 !important;
}

/* Нижня панель також не повинна торкатися країв. */
dialog.wh-v30-modal :is(
  footer,
  .modal-footer,
  .dialog-footer,
  .wh-modal-footer,
  [data-modal-footer]
),
dialog.wh-v31-modal :is(
  footer,
  .modal-footer,
  .dialog-footer,
  .wh-modal-footer,
  [data-modal-footer]
) {
  box-sizing: border-box !important;
  margin-left: -24px !important;
  margin-right: -24px !important;
  margin-bottom: -22px !important;
  padding: 18px 24px !important;
  width: calc(100% + 48px) !important;
  max-width: none !important;
}

/* Компенсація для заголовка, щоб лінія й фон залишалися на всю ширину. */
dialog.wh-v30-modal :is(
  header,
  .modal-header,
  .dialog-header,
  .wh-modal-header,
  [data-modal-header]
),
dialog.wh-v31-modal :is(
  header,
  .modal-header,
  .dialog-header,
  .wh-modal-header,
  [data-modal-header]
) {
  box-sizing: border-box !important;
  margin-left: -24px !important;
  margin-right: -24px !important;
  margin-top: -20px !important;
  padding: 20px 24px 18px !important;
  width: calc(100% + 48px) !important;
  max-width: none !important;
}

@media (max-width: 900px) {
  dialog.wh-v30-modal,
  dialog.wh-v31-modal {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    padding: 16px !important;
  }

  dialog.wh-v30-modal :is(
    footer,
    .modal-footer,
    .dialog-footer,
    .wh-modal-footer,
    [data-modal-footer]
  ),
  dialog.wh-v31-modal :is(
    footer,
    .modal-footer,
    .dialog-footer,
    .wh-modal-footer,
    [data-modal-footer]
  ) {
    margin-left: -16px !important;
    margin-right: -16px !important;
    margin-bottom: -16px !important;
    padding: 14px 16px !important;
    width: calc(100% + 32px) !important;
  }

  dialog.wh-v30-modal :is(
    header,
    .modal-header,
    .dialog-header,
    .wh-modal-header,
    [data-modal-header]
  ),
  dialog.wh-v31-modal :is(
    header,
    .modal-header,
    .dialog-header,
    .wh-modal-header,
    [data-modal-header]
  ) {
    margin-left: -16px !important;
    margin-right: -16px !important;
    margin-top: -16px !important;
    padding: 16px !important;
    width: calc(100% + 32px) !important;
  }
}

/* UA-ERP GLOBAL MODAL SPACING FIX V2 END */
