.wrapper {
  display: flex;
  width: 100%;
  align-items: stretch;
  min-height: calc(100vh - 56px);
}

.wrapper.wrapper--tabs {
  flex-grow: 1;
  margin-bottom: 0;
  min-height: 0;
}

#sidebar {
  background: #e9edf8;
  color: #233056;
  flex: 0 0 250px;
}

/* all items have an equal height and are separated by clear lines */
#sidebar .list-group-item {
  align-items: center;
  background: transparent;
  border: none;
  border-bottom: 1px solid #c9d2ea;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
  min-height: 3rem;
  padding: 0.5rem 1rem;
}

#sidebar .list-group-item a,
#sidebar a.list-group-item {
  color: inherit;
  text-decoration: none;
}

#sidebar a.list-group-item:hover {
  background: #dbe2f4;
  cursor: pointer;
}

#sidebar .list-group-item.active,
#sidebar .list-group-item.active a {
  background: #cfd9f1;
  box-shadow: inset 3px 0 0 #7386d5;
  color: #101d45;
  font-weight: 600;
}

/* items with children are non-clickable section headers, always expanded */
#sidebar .list-group-item.header {
  background: #dde3f4;
  color: #1c2a55;
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

#sidebar .list-group-item.child {
  padding-left: 2rem;
}

#sidebar .list-group-item.back {
  font-size: 0.875rem;
}

#sidebar .list-group-item.title {
  background: #dde3f4;
  font-size: 1.25rem;
  font-weight: 600;
}

#sidebar .badge {
  background-color: #7386d5;
  color: #fff;
  margin-left: auto;
}

#sidebar .badges {
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
}

#sidebar a.blocked {
  text-decoration: line-through;
}

/*
 * The account pages turn their sidebar into a horizontally scrolling tab bar on narrow screens,
 * so the forms keep the full width. This works without JavaScript.
 */
@media (max-width: 767px) {
  .wrapper.wrapper--tabs {
    flex-direction: column;
  }

  .wrapper--tabs #sidebar {
    flex: none;
    flex-direction: row;
    overflow-x: auto;
    width: 100%;
  }

  .wrapper--tabs #sidebar .list-group-item {
    border-bottom: none;
    flex: 0 0 auto;
    min-height: 2.75rem;
    white-space: nowrap;
  }

  .wrapper--tabs #sidebar .list-group-item.title {
    display: none;
  }

  .wrapper--tabs #sidebar .list-group-item.active {
    box-shadow: inset 0 -3px 0 #7386d5;
  }
}

.pb-10rem {
  padding-bottom: 10rem;
}

.badge-large {
  font-size: 0.93rem;
}

/*
 * Dark variant used by the back office and the account pages when the front-end theme is dark.
 * The navbar and footer use bg-dark, which matches the dark body background, so they get a darker shade and a border.
 */
html[data-bs-theme="dark"] .navbar.bg-dark,
html[data-bs-theme="dark"] .legal-footer.bg-dark {
  background-color: #111315 !important;
}

html[data-bs-theme="dark"] .navbar.bg-dark {
  border-bottom: 1px solid var(--bs-border-color);
}

html[data-bs-theme="dark"] .legal-footer.bg-dark {
  border-top: 1px solid var(--bs-border-color);
}

html[data-bs-theme="dark"] #sidebar,
html[data-bs-theme="dark"] #sidebar .list-group-item,
html[data-bs-theme="dark"] #sidebar .list-group-item a {
  background: var(--bs-tertiary-bg);
  color: var(--bs-body-color);
}

html[data-bs-theme="dark"] #sidebar .list-group-item.child,
html[data-bs-theme="dark"] #sidebar .list-group-item.child a {
  background: var(--bs-secondary-bg);
}

html[data-bs-theme="dark"] #sidebar .list-group-item {
  border-bottom-color: var(--bs-border-color);
}

