/* Home page: four big numbers, then two cards side by side */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
  gap: var(--space-3);
}

.stat {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4);
  color: inherit;
  text-decoration: none;

  &:hover {
    border-color: var(--color-primary);
  }
}

.stat__value {
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
}

.stat__label {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.dashboard-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
  gap: var(--space-4);
  align-items: start;
}

/* "Install the app" card (shared/_install_card) */
.install-card__body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.install-card__icon {
  width: 2.75rem;
  height: 2.75rem;
}

.install-card__text {
  flex: 1 1 14rem;
}

.install-card__actions {
  display: flex;
  gap: var(--space-2);
}

/* A caretaker's colonies on their home page */
.my-colony {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4);
  color: inherit;
  text-decoration: none;

  &:hover {
    border-color: var(--color-primary);
  }
}

.my-colony__name {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}

.my-colony__facts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-top: var(--space-1);
}

/* What to work on first: the list wide, the to-do numbers beside it (one column on phones) */
.dashboard-main {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: var(--space-4);
  align-items: start;

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

.dashboard-main--single {
  grid-template-columns: minmax(0, 1fr);
}

/* The card that matters most on the page */
.card--highlight {
  border-color: var(--color-primary-border);
  box-shadow: inset 4px 0 0 var(--color-primary);
}

/* The traffic light's three counts in one stat */
.health-tally {
  display: flex;
  gap: var(--space-3);
  font-size: var(--text-lg);
}

/* Stats: the period's dates and quick choices in one row */
.stats-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

/* On a phone: a grid, the two dates side by side and everything else (the colony's or clinic's long names, the
   button, the presets) on a row of its own. Not a wrapping flex row: iOS Safari gives date fields a minimum width
   of their own, so they ran into each other and into the button with no gap */
@media (max-width: 48rem) {
  .stats-filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;

    > :not(.form-field:has(.input[type="date"])) {
      grid-column: 1 / -1;
    }
  }
}

.stats-filters__presets {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.stats-chart__table {
  margin-top: var(--space-3);

  summary {
    cursor: pointer;
    color: var(--color-text-muted);
  }

  .table {
    margin-top: var(--space-2);
  }
}

/* Stats: what share a figure is of done + still waiting, and the change against the previous period */
/* A row, so the template's line breaks don't add space: "/90" sits right after the figure */
.stat__value--ratio {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  /* "963 kg" never breaks inside: when there's no room, the ratio goes under it as a whole */
  white-space: nowrap;
}

/* Kilos per cat: apart from the figure on its line, flush left when it goes under it */
.stat__value--detail {
  column-gap: var(--space-2);
}

.stat__ratio {
  display: inline-flex;
  gap: var(--space-2);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.stat__change {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 var(--space-1);
  margin-top: var(--space-1);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}

.stat__change--up { color: var(--color-success-text); }
.stat__change--down { color: var(--color-danger-text); }
.stat__change--same { color: var(--color-text-subtle); }

/* The second figure's change (food: g/gato), coloured by its own direction */
.stat__change-detail {
  margin-left: var(--space-2);
}

.stat__change-detail--up { color: var(--color-success-text); }
.stat__change-detail--down { color: var(--color-danger-text); }

.stat__change-label {
  color: var(--color-text-subtle);
  font-weight: var(--weight-regular);
}

/* ---------- Home: the calendar today and the next days (dashboard/_agenda) ---------- */
.agenda-list {
  display: flex;
  flex-direction: column;
  padding: var(--space-1) var(--space-4) var(--space-3);
  list-style: none;
}

.agenda-item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-2) 0 var(--space-2) var(--space-3);
  border-left: 3px solid var(--color-primary);

  & + & {
    margin-top: var(--space-1-5);
  }
}

.agenda-item--place { border-left-color: var(--color-warning); }
.agenda-item--training { border-left-color: var(--color-info); }

.agenda-item__time {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  min-width: 3.25rem;
  color: var(--color-text);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
}

.agenda-item__day {
  color: var(--color-text-subtle);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  text-transform: capitalize;
}

.agenda-item__body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.agenda-item__title {
  color: var(--color-text);
  font-weight: var(--weight-medium);
}

.agenda__subtitle {
  padding: var(--space-3) var(--space-4) 0;
  border-top: var(--border);
  color: var(--color-text-subtle);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

/* ---------- Home: the objetivos under way (dashboard/_objectives) ---------- */
.dashboard-objectives {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-4);
  list-style: none;

  li {
    display: flex;
    flex-direction: column;
    gap: var(--space-1-5);
  }
}

.dashboard-objectives__title {
  color: var(--color-text);
  font-weight: var(--weight-medium);
}

/* A viewer's home (dashboard/viewer): their pages, each with its menu icon */
.viewer-pages a {
  display: flex;
  align-items: center;
  gap: var(--space-3);

  svg {
    width: 1.25rem;
    height: 1.25rem;
    color: var(--color-text-subtle);
  }
}
