// Swaplist
//================================================== //

@mixin is-dragging() {
  background-color: $swaplist-bg-color;
  border: 1px solid transparent;
  opacity: 0.4;
  padding: 9px 20px 8px;
}

@mixin is-dragging-touch() {
  @include is-dragging();

  background-color: $swaplist-bg-color-selected;
  color: $ids-color-palette-white;
  opacity: 0.7;
  position: fixed;
  z-index: 2;

  p {
    color: $ids-color-palette-white;
  }
}

.swaplist {
  .card {
    border-bottom-width: 1px;
    border-color: $swaplist-border-color-card;
    border-left-width: 0;
    float: left;
    overflow: hidden;
    width: 50%;

    &:first-child {
      border-left-width: 1px;
    }

    .card-content {
      width: 100%;
      border-bottom-left-radius: 0;
      border-bottom-right-radius: 0;

      .listview {
        li {
          border-radius: 0;

          &:last-child {
            &.over {
              border: 1px dashed $swaplist-border-color !important;
              border-bottom-color: inherit;
            }
          }
        }
      }
    }

    .card-header {
      border-bottom: none;
      width: 100%;

      .btn {
        background-color: transparent;
        border: 0;
        color: $swaplist-icon-color;
        line-height: normal;
        margin: 0;
        min-width: 0;
        padding: 0;
        width: 35px;

        &::after,
        &::before {
          background: $swaplist-icon-color; //border color
          content: '';
          display: inline-block;
          left: 9px;
          position: absolute;
          top: 8px;
        }

        &::after { //border left and right
          box-shadow:
            0 6px 0 $swaplist-icon-color,
            0 12px 0 $swaplist-icon-color,
            16px 0 0 $swaplist-icon-color,
            16px 6px 0 $swaplist-icon-color,
            16px 12px 0 $swaplist-icon-color;
          height: 5px;
          width: 2px;
        }

        &::before { //border top and bottom
          box-shadow:
            13px 0 0 $swaplist-icon-color,
            0 16px 0 $swaplist-icon-color,
            13px 16px 0 $swaplist-icon-color;
          height: 2px;
          width: 5px;
        }

        &:hover,
        &:focus:not(.hide-focus):not(.is-disabled) {
          &::after,
          &::before {
            background: $swaplist-icon-color-hover; //border color
          }

          &::after {
            box-shadow:
              0 6px 0 $swaplist-icon-color-hover,
              0 12px 0 $swaplist-icon-color-hover,
              16px 0 0 $swaplist-icon-color-hover,
              16px 6px 0 $swaplist-icon-color-hover,
              16px 12px 0 $swaplist-icon-color-hover;
          }

          &::before {
            box-shadow:
              13px 0 0 $swaplist-icon-color-hover,
              0 16px 0 $swaplist-icon-color-hover,
              13px 16px 0 $swaplist-icon-color-hover;
          }

          .icon {
            color: $swaplist-icon-svg-color-hover;
          }
        }

        &:focus:not(.hide-focus):not(.is-disabled) {
          box-shadow: 0 0 0 1px $swaplist-border-color-hover, $focus-box-shadow;
        }

        &[disabled] {
          &::after,
          &::before {
            background: $swaplist-icon-color-disabled;
          }
        }

        &[disabled] {
          &::after {
            box-shadow:
              0 6px 0 $swaplist-icon-color-disabled,
              0 12px 0 $swaplist-icon-color-disabled,
              16px 0 0 $swaplist-icon-color-disabled,
              16px 6px 0 $swaplist-icon-color-disabled,
              16px 12px 0 $swaplist-icon-color-disabled;
          }
        }

        &[disabled] {
          &::before {
            box-shadow:
              13px 0 0 $swaplist-icon-color-disabled,
              0 16px 0 $swaplist-icon-color-disabled,
              13px 16px 0 $swaplist-icon-color-disabled;
          }
        }

        .icon {
          color: $swaplist-icon-svg-color;
          left: 13px;
          margin: 0;
          position: absolute;
          top: 8px;
          width: 10px;
        }

        &[disabled] {
          .icon {
            color: $swaplist-icon-svg-color-disabled;
          }
        }
      }
    }

    .buttons {
      line-height: normal;
      max-height: 35px;
      position: absolute;
      right: 10px;
      top: 7px;
      vertical-align: bottom;
    }

    .card-title {
      color: $swaplist-title-text-color;
      font-weight: $ids-number-font-weight-base;
      position: relative;
      top: 0;
    }

    p {
      color: $swaplist-text-color;
    }

    .is-disabled p {
      color: $listview-disabled-color;
    }
  }

  &.one-third {
    min-width: 370px;

    .card {
      width: 33%;
    }

    @include respond-to(phone) {
      .card {
        width: 50%;

        &:nth-child(2) {
          height: 180px;
          min-height: 180px;

          .btn:last-child svg {
            @include rotate(90);
          }

          .card-content {
            height: 130px;
            min-height: 130px;
          }
        }

        &:nth-child(3) {
          border-top: 0;
          height: 190px;
          margin-top: -20px;
          min-height: 190px;

          .btn:not(.is-rotate) svg {
            @include rotate(90);
          }

          .card-content {
            height: 140px;
            min-height: 140px;
          }
        }

        .buttons {
          right: 5px;
        }
      }
    }
  }

  .handle {
    color: $swaplist-icon-color-hover;
    display: none;
    font-size: 2.5em;
    left: 6px;
    position: absolute;
    top: 0;
  }

  .is-multiselect {
    background-color: $listview-bg-color;
    border-top: thin solid $swaplist-border-color-card;
    max-height: 100%;
    overflow-y: auto;

    ul {
      min-height: 40px;
      padding: 0 0 5px;

      &.is-not-droppable {
        li {
          &.is-selected {
            &:hover:not(.is-disabled),
            &:focus:not(.is-disabled) {
              .handle {
                display: none;
              }
            }
          }

          &:hover:not(.is-disabled):not(.is-selected),
          &:focus:not(.is-disabled):not(.is-selected) {
            .handle {
              display: none;
            }
          }
        }
      }
    }

    li {
      border: 1px solid transparent;
      margin-bottom: 1px;
      padding: 9px 20px;

      &::after,
      &::before,
      &.is-selected::after {
        content: none;
      }

      &.draggable {
        cursor: move;
      }

      &:hover:not(.is-disabled):not(.is-selected),
      &:focus:not(.is-disabled):not(.is-selected) {
        .handle {
          color: $swaplist-text-color;
          display: inline-block;
        }

        &:focus {
          border-color: $swaplist-border-color-focus;
        }
      }

      &.is-selected {
        background-color: $swaplist-bg-color-selected;

        p {
          color: $swaplist-text-color-selected;
          font-weight: $ids-number-font-weight-bold;
        }

        &:hover:not(.is-disabled),
        &:focus:not(.is-disabled) {
          background-color: $swaplist-bg-color-selected;

          .handle {
            color: $swaplist-text-color-selected;
            display: inline-block;
          }

          &:focus {
            border-color: $swaplist-border-color-focus;
          }
        }
      }

      &.is-dragging {
        @include is-dragging();
      }
    }

    .over {
      border: 1px dashed $swaplist-border-color !important;
      min-height: 40px;
    }
  }

  .is-dragging-touch {
    @include is-dragging-touch();
  }

  &.is-touch {
    .is-multiselect li:hover:not(.is-disabled):not(.is-selected) {
      background-color: transparent;

      .handle {
        display: none;
      }
    }
  }
}

.is-mac.is-firefox {
  .swaplist {
    .handle {
      top: 4px;
    }
  }
}

// Touch placeholder
#sl-placeholder-container {
  p,
  div {
    display: inline-block;
    margin: 0;
    padding: 0;
  }

  .is-dragging-touch {
    @include is-dragging-touch();
  }
}

// RTL Styles
html[dir='rtl'] {
  .swaplist {
    .card {
      border-left-width: 1px;
      border-right-width: 0;
      float: right;

      &:first-child {
        border-right-width: 1px;
      }

      .buttons {
        left: 10px;
        right: auto;
      }
    }

    &.one-third {
      @include respond-to(phone) {
        .card {
          .buttons {
            left: 5px;
            right: auto;
          }
        }
      }
    }

    .handle {
      left: auto;
      right: 10px;
    }
  }
}
