@import '../variables/color';
@import '../mixins/hover';

.custom-toggle {
  .custom-control-label {
    &::before {
      display: none;
    }
  }
}

.toggle-container {
  display: flex;
  align-items: center;

  &.toggle-lg {
    .toggle {
      height: 1.25rem;
      width: 3.5rem;
      
      .handle {
        height: 2rem;
        width: 2rem;
        left: 2rem;
        margin-left: -2rem; 
        font-size: 1.5rem;
      }
    }
  }

  .toggle {
    margin-bottom: 0;
    position: relative;
    height: 1rem;
    width: 2.5rem;
    border-radius: 1rem;
    display: -webkit-flex;
    display: -ms-flex;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    cursor: pointer;
    transition: linear 0.2s, background-color linear 0.2s;
    background-color: $gray-30;

    input {
      display: none;
    }
    &:hover {
      .handle{
        //box-shadow: 0 0 0 2px map-get($button-hover-colors, 'secondary');
        background-color: map-get($button-hover-colors, 'secondary');
      }
    }
    &:focus-visible {
      outline: none;
      .handle{
        background-color: map-get($button-hover-colors, 'secondary');
        outline: 2px solid map-get($button-hover-colors, 'secondary');
        box-shadow: inset 0 0 0 2px map-get($button-focus-colors, 'secondary') !important;
      }
      &.checked {
        .handle{
          outline: 2px solid map-get($button-hover-colors, 'primary');
          box-shadow: inset 0 0 0 2px map-get($button-focus-colors, 'primary') !important;
        }
      }
    }
    .handle {
      height: 1.5rem;
      width: 1.5rem;
      padding: .25rem;
      border-radius: 100px;
      display: flex;
      justify-content: center;
      align-items: center;
      transition: linear 0.15s, background-color linear 0.15s;
      position: absolute;
      left: 1.5rem;
      margin-left: -1.5rem;
      cursor: pointer;
      background-color: $navy;
      color: $white;
      font-size: 1rem;
    }

    /* When toggle is checked */
    &.checked {
      justify-content: flex-start;
      background-color: map-get($badge-buttons-light, 'primary');

      .handle {
        left: 100%;
        background-color: $primary;
      }
      @include hover-focus{
        .handle{
          background-color: map-get($button-hover-colors, 'primary');
        }
      }
    }

    /* When togle is disabled */
    &.disabled {
      cursor: not-allowed;
      .handle {
        background-color: #828B8E;
        cursor: not-allowed;
      }

      @include hover-focus{
        .handle{
          background-color: #828B8E;
          box-shadow: none;
        }
      }
      &.checked {
        .handle {
          background-color: #6EB2AF;
        }
  
        @include hover-focus{
          .handle{
            background-color: #6EB2AF;
            box-shadow: none;
          }
        }
      }
    }
  }

  .toggle-label {
    margin-left: 0.5rem;
    margin-bottom: 0;
    line-height: 26px;
    &:hover{
      cursor: pointer;
    }
  }
}
