@import "src/assets/scss/variables";

:root {
  --toggle-color: #ccc;
}

:root[data-theme="dark"] {
  --toggle-color: transparent;
}

.custom-toggler {
  .readonly{
    pointer-events: none!important;
    cursor: not-allowed!important;
  }
  margin-top: 1.4rem;
  position: relative;
  display: inline-block;
  width: 100%;
  height: 34px;
  min-width: max-content;
  padding-right: 45px;

  &.small {
    transform: scale(0.8);
    margin-top: 0.9rem;
  }

  p {
    font-size: $index-size;
    color: $white;
    width: max-content;
    margin-right: 10px;

    &.white {
      color: $rolebox-background;
    }
    &.semi {
      color: $white;
    }

    &.dark {
      color: $title-color;
    }
  }

  .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    right: 0;
    bottom: 0;
    background-color: var(--toggle-color);
    border: 1px solid $inactive-text;
    transition: 0.25s;
    border-radius: 34px;
    width: 50px;
    height: 22px;
    display: flex;
    justify-content: center;
    align-items: center;

    &::before {
      position: absolute;
      content: "";
      height: 14px;
      width: 14px;
      bottom: 3px;
      background-color: $white;
      transition: left 0.25s, background-color 0.25s;
      border-radius: 50%;
      left: 4px;
    }

    /* Default 2-state off appearance (keeps old behavior) */
    &.state-off {
      background-color: var(--toggle-color);
      border-color: $inactive-text;

      &::before {
        left: 4px;

      }
    }

    /* neutral middle (indeterminate) */
    &.state-null {
      background-color: var(--toggle-color);
      border-color: var(--inactive-text);

      &::before {
        left: calc(50% - 7px);
      }
    }

    /* on states */
    &.state-on.secondary-color {
      background-color: $secondary-color;
      border-color: $secondary-color;

      &::before {
        left: calc(100% - 18px);
      }
    }

    &.state-on.success-color {
      background-color: $success-color;
      border-color: $success-color;

      &::before {
        left: calc(100% - 18px);
      }
    }
  }

  /* --- tri-state specific overrides --- */
  &.tri-state {
    .slider {
      /* when this component is tri-state, the off state should be the error color */
      &.state-off {
        background-color: $error-color;
        border-color: $error-color;

        &::before {
          left: 4px;
        }
      }

      /* make sure state-null stays neutral */
      &.state-null {
        background-color:var(--toggle-color);
        border-color: var(--inactive-text);
      }

      /* on states unchanged (success/secondary) */
    }
  }
  &.a1lock{
    p{

      margin-left: 10px;
      max-width:65px ;
      font-size: 10px;
      margin-right: 10px;
      line-height: 12px;
    }
    margin-right: 10px;
    margin-top: 0!important;
    width:150px!important;
    padding-right: 50px;
    height:30px;
    display: flex;
    align-items: center;

    .slider {
      top: 50%;
      transform: translateY(-50%);
      margin-right: 10px;
      padding-left: 10px;
    }
    &.locked{
      background-color: #61C765;
    }
    &.unlocked{
      background-color: #E3AC16;
    }
  }
}
