.navds-switch {
  position: relative;
  min-height: 3rem;
  width: fit-content;
}

.navds-switch--right {
  width: auto;
}

.navds-switch--small {
  position: relative;
  min-height: 2rem;
}

/* Input */
.navds-switch__input {
  cursor: pointer;
  position: absolute;
  z-index: 1;
  width: 3rem;
  height: 3rem;
  opacity: 0;
  top: 0;
}

.navds-switch--small > .navds-switch__input {
  height: 2rem;
  top: 0;
}

/* Label */
.navds-switch__label-wrapper {
  cursor: pointer;
  color: var(--a-text-default);
}

.navds-switch__content {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding: 0.75rem 0 0.75rem 3.25rem;
}

.navds-switch--right > .navds-switch__label-wrapper > .navds-switch__content {
  padding: 0.75rem 3.25rem 0.75rem 0;
}

.navds-switch--small > .navds-switch__label-wrapper > .navds-switch__content {
  padding: calc(var(--a-spacing-2) - var(--a-spacing-05)) 0 calc(var(--a-spacing-2) - var(--a-spacing-05)) 3.25rem;
}

.navds-switch--right.navds-switch--small > .navds-switch__label-wrapper > .navds-switch__content {
  padding: calc(var(--a-spacing-2) - var(--a-spacing-05)) 3.25rem calc(var(--a-spacing-2) - var(--a-spacing-05)) 0;
}

.navds-switch--with-description,
.navds-switch--small > .navds-switch__label-wrapper > .navds-switch--with-description {
  padding-bottom: 0;
}

.navds-switch__input:hover ~ .navds-switch__label-wrapper,
.navds-switch__label-wrapper:hover {
  color: var(--ac-switch-action, var(--a-surface-action-selected));
}

.navds-switch__input:disabled:hover ~ .navds-switch__label-wrapper {
  color: inherit;
}

