/* smart-switch-button */
smart-switch-button {
  width: var(--smart-switch-button-default-width);
  height: var(--smart-switch-button-default-height);

  &[orientation="vertical"] {
    height: var(--smart-switch-button-default-width);
    width: var(--smart-switch-button-default-height);
  }

  &.smart-element {
    display: inline-block;
    border: none;
    background: none;
    overflow: visible;
  }
}

.smart-switch-button {
  .smart-thumb {
    border: var(--smart-border-width) solid var(--smart-border);
    border-radius: 100%;
    width: var(--smart-switch-button-thumb-size);
    height: var(--smart-switch-button-thumb-size);
    background-color: var(--smart-surface);
    box-shadow: var(--smart-elevation-2);
    align-self: center;
    position: relative;
    cursor: pointer;
    order: 2;
    pointer-events: all;

    &:before {
      background-color: var(--smart-primary);
      position: absolute;
      width: 200%;
      height: 200%;
      left: 50%;
      top: 50%;
      transition: 0.2s;
      display: block;
      border-radius: 100%;
      content: "";
      transform: scale(0) translate(-50%, -50%);
      transform-origin: left top;
      opacity: 0.2;
    }

    &:active {
      &:before {
        animation: button-wave-effect 0.1s ease-in;
        transform: scale(1) translate(-50%, -50%);
      }
    }
  }

  .smart-container {
    font-size: inherit;
    position: relative;
    user-select: none;
    -moz-user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
    touch-action: none;

    &:before {
      content: "";
      position: absolute;
      width: 90%;
      height: 50%;
      left: 5%;
      top: 25%;
      border-radius: 10px;
      background-color: var(--smart-surface);
    }
  }

  .smart-inner-container {
    width: calc(200% - var(--smart-switch-button-thumb-size));
    height: 100%;
    position: absolute;
    color: inherit;
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    pointer-events: none;
    left: 0;
  }

  .smart-true-content,
  .smart-false-content {
    font-size: inherit;
    font-weight: inherit;
    display: inline-block;
    text-align: center;
    box-sizing: border-box;
    color: inherit;
  }

  .smart-true-content-container,
  .smart-false-content-container {
    //width: calc(100% - var(--smart-switch-button-thumb-size));
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-clip: content-box;
    padding: 2px 0px 2px 0px;
    color: inherit;
    overflow: hidden;
    order: 1;

    width: calc((100% - var(--smart-switch-button-thumb-size)) / 2);
  }

  .smart-true-content-container {
    order: 1;
  }

  .smart-false-content-container {
    order: 3;
  }

  &:not([animation="none"]) {
    .smart-container {
      &:before {
        transition: opacity 0.2s ease-in-out, background 0.2s ease-in-out;
      }
    }

    &:not([dragged]):not([checked="null"]) {
      .smart-inner-container {
        transition: left 0.2s ease-in-out;
      }
    }

    &[orientation="vertical"]:not([dragged]):not([checked="null"]) {
      .smart-inner-container {
        transition: top 0.2s ease-in-out;
      }
    }
  }

  &[hover] {
    border-color: var(--smart-ui-state-hover);
  }

  &:focus {
    .smart-thumb {
      background-color: var(--smart-primary);
      border-color: var(--smart-primary);

      &:before {
        transform: scale(1) translate(-50%, -50%);
        background-color: var(--smart-primary);
        animation: button-wave-effect 0.1s ease-in;
      }
    }
  }

  &[readonly] {
    pointer-events: none;
  }

  &[disabled] {
    .smart-thumb {
      &:before {
        content: none;
      }
    }
  }

  &[checked] {
    .smart-thumb {
      background-color: var(--smart-primary);
      border-color: var(--smart-primary);

      &:active {
        &:before {
          transform: scale(1) translate(-50%, -50%);
          background-color: var(--smart-primary);
        }
      }
    }

    .smart-container {
      &:before {
        background-color: var(--smart-primary);
        opacity: 0.4;
      }
    }

    .smart-inner-container {
      left: calc(-1 * (100% - var(--smart-switch-button-thumb-size)));
    }

    &:focus {
      .smart-thumb {
        &:before {
          transform: scale(1) translate(-50%, -50%);
          background-color: var(--smart-primary);
        }
      }
    }

    &[inverted] {
      .smart-inner-container {
        left: 0;
      }
    }

    &:not([animation="none"]) {
      .smart-thumb {
        &:active {
          &:before {
            animation: button-wave-effect 0.1s ease-in;
          }
        }
      }

      &:focus {
        .smart-thumb {
          &:before {
            animation: button-wave-effect 0.1s ease-in;
          }
        }
      }
    }

    &[orientation="vertical"] {
      .smart-thumb {
        background-color: var(--smart-primary);

        &:active {
          &:before {
            transform: scale(1) translate(-50%, -50%);
            background-color: var(--smart-primary);
          }
        }
      }

      .smart-container {
        &:before {
          background-color: var(--smart-primary);
          opacity: 0.4;
        }
      }

      &:focus {
        .smart-thumb {
          &:before {
            transform: scale(1) translate(-50%, -50%);
            background-color: var(--smart-primary);
          }
        }
      }

      &:not([animation="none"]) {
        .smart-thumb {
          &:active {
            &:before {
              animation: button-wave-effect 0.1s ease-in;
            }
          }
        }

        &:focus {
          .smart-thumb {
            &:before {
              animation: button-wave-effect 0.1s ease-in;
            }
          }
        }
      }
    }
  }

  &[checked="null"] {
    .smart-thumb {
      background-color: var(--smart-surface);
      border-color: var(--smart-border);
    }

    .smart-inner-container {
      left: calc(-1 * 100% / 2 + var(--smart-switch-button-thumb-size) / 2);
    }

    .smart-true-content,
    .smart-false-content {
      visibility: hidden;
    }

    .smart-true-content-container,
    .smart-false-content-container {
      color: transparent;
    }

    &[inverted] {
      .smart-inner-container {
        left: calc(-1 * 100% / 2 + var(--smart-switch-button-thumb-size) / 2);
      }
    }
  }

  &[inverted] {
    .smart-inner-container {
      left: calc(-1 * (100% - var(--smart-switch-button-thumb-size)));
    }

    .smart-true-content-container {
      order: 3;
    }

    .smart-false-content-container {
      order: 1;
    }
  }

  &[orientation="vertical"] {
    .smart-thumb {
      //width: 100%;

      width: var(--smart-switch-button-thumb-size);
      height: var(--smart-switch-button-thumb-size);
      box-shadow: var(--smart-elevation-2);

      &:before {
        border: var(--smart-border-width) solid var(--smart-border);
      }

      &:active {
        &:before {
          animation: button-wave-effect 0.1s ease-in;
          transform: scale(1) translate(-50%, -50%);
        }
      }

      &:focus {
        .smart-thumb {
          &:before {
            transform: scale(1) translate(-50%, -50%);
          }
        }
      }
    }

    .smart-container {
      &:before {
        content: "";
        position: absolute;
        width: 50%;
        height: 90%;
        left: 25%;
        top: 5%;
        border-radius: 10px;
      }
    }

    .smart-inner-container {
      height: calc(200% - var(--smart-switch-button-thumb-size));
      width: 100%;
      flex-direction: column;
      left: 0;
      top: 0;
    }

    .smart-true-content-container,
    .smart-false-content-container {
      //height: calc(100% - var(--smart-switch-button-thumb-size));
      width: 100%;
      padding: 0px 2px 0px 2px;
      height: calc((100% - var(--smart-switch-button-thumb-size)) / 2);
    }

    &:focus {
      .smart-thumb {
        &:before {
          animation: button-wave-effect 0.1s ease-in;
        }
      }
    }

    &[checked] {
      .smart-inner-container {
        left: 0;
        top: calc(-1 * (100% - var(--smart-switch-button-thumb-size)));
      }

      &[inverted] {
        .smart-inner-container {
          top: 0;
        }
      }
    }

    &[checked="null"] {
      .smart-inner-container {
        top: calc(-1 * 100% / 2 + var(--smart-switch-button-thumb-size) / 2);
      }

      &[inverted] {
        .smart-inner-container {
          left: 0;
          top: calc(-1 * 100% / 2 + var(--smart-switch-button-thumb-size) / 2);
        }
      }
    }

    &[inverted] {
      .smart-inner-container {
        left: 0;
        top: calc(-1 * (100% - var(--smart-switch-button-thumb-size)));
      }
    }
  }
}

@keyframes button-wave-effect {
  0% {
    transform: scale(0.2) translate(-50%, -50%);
  }

  50% {
    transform: scale(0.5) translate(-50%, -50%);
  }

  100% {
    transform: scale(1) translate(-50%, -50%);
  }
}

@import 'rtl/_switchbutton';