/*! _toggles.scss | Vuero | Css ninja 2020-2024 */

/*
    1. Sliding Switch
    2. Special Checkbox
*/

/* ==========================================================================
1. Sliding Switch
========================================================================== */

.sliding-toggle {
  width: 86px;
  display: block;
  position: relative;
  cursor: pointer;
  font-size: 22px;
  user-select: none;

  input {
    position: absolute;
    opacity: 0;
    cursor: pointer;

    &:checked ~ .toggler {
      border-color: var(--primary);

      .dark,
      .light {
        transform: translateX(calc(var(--transform-direction) * 100%))
          rotate(calc(var(--transform-direction) * 360deg));
      }

      .dark {
        opacity: 1 !important;
      }

      .light {
        opacity: 0 !important;
      }
    }
  }

  .toggler {
    position: relative;
    display: block;
    height: 31px;
    width: 53px;
    border: 2px solid var(--primary);
    border-radius: 100px;
    transition: all 0.3s; // transition-all test

    .dark,
    .light {
      position: absolute;
      top: 2px;
      inset-inline-start: 2px;
      height: 22px;
      width: 22px;
      border-radius: var(--radius-rounded);
      background: black;
      display: flex;
      justify-content: center;
      align-items: center;
      transform: translateX(calc(var(--transform-direction) * 0))
        rotate(calc(var(--transform-direction) * 0));
      transition: all 0.3s ease;

      .iconify {
        color: var(--white) !important;
        height: 14px !important;
        width: 14px !important;
        opacity: 1 !important;
      }
    }

    .light {
      background: var(--primary);
      border-color: var(--primary);
      opacity: 1;
      z-index: 1;
    }

    .dark {
      background: var(--primary);
      border-color: var(--primary);
      opacity: 0;
      z-index: 0;

      .iconify {
        color: var(--white) !important;
      }
    }
  }
}

/* =====================================================
2. Special Checkbox
===================================================== */

.special-checkbox {
  position: relative;

  label {
    background-color: var(--white);
    border: 1px solid var(--primary-grey);
    border-radius: var(--radius-rounded);
    cursor: pointer;
    height: 28px;
    inset-inline-start: 0;
    position: absolute;
    top: 0;
    width: 28px;

    &::after {
      border: 2px solid var(--white);
      border-top: none;
      border-inline-end: none;
      content: '';
      height: 6px;
      inset-inline-start: 7px;
      opacity: 0;
      position: absolute;
      top: 8px;
      transform: rotate(calc(var(--transform-direction) * -45deg));
      width: 12px;
    }
  }

  input[type='checkbox'] {
    visibility: hidden;
  }

  input[type='checkbox']:checked + label {
    background-color: var(--primary);
    border-color: var(--primary);
  }

  input[type='checkbox']:checked + label::after {
    opacity: 1;
  }

  // Size modifier
  &.is-small {
    label {
      height: 20px;
      width: 20px;

      &::after {
        inset-inline-start: 4px;
        top: 5px;
        width: 11px;
        height: 6px;
        transform: rotate(calc(var(--transform-direction) * -45deg)) scale(0.8);
      }
    }

    span {
      position: relative;
      top: -2px;
      padding: 0 10px;
      cursor: default;
    }
  }
}
