.dropdown-menu {
  padding: 0;
  box-shadow: $box-shadow-sm;
  .dropdown-item {
    svg {
      fill: currentColor;
    }
  }
}

// taken from
// https://github.com/twbs/bootstrap/blob/main/scss/_accordion.scss#L32-L41
.dropdown-toggle {
  padding: 0.5rem 0.75rem;
  svg {
    fill: currentColor;
  }
  &:empty {
    padding: 0.5rem 0.25rem;
  }
  display: inline-flex;
  align-items: center;
  &::after {
    display: inline-block;
    flex-shrink: 0;
    width: rem(24px);
    height: rem(24px);
    margin: auto 0 auto auto;
    content: "";
    background-image: escape-svg($arrow-bg-dark);
    background-repeat: no-repeat;
    background-size: rem(24px);
    transition: transform 0.3s ease-in-out;
  }
  &.disabled::after,
  &:disabled::after {
    background-image: escape-svg(
      url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' fill='#{$navbar-dark-disabled-color}' viewBox='0 0 24 24'><path d='M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z'></path></svg>")
    ) !important;
  }

  &.active:focus-visible,
  &:focus-visible {
    outline: $border-width solid $blue-dark;
  }
  &.active:focus:not(:focus-visible),
  &:focus:not(:focus-visible) {
    outline: none;
  }

  &.vertical-toggle {
    background: none;
    border: none;

    &::after {
      content: none;
    }
  }
}

@each $color, $value in $caret-icon-fill {
  .dropdown {
    .btn-#{$color} {
      &.dropdown-toggle {
        &::after,
        &:hover::after {
          background-image: escape-svg(
            url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' fill='#{$value}' viewBox='0 0 24 24'><path d='M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z'></path></svg>")
          ) !important;
        }
      }
    }

    &.show {
      .dropdown-toggle {
        &::after {
          transform: rotate(180deg);
          background-image: escape-svg(
            url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' fill='#{$value}' viewBox='0 0 24 24'><path d='M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z'></path></svg>")
          ) !important;
        }
      }
    }
  }
}

@each $color, $value in $theme-colors {
  .btn-outline-#{$color} {
    &.dropdown-toggle {
      &::after {
        background-image: escape-svg(
          url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' fill='#{$value}' viewBox='0 0 24 24'><path d='M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z'></path></svg>")
        ) !important;
      }
      &:hover::after {
        background-image: escape-svg($arrow-bg-dark) !important;
      }
    }
  }
}

.btn-outline-light {
  &.dropdown-toggle {
    &::after,
    &:hover::after {
      background-image: escape-svg($arrow-bg-light) !important;
    }
  }
}

// navbar related
.bg-light {
  .dropdown-toggle {
    &::after {
      background-image: escape-svg($arrow-bg-light) !important;
    }
    &:hover::after {
      background-image: escape-svg($arrow-bg-dark) !important;
    }
    &.disabled::after,
    &:disabled::after {
      background-image: escape-svg(
        url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' fill='#{$gray-300}' viewBox='0 0 24 24'><path d='M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z'></path></svg>")
      ) !important;
    }
  }
}
// end of navbar related

.dropdown {
  &.show {
    .btn-outline-light.dropdown-toggle {
      border-color: $gray-100;

      &::after {
        transform: rotate(180deg);
        background-image: escape-svg($arrow-bg-light) !important;
      }
    }

    .dropdown-toggle {
      &::after {
        transform: rotate(180deg);
        background-image: escape-svg($arrow-bg-dark) !important;
      }
    }

    .vertical-toggle {
      background-color: $blue;
      outline: none;

      svg {
        fill: $white;
      }
    }
  }

  .vertical-toggle {
    border-radius: 4px;
    padding: 0.5rem;
    color: $black;
    &:hover {
      background-color: $gray-100;
      svg {
        fill: $black;
      }
    }

    &:focus {
      background-color: $blue;

      svg {
        fill: $white;
      }
    }
  }
}

.dropdown-item {
  &.disabled,
  &:disabled {
    color: $gray-300;
    cursor: not-allowed;
    pointer-events: visible;
    background-color: $white;
    // Remove CSS gradients if they're enabled
    @if $enable-gradients {
      background-image: none;
    }
  }
  &.active {
    outline: $border-width solid $blue;
  }
  &.active:focus,
  &:focus {
    outline: $border-width solid $blue-dark;
  }
}

.dropdown-divider {
  border-color: $dropdown-border-color;
}

// Dropdown section headers
.dropdown-header {
  display: block;
  padding: $dropdown-header-padding;
  margin-bottom: 0; // for use with heading elements
  @include font-size($font-size-sm);
  color: $dropdown-header-color;
  white-space: nowrap; // as with > li > a
  text-transform: uppercase;
}

/* input group button group custom styling */

@each $color, $value in $theme-colors {
  .input-group-prepend > .dropdown > .btn-group.btn-outline-#{$color},
  .input-group-prepend > .dropdown > .dropdown-toggle.btn.btn-outline-#{$color} {
    @include border-left-radius(0);
  }
  .input-group-append > .dropdown > .btn-outline-#{$color},
  .input-group-append > .dropdown > .dropdown-toggle.btn.btn-outline-#{$color} {
    @include border-right-radius(0);
  }
}
