.sidebar {
  min-width: $sidebar-width;
  max-width: $sidebar-width;
  transition: $sidebar-transition;
  direction: ltr;
  background: $sidebar-bg;
}

.sidebar-content {
  transition: $sidebar-transition;
  display: flex;
  height: 100vh;
  flex-direction: column;
  background: $sidebar-bg;
}

.sidebar-nav {
  padding: 0.7rem;
  margin-bottom: 0;
  list-style: none;
  flex-grow: 1;
}

// Sidebar links
.sidebar-link,
a.sidebar-link {
  display: block;
  padding: $sidebar-link-padding;
  font-weight: $sidebar-link-font-weight;
  transition: background 0.1s ease-in-out;
  position: relative;
  text-decoration: none;
  cursor: pointer;
  border-left-style: solid;
  border-left-width: 3px;
  color: $sidebar-link-color;
  background: $sidebar-link-bg;
  border-left-color: $sidebar-link-border-left-color;

  i,
  svg {
    margin-right: 0.75rem;
    color: $sidebar-link-icon-color;
  }
}

.sidebar-link:focus {
  outline: 0;
}

.sidebar-link:hover {
  color: $sidebar-link-hover-color;
  background: $sidebar-link-hover-bg;
  border-radius: var(--#{$prefix}border-radius);

  i,
  svg {
    color: $sidebar-link-icon-hover-color;
  }
}

.sidebar-link[aria-expanded="true"] {
  color: $primary;
  background: $sidebar-link-active-bg;
  border-radius: var(--#{$prefix}border-radius);

  i,
  svg {
    color: $primary;
  }
}

.sidebar-item.active > .sidebar-link,
.sidebar-item.active .sidebar-link:hover {
  color: $sidebar-link-active-color;
  background: $sidebar-link-active-bg;
  border-radius: var(--#{$prefix}border-radius);

  i,
  svg {
    color: $sidebar-link-icon-active-color;
  }
}

// Children
.sidebar-dropdown .sidebar-link {
  padding: $sidebar-link-child-padding;
  font-weight: $sidebar-link-child-font-weight;
  font-size: $sidebar-link-child-font-size;
  border-left: 0;
  color: $sidebar-link-child-color;
  background: $sidebar-link-child-bg;

  &:before {
    content: "→";
    display: inline-block;
    position: relative;
    left: -14px;
    transition: all 0.1s ease;
    transform: translateX(0);
  }
}

.sidebar-dropdown .sidebar-item .sidebar-link:hover {
  font-weight: $sidebar-link-hover-font-weight;
  border-left: 0;
  color: $sidebar-link-child-hover-color;
  background: $sidebar-link-child-hover-bg;

  &:hover {
    &:before {
      transform: translateX(4px);
    }
  }
}

.sidebar-dropdown .sidebar-item.active .sidebar-link {
  font-weight: $sidebar-link-active-font-weight;
  border-left: 0;

  color: $sidebar-link-child-active-color;
  background: $sidebar-link-child-active-bg;
}

// Chevron
.sidebar [data-bs-toggle="collapse"] {
  position: relative;
}

.sidebar [data-bs-toggle="collapse"]:after {
  content: " ";
  border: solid;
  border-width: 0 0.075rem 0.075rem 0;
  display: inline-block;
  padding: 2px;
  transform: rotate(45deg);
  position: absolute;
  top: 1.2rem;
  right: 1.5rem;
  transition: all 0.2s ease-out;
}

.sidebar [aria-expanded="true"]:after,
.sidebar [data-bs-toggle="collapse"]:not(.collapsed):after {
  transform: rotate(-135deg);
  top: 1.4rem;
}

// Sidebar brand
.sidebar-brand {
  font-weight: $sidebar-brand-font-weight;
  font-size: $sidebar-brand-font-size;
  padding: $sidebar-brand-padding-y $sidebar-brand-padding-x;
  display: block;
  color: $sidebar-brand-color;

  &:hover {
    text-decoration: none;
    color: $sidebar-brand-color;
  }

  &:focus {
    outline: 0;
  }
}

.sidebar-brand-text {
  display: block;
  padding-left: 1rem;
}

// Toggle states
.sidebar-toggle {
  cursor: pointer;
  width: 26px;
  height: 26px;
  display: flex;
}

.sidebar {
  &.collapsed {
    margin-left: -$sidebar-width;
  }

  // Workaround for IE bug, more info:
  // https://stackoverflow.com/a/25850649
  @media (min-width: 1px) and (max-width: #{map-get($grid-breakpoints, 'lg') - .02px}) {
    // Sidebar default state (on mobile)
    margin-left: -$sidebar-width;

    // Sidebar collapsed state (on mobile)
    &.collapsed {
      margin-left: 0;
    }
  }
}

.sidebar-toggle {
  margin-right: $spacer;
}

// Sidebar header
.sidebar-header {
  background: transparent;
  padding: $sidebar-header-padding;
  font-size: $sidebar-header-font-size;
  color: $sidebar-header-color;
}

// Badge
.sidebar-badge {
  position: absolute;
  right: 15px;
  top: 14px;
  z-index: 1;
}

@if $enable-dark-mode {
  @include color-mode(dark) {
    .sidebar {
      background: $body-bg-dark;
    }

    .sidebar-content {
      background: $body-bg-dark;
    }

    .sidebar-link,
    a.sidebar-link {
      color: $sidebar-link-color-dark;
      background: $sidebar-link-bg-dark;

      i,
      svg {
        color: $sidebar-link-icon-color-dark;
      }
    }

    .sidebar-link:hover {
      background: $sidebar-link-hover-bg;
      color: $primary;

      i,
      svg {
        color: $primary;
      }
    }

    .sidebar-link[aria-expanded="true"] {
      background: $sidebar-link-hover-bg;
      color: $primary;

      i,
      svg {
        color: $primary;
      }
    }

    .sidebar-brand {
      color: $sidebar-brand-color-dark;
    }
  }
}
