:root {
  --patients-tab-offset: 1.5rem;
}

.patients-layout--main-container {
  width: calc(100vw - var(--navbar-width));
  height: 100%;
  position: relative;
  z-index: 1;
}

.patients-layout--main-content {
  width: calc(100% - var(--sidebar-width));
  height: 100%;
  overflow-y: auto;
  padding-inline: 3.5rem;
  padding-bottom: 2rem;
  transition: width 0.3s ease-in-out;
  position: relative;
  z-index: 3;
  transition: width 0.3s ease-in-out;
  background-color: var(--neutral-50);
  
  &:has(.patients-layout--documents-container .highlight) {
    scroll-padding-top: 170px;
  }

  &:has(+ .sidebar--main-container[data-hidden="true"][data-opening="true"]) {
    width: calc(100% - var(--sidebar-width));
  }

  &:has(+ .sidebar--main-container[data-hidden="true"]) {
    width: 100%;
  }

  @media screen and (max-width: 576px) {
    width: 100%;
    padding-inline: 1rem;
    padding-block: 1rem;

    &:has(+ .sidebar--main-container[data-hidden="true"][data-opening="true"]),
    &:has(+ .sidebar--main-container[data-hidden="true"]) {
      width: 100%;
    }
  }
}

.patients-layout--main-content .tabs--div-container:has(a[data-tab-panel="profile"]) {
  top: var(--header-height);
  padding-block: var(--patients-tab-offset);
}

.main-content-container:has(.patients-layout--main-container) {
  padding: unset;
}

.patients-layout--container {
  padding-inline: 1px;
  padding-top: 0px;
  padding-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  position: relative;

  &:has(.tabs--anchored-container) > .layouts--details-cards-container {
    padding-block: unset;
    padding-bottom: 1.5rem;
  }

  @media screen and (max-width: 576px) {
    overflow-x: auto;
  }

  > .tabs--div-container {
    padding-bottom: 1.5rem;
  }
}

.patients-layout--lists-container {
  padding-top: 2rem;

  .log-entries--list-container {
    margin-top: 0;
  }
}

.patients-layout--referrals-list-container {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: .5rem;

  .pending-referral-list-item--container:not(:first-of-type) {
    border-top: 1px solid var(--neutral-100);
    padding-top: .5rem;
  }
}

.patients-layout--referrals-container {
  padding-top: 1.5rem;
}

.patients-layout--main-content > #chart--tabs.tabs--div-container {
  top: calc(var(--header-top-offset) + var(--header-height) + var(--tabs-height) + var(--patients-tab-offset) - 9px);
  z-index: 2;

  @media screen and (max-width: 576px) {
    position: relative;
    top: unset;
  }
}

.patients-layout--clincal-notes-filters-container {
  width: 100%;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: .5rem;
  padding-bottom: 1.5rem;
}

.patients-layout--referrals-tabs-filters-container {
  width: 100%;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: 1.5rem;

  .referrals--filters-container {
    margin-bottom: 0;
    padding: 1px;
    max-width: 100%;
    overflow-x: auto;
  }
}

.profile-with-nav {
  display: flex;
  align-items: flex-start;
  gap: 24px;
}

.profile-with-nav > .layouts--details-cards-container {
  flex: 1 1 auto;
  min-width: 0;
  /* Trailing space so the last card can scroll up to the top of the viewport */
  padding-bottom: calc(100dvh - 12rem);
}

/* On the patient profile the nav must pin below the sticky page header + tabs,
   not behind them, and sit 40px down per the design. */
.profile-with-nav .vertical-nav--container {
  top: calc(var(--header-top-offset) + var(--header-height) + var(--tabs-height) + var(--patients-tab-offset) + 40px - var(--patients-tab-offset));
  margin-top: calc(40px - var(--patients-tab-offset));
}

@media (max-width: 1024px) {
  .profile-with-nav > .vertical-nav--container { display: none; }
}
