/* --- The dashboard (modules/dashboard/views/dashboard.php): a greeting, then white tiles on the hexagons. Phones: two
   numbers a row, every other tile full width; from 768px four numbers a row and the lists two a row. --- */
/* The dashboard fills the screen's height (under the phone top bar), so Clients, the last tile, stretches down to the
   bottom; with more clients than fit, the page grows instead. Phones: five rows above Clients (the greeting, two rows
   of numbers, Coming up, Consultations held); from 768px three. */
.admin__page:has(> .dashboard) {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--admin-top-h));
  min-height: calc(100dvh - var(--admin-top-h)); /* 100vh first for browsers without dvh */
}

.dashboard {
  display: grid;
  flex: 1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(5, auto) 1fr;
  gap: var(--sp-5);
  /* Coming up's three rows (a day box with its padding, and the lines between them): the least height of Coming up and
     Consultations held, empty or not. */
  --dashboard-rows-h: calc(3 * (var(--sp-10) + 2 * var(--sp-2)) + 2 * var(--border-1));
}

.dashboard__hello {
  grid-column: 1 / -1;
  min-width: 0;
  margin-bottom: var(--sp-2);
}

/* One line, never wrapped: below 768px site.js (data-fit) grows it to fill the width, up to its desktop size; a name
   too long even at its CSS size is cut off with "…". */
.dashboard__hello h1 {
  overflow: hidden;
  font-size: var(--fs-h3);
  line-height: var(--lh-heading);
  white-space: nowrap;
  text-overflow: ellipsis;
  --fit-max: var(--fs-hello-max);
}

.dashboard__hello p {
  margin-top: var(--sp-1);
  font-size: var(--fs-small);
  color: var(--c-text-muted);
}

.dashboard__tile {
  display: grid;
  align-content: start;
  gap: var(--sp-2);
  min-width: 0;
  padding: var(--sp-4);
  font-size: var(--fs-small);
  background-color: var(--c-page);
  border: var(--border-1) solid var(--c-line);
  border-radius: var(--radius-2);
}

.dashboard__tile--half,
.dashboard__tile--wide {
  grid-column: 1 / -1;
  overflow: clip; /* the head's band follows the tile's round corners */
}

.dashboard__tile--half {
  grid-template-rows: auto minmax(var(--dashboard-rows-h), 1fr);
}

/* A number: what it counts (with its icon on the right), the number, and a short note. */
.dashboard__label {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
  color: var(--c-text-muted);
}

.dashboard__label i {
  margin-left: auto;
}

.dashboard__label,
.dashboard__note {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.dashboard__number {
  font-family: var(--font-heading);
  font-size: var(--fs-h3);
  font-weight: 400;
  line-height: 1;
  color: var(--c-heading);
}

.dashboard__note {
  font-size: var(--fs-xs);
  color: var(--c-text-muted);
}

/* A list tile's head: an anthracite band across the top of the tile, its title in white small capitals, with a link or a
   note on the right. */
.dashboard__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  min-height: var(--sp-8); /* the same height with or without a link on the right */
  margin: calc(-1 * var(--sp-4)) calc(-1 * var(--sp-4)) var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  line-height: var(--lh-heading);
  color: var(--c-page);
  background-color: var(--c-anthracite);
}

.dashboard__head h2 {
  font-family: inherit;
  font-size: var(--fs-xxs);
  font-weight: 600;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: inherit;
}

.dashboard__head > :last-child:not(h2) {
  flex: none; /* the note stays on one line; on the narrowest phones the title wraps instead */
  font-size: var(--fs-xxs);
  color: inherit;
}

.dashboard__head > a:last-child {
  font-size: var(--fs-xs); /* a link people tap stays a step bigger */
}

.dashboard__none {
  color: var(--c-text-muted);
}

/* Coming up: the day in a small box, then who and what, cut short with "…". */
.dashboard__row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding-block: var(--sp-2);
}

.dashboard__row + .dashboard__row {
  border-top: var(--border-1) solid var(--c-line);
}

.dashboard__date {
  display: grid;
  place-items: center;
  flex: none;
  width: var(--sp-10);
  height: var(--sp-10);
  font-size: var(--fs-xs);
  line-height: var(--lh-heading);
  color: var(--c-text-muted);
  border: var(--border-1) solid var(--c-line);
  border-radius: var(--radius-1);
}

.dashboard__date strong {
  font-size: var(--fs-body);
  color: var(--c-text);
}

.dashboard__what {
  display: grid;
  min-width: 0;
}

