// Accordions
// *******************************************************************************

@each $color, $value in $theme-colors {
  @if $color != primary {
    // Mixins of different Advance Styling
    @include template-accordion-header-variant('.accordion-header-#{$color}', $value);
  }
}
// arrow left

.accordion-arrow-left {
  .accordion-button.collapsed:focus {
    box-shadow: none;
  }

  .accordion-item {
    border: 0;
    &.active {
      box-shadow: none !important;
    }
  }
  .accordion-button {
    padding: var(--#{$prefix}accordion-btn-padding-y) 0;
    // Accordion icon
    &::after {
      content: '';
      display: none;
    }
    &:not(.collapsed) {
      color: var(--#{$prefix}accordion-active-color);
      background-color: var(--#{$prefix}accordion-active-bg);
      box-shadow: none; // stylelint-disable-line function-disallowed-list

      &::before {
        background-image: var(--#{$prefix}accordion-btn-active-icon);
        transform: var(--#{$prefix}accordion-btn-icon-transform);
      }
      &::after {
        background-image: none;
        transform: none;
      }
    }
    &::before {
      flex-shrink: 0;
      width: var(--#{$prefix}accordion-btn-icon-width);
      height: var(--#{$prefix}accordion-btn-icon-width);
      margin-left: 0;
      margin-right: 1.1rem;
      content: '';
      background-image: var(--#{$prefix}accordion-btn-icon);
      background-repeat: no-repeat;
      background-size: var(--#{$prefix}accordion-btn-icon-width);
      @include transition(var(--#{$prefix}accordion-btn-icon-transition));
    }
  }
}

// Accordion Popout Variant
.accordion-popout {
  .accordion-item {
    transition: margin 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    &:not(.active) {
      margin-left: 1rem;
      margin-right: 1rem;
    }
  }
}

.accordion-header + .accordion-collapse .accordion-body {
  padding-top: 0;
  padding-left: $accordion-padding-x;
}

.accordion:not(.accordion-custom-button):not(.accordion-arrow-left) {
  // accordion without icon
  &.accordion-without-arrow {
    .accordion-button::after {
      background-image: none !important;
    }
  }
  .accordion-item {
    box-shadow: $box-shadow-xs;
    border: 0;
    &.active {
      box-shadow: $box-shadow;
      & .accordion-button:not(.collapsed) {
        box-shadow: none;
      }
    }
    &:not(:first-child) {
      margin-top: $spacer * 0.5;
    }
    &:last-child {
      margin-bottom: $spacer * 0.5;
    }
  }
}

.accordion-header {
  line-height: $line-height-base;
}

// Accordion border radius
.accordion-button {
  padding-right: $accordion-body-padding-x;
  font-weight: inherit;
  @include border-top-radius($accordion-border-radius);
  &.collapsed {
    @include border-radius($accordion-border-radius);
  }
  &:not(.collapsed) {
    box-shadow: none;
  }
}

// Default card styles of accordion
.accordion > .card.accordion-item {
  border-radius: $accordion-border-radius !important;
  margin-bottom: 0.5rem;
}

// Accordion custom button

.accordion-custom-button {
  .accordion-item {
    transition: $accordion-transition;
    transition-property: margin-top, margin-bottom, border-radius, border;
    box-shadow: none;
    border: $accordion-border-width solid $accordion-border-color;
    &:not(:last-child) {
      border-bottom: 0;
    }
    &:not(.active):not(:first-child) {
      .accordion-header {
        border: none;
      }
    }
    .accordion-button {
      border-color: $accordion-border-color;
    }
    &.active {
      margin: 0;
      box-shadow: none;
      .accordion-header .accordion-button {
        border-bottom: $accordion-border-width solid $accordion-border-color;
      }
      & + .accordion-item {
        @include border-top-radius(0);
      }
      &:not(:first-child) {
        @include border-top-radius(0);
      }
      &:not(:last-child) {
        @include border-bottom-radius(0);
      }
    }
    .accordion-body {
      padding-top: $accordion-body-padding-x;
    }
    &.previous-active {
      @include border-bottom-radius(0);
    }
  }

  .accordion-button {
    border-radius: 0;
    background-color: #fafafa;
    &:not(.collapsed) {
      &::after {
        background-image: escape-svg($accordion-custom-button-active-icon);
        transform: rotate(-180deg);
      }
    }
    // Accordion icon
    &::after {
      background-image: escape-svg($accordion-custom-button-icon);
    }
  }

  &:focus {
    z-index: 3;
    border-color: $border-color;
    outline: 0;
    box-shadow: var(--#{$prefix}accordion-btn-focus-box-shadow);
  }
}

// RTL
// *******************************************************************************

@include rtl-only {
  .accordion-arrow-left {
    .accordion-button {
      &::before {
        margin-left: 1.1rem;
        margin-right: 0;
        transform: rotate(90deg);
      }
      // !- For RTL accordion icon rotation in other templates
      &:not(.collapsed)::before {
        transform: rotate(0deg);
      }
    }
  }
  .accordion-button {
    text-align: right;
    &::after {
      margin-left: 0;
      margin-right: auto;
    }
  }
  .accordion-custom-button {
    .accordion-button:not(.collapsed)::after {
      transform: rotate(180deg);
    }
  }
}

//Dark style
// *******************************************************************************

@include dark-layout-only {
  .accordion-custom-button {
    .accordion-button {
      background-color: #313246;
    }
  }
  .accordion:not(.accordion-custom-button):not(.accordion-arrow-left) .accordion-item {
    box-shadow: $box-shadow-xs;
    &.active {
      box-shadow: $box-shadow;
    }
  }
}