html[data-bs-theme="dark"] #sidebar a.list-group-item:hover,
html[data-bs-theme="dark"] #sidebar .list-group-item a:hover,
html[data-bs-theme="dark"] #sidebar .list-group-item:hover a {
  background: var(--bs-secondary-bg);
  color: var(--bs-emphasis-color);
}

/* the active item keeps its background and bar, the general dark rule above would override them */
html[data-bs-theme="dark"] #sidebar .list-group-item.active,
html[data-bs-theme="dark"] #sidebar .list-group-item.active a {
  background: var(--bs-primary-bg-subtle);
  color: var(--bs-primary-text-emphasis);
}

/* tag picker (see backoffice/tag-picker.js): pills and the combobox in a box which looks like a text field */
.tag-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  cursor: text;
}

/* like .form-control:focus; the transparent outline becomes visible in forced colors mode, which drops the shadow */
.tag-picker:focus-within {
  border-color: #86b7fe;
  outline: 2px solid transparent;
  outline-offset: 2px;
  box-shadow: 0 0 0 var(--bs-focus-ring-width) var(--bs-focus-ring-color);
}

.tag-picker.is-invalid:focus-within {
  border-color: var(--bs-form-invalid-border-color);
  box-shadow: 0 0 0 var(--bs-focus-ring-width) rgba(var(--bs-danger-rgb), 0.25);
}

/* the pills flow with the text field, so it stays on the last line if there is room (role=list keeps the semantics) */
.tag-picker-pills {
  display: contents;
  list-style: none;
}

.tag-picker-pills[hidden] {
  display: none;
}

.tag-picker-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.125rem;
  max-width: 100%;
  min-height: 1.5rem;
  padding: 0 0 0 0.5rem;
  border: 1px solid var(--bs-border-color);
  /* round for a single line, a rounded rectangle when a long tag wraps */
  border-radius: 0.75rem;
  background: var(--bs-secondary-bg);
  color: var(--bs-emphasis-color);
  line-height: 1.25;
  cursor: default;
}

.tag-picker-pill > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* 24x24 px (WCAG 2.5.8) */
.tag-picker-remove {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  margin: -1px 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 0.75rem;
}

.tag-picker-remove:hover {
  background: var(--bs-tertiary-bg);
  color: var(--bs-danger-text-emphasis);
}

/* the emphasis color has enough contrast to the pill and the box in both themes */
.tag-picker-remove:focus-visible {
  outline: 2px solid var(--bs-emphasis-color);
  outline-offset: 0;
}

.tag-picker-input {
  flex: 1 1 6rem;
  min-width: 6rem;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: inherit;
}

/* creating a tag is set apart from the existing ones */
.tag-picker-create {
  border-top: 1px solid var(--bs-border-color-translucent);
}

.tag-picker-create:first-child {
  border-top: 0;
}

/* the highlighted option of the comboboxes (see backoffice/combobox.js), Bootstrap only sets its background */
@media (forced-colors: active) {
  .dropdown-item.active {
    forced-color-adjust: none;
    background: Highlight;
    color: HighlightText;
  }
}

/*
 * Contrast (WCAG 2.2 AA): Bootstrap's border of unticked checkboxes has 1.3:1 against the background, it needs 3:1.
 * In dark mode, Bootstrap keeps the light-mode colours of outline buttons, which fall to about 3.3:1 on dark cards.
 */
.form-check-input {
  border-color: var(--bs-secondary-color);
}

html[data-bs-theme="dark"] .btn-outline-primary {
  --bs-btn-color: var(--bs-primary-text-emphasis);
  --bs-btn-border-color: var(--bs-primary-text-emphasis);
}

html[data-bs-theme="dark"] .btn-outline-secondary {
  --bs-btn-color: var(--bs-secondary-color);
  --bs-btn-border-color: var(--bs-secondary-color);
}

/* OIDC consent screen: rows that get the focus scroll into view above the sticky action bar, not under it */
html:has(.consent-actions) {
  scroll-padding-bottom: 8rem;
}
