// Old Third party dependency modification | Remove it, when 2024 AppsCode Custom Checkbox, Radio, Switch used everywhere
.is-checkradio.is-primary[type="checkbox"].is-primary:checked.has-background-color + label::before,
.is-checkradio.is-primary[type="checkbox"].is-primary:checked.has-background-color + label:before,
.is-checkradio.is-primary[type="checkbox"].is-primary:checked.has-background-color + label::after,
.is-checkradio.is-primary[type="checkbox"].is-primary:checked.has-background-color + label:after {
  background-color: $ac-primary !important;
}

.is-checkradio[type="checkbox"] + label::after,
.is-checkradio[type="checkbox"] + label:after {
  border-color: $ac-primary;
}

.is-checkradio[type="checkbox"]:checked + label::before,
.is-checkradio[type="checkbox"]:checked + label:before {
  border: 1px solid $ac-primary;
}

.is-checkradio.is-primary[type="radio"] + label::after,
.is-checkradio.is-primary[type="radio"] + label:after {
  background: $ac-primary !important;
}

.is-checkradio.is-primary[type="checkbox"]:checked + label::before,
.is-checkradio.is-primary[type="checkbox"]:checked + label:before,
.is-checkradio.is-primary[type="radio"]:checked + label::before,
.is-checkradio.is-primary[type="radio"]:checked + label:before {
  border-color: $ac-primary;
}

.is-checkradio[type="radio"].is-primary:checked + label::after,
.is-checkradio[type="radio"].is-primary:checked + label:after {
  background-color: $ac-primary !important;
  border-color: $ac-primary;
}

.switch[type="checkbox"].is-primary:checked + label::before,
.switch[type="checkbox"].is-primary:checked + label:before {
  background-color: $ac-primary;
}

.is-checkradio[type="radio"] + label::after,
.is-checkradio[type="radio"] + label:after {
  background-color: $ac-primary;
}

// 2024 AppsCode Custom Checkbox, Radio, Switch style
// checkbox
.ac-checkbox {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;

  input {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    cursor: pointer;
  }

  input:checked ~ .checkmark {
    background: $ac-primary;
    border: 1px solid $ac-primary;
  }

  input:checked ~ .checkmark::after {
    opacity: 1;
    transition: all 0.2s ease;
  }

  .checkmark {
    position: relative;
    display: block;
    top: 0;
    left: 1px;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 4px;
    border: 1px solid $color-border-dark;
    transition: all 0.2s ease;

    &::after {
      position: absolute;
      display: block;
      content: "";
      left: 50%;
      top: 45%;
      width: 4px;
      height: 8px;
      border: solid white;
      border-width: 0 2px 2px 0;
      transform: translate(-50%, -50%) rotate(45deg);
      opacity: 0;
      transition: all 0.2s ease;
    }
  }
  &:hover {
    .checkmark {
      border: 1px solid $ac-primary;
    }
  }
}

// radio button
.ac-radio {
  &:not(:last-child) {
    margin-bottom: 8px;
  }

  // Hide the actual radio inputs off-screen
  [type="radio"] {
    position: absolute;
    left: -9999px;
  }

  // Style for labels associated with radio buttons
  [type="radio"] + label {
    position: relative;
    padding-left: 24px;
    cursor: pointer;
    line-height: 20px;
    display: inline-block;

    // Base circle style
    &::before {
      content: "";
      position: absolute;
      left: 0;
      top: 0;
      width: 18px;
      height: 18px;
      border: 1px solid $color-border-dark;
      border-radius: 50%; // Full circle
      background: #fff;
      transition: 0.2s ease-in-out;
    }

    // Inner dot for selected radio button
    &::after {
      content: "";
      position: absolute;
      top: 4px;
      left: 4px;
      width: 10px;
      height: 10px;
      background: $ac-primary;
      border-radius: 50%;
      opacity: 0;
      transform: scale(0);
      transition:
        opacity 0.2s ease,
        transform 0.2s ease;
    }
  }

  // Checked state styles
  [type="radio"]:checked + label::after {
    opacity: 1;
    transform: scale(1);
  }
  [type="radio"]:checked + label::before {
    border: 1px solid $ac-primary;
  }
  &:hover {
    [type="radio"] + label {
      &::before {
        border: 1px solid $ac-primary;
      }
    }
  }
}

.ac-switch {
  &.is-fullwidth {
    background-color: $primary-light-gray;
    padding: 16px;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    border: 1px solid $color-border;
    label {
      color: $color-heading;
    }
  }
  .switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;

    input {
      position: absolute;
      opacity: 0;
      width: 100%;
      height: 100%;
      z-index: 1; // Keeps input clickable
      cursor: pointer;
    }

    .slider {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background-color: #ccc;
      transition:
        background-color 0.4s,
        box-shadow 0.4s;

      &.round {
        border-radius: 34px;

        &::before {
          border-radius: 50%;
        }
      }

      &:before {
        content: "";
        position: absolute;
        height: 16px;
        width: 16px;
        left: 4px;
        bottom: 3px;
        background-color: white;
        transition:
          transform 0.4s,
          background-color 0.4s;
      }
    }

    input:checked + .slider {
      background-color: $ac-primary;
    }

    input:checked + .slider:before {
      transform: translateX(16px);
    }

    input:focus-visible + .slider {
      box-shadow: 0 0 3px $ac-primary;
    }
  }
}

.details-with-checkradio-wrapper {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
}
