@import '../style/theme/color';
@import '../style/core/font';
@import '../style/core/animation';
@import '../style/theme/corner';

:host {
  display: inline-block;
  width: fit-content;
  font-size: 0;
  line-height: 1;
  vertical-align: middle;
}

.devui-toggle {
  width: 36px;
  height: 18px;
  border-radius: $devui-border-radius-full;
  background: $devui-line;
  border: 1px solid $devui-line;
  position: relative;
  display: inline-block;
  box-sizing: content-box;
  overflow: visible;
  padding: 0;
  margin: 0;
  cursor: pointer;
  transition: $devui-animation-duration-slow $devui-animation-ease-in-out-smooth all;

  &:not(.devui-checked):hover {
    background-color: $devui-gray-40;
    border-color: $devui-gray-40;
  }

  .devui-toggle-inner-wrapper {
    display: inline-block;
    width: 100%;
    height: 100%;
    font-size: $devui-font-size-sm;
    line-height: 18px;
    padding-left: 14px;

    .devui-toggle-inner {
      width: 100%;
      height: 100%;
      text-align: center;
      color: $devui-light-text;
    }
  }

  &.devui-checked .devui-toggle-inner-wrapper {
    padding-left: unset;
    padding-right: 14px;
  }

  small {
    width: 12px;
    height: 12px;
    background: $devui-light-text;
    border-radius: $devui-border-radius-full;
    position: absolute;
    top: 3px;
    left: 3px;
    transition: $devui-animation-duration-base $devui-animation-ease-in-out-smooth all;

    &.mouseDown {
      width: 15px;
    }
  }

  &.devui-checked small {
    left: 21px;

    &.mouseDown {
      left: 18px;
    }
  }

  &.devui-toggle-lg {
    width: 58px;
    height: 30px;

    .devui-toggle-inner-wrapper {
      font-size: $devui-font-size-modal-title;
      line-height: 30px;
      padding-left: 24px;
    }

    &.devui-checked .devui-toggle-inner-wrapper {
      padding-left: unset;
      padding-right: 24px;
    }

    & small {
      width: 22px;
      height: 22px;
      top: 4px;
      left: 4px;

      &.mouseDown {
        width: 26px;
      }
    }

    &.devui-checked small {
      background: $devui-light-text;
      left: 32px;

      &.mouseDown {
        left: 28px;
      }
    }
  }

  &.devui-toggle-sm {
    width: 30px;
    height: 14px;

    .devui-toggle-inner-wrapper {
      font-size: $devui-font-size-sm;
      line-height: 14px;
      padding-left: 12px;
    }

    &.devui-checked .devui-toggle-inner-wrapper {
      padding-left: unset;
      padding-right: 12px;
    }

    & small {
      width: 10px;
      height: 10px;
      position: absolute;
      top: 2px;
      left: 3px;

      &.mouseDown {
        width: 12px;
      }
    }

    &.devui-checked small {
      left: 17px;

      &.mouseDown {
        left: 15px;
      }
    }
  }

  &.devui-checked {
    background: $devui-brand;
    border-color: $devui-brand;

    &:hover {
      background: $devui-primary-hover;
      border-color: $devui-primary-hover;
    }

    &:active {
      background: $devui-primary-hover;
      border-color: $devui-primary-hover;
    }
  }

  &.devui-disabled {
    &,
    &:hover,
    &:active,
    &.devui-checked {
      cursor: not-allowed;
    }

    &,
    &:hover,
    &:active {
      background-color: $devui-disabled-line;
      border-color: $devui-disabled-line;

      small {
        background-color: $devui-unavailable;
      }
    }

    &.devui-checked {
      background-color: $devui-icon-fill-active-disabled;
      border-color: $devui-icon-fill-active-disabled;

      small {
        background-color: $devui-light-text;
      }
    }
  }
}
