/* =============================================================================
   OrganicSystem — ERP Dynamic Height
   Grid hosts fill Available = viewport − chrome − margins.
   No hardcoded pixel heights on page grids.
   ============================================================================= */

:root {
  --os-dh-min: 180px;
}

/* Fill hosts sized by os-dynamic-height.js */
.os-dh-fill,
[data-os-dh-fill="1"] {
  box-sizing: border-box !important;
  flex: 1 1 auto !important;
  min-height: var(--os-dh-min) !important;
  overflow: hidden !important;
  max-width: 100% !important;
}

.os-dh-fill > .dx-datagrid,
[data-os-dh-fill="1"] > .dx-datagrid,
.os-dh-fill.dx-datagrid,
[data-os-dh-fill="1"].dx-datagrid {
  height: 100% !important;
  min-height: 0 !important;
  max-height: 100% !important;
  flex: 1 1 auto !important;
  width: auto !important;
  max-width: 100% !important;
  overflow: hidden !important;
}

/* Neutralize legacy hardcoded floors — JS sets the real height */
.plan-grids-row {
  min-height: 0 !important;
}

.plan-grid-panel > [id$="-grid"] {
  min-height: var(--os-dh-min) !important;
}

.ags-farms-sites-grid,
.ags-farms-plots-grid,
.aps-sites-page .os-dx-grid,
.aps-sites-page #aps-sites-grid,
.ags-find-replace-grid {
  min-height: var(--os-dh-min) !important;
  height: auto;
}

.ags-find-replace-grid.os-dh-fill,
.ags-find-replace-grid[data-os-dh-fill="1"] {
  height: var(--os-dh-applied, auto) !important;
}

/*
  Document-flow DH hosts (no --fill marker): page owns Y.
  Viewport-fitted / --fill hosts: rowsview clips; scrollable-container owns Y
  (matches os-scroll-engine — avoids double bars / missing native scrollbar).
*/
html[data-os-dh="fill"]:not([data-os-grid-scroll="internal"]) .os-dh-fill:not(.os-dx-grid--fill):not([data-os-grid-internal-scroll="1"]) .dx-datagrid-rowsview,
html[data-os-dh="fill"]:not([data-os-grid-scroll="internal"]) [data-os-dh-fill="1"]:not(.os-dx-grid--fill):not([data-os-grid-internal-scroll="1"]) .dx-datagrid-rowsview {
  overflow-x: auto !important;
  overflow-y: visible !important;
}

html[data-os-dh="fill"] .os-dh-fill.os-dx-grid--fill .dx-datagrid-rowsview,
html[data-os-dh="fill"] [data-os-dh-fill="1"].os-dx-grid--fill .dx-datagrid-rowsview,
html[data-os-dh="fill"] [data-os-grid-internal-scroll="1"] .dx-datagrid-rowsview,
html[data-os-grid-scroll="internal"] .os-dh-fill .dx-datagrid-rowsview {
  overflow-x: hidden !important;
  overflow-y: hidden !important;
}

html[data-os-dh="fill"] .os-dh-fill.os-dx-grid--fill .dx-datagrid-rowsview.dx-scrollable-native .dx-scrollable-container,
html[data-os-dh="fill"] [data-os-dh-fill="1"].os-dx-grid--fill .dx-datagrid-rowsview.dx-scrollable-native .dx-scrollable-container,
html[data-os-dh="fill"] [data-os-grid-internal-scroll="1"] .dx-datagrid-rowsview.dx-scrollable-native .dx-scrollable-container,
html[data-os-grid-scroll="internal"] .os-dh-fill .dx-datagrid-rowsview.dx-scrollable-native .dx-scrollable-container {
  overflow-x: auto !important;
  overflow-y: auto !important;
}

/* Stacked split still grows naturally (second pane never clipped) */
.os-split-view[data-os-split-mode="stack"] .os-dh-fill,
.os-split-view[data-os-split-mode="stack"] [data-os-dh-fill="1"] {
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
}
