/* Treatment results: the list on the clinic page and one result's page */

.results-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 0.75rem;
}

.results-toolbar__search {
  flex: 1 1 18rem;
}

.results-toolbar__filter {
  flex: 0 1 16rem;
}

.results-toolbar .form-group {
  margin-bottom: 0;
}

.results-list .table-container {
  margin-top: 0;
}

.results-table__patient {
  font-weight: 500;
  color: var(--c-base-text);
}

.results-table__patient--deleted {
  font-style: italic;
  color: var(--c-base-subtitle-text);
}

.results-table__demographics {
  font-size: 0.75rem;
  color: var(--c-base-subtitle-text);
}

.results-table__adherence {
  font-variant-numeric: tabular-nums;
}

.results-table td .patient-shelf__grade-swatch {
  margin-right: 0.4rem;
}

/* One result: the numbers above the chart */
.result-title--deleted {
  font-style: italic;
  color: var(--c-base-subtitle-text);
}

.result-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.result-stat {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding: 0.875rem 1rem;
  background: var(--c-app-bg);
  border: 1px solid var(--c-border);
  border-radius: 12px;
}

.result-stat__value {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--c-base-text);
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.result-stat__label {
  font-size: 0.75rem;
  color: var(--c-base-subtitle-text);
}

/* The chart card */
.result-chart-card {
  background: var(--c-app-bg);
  border: 1px solid var(--c-border);
  border-radius: 12px;
  padding: 1rem 1.25rem 0.5rem;
}

.result-chart__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.result-chart__axis .form-group {
  margin-bottom: 0;
}

/* The display panel: a button in the controls row, a panel under it (the plan
   picker's panel look) that stays open while the chart is tried out. */
.chart-filters {
  position: relative;
  margin-left: auto;
}

.chart-filters .chart-filters__panel {
  left: auto;
  right: 0;
}

.chart-filters__trigger svg {
  width: 0.875rem;
  height: 0.875rem;
  margin-right: 0.375rem;
}

.chart-filters .chart-filters__panel {
  display: none;
  width: 24rem;
  max-height: min(70vh, 36rem);
  overflow-y: auto;
}

.chart-filters .chart-filters__panel.is-open {
  display: block;
}

.chart-filters__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.625rem;
}

.chart-filters__title {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--c-base-subtitle-text);
}

.chart-filters__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--c-base-subtitle-text);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.chart-filters__close:hover {
  background: var(--c-surface-subtle);
  color: var(--c-base-text);
}

.chart-filters__section .form-group {
  margin-bottom: 0.75rem;
}

.chart-filters__section .form-label {
  font-size: 0.75rem;
}

.chart-filters__series {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  padding-top: 0.25rem;
  border-top: 1px solid var(--c-border);
}

.chart-filters__group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.chart-filters__group-head {
  align-self: flex-start;
}

.chart-filters__group-list {
  padding: 0 0 0 0.25rem;
}

.result-chart__wrap {
  position: relative;
  height: 28rem;
}

.result-chart__placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  font-size: 0.875rem;
  color: var(--c-base-subtitle-text);
}

.result-chart__placeholder[hidden] {
  display: none;
}

.result-chart__legend {
  padding-left: 0;
  padding-right: 0;
}

@media (max-width: 600px) {
  .result-chart__wrap {
    height: 22rem;
  }
}

/* Focus layout: the header folds to a third, titles shrink; animated both ways */
.dashboard--focus .dashboard-header {
  transition: padding 0.25s ease;
}

.dashboard--focus .nav-tab,
.dashboard--focus .nav-tabs__logo-img,
.dashboard--focus .user-avatar {
  transition: font-size 0.25s ease, height 0.25s ease, width 0.25s ease;
}

/* A reload of the same page arrives already folded: painted folded, no transition */
.dashboard--focus-still .dashboard-header,
.dashboard--focus-still .nav-tab,
.dashboard--focus-still .nav-tabs__logo-img,
.dashboard--focus-still .user-avatar {
  transition: none;
}

.dashboard--focus-on .dashboard-header {
  padding-top: 0.3rem;
  padding-bottom: 0.3rem;
}

.dashboard--focus-on .nav-tab {
  font-size: 0.875rem;
  padding-bottom: 0.125rem;
}

.dashboard--focus-on .nav-tabs__logo-img {
  height: 1.25rem;
}

.dashboard--focus-on .user-avatar {
  width: 1.75rem;
  height: 1.75rem;
  font-size: 0.75rem;
}

/* The comparison page: a bar, then the chart filling what is left of the screen */
.compare-main {
  display: flex;
  flex-direction: column;
  padding: 0.75rem 1.25rem 0.75rem;
  min-height: calc(100dvh - 3rem);
}

