/* --- Users (modules/users/views/list.php): one box filling the page, its 32px bar "Users" and its toolbar from the
   partner Overview (.overview__bar, .overview__toolbar, pages/dashboard.css), then the list straight in the box, its
   lines running edge to edge, its rows with initials (pages/clients.css). Phones to 1199px: the role and status under
   the name, an arrow at the right. From 1200px: a table, Name | Role | Belongs to | Status. --- */

.users {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 1fr; /* the box takes the whole screen, and grows with its content */
}

.users .box__toolbar {
  padding-inline: var(--sp-4); /* the buttons line up with the list under it (as Partners' search) */
}

/* The list straight in the box: the text size and spacing it had in its tile (.dashboard__tile), and no side padding
   of its own, so each row's line runs edge to edge; the rows and the column names carry the padding instead. */
.users .box__body {
  gap: var(--sp-3);
  padding-inline: 0;
  font-size: var(--fs-small);
}

.users__row,
.users__cols,
.users__none {
  padding-inline: var(--sp-4);
}

.users__rows {
  border-bottom: var(--border-1) solid var(--c-line);
}

@media (min-width: 768px) {
  .users .box__toolbar,
  .users__row,
  .users__cols,
  .users__none {
    padding-inline: var(--sp-6);
  }
}

/* Sort & filter and Search: a square button in the toolbar; under it a white panel with a dark bar (as Change dose,
   32px like the box's bar) and an × that closes it (site.js data-drop-close; a click outside or Escape too). From
   768px the panel opens leftwards from its button; below, it hangs from the toolbar, as wide as it less a small margin,
   so it never leaves the screen. */
.users__drop {
  position: relative;
}

.users__drop > summary {
  list-style: none; /* no triangle */
  cursor: pointer;
}

.users__drop > summary::-webkit-details-marker {
  display: none; /* Safari: its own triangle ignores list-style */
}

.users__drop[open] > summary {
  color: var(--c-page);
  background: var(--c-anthracite);
  border-color: var(--c-anthracite);
}

.users__panel {
  position: absolute;
  top: calc(100% + var(--sp-2));
  right: 0;
  z-index: 3;
  display: grid;
  gap: var(--sp-3);
  width: max-content;
  min-width: 100%;
  padding: var(--sp-4);
  background-color: var(--c-page);
  border: var(--border-1) solid var(--c-line);
  border-radius: var(--radius-2);
  box-shadow: var(--shadow-1);
}

.users__drop--search .users__panel {
  width: min(var(--calendar-panel-w), calc(100vw - 2 * var(--gutter)));
}

.users__panel .availability__bar {
  height: var(--sp-8);
  padding-block: 0;
  padding-inline: var(--sp-4) 0; /* the × reaches the right edge */
  font-size: var(--fs-xxs);
}

.users__close {
  width: var(--sp-8);
  height: var(--sp-8);
  padding: 0;
  font-size: var(--fs-small);
  background: none;
  border: 0;
  cursor: pointer;
}

.users__options {
  display: grid;
  gap: var(--sp-1);
}

.users__options .client__band {
  margin: 0;
}

.users__options .users__band {
  margin-top: var(--sp-2);
}

.users__options .client__menu-item {
  font-family: inherit;
  text-align: left;
  background: none;
  border: 0;
  cursor: pointer;
}

.users__options .client__menu-item:hover {
  background-color: var(--c-surface);
}

.users__options .client__menu-item[aria-current="true"] {
  font-weight: 600;
  color: var(--c-accent-text);
  background-color: var(--c-chip);
}

@media (max-width: 767.98px) {
  .users .box__toolbar {
    position: relative;
  }

  .users__drop {
    position: static;
  }

  .users__panel,
  .users__drop--search .users__panel {
    top: calc(100% - var(--sp-1));
    left: var(--sp-2);
    right: var(--sp-2);
    width: auto;
    min-width: 0;
  }
}

/* Add a user: the password's help line sits close under its field. */
.users__help {
  margin-top: calc(-1 * var(--sp-2));
}

/* A person: initials, name over email, the arrow; role (and status, when there is one) on the line under the name. */
.users__row {
  position: relative; /* holds its open button, which covers the whole row (.clients__open) */
  display: grid;
  grid-template-columns: var(--sp-8) minmax(0, 1fr) auto auto;
  grid-template-areas:
    "avatar who  who    chevron"
    "avatar role status chevron"
    "avatar org  org    chevron";
  align-items: center;
  gap: var(--sp-1) var(--sp-3);
  padding-block: var(--sp-2);
}

.users__row > .open {
  display: contents; /* its form takes no cell; the button inside covers the row */
}

.users__row + .users__row {
  border-top: var(--border-1) solid var(--c-line);
}

.users__row .clients__avatar { grid-area: avatar; }
.users__who { grid-area: who; }
.users__role { grid-area: role; justify-self: start; }
.users__status { grid-area: status; }
.users__chevron { grid-area: chevron; color: var(--c-text-muted); }

.users__org {
  grid-area: org;
  font-size: var(--fs-xs);
  color: var(--c-text-muted);
}

.users__org--none,
.users__row:not(.users__row--status) .users__status {
  display: none; /* phones to 1199px: no dash for a login without a partner or clinic; "Active" goes without saying */
}

/* Below 576px the status gets its own line under the role, so the two never run into each other. */
@media (max-width: 575.98px) {
  .users__row {
    grid-template-columns: var(--sp-8) minmax(0, 1fr) auto;
    grid-template-areas:
      "avatar who    chevron"
      "avatar role   chevron"
      "avatar status chevron"
      "avatar org    chevron";
  }

  .users__status {
    justify-self: start;
  }
}

/* Their role: a pale blue chip. */
.users__role {
  padding-inline: var(--sp-2);
  font-size: var(--fs-xs);
  line-height: var(--sp-5);
  color: var(--c-accent-text);
  white-space: nowrap;
  background-color: var(--c-chip);
  border: var(--border-1) solid var(--c-chip-border);
  border-radius: var(--radius-pill);
}

/* Switched off: red; Invited and Not confirmed use Clients' amber "To contact" (.dashboard__tag--contact). */
.users__tag--off {
  color: var(--c-error);
  background-color: var(--c-error-bg);
}

.users__active {
  font-size: var(--fs-xs);
  color: var(--c-text-muted);
}

.users__cols {
  display: none;
}

@media (hover: hover) {
  .users__row:has(.clients__open:hover) {
    background-color: var(--c-off-white);
  }
}

/* From 1200px: a table, with the column names in the band's small capitals above it. */
@media (min-width: 1200px) {
  .users__row,
  .users__cols {
    grid-template-columns: var(--sp-8) minmax(0, 3fr) minmax(0, 1.4fr) minmax(0, 2.4fr) minmax(0, 1.2fr) var(--sp-4);
    grid-template-areas: "avatar who role org status chevron";
  }

  .users__org--none,
  .users__row:not(.users__row--status) .users__status {
    display: block;
  }

  .users__org {
    font-size: inherit;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: var(--c-text-muted);
  }

  .users__cols {
    display: grid;
    column-gap: var(--sp-3);
    padding-block: 0 var(--sp-2);
    font-size: var(--fs-xxs);
    font-weight: 600;
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    color: var(--c-anthracite);
    border-bottom: var(--border-1) solid var(--c-line);
  }

  .users__cols > :nth-child(2) { grid-column: 2; }
}