/* Track */
.navds-switch__track {
  width: 2.75rem;
  height: 1.5rem;
  background-color: var(--ac-switch-bg, var(--a-surface-default));
  border: 2px solid var(--a-border-default);
  position: absolute;
  top: var(--a-spacing-3);
  left: 0;
  border-radius: var(--a-border-radius-full);
  transition-property: background-color, border-color;
  transition-duration: 100ms;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

.navds-switch--small > .navds-switch__track {
  top: var(--a-spacing-1);
}

.navds-switch--right > .navds-switch__input,
.navds-switch--right > .navds-switch__track {
  right: 0;
  left: auto;
}

.navds-switch__input:checked ~ .navds-switch__track {
  background-color: var(--ac-switch-checked-bg, var(--a-surface-action-selected));
  border-color: var(--ac-switch-checked-bg, var(--a-surface-action-selected));
}

.navds-switch__input:hover ~ .navds-switch__track {
  background-color: var(--ac-switch-hover-bg, var(--a-surface-subtle));
}

.navds-switch__input:hover:checked:not(:disabled) ~ .navds-switch__track {
  background-color: var(--ac-switch-checked-hover-bg, var(--a-surface-action-selected-hover));
  border-color: var(--ac-switch-checked-hover-bg, var(--a-surface-action-selected-hover));
}

.navds-switch__input:disabled ~ .navds-switch__track {
  background-color: var(--ac-switch-bg, var(--a-surface-default));
}

.navds-switch__input:checked:disabled ~ .navds-switch__track {
  background-color: var(--ac-switch-checked-bg, var(--a-border-action-selected));
}

.navds-switch__input:focus-visible ~ .navds-switch__track {
  outline: 2px solid transparent;
  outline-offset: 2px;
  box-shadow:
    0 0 0 1px var(--a-surface-default),
    var(--a-shadow-focus);
}

@supports not selector(:focus-visible) {
  .navds-switch__input:focus ~ .navds-switch__track {
    outline: 2px solid transparent;
    box-shadow:
      0 0 0 1px var(--a-surface-default),
      var(--a-shadow-focus);
  }
}

/* Thumb */
.navds-switch__thumb {
  background-color: var(--ac-switch-thumb-bg, var(--a-surface-neutral));
  color: var(--ac-switch-thumb-icon, var(--a-icon-subtle));
  border-radius: var(--a-border-radius-full);
  width: 1.125rem;
  height: 1.125rem;
  position: absolute;
  transform: translateX(0);
  left: 0.0625rem;
  top: 0.0625rem;
  transition: transform 250ms cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.navds-switch__input:checked ~ .navds-switch__track > .navds-switch__thumb {
  transform: translateX(1.25rem);
  color: var(--ac-switch-thumb-icon-checked, var(--a-icon-action-selected));
  background-color: var(--a-surface-default);
  width: 1.25rem;
  height: 1.25rem;
  left: 0;
  top: 0;
}

.navds-switch__input:checked ~ .navds-switch__track .navds-switch__checkmark {
  visibility: visible;
}

.navds-switch__checkmark {
  visibility: hidden;
}

@media (hover: hover) and (pointer: fine) {
  .navds-switch__input:hover ~ .navds-switch__track > .navds-switch__thumb {
    transform: translateX(0.125rem);
  }

  .navds-switch__input:checked:hover ~ .navds-switch__track > .navds-switch__thumb {
    transform: translateX(1.125rem);
  }
}

.navds-switch__input:disabled:hover ~ .navds-switch__track > .navds-switch__thumb {
  transform: translateX(0);
}

.navds-switch__input:checked:disabled:hover ~ .navds-switch__track > .navds-switch__thumb {
  transform: translateX(1.25rem);
}

/* Disabled */
.navds-switch__input:disabled {
  appearance: none;
}

.navds-switch--disabled:not(.navds-switch--loading) {
  opacity: 0.3;
}

.navds-switch__input:disabled,
.navds-switch__input:disabled ~ .navds-switch__label-wrapper {
  cursor: not-allowed;
}

/* Readonly */
.navds-switch--readonly > .navds-switch__track,
.navds-switch--readonly > .navds-switch__input:hover ~ .navds-switch__track,
.navds-switch--readonly > .navds-switch__input:checked ~ .navds-switch__track,
.navds-switch--readonly > .navds-switch__input:checked:hover ~ .navds-switch__track {
  background-color: var(--a-surface-neutral-moderate);
  border-color: var(--a-border-subtle);
}

.navds-switch--readonly > .navds-switch__label-wrapper,
.navds-switch--readonly > .navds-switch__input {
  cursor: default;
}

.navds-switch--readonly > .navds-switch__input:hover ~ .navds-switch__label-wrapper,
.navds-switch--readonly .navds-switch__label-wrapper:hover {
  color: var(--a-text-default);
}

.navds-switch--readonly .navds-switch__label {
  display: inline-flex;
}

.navds-switch--readonly .navds-switch__thumb {
  background-color: var(--a-surface-neutral);
}

.navds-switch--readonly > .navds-switch__input:checked ~ .navds-switch__track > .navds-switch__thumb {
  color: var(--a-icon-on-neutral);
  background-color: var(--a-surface-neutral);
}

@media (hover: hover) and (pointer: fine) {
  .navds-switch--readonly > .navds-switch__input:hover ~ .navds-switch__track > .navds-switch__thumb {
    transform: translateX(0);
  }

  .navds-switch--readonly > .navds-switch__input:checked:hover ~ .navds-switch__track > .navds-switch__thumb {
    transform: translateX(1.25rem);
  }
}

@media (forced-colors: active) {
  .navds-switch__input:hover ~ .navds-switch__label-wrapper,
  .navds-switch__label-wrapper:hover {
    color: highlight;
  }

  .navds-switch__thumb,
  .navds-switch--readonly .navds-switch__thumb,
  .navds-switch__input:checked ~ .navds-switch__track > .navds-switch__thumb,
  .navds-switch--readonly .navds-switch__input:checked ~ .navds-switch__track > .navds-switch__thumb {
    background-color: fieldtext;
  }

  .navds-switch__input:checked ~ .navds-switch__track > .navds-switch__thumb,
  .navds-switch--readonly .navds-switch__input:checked ~ .navds-switch__track > .navds-switch__thumb {
    color: field;
  }

  .navds-switch--disabled:not(.navds-switch--loading) .navds-switch__input:checked ~ .navds-switch__track > .navds-switch__thumb {
    background-color: graytext;
  }

  .navds-switch__input:focus-visible ~ .navds-switch__track {
    outline: 2px solid highlight;
    outline-offset: 2px;
  }

  .navds-switch--disabled:not(.navds-switch--loading) {
    opacity: 1;
  }

  .navds-switch--disabled:not(.navds-switch--loading) .navds-switch__thumb {
    background-color: graytext;
    border-color: graytext;
  }

  .navds-switch--disabled:not(.navds-switch--loading) .navds-switch__track {
    border-color: graytext;
  }

  .navds-switch--disabled:not(.navds-switch--loading) .navds-switch__label-wrapper,
  .navds-switch--disabled:not(.navds-switch--loading) .navds-switch__label-wrapper:hover {
    color: graytext !important;
  }
}