.compare-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.compare-bar__title {
  min-width: 0;
  margin-left: 0.5rem;
}

.compare-bar__title h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  transition: font-size 0.25s ease;
}

.compare-bar__title .page-subtitle {
  margin: 0;
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compare-picker {
  position: relative;
}

.compare-picker__badge {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0 0.375rem;
  border-radius: 999px;
  background: var(--c-brand-highlight);
  color: var(--c-brand);
  margin-left: 0.375rem;
}

.compare-picker__caret {
  margin-left: 0.25rem;
  font-size: 0.6875rem;
}

.compare-picker__panel {
  position: absolute;
  top: calc(100% + 0.375rem);
  left: 0;
  z-index: 20;
  width: 22rem;
  max-width: calc(100vw - 2.5rem);
  background: var(--c-popup-bg);
  border: 1px solid var(--c-border);
  border-radius: 0.75rem;
  box-shadow: 0 12px 24px -8px rgba(0, 0, 0, 0.18);
  padding: 0.875rem 1rem;
}

.compare-picker__panel[hidden] {
  display: none;
}

.compare-picker__hint {
  margin: 0 0 0.625rem;
  font-size: 0.75rem;
  color: var(--c-base-subtitle-text);
}

.compare-picker__list {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  max-height: 18rem;
  overflow-y: auto;
  margin-bottom: 0.75rem;
}

.compare-picker__item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.5rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  cursor: pointer;
}

.compare-picker__item:hover {
  background: var(--c-surface-subtle);
}

.compare-picker__item input {
  accent-color: var(--c-brand);
}

.compare-picker__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compare-picker__count {
  font-size: 0.6875rem;
  color: var(--c-base-subtitle-text);
  white-space: nowrap;
}

.compare-picker__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Live patients beside the plan picker: chips for those shown, a search to add one */
.compare-live {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.375rem;
  min-width: 0;
}

.compare-live .base-searchbar {
  width: 14rem;
}

.compare-live .base-searchbar__input {
  padding: 0.4rem 0.75rem 0.4rem 2.25rem;
  font-size: 0.8125rem;
  border-radius: 999px;
}

.compare-live .base-searchbar__icon {
  left: 0.75rem;
  width: 0.9375rem;
  height: 0.9375rem;
}

.compare-live .base-searchbar__results {
  min-width: 18rem;
}

.compare-live__chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.375rem 0.25rem 0.625rem;
  border: 1px solid var(--chip-color);
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  background: var(--c-popup-bg);
}

.compare-live__chip-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--chip-color);
}

.compare-live__chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.125rem;
  height: 1.125rem;
  border-radius: 50%;
  color: var(--c-base-subtitle-text);
  text-decoration: none;
  font-size: 0.9375rem;
  line-height: 1;
}

.compare-live__chip-remove:hover {
  background: var(--c-surface-subtle);
  color: var(--c-base-text);
}

/* A match in the live search: the name, then which day of the plan the patient is on */
.compare-live__result-day {
  font-size: 0.75rem;
  color: var(--c-base-subtitle-text);
  white-space: nowrap;
}

.base-searchbar__result-item--active {
  background-color: var(--c-brand-highlight);
}

/* Chart fills the rest of the screen */
.result-chart-card--fill {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.result-chart__wrap--fill {
  flex: 1 1 auto;
  min-height: 18rem;
  height: auto;
}

.result-chart__wrap--screen {
  height: calc(100dvh - 22rem);
  min-height: 22rem;
}

/* Measurements by value: a chart of their own above the main one, on the same day
   axis. The main chart gives up that much height while the pair is shown. */
.result-chart__wrap--values {
  height: 13rem;
  flex: 0 0 13rem;
  margin-bottom: 0.25rem;
}

.result-chart__wrap--values[hidden] {
  display: none;
}

.result-chart-card--split .result-chart__wrap--fill {
  min-height: 14rem;
}

.result-chart-card--split .result-chart__wrap--screen {
  height: calc(100dvh - 35rem);
  min-height: 16rem;
}

.result-chart__focus {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.result-chart__focus .form-group {
  margin-bottom: 0;
  min-width: 12rem;
}

.result-chart__focus[hidden] {
  display: none;
}

.result-chart__reset[hidden] {
  display: none;
}

/* Drag-selecting a time segment */
.result-chart__wrap {
  user-select: none;
  touch-action: pan-y;
}

.result-chart__selection {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--c-brand-highlight);
  border-left: 1px solid var(--c-brand);
  border-right: 1px solid var(--c-brand);
  pointer-events: none;
}

.result-chart__hint {
  margin: 0.25rem 0 0;
  font-size: 0.6875rem;
  color: var(--c-base-subtitle-text);
}
