/* Loaded after MudBlazor and the component bundle so these bounds win.
   The shell is a viewport flex column. The TEST MODE banner and the menu bar
   take their own height. The active tab pane gets whatever is left, so a
   Height=100% grid has a real height and scrolls its body. Document pages
   scroll inside the pane instead of the window. */

html, body {
    height: 100%;
    margin: 0;
    overflow: hidden;
}

#app {
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

/* One page root fills the pane as a column, so toolbars stay put and the
   grid takes the rest. Several roots (a toolbar, then tabs) keep the last
   one as the filler. A page with no grid still scrolls inside that filler.
   flex-basis 0, not auto: an auto basis is the row content, and the table
   then grows to thousands of pixels inside an overflow:hidden pane. */
.sc-tab-pane > * {
    flex: 0 0 auto;
    min-width: 0;
    max-width: 100%;
}

.sc-tab-pane > :only-child,
.sc-tab-pane > :last-child:not(:only-child) {
    flex: 1 1 0%;
    min-height: 0;
    overflow: auto;
}

/* Horizontal shells set display:flex and leave flex-direction at row.
   flex-direction is its own property, so this rule has to skip them.
   .mud-tabs is skipped too: a left tab bar is a row, and forcing a column
   pushes the job editor's grids under the tab list. */
.sc-tab-pane > :only-child:not(.clock-punches):not(.timecards):not(.bidding-rates-page):not(.mud-tabs),
.sc-shell .sc-tab-pane > :last-child:has(.tckrd-grid):not(.clock-punches):not(.timecards):not(.bidding-rates-page):not(.mud-tabs) {
    display: flex;
    flex-direction: column;
}

.sc-shell .sc-tab-pane > :is(:only-child, :last-child):has(.tckrd-grid) > .mud-grid {
    flex: 1 1 0%;
    min-height: 0;
    height: auto;
}

/* Mud 9 names the cell mud-grid-item. min-height:auto is the table, so a
   row of 150 reports grows the paper and the footer sits under the pane. */
.sc-shell .mud-grid-item:has(.tckrd-grid) {
    display: flex;
    flex-direction: column;
    align-self: stretch;
    height: 100%;
    max-height: 100%;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

/* These hosts are the scroll boundary. The pane's only-child rule sets
   overflow:auto, which lets the host grow with the rows and clips the footer. */
.sc-shell .sc-tab-pane > :is(.sc-jobs-page, .bid-manager-page),
.sc-shell .sc-tab-pane > .mud-paper:has(.tckrd-grid) {
    overflow: hidden;
    height: auto;
    min-height: 0;
}

/* Job Manager's wrapper has no stylesheet of its own. */
.sc-jobs-page {
    display: flex;
    flex-direction: column;
    flex: 1 1 0%;
    min-height: 0;
    height: auto;
    overflow: hidden;
}

/* Bidding rates is a row under its own toolbar. height:100% is the whole
   pane, so the sheet's scrollport hangs past the window. */
.sc-tab-pane > .bidding-rates-page {
    display: flex;
    flex: 1 1 0%;
    flex-direction: row;
    height: auto;
    min-height: 0;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

/* Mud's active panel is display:contents, so the panel's children are the
   flex items of .mud-tabs-panels. The panels box has to be a definite-height
   column or those children grow with their rows (Billing, Job tabs). */
.sc-shell .mud-tabs {
    min-height: 0;
    min-width: 0;
}

.sc-shell .sc-tab-pane > .mud-tabs,
.sc-shell .sc-tab-pane > :only-child > .mud-tabs,
.sc-shell .sc-tab-pane > :last-child.mud-tabs {
    flex: 1 1 0%;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    height: auto;
}

.sc-shell .mud-tabs-panels {
    flex: 1 1 0%;
    min-height: 0;
    min-width: 0;
    height: auto;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sc-shell .mud-tabs-panels > .mud-tab-panel-active > * {
    min-width: 0;
    min-height: 0;
    box-sizing: border-box;
}

.sc-shell .mud-tabs-panels > .mud-tab-panel-active > :last-child,
.sc-shell .mud-tabs-panels > .mud-tab-panel-active > :only-child {
    flex: 1 1 0%;
    min-height: 0;
    overflow: auto;
}

.sc-shell .mud-tabs-panels > .mud-tab-panel-active > :is(:last-child, :only-child):has(.tckrd-grid) {
    display: flex;
    flex-direction: column;
    flex: 1 1 0%;
    min-height: 0;
    height: auto;
    overflow: hidden;
}

/* MudStack is d-flex flex-column, not .mud-stack. A toolbar or filter, then
   a wrapper (.sm-grid), then the grid. The wrapper has to take the free
   space or the table grows under the pane. Dialogs are outside the panels. */
.sc-shell .mud-tabs-panels .d-flex.flex-column > :has(.tckrd-grid),
.sc-shell .tasks-grid-host {
    flex: 1 1 0%;
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: auto;
    overflow: hidden;
}

/* The component sheet sets height:100% on .tckrd-grid. That percentage is the
   whole page, including sibling toolbars, so the footer lands past the pane.
   flex-basis 0 fills only the free space. Do not set max-height:100% here:
   that percentage is the whole parent, so a grid beside a toolbar is one
   toolbar too tall. Inline height from Mud is beaten below. */
.sc-shell .tckrd-row-edit-gate,
.sc-shell .tckrd-grid,
.sc-shell .mud-data-grid {
    display: flex;
    flex-direction: column;
    height: auto;
    flex: 1 1 0%;
    min-height: 0;
    min-width: 0;
    max-height: none;
    overflow: hidden;
}

/* A pixel Height stays that tall and scrolls itself. flex-grow would stretch
   it to the row content and throw away the pixel height. */
.sc-shell .mud-data-grid > .mud-table-container[style*="height:"] {
    flex: 0 0 auto;
    min-height: 0;
    overflow: auto;
}

/* Height=100% is an inline style, so it beats the class and sizes the
   container to an indefinite parent. The flex slot is the real height. */
.sc-shell .mud-data-grid > .mud-table-container[style*="height:100%"],
.sc-shell .mud-data-grid > .mud-table-container[style*="height: 100%"] {
    flex: 1 1 0% !important;
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    overflow: auto !important;
}

/* The week board fills a hybrid WebView with 100vh. Inside the shell that
   is taller than the pane (banner + menu), so let the flex slot size it. */
.sc-shell .ftb-page {
    height: auto;
    max-height: 100%;
}
