/* Small layout tweaks on top of Bootstrap. Prefer Bootstrap utilities over adding rules here. */
/*
  Sidebar (templates/app_base.html, templates/includes/sidebar.html).
  Every row is an icon in a fixed 2rem box followed by a .sidebar-label, so the icons line up
  in one column. On large screens the sidebar is a 4rem rail of icons; while the pointer or
  keyboard focus is in it (or its user menu is open) the panel widens over the page and the
  labels fade in. Below lg it's the Bootstrap offcanvas menu and these width rules don't apply.
*/
.sidebar .nav-link,
.sidebar-brand,
.sidebar-user {
  display: flex;
  align-items: center;
  padding-inline: 0.5rem;
  white-space: nowrap;
}
.sidebar .nav-item,
.sidebar-label {
  min-width: 0;
}
.sidebar .nav-link {
  overflow: hidden;
}
.sidebar-icon {
  flex-shrink: 0;
  width: 2rem;
  margin-right: 0.5rem;
  text-align: center;
}
@media (min-width: 992px) {
  .sidebar {
    --sidebar-rail-width: 4rem;
    --sidebar-width: 260px;
    position: relative;
    z-index: 1030;
    flex-shrink: 0;
    width: var(--sidebar-rail-width);
    border-right: 0 !important;
  }
  .sidebar .sidebar-panel {
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--sidebar-rail-width);
    overflow: hidden auto;
    background-color: var(--bs-tertiary-bg) !important;
    border-right: var(--bs-border-width) solid var(--bs-border-color);
  }
  .sidebar .sidebar-label,
  .sidebar .sidebar-user::after {
    opacity: 0;
  }
  .sidebar:hover .sidebar-panel,
  .sidebar:has(:focus-visible) .sidebar-panel,
  .sidebar:has(.dropdown-menu.show) .sidebar-panel {
    width: var(--sidebar-width);
    box-shadow: var(--bs-box-shadow);
  }
  .sidebar:hover .sidebar-label,
  .sidebar:has(:focus-visible) .sidebar-label,
  .sidebar:has(.dropdown-menu.show) .sidebar-label,
  .sidebar:hover .sidebar-user::after,
  .sidebar:has(:focus-visible) .sidebar-user::after,
  .sidebar:has(.dropdown-menu.show) .sidebar-user::after {
    opacity: 1;
  }
}
@media (min-width: 992px) and (prefers-reduced-motion: no-preference) {
  .sidebar .sidebar-panel {
    transition: width 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
  }
  .sidebar .sidebar-label,
  .sidebar .sidebar-user::after {
    transition: opacity 0.15s ease-in-out;
  }
}
.brand-logo {
  object-fit: contain;
}
.min-w-0 {
  min-width: 0;
}
.min-vw-0 {
  min-width: 0;
}
/* Keep forms on in-app pages a readable width. */
.app-main .settings-form,
.form-column {
  max-width: 560px;
}
/* Admin > Instance > Pages: the icon preview beside each page's name and icon boxes (#26). */
.page-icon-preview {
  /* The height of a Bootstrap .form-control, so the preview lines up with the boxes. */
  width: calc(1.5rem + 0.75rem + 2px);
  height: calc(1.5rem + 0.75rem + 2px);
  font-size: 1.25rem;
}
/* Profile photos and their initials fallback (templates/includes/user_avatar.html). */
.user-avatar {
  object-fit: cover;
}
.user-avatar-initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  line-height: 1;
  color: var(--bs-primary-text-emphasis);
  background-color: var(--bs-primary-bg-subtle);
}
/* Settings > Profile: the photo is a button that opens the photo editor. */
.photo-button {
  position: relative;
}
.photo-button-badge {
  position: absolute;
  right: 0;
  bottom: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  color: var(--bs-body-color);
  background-color: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
}
.photo-button:hover .user-avatar,
.photo-button:focus-visible .user-avatar {
  filter: brightness(0.85);
}
.photo-cropper {
  height: min(60vh, 360px);
}
.photo-cropper img {
  display: block;
  max-width: 100%;
}
/* Show the crop as the circle people will appear in. */
.photo-cropper .cropper-view-box,
.photo-cropper .cropper-face {
  border-radius: 50%;
}
/* Bootstrap's display utilities (d-flex) would otherwise beat the hidden attribute. */
[data-photo-editor] [hidden] {
  display: none !important;
}
/* Reports: a pencil on the avatar of whoever is editing a report (templates/reports). */
.presence-editing {
  position: absolute;
  right: -4px;
  bottom: -4px;
  font-size: 0.65rem;
  color: var(--bs-warning-text-emphasis);
}
/* Reports: maps in the Location box (Leaflet). */
.report-map {
  height: 200px;
  border-radius: var(--bs-border-radius);
}
.report-map-picker {
  height: 300px;
}
/*
  Page alerts (templates/app_base.html, "Page layout" in the README). The top of the page keeps a
  fixed slot above the header, and alerts float in it, so showing or dismissing one never moves
  the header or the content. Alerts here are compact to fit the slot; if several show, or a long
  one wraps, they overlap the header instead of pushing it down.
*/
.app-main {
  --page-alerts-slot: 2.75rem;
  --page-alerts-inset: 1rem;
  position: relative;
  padding-top: var(--page-alerts-slot);
}
@media (min-width: 992px) {
  .app-main {
    --page-alerts-inset: 1.5rem;
  }
}
.page-alerts {
  position: absolute;
  top: 0.375rem;
  inset-inline: var(--page-alerts-inset);
  z-index: 1020;
}
.page-alerts .alert {
  --bs-alert-padding-y: 0.25rem;
  --bs-alert-padding-x: 0.75rem;
  --bs-alert-margin-bottom: 0.25rem;
  font-size: 0.875rem;
  box-shadow: var(--bs-box-shadow-sm);
}
.page-alerts .alert-dismissible {
  padding-right: 2.25rem;
}
.page-alerts .alert-dismissible .btn-close {
  height: 100%;
  padding: 0 0.75rem;
}
/*
  Page header (templates/app_base.html): a band in the sidebar's color that runs the full width of
  the page, edge to edge, with the title row centered in it. The band starts at the top of main and
  takes in the alerts slot above, so alerts float over the band's top padding; its bottom padding
  matches, keeping the title centered. --page-alerts-inset matches main's side padding
  (px-3 px-lg-4), so the band's negative margins reach the edges.
*/
.page-header {
  margin: calc(-1 * var(--page-alerts-slot)) calc(-1 * var(--page-alerts-inset)) var(--page-alerts-inset);
  padding: var(--page-alerts-slot) var(--page-alerts-inset);
  background-color: var(--bs-tertiary-bg);
  border-bottom: var(--bs-border-width) solid var(--bs-border-color);
}
/* Tabs in the header sit on its bottom edge; the active tab opens onto the page below. */
.page-header:has(> .nav-tabs) {
  padding-bottom: 0;
}
.page-header > .nav-tabs {
  margin-bottom: calc(-1 * var(--bs-border-width));
  border-bottom: 0;
}