.dashboard__what > * {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.dashboard__what strong {
  font-weight: 600;
}

.dashboard__what span {
  color: var(--c-text-muted);
}

/* Consultations held: a bar a month, this month darker. The bars fill the tile's height down to its bottom (beside
   Coming up, as tall as it). Each bar's height is a tenth of the column per step (--1 to --10, set by PHP: no style=""
   under the site's security headers); an empty month still shows a sliver. */
.dashboard__bars {
  display: flex;
  gap: var(--sp-2);
  padding-top: var(--sp-2);
}

.dashboard__bar {
  display: grid;
  flex: 1;
  grid-template-rows: repeat(10, 1fr) auto;
}

.dashboard__bar-fill {
  grid-row: 10; /* --0: a sliver at the bottom */
  align-self: end;
  min-height: var(--sp-1);
  background-color: var(--c-bar);
  border-radius: var(--radius-1) var(--radius-1) 0 0;
}

.dashboard__bar-fill--1 { grid-row: span 1 / -2; }
.dashboard__bar-fill--2 { grid-row: span 2 / -2; }
.dashboard__bar-fill--3 { grid-row: span 3 / -2; }
.dashboard__bar-fill--4 { grid-row: span 4 / -2; }
.dashboard__bar-fill--5 { grid-row: span 5 / -2; }
.dashboard__bar-fill--6 { grid-row: span 6 / -2; }
.dashboard__bar-fill--7 { grid-row: span 7 / -2; }
.dashboard__bar-fill--8 { grid-row: span 8 / -2; }
.dashboard__bar-fill--9 { grid-row: span 9 / -2; }
.dashboard__bar-fill--10 { grid-row: span 10 / -2; }

.dashboard__bar-fill:not(.dashboard__bar-fill--0) {
  align-self: stretch; /* the steps fill their rows */
}

.dashboard__bar:last-child .dashboard__bar-fill {
  background-color: var(--c-menu-button);
}

.dashboard__bar-month {
  grid-row: -2 / -1; /* always the last row, under the bar */
  padding-top: var(--sp-1);
  font-size: var(--fs-xs);
  text-align: center;
  color: var(--c-text-muted);
}

/* Clients: a small table; the email only from 576px. */
.dashboard__table {
  width: 100%;
  border-collapse: collapse;
}

.dashboard__table th {
  padding-block: var(--sp-1);
  font-size: var(--fs-xs);
  font-weight: 400;
  text-align: left;
  color: var(--c-text-muted);
}

.dashboard__table td {
  padding-block: var(--sp-2);
  border-top: var(--border-1) solid var(--c-line);
  white-space: nowrap;
}

.dashboard__table td:first-child {
  white-space: normal; /* a long name wraps, so the table never runs out of its tile */
}

.dashboard__table :is(th, td) + :is(th, td) {
  padding-left: var(--sp-3);
}

.dashboard__table .dashboard__end {
  text-align: right;
}

.dashboard__wide {
  display: none;
}

/* Clients: Newest (sign-up) or A–Z, two choices on the band's right. The chosen one is a white pill; both lists are in
   the page and only the chosen one shows. Each choice is 24px high for a finger (its label, reaching over the band's
   padding so the band keeps its height), with a 16px pill inside. */
.dashboard__sort {
  display: flex;
  flex: none;
  gap: var(--sp-1);
  margin: calc(-1 * var(--sp-1)) 0;
  padding: 0;
  border: 0;
}

.dashboard__sort label {
  padding-block: var(--sp-1);
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
}

.dashboard__sort span {
  display: block;
  padding-inline: var(--sp-2);
  line-height: var(--sp-4);
  border-radius: var(--radius-pill);
}

.dashboard__sort :checked + span {
  color: var(--c-anthracite);
  background-color: var(--c-page);
}

.dashboard__sort :focus-visible + span {
  outline: var(--border-1) solid var(--c-page); /* the site's soft blue ring would not show on the dark band */
  outline-offset: var(--border-1);
}

.dashboard__by-name,
.dashboard__tile:has([value="name"]:checked) .dashboard__by-new {
  display: none;
}

.dashboard__tile:has([value="name"]:checked) .dashboard__by-name {
  display: table-row-group;
}

/* A client's status: grey Booked, yellow To contact. */
.dashboard__tag {
  display: inline-block;
  padding-inline: var(--sp-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: var(--sp-5);
  color: var(--c-text-muted);
  background-color: var(--c-surface);
  border-radius: var(--radius-pill);
}

.dashboard__tag--contact {
  color: var(--c-warning-text);
  background-color: var(--c-warning-bg);
}

@media (min-width: 576px) {
  .dashboard__wide {
    display: table-cell;
  }
}

@media (min-width: 768px) {
  .dashboard {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: repeat(3, auto) 1fr;
  }

  .dashboard__tile--half {
    grid-column: span 2;
  }
}

@media (min-width: 992px) {
  .admin__page:has(> .dashboard) {
    min-height: 100vh;
    min-height: 100dvh; /* no top bar beside the sidebar */
  }
}
