/* Vaca Orders app: only what components.css lacks. Tokens only. */

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}
.stack {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: minmax(0, 1fr);
}
.is-hidden {
  display: none !important;
}
.t-right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.shell {
  min-height: 100vh;
}
.shell__col {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.shell__col > .page {
  flex: 1;
  grid-template-columns: minmax(0, 1fr);
}
.topbar__search {
  flex: 1 1 20rem;
  min-width: 12rem;
}
.topbar__spacer {
  flex: 0 1 0;
}

/* Topbar: demo flag and role switch */
.topbar__user {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.topbar__user .icon {
  width: 1rem;
  height: 1rem;
}
.role-switch {
  display: grid;
  gap: 0;
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.role-switch .select {
  width: auto;
  height: var(--control-height-sm);
  font-size: var(--text-sm);
}
.topbar .badge {
  flex: none;
}

/* Rail footer */
.rail__reset {
  margin-top: auto;
  min-height: var(--control-height-sm);
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--text-on-shell-muted);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-on-shell-muted);
  font: inherit;
  font-size: var(--text-xs);
  line-height: var(--leading-tight);
  text-align: left;
  cursor: pointer;
}
.rail__reset:hover,
.rail__reset.is-armed {
  background: var(--surface-shell-hover);
  color: var(--text-on-shell);
  border-color: var(--text-on-shell);
}
.rail__reset:focus-visible {
  box-shadow:
    0 0 0 2px var(--surface-shell),
    0 0 0 4px var(--text-on-shell);
}
.rail__reset:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Rail footer: the demo reset button. On wide screens the rail is pinned to the viewport, so
   it stays at the bottom left on every page; its colour continues down the page behind it. */
.rail__foot {
  margin-top: auto;
  display: grid;
  gap: var(--space-3);
}

@media (min-width: 56.0625rem) {
  .shell {
    background: linear-gradient(
      to right,
      var(--surface-shell) var(--rail-width),
      var(--surface-ground) var(--rail-width)
    );
  }
  .rail {
    position: sticky;
    top: 0;
    align-self: start;
    box-sizing: border-box;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
  }
  /* The demo badge makes the bar wider than the page between 56rem and about 1050px: with it, break into
     two rows when even the minimum sizes do not fit. Without the badge (production) nothing changes. */
  .topbar:has(> .badge) {
    flex-wrap: wrap;
  }
  .topbar:has(> .badge) .topbar__search {
    flex-basis: 12rem;
  }
}

/* Filters bar */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--space-3);
}
.filters .field {
  gap: 2px;
}
.filters .field__label {
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.filters .select {
  width: auto;
  min-width: 9rem;
  height: var(--control-height-sm);
  font-size: var(--text-sm);
}

/* Table helpers */
.cell-sub {
  display: block;
  max-width: 18rem;
  margin-top: 2px;
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
  color: var(--text-muted);
  white-space: normal;
}
.table tbody td {
  padding-top: var(--space-1);
  padding-bottom: var(--space-1);
}
.table .row-link {
  display: inline-block;
}
.table tbody tr[data-href] {
  cursor: pointer;
}

/* Key/value list for detail pages */
.kv {
  display: grid;
  grid-template-columns: minmax(8rem, max-content) minmax(0, 1fr);
  gap: var(--space-1) var(--space-4);
  margin: 0;
}
.kv dt {
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.kv dd {
  margin: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 56rem) {
  .rail__reset {
    margin: 0 0 0 auto;
    flex: none;
    white-space: nowrap;
  }
  .rail__foot {
    margin: 0 0 0 auto;
    display: flex;
    align-items: center;
    gap: var(--space-2);
  }
  .topbar {
    flex-wrap: wrap;
  }
  .topbar__search {
    flex: 1 1 14rem;
  }
  .topbar__spacer {
    display: none;
  }
}

@media (max-width: 44rem) {
  .kv {
    grid-template-columns: minmax(0, 1fr);
  }
  .kv dd {
    margin-bottom: var(--space-2);
  }
}

@media (max-width: 40rem) {
  .topbar > .btn--primary {
    order: 0;
  }
  .topbar__search {
    order: 1;
    flex: 1 1 100%;
    max-width: none;
  }
  .topbar > .badge,
  .topbar > .role-switch,
  .topbar > .topbar__user {
    order: 2;
  }
  .filters .field {
    flex: 1 1 8rem;
  }
  .filters .select {
    width: 100%;
    min-width: 0;
  }
  .tabs {
    overflow-x: auto;
  }
  .tab {
    white-space: nowrap;
  }
}

/* Avoid one-word last lines in running text */
.reconcile,
.alert__text,
.alert__list li,
.section__note,
.page__sub,
.field__hint {
  text-wrap: pretty;
}
