.bslib-card {
  margin-bottom: $spacer;

  // Avoid "double padding" when two card_body()s are immediate siblings
  .card-body + .card-body {
    padding-top: 0;
  }

  .card-body {
    overflow: auto;
    p, h1, h2, h3, h4, h5, h6 {
      margin-top: 0;

      &:last-child {
        margin-bottom: 0;
      }
    }
  }

  .card-body {
    max-height: var(--bslib-card-body-max-height, none);
  }

  &.bslib-full-screen > .card-body {
    max-height: var(--bslib-card-body-max-height-full-screen, none);
  }

  .card-header {
    .form-group {
      margin-bottom: 0;
    }
    .selectize-control {
      margin-bottom: 0;
      // TODO: we should probably add this to selectize's SCSS since this actually makes selectInput()
      // usable with width="fit-content"
      .item {
        margin-right: 1.15rem;
      }
    }
  }

  .card-footer {
    margin-top: auto;
  }

  // For card_title()
  .bslib-card-title {
    padding-left: var(--bs-card-spacer-x, 1rem);
    padding-right: var(--bs-card-spacer-x, 1rem);
  }

  // For navs_tab_card(title = ...)
  .bslib-navs-card-title {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    .nav {
      margin-left: auto;
    }
  }

  .tab-content {
    // Workaround for pkgdown's CSS to make tab-pane all a consistent height
    // https://github.com/r-lib/pkgdown/blob/956f07/inst/BS5/assets/pkgdown.scss#L342-L355
    > .tab-pane.html-fill-container {
      display: none;
    }

    // Take precedence over Bootstrap's `display:block` rule
    > .active.html-fill-container {
      display: flex;
    }

    // Another workaround for pkgdown adding extra padding we didn't ask for
    // https://github.com/r-lib/pkgdown/blob/956f07/inst/BS5/assets/pkgdown.scss#L335-L337
    &.html-fill-container {
      padding: 0;
    }
  }
}



/*************************************************
* Full screen card logic
*************************************************/

.bslib-full-screen {
  position: fixed;
  inset: 3.5rem 1rem 1rem;
  height: auto !important;
  width: auto !important;
  z-index: $zindex-popover;
}

.bslib-full-screen-enter {
  display: none;
  position: absolute;
  bottom: 1px;
  right: 3px;
  margin: 0.5rem;
  padding: 0.55rem !important;
  font-size: .8rem;
  cursor: pointer;
  opacity: .6;
  color: rgba(var(--bs-body-bg-rgb), 1);
  &:hover {
    opacity: 1;
  }
  z-index: $zindex-popover;
}

.card:hover:not(.bslib-full-screen) .bslib-full-screen-enter {
  display: block;
}

// Only allow full_screen on desktop screens
@include media-breakpoint-down(sm) {
  .bslib-full-screen-enter { display: none !important; }
}

.bslib-full-screen-exit {
  position: relative;
  top: 1.35rem;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  float: right;
  margin-right: 2.15rem;
  align-items: center;
  color: rgba(var(--bs-body-bg-rgb), 0.8);
  &:hover {
    color: rgba(var(--bs-body-bg-rgb), 1);
  }
  svg {
    margin-left: 0.5rem;
    font-size: 1.5rem;
  }
}

#bslib-full-screen-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(var(--bs-body-color-rgb), 0.6);
  z-index: $zindex-popover - 1;
}
