/* The back office on a computer: less scrolling. Rows are tighter, short sections of a record sit
   side by side, a date and its time share a line, paired fields share a row in a split record's
   left column, and a list's search and filters share one. Loaded after backoffice.css; phones and
   narrow windows keep their own layouts (phone.css). */
@media (min-width: 1100px) {
  /* ---- 1. Tighter rows ---- */
  #content { padding-top: 14px; }
  #content h1 { margin-bottom: 10px; }
  .record-bar { margin-top: -6px; margin-bottom: 10px; padding-top: 7px; padding-bottom: 7px; }
  .aligned .form-row, .record-head .form-row, .split-left .aligned .form-row { padding: 4px 10px; }
  :is(fieldset.module, .inline-group) h2 { padding: 8px 10px 5px; }
  body.change-form #content-main :is(fieldset.module, .inline-group) { margin-bottom: 10px; }
  .record-head fieldset.module { margin-bottom: 4px; }
  .inline-group .tabular tbody tr.form-row > td { padding-top: 4px; padding-bottom: 2px; }
  .inline-group .tabular tr.add-row td { padding-top: 5px; padding-bottom: 5px; }
  /* A line's pick-several box with one choice (its one tax) is one row tall (backoffice.js 15). */
  .inline-group .tabular td select.one-choice { height: 29px; overflow: hidden; }
  .side-table th, .side-table td { padding: 4px 10px; }
  .side-more, .side-empty { margin: 5px 10px; }
  .process-bar { margin-bottom: 8px; }
  .record-foot { margin-top: 14px; }
  form .aligned p.datetime { padding: 0; }
  .aligned textarea { min-height: 0; }

  /* Lists: shorter rows (a product's picture smaller), less around them. */
  #result_list tbody :is(td, th) { padding-top: 5px; padding-bottom: 5px; vertical-align: middle; }
  #result_list tbody img { width: 28px !important; height: 28px !important; vertical-align: middle; }
  /* Short values (a type, a status, a date, a unit) stay on one line, so they don't make a row two tall. */
  #result_list tbody td:is(.field-type, .field-procurement, .field-state, .field-kind, .field-uom, .field-status,
                           [class*="date"], [class*="_at"]) { white-space: nowrap; }
  #changelist .actions { padding-top: 6px; padding-bottom: 6px; }
  #changelist .paginator { padding-top: 6px; padding-bottom: 6px; }

  /* ---- 2. A list's search and its filters on one row ---- */
  .changelist-form-container { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 16px;
                               align-items: center; }
  .changelist-form-container > * { grid-column: 1 / -1; min-width: 0; }
  .changelist-form-container > .list-toolbar { grid-column: 1; margin-bottom: 8px; }
  .changelist-form-container > .list-filters { grid-column: 2; margin: 0 0 8px; }
  .changelist-form-container > .list-toolbar #toolbar { padding: 0; border: 0; background: none; }

  /* ---- 3. A date and its time on one line: "Date:" and "Time:" go, the boxes say which ---- */
  p.datetime { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; font-size: 0; }
  p.datetime br { display: none; }
  p.datetime > * { font-size: 0.8125rem; }
  p.datetime input.vDateField { width: 7.5em; margin: 0; }
  p.datetime input.vTimeField { width: 5.5em; margin: 0 0 0 6px; }
  /* Its calendar and clock stay; their pop-ups have Today and Now, so the words beside them go. */
  p.datetime .datetimeshortcuts { font-size: 0; white-space: nowrap; }
  p.datetime .datetimeshortcuts a:not(:has(.date-icon, .clock-icon)) { display: none; }
  p.datetime .timezonewarning { flex-basis: 100%; }

  /* ---- 4. A one-column record's short sections side by side ----
     Each titled section (Dates, Locations, Links, Notes) takes a column; lines, panels and the
     record's head keep the whole width. One holding a table takes two columns. */
  body.change-form #content-main form > div:not(:has(> .split-layout)) {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 0 28px; align-items: start;
  }
  body.change-form #content-main form > div:not(:has(> .split-layout)) > * { grid-column: 1 / -1; min-width: 0; }
  body.change-form #content-main form > div:not(:has(> .split-layout)) > fieldset.module.aligned:has(> h2):not(.side-panel) {
    grid-column: auto;
  }
  body.change-form #content-main form > div:not(:has(> .split-layout)) > fieldset.module.aligned:has(> h2):has(.side-table):not(.side-panel) {
    grid-column: span 2;
  }
  /* A two-list picker (a user's groups and permissions) needs the whole width. */
  body.change-form #content-main form > div:not(:has(> .split-layout)) > fieldset.module.aligned:has(> h2):has(.selector, .inline-group) {
    grid-column: 1 / -1;
  }
  /* In a column: a narrower label, and boxes that fill what's left instead of their fixed widths. */
  form > div:not(:has(> .split-layout)) > fieldset.module.aligned:has(> h2):not(.side-panel) .flex-container > label:not(.vCheckboxLabel) {
    flex: none; width: 124px; min-width: 124px;
  }
  form > div:not(:has(> .split-layout)) > fieldset.module.aligned:has(> h2):not(.side-panel) .flex-container > :is(input:not([type=checkbox]):not(.vDateField):not(.vTimeField), textarea, select, .related-widget-wrapper) {
    flex: 1 1 auto; min-width: 0; max-width: 100%; box-sizing: border-box;
  }
  form > div:not(:has(> .split-layout)) > fieldset.module.aligned:has(> h2):not(.side-panel) .flex-container > textarea { width: 100%; }
  form > div:not(:has(> .split-layout)) > fieldset.module.aligned:has(> h2):not(.side-panel) :is(div.help, ul.errorlist) {
    margin-left: 134px; padding-left: 0;
  }
  form > div:not(:has(> .split-layout)) > fieldset.module.aligned:has(> h2):not(.side-panel) .readonly { margin-left: 0 !important; flex: 1 1 auto; min-width: 0; }
  form > div:not(:has(> .split-layout)) > fieldset.module.aligned:has(> h2):not(.side-panel) .readonly :is(p, ul) { margin-left: 0; padding-left: 0; }

  /* ---- 5. A split record's paired fields share a row while its left column has the room ---- */
  @container details (min-width: 540px) {
    .split-left .form-multiline { flex-direction: row; flex-wrap: nowrap; gap: 0 14px; }
    .split-left .form-multiline > div { flex: 1 1 0; width: auto; min-width: 0; }
    .split-left .form-multiline > div:first-child { flex-grow: 1.35; }  /* its label has the label column */
    .split-left .form-multiline > div > .fieldBox, .split-left .form-multiline .flex-container { width: 100%; }
    .split-left .form-multiline .flex-container > :is(input:not([type=checkbox]), select, .related-widget-wrapper) {
      flex: 1 1 0; width: 0; min-width: 3.5em;
    }
    .split-left .aligned .form-multiline > div + div > .fieldBox > label:not(.vCheckboxLabel) {
      width: auto; min-width: 0; max-width: 9.5em; padding-left: 0; padding-right: 8px;
    }
  }
}
