/**
* Copyright (c) 2022 - present TinyVue Authors.
* Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/

@import '../custom.less';
@import './vars.less';

@switch-prefix-cls: ~'@{css-prefix}switch';

.@{switch-prefix-cls} {
  .component-css-vars-switch();

  display: inline-block;
  width: var(--ti-switch-width);
  height: var(--ti-switch-height);
  line-height: calc(var(--ti-switch-height) - var(--ti-switch-border-weight) * 2);
  border-radius: var(--ti-switch-border-radius);
  vertical-align: middle;
  border: var(--ti-switch-border-weight) solid var(--ti-switch-off-bg-color);
  background-color: var(--ti-switch-off-bg-color);
  position: relative;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease-in-out;

  & &-inner {
    color: var(--ti-switch-text-color);
    font-size: var(--ti-switch-inner-font-size);
    position: absolute;
  }

  &__text {
    width: var(--ti-switch-text-width);
    .@{switch-prefix-cls}-inner {
      left: calc(var(--ti-switch-dot-size));
      width: calc(100% - var(--ti-switch-dot-size));
      text-align: center;
      overflow: hidden;
    }
  }

  &.mini {
    width: calc(var(--ti-switch-width) - 4px);
  }

  &&-checked.disabled,
  &.disabled {
    cursor: not-allowed;
    background: var(--ti-switch-disabled-bg-color);
    border-color: var(--ti-switch-disabled-bg-color);

    &::after {
      background: var(--ti-switch-disabled-dot-bg-color);
      cursor: not-allowed;
    }

    .@{switch-prefix-cls}-inner {
      color: var(--ti-switch-disabled-text-color);
    }
  }

  &&-checked.disabled {
    background: var(--ti-switch-checked-disabled-bg-color);
    border-color: var(--ti-switch-checked-disabled-border-color);
  }

  &::after {
    content: '';
    width: var(--ti-switch-dot-size);
    height: var(--ti-switch-dot-size);
    border-radius: 50%;
    background-color: var(--ti-switch-dot-bg-color);
    position: absolute;
    left: var(--ti-switch-dot-position-left); // smb新增
    top: var(--ti-switch-dot-position-top); // smb新增
    cursor: pointer;
    transition:
      left 0.2s ease-in-out,
      width 0.2s ease-in-out;
  }

  &&-checked {
    border-color: var(--ti-switch-on-bg-color);
    background-color: var(--ti-switch-on-bg-color);

    .@{switch-prefix-cls}-inner {
      left: 2px;
      width: calc(100% - var(--ti-switch-dot-size));
      text-align: center;
      overflow: hidden;
    }

    &:after {
      left: calc(100% - var(--ti-switch-dot-offset));
    }
  }
}
