/*
 * Clients, and the two parts the one table pattern gained for long lists
 * (sortable headers, rows added as she scrolls). Every colour is a variable
 * from theme.css; no hex value here. Nothing has a fixed height that holds
 * words: text wraps and boxes grow.
 */

/* The table: sortable headers -------------------------------------------- */

.tbl th.is-sortable {
  padding: 0;
}

.tbl-sort {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 600;
  text-align: inherit;
}

.tbl .is-num .tbl-sort {
  justify-content: flex-end;
}

.tbl-sort:hover {
  color: var(--ink);
}

.tbl-sort.is-on {
  color: var(--ink);
}

/* The arrow shows only on the column sorted by: up for A to Z, down for Z to A. */
.tbl-sort__arrow {
  flex: 0 0 auto;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 5px solid currentColor;
  opacity: 0;
}

.tbl-sort.is-on .tbl-sort__arrow {
  opacity: 1;
}

.tbl-sort.is-desc .tbl-sort__arrow {
  border-bottom: 0;
  border-top: 5px solid currentColor;
}

.tbl-more td {
  height: 1px;
  padding: 0;
  border: 0;
}

.quiet {
  color: var(--ink-2);
}

/* Short facts that read wrong broken in two (a phone number, a date, a time,
   an amount): the column grows to fit them instead. */
.tbl .nowrap,
.clients-table .is-num,
.client-page .tbl .is-num {
  white-space: nowrap;
}

/* The list -------------------------------------------------------------- */

.clients-head {
  justify-content: space-between;
  align-items: center;
}

.clients-head__new svg,
.client-head__actions svg,
.card__actions svg,
.new-client svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.clients-numbers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: var(--gap-2);
}

/* Five cards (Quotes) fit one row at 1280 as four do (D11): at 190 the fifth sat
   alone on a second row. */
.clients-numbers:has(> :nth-child(5):last-child) {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.clients-number {
  align-content: start;
  align-items: start;
  background: var(--card);
  box-shadow: 0 0 0 1px var(--card-ring);
}

.figure.clients-number + .figure.clients-number {
  box-shadow: 0 0 0 1px var(--card-ring);
}

.clients-number:hover {
  background: var(--hover);
  box-shadow: 0 0 0 1px var(--card-ring);
}

/* A number that is filtering the table says so: the brand ring and fill. */
.clients-number[aria-pressed="true"],
.clients-number[aria-pressed="true"]:hover {
  box-shadow: 0 0 0 2px var(--brand);
  background: var(--card);
}

.clients-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap-1) 12px;
  margin-bottom: 12px;
}

.clients-find {
  flex: 0 1 420px;
}

.clients-showing {
  color: var(--ink-2);
  font-weight: 600;
}

/* The header stays under the band while the page scrolls. */
.clients-table .tbl th {
  top: var(--band-height);
}

.clients-owed {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 2px 10px;
}

/* One client ------------------------------------------------------------- */

.clients-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: var(--gap-1);
  color: var(--ink-2);
  font-weight: 600;
  text-decoration: none;
}

.clients-back:hover {
  color: var(--ink);
}

.clients-back__arrow {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transform: rotate(180deg);
}

.client-head {
  justify-content: space-between;
  align-items: center;
}

.client-head__actions,
.card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-1);
}

.card__head .card__actions {
  margin-left: auto;
}

.client-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  gap: var(--gap-2);
  align-items: start;
}

.client-page__main,
.client-page__side {
  display: grid;
  gap: var(--gap-2);
  min-width: 0;
}

@media (max-width: 1180px) {
  .client-page {
    grid-template-columns: minmax(0, 1fr);
  }
}

.props {
  margin: 0;
  padding: 0 0 8px;
  list-style: none;
}

.props__item {
  display: flex;
  align-items: flex-start;
  gap: var(--gap-2);
  padding: 12px 20px;
  border-top: 1px solid var(--line);
}

.props__text {
  flex: 1;
  display: grid;
  gap: 2px;
  min-width: 0;
}

.props__address {
  font-weight: 600;
}

.props__notes {
  white-space: pre-wrap;
}

.props__jobs {
  color: var(--ink-2);
  font-size: var(--size-small);
}

/* New client ------------------------------------------------------------ */

.new-client {
  max-width: 880px;
  padding: 20px;
}

.new-client__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: var(--gap-2);
}

.new-client__sub {
  margin: var(--gap-1) 0 12px;
}

.new-prop {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  align-items: start;
  column-gap: var(--gap-2);
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.new-prop__remove {
  margin-top: 26px;
}

.new-job .new-client__sub:not(:first-child) {
  margin-top: var(--gap-3);
}

.new-job__message {
  margin-top: var(--gap-2);
}

.new-job__find {
  display: grid;
  gap: var(--gap-1);
  justify-items: start;
}

.new-job__find .field,
.new-job__find .money-pick {
  width: 100%;
}

.new-job__when {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.new-job__ends {
  margin-top: var(--gap-1);
  font-size: var(--size-small);
}

.new-job__ends:empty {
  display: none;
}

.new-job__repeat {
  margin-top: var(--gap-2);
}

.new-job__address {
  margin: var(--gap-2) 0;
}

.new-job__people {
  max-height: 320px;
  overflow-y: auto;
}

.new-client__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-1);
  margin-top: var(--gap-3);
}

.field-area {
  min-height: 44px;
  padding: 10px 12px;
  font: inherit;
  resize: vertical;
}

select.field-input {
  font: inherit;
}

/* Forms in the side panel ------------------------------------------------ */

.panel-form {
  padding: 4px 20px 0;
}

.panel-form .drawer__actions {
  padding: 4px 0 20px;
}

.panel-form__remove {
  margin-left: auto;
}
