@use '../abstract/_all';
@use '../abstract/setup';

.checkbox-item {
  text-align: center;
  position: relative;

  &.is-error {
    color: setup.$c-error;
    [type='checkbox']:checked + label::before,
    [type='checkbox']:not(:checked) + label::before {
      border: 1px solid setup.$c-error;
    }
  }

  .ico-check {
    width: 22px;
    height: 22px;
    left: 0;
    top: 0;
  }

  .ico-check::after {
    position: absolute;
    content: '';
    height: 1px;
    background-color: setup.$c-primary;
    width: 16px;
    transform: rotate(136deg);
    left: 4px;
    top: 8px;
  }

  .ico-check::before {
    position: absolute;
    content: '';
    width: 8px;
    height: 1px;
    top: 10px;
    transform: rotate(50deg);
    background-color: setup.$c-primary;
  }

  [type='checkbox']:not(:checked) + label,
  [type='checkbox']:checked + label {
    position: relative;
    padding-left: 40px;
    cursor: pointer;
    font-weight: normal;
    font-size: setup.$text-sm;
    text-align: initial;
    display: box;
    display: flexbox;
    display: flex;
  }

  [type='checkbox']:not(:checked) + label::before,
  [type='checkbox']:checked + label::before {
    position: absolute;
    content: '';
    width: 25px;
    height: 25px;
    left: 0;
    border: none;
    border: 1px solid setup.$c-dark-grey;
    outline: 0;
    display: inline-block;
    vertical-align: top;
    margin: 0 10px 0 0;
  }

  [type='checkbox']:not(:checked) + label span,
  [type='checkbox']:checked + label span {
    display: initial;
    vertical-align: top;
    margin: 5px 0 0;
    line-height: 16px;
    min-height: 20px;
    padding-left: 0;

    &::after {
      content: ' ';
    }
  }

  [type='checkbox']:not(:checked) + label a,
  [type='checkbox']:checked + label a {
    text-decoration: underline;
    margin-right: 4px;
  }

  [type='checkbox']:not(:checked),
  [type='checkbox']:checked {
    position: absolute;
    left: -9999px;
    width: 70px;
  }

  input[type='checkbox'] {
    box-sizing: border-box;
    padding: 0;
    margin: 4px 0 0;
    margin-top: 1px \9;
    line-height: normal;
  }

  [type='checkbox']:not(:checked) + label .icon,
  [type='checkbox']:checked + label .icon {
    position: absolute;
    top: 5px;
    left: 5px;
    color: setup.$c-primary;
    transition: all 0.2s;
  }

  [type='checkbox']:not(:checked) + label .icon {
    opacity: 0;
    transform: scale(0);
  }

  [type='checkbox']:checked + label .icon {
    opacity: 1;
    transform: scale(1);
  }

  &.color-filter {
    [type='checkbox']:not(:checked) + label,
    [type='checkbox']:checked + label {
      padding-left: 32px;
    }

    .color-wrap {
      button {
        margin-right: 0;
      }
    }

    [type='checkbox']:not(:checked) + label span,
    [type='checkbox']:checked + label span {
      padding-left: 24px;
    }
  }
}

.checkbox-item-2 {
  display: inline-block;
  text-align: center;
  margin: 10px 10px 0 0;

  [type='checkbox']:not(:checked) + label,
  [type='checkbox']:checked + label {
    position: relative;
    padding-left: 0;
    cursor: pointer;
    font-weight: normal;
    font-size: setup.$text-sm;
    text-align: initial;
    display: box;
    display: flexbox;
    display: flex;
  }

  [type='checkbox']:not(:checked) + label::before,
  [type='checkbox']:checked + label::before {
    position: absolute;
    content: '';
    width: 62px;
    height: 26px;
    border-radius: 30px;
    left: 0;
    border: none;
    border: 1px solid setup.$c-primary;
    outline: 0;
    display: inline-block;
    vertical-align: top;
    margin: 0 10px 0 0;
  }

  [type='checkbox']:not(:checked) + label span,
  [type='checkbox']:checked + label span {
    display: inline-block;
    vertical-align: top;
    margin: 5px 0 0;
    line-height: 16px;
    padding-left: 70px;
    min-height: 20px;
  }

  [type='checkbox']:not(:checked),
  [type='checkbox']:checked {
    position: absolute;
    left: -9999px;
    width: 70px;
  }

  input[type='checkbox'] {
    box-sizing: border-box;
    padding: 0;
    margin: 4px 0 0;
    margin-top: 1px \9;
    line-height: normal;
  }

  .checkbox-circle {
    background: setup.$c-primary;
    width: 20px;
    height: 20px;
    border-radius: 50%;
  }

  [type='checkbox']:not(:checked) + label .checkbox-circle,
  [type='checkbox']:checked + label .checkbox-circle {
    position: absolute;
    top: 3px;
    left: 6px;
    color: setup.$c-primary;
    transition: all 0.2s;
  }

  [type='checkbox']:not(:checked) + label .checkbox-circle {
    opacity: 1;
    transform: scale(1);
    left: 4px;
  }

  [type='checkbox']:checked + label .checkbox-circle {
    opacity: 1;
    transform: scale(1);
    left: 38px;
  }
}

.checkbox-radio {
  position: relative;

  [type='radio']:not(:checked) + label,
  [type='radio']:checked + label {
    position: relative;
    padding-left: 0;
    cursor: pointer;
    font-weight: normal;
    font-size: setup.$text-sm;
    text-align: initial;
    display: box;
    display: flexbox;
    display: flex;
    flex-direction: column;
    float: none;
  }

  [type='radio']:not(:checked) + label::before,
  [type='radio']:checked + label::before {
    position: absolute;
    box-sizing: border-box;
    content: '';
    width: 24px;
    height: 24px;
    left: 0;
    border: none;
    border: 1px solid setup.$c-dark-grey;
    outline: 0;
    display: inline-block;
    vertical-align: top;
    margin: 0 10px 0 0;
    border-radius: 50%;
  }

  [type='radio']:not(:checked) + label span,
  [type='radio']:checked + label span {
    display: inline-block;
    vertical-align: top;
    margin: 5px 0 0;
    line-height: 16px;
    padding-left: 32px;
    min-height: 20px;
  }

  [type='radio']:not(:checked),
  [type='radio']:checked {
    position: absolute;
    left: -9999px;
    width: 70px;
  }

  input[type='radio'] {
    box-sizing: border-box;
    padding: 0;
    margin: 4px 0 0;
    margin-top: 1px \9;
    line-height: normal;
  }

  [type='radio']:not(:checked) + label .ico-radio,
  [type='radio']:checked + label .ico-radio {
    position: absolute;
    top: 7px;
    left: 7px;
    width: 10px;
    height: 10px;
    background-color: setup.$c-primary;
    border-radius: 50%;
    transition: all 0.2s;
  }

  [type='radio']:not(:checked) + label .ico-radio {
    opacity: 0;
    transform: scale(0);
  }

  [type='radio']:checked + label .ico-radio {
    opacity: 1;
    transform: scale(1);
  }

  label {
    padding-bottom: 0;
  }
}

.checkbox-item-text {
  min-height: 42px;

  span {
    position: relative;
    margin-left: 40px;
    min-height: 48px;
  }
}

.checkbox-item-box {
  position: relative;
  width: 25px;
  height: 25px;
}
.checkbox-item-img {
  text-align: center;
  position: relative;
  &.is-error {
    color: setup.$c-error;
    [type='checkbox']:checked + label::before,
    [type='checkbox']:not(:checked) + label::before {
      border: 1px solid setup.$c-error;
    }
  }
  .ico-check {
    width: 22px;
    height: 22px;
    left: 0;
    top: 0;
    &::after {
      position: absolute;
      content: '';
      height: 1px;
      background-color: setup.$c-primary;
      width: 16px;
      transform: rotate(136deg);
      left: 4px;
      top: 8px;
    }
    &::before {
      position: absolute;
      content: '';
      width: 8px;
      height: 1px;
      top: 10px;
      transform: rotate(50deg);
      background-color: setup.$c-primary;
    }
  }
  [type='checkbox'] + label::after,
  [type='checkbox'] + label::after {
    width: 80px;
    height: 80px;
    content: '';
  }
  [type='checkbox']:not(:checked),
  [type='checkbox']:checked {
    position: absolute;
    left: -9999px;
  }
  [type='checkbox']:not(:checked) + label,
  [type='checkbox']:checked + label {
    padding-bottom: calc(132%);
    height: 100%;
    width: 100%;
    aspect-ratio: 3 / 4;
    position: relative;
    padding-left: 40px;
    cursor: pointer;
    font-weight: normal;
    font-size: 12px;
    text-align: initial;
    display: flex;
    span {
      display: initial;
      vertical-align: top;
      margin: 5px 0 0;
      line-height: 16px;
      min-height: 20px;
      padding-left: 0;
      &::after {
        content: ' ';
      }
    }
    &::before {
      position: absolute;
      content: '';
      width: 100%;
      height: 100%;
      aspect-ratio: 3 / 4;
      left: 0;
      border: none;
      border: 1px solid #a3a0a0;
      outline: 0;
      display: inline-block;
      vertical-align: top;
      margin: 0 0 0 0;
    }
    a {
      text-decoration: underline;
      margin-right: 4px;
    }
  }
  .checkbox-item [type='checkbox']:not(:checked) + label .icon,
  .checkbox-item [type='checkbox']:checked + label .icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: scale(1) translate(-50%, calc(-50% - 40px));
    color: setup.$c-primary;
    transition: all 0.2s;
  }
  input[type='checkbox'] {
    box-sizing: border-box;
    padding: 0;
    margin: 4px 0 0;
    margin-top: 1px \9;
    line-height: normal;
  }
  [type='checkbox']:checked + label .icon {
    opacity: 1;
    transform: scale(1) translate(-50%, calc(-50% - 40px));
  }
  .checkbox-item [type='checkbox']:checked + label .icon {
    opacity: 1;
    transform: scale(1) translate(-50%, calc(-50% - 40px));
  }
  [type='checkbox']:checked + label {
    border: 1px solid setup.$c-primary;
  }
  [type='checkbox']:not(:checked) + label .icon {
    opacity: 0;
    transform: scale(0) translate(-50%, calc(-50% - 40px));
  }
  [type='checkbox']:not(:checked) + label {
    border: 1px solid transparent;
  }
  &.color-filter {
    [type='checkbox']:not(:checked) + label,
    [type='checkbox']:checked + label {
      padding-left: 32px;
    }
    .color-wrap {
      button {
        margin-right: 0;
      }
    }
    [type='checkbox']:not(:checked) + label span,
    [type='checkbox']:checked + label span {
      padding-left: 24px;
    }
  }
  img {
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
  }
  .checkbox-item-img-text {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 80px;
  }
}

.check-no {
  &.checkbox-radio [type='radio']:checked + label::before,
  &.checkbox-radio [type='radio']:not(:checked) + label::before {
    display: none;
  }

  &.checkbox-radio [type='radio']:checked + label .ico-radio {
    display: none;
  }

  &.checkbox-radio [type='radio']:checked + label .border-1 {
    border: 1px solid setup.$c-primary;
  }
}

.check-center {
  &.checkbox-radio [type='radio']:checked + label::before,
  &.checkbox-radio [type='radio']:not(:checked) + label::before {
    position: absolute;
    top: 50%;
    left: 16px;
    transform: translateY(-50%);
  }

  &.checkbox-radio [type='radio']:checked + label .ico-radio,
  &.checkbox-radio [type='radio']:not(:checked) + label .ico-radio {
    top: 50%;
    left: 23px;
    margin-top: -5px;
  }

  .box3-content {
    padding-left: calc(24px + 16px);
  }

  &.checkbox-radio [type='radio']:checked + label .border-1 {
    border: 1px solid setup.$c-primary;
  }
}

.check-bleed {
  &.checkbox-radio [type='radio']:checked + label::before,
  &.checkbox-radio [type='radio']:not(:checked) + label::before {
    left: 0;
  }

  &.checkbox-radio [type='radio']:checked + label .ico-radio,
  &.checkbox-radio [type='radio']:not(:checked) + label .ico-radio {
    left: 7px;
  }
}

.check-top {
  &.checkbox-radio [type='radio']:checked + label::before,
  &.checkbox-radio [type='radio']:not(:checked) + label::before {
    position: absolute;
    top: 16px;
    left: 16px;
  }

  &.checkbox-radio [type='radio']:checked + label .ico-radio,
  &.checkbox-radio [type='radio']:not(:checked) + label .ico-radio {
    top: 23px;
    left: 23px;
  }

  .box3-content {
    padding-left: calc(24px + 16px);
  }

  &.checkbox-radio [type='radio']:checked + label .border-1 {
    border: 1px solid setup.$c-primary;
  }
}

.check-clear {
  &.checkbox-radio [type='radio']:checked + label::before,
  &.checkbox-radio [type='radio']:not(:checked) + label::before {
    position: absolute;
    top: 16px;
    left: 0;
  }

  &.checkbox-radio [type='radio']:checked + label .ico-radio,
  &.checkbox-radio [type='radio']:not(:checked) + label .ico-radio {
    top: 23px;
    left: 7px;
  }

  .box3-content {
    padding-left: calc(24px + 16px);
  }

  &.checkbox-radio [type='radio']:checked + label .border-1 {
    border: 1px solid setup.$c-primary;
  }
}

.checkbox-card {
  .checkbox-card-label {
    border-radius: setup.$btn-radius;
    overflow: hidden;
    border: 1px solid setup.$c-middle-grey;
    background: setup.$c-white;
    flex-direction: column;
    display: flex;
    width: 100%;
    padding: 8px;
    box-sizing: border-box;
    transition: all 0.2s ease;
  }
  & [type='radio'] {
    position: absolute;
    left: -9999px;
    width: 70px;
  }
  & [type='radio']:checked,
  & :hover {
    & + .checkbox-card-label {
      cursor: pointer;
      border: 1px solid setup.$c-primary;
    }
  }

  .has-light & {
    color: setup.$c-white;
    .checkbox-card-label {
      border: 1px solid setup.$c-dark-grey;
      background: setup.$c-primary;
    }

    & [type='radio']:checked,
    & :hover {
      & + .checkbox-card-label {
        cursor: pointer;
        border: 1px solid setup.$c-white;
      }
    }
  }
}

.is-active {
  &.checkbox-radio .border-1 {
    border: 1px solid setup.$c-primary;
  }

  &.checkbox-radio [type='radio'] + label .ico-radio {
    opacity: 1;
    transform: scale(1);
  }
}

.is-error {
  .checkbox-item {
    [type='checkbox']:checked + label::before,
    [type='checkbox']:not(:checked) + label::before {
      border: 1px solid setup.$c-error !important;
    }
    a {
      color: setup.$c-error !important;
    }
    svg {
      g {
        fill: setup.$c-error !important;
        polyline {
          stroke: setup.$c-error !important;
        }
      }
    }
  }
}

.has-light {
  .checkbox-item {
    .ico-check::after {
      background-color: transparent;
    }

    .ico-check::before {
      background-color: setup.$c-white;
    }

    [type='checkbox']:not(:checked) + label::before,
    [type='checkbox']:checked + label::before {
      border: 1px solid setup.$c-white;
    }

    [type='checkbox']:not(:checked) + label .icon,
    [type='checkbox']:checked + label .icon {
      color: setup.$c-white;
    }

    svg {
      g {
        fill: setup.$c-white;

        polyline {
          stroke: setup.$c-white;
        }
      }
    }
  }
  .checkbox-radio {
    [type='radio']:not(:checked) + label::before,
    [type='radio']:checked + label::before {
      border: 1px solid setup.$c-white;
    }

    [type='radio']:not(:checked) + label .ico-radio,
    [type='radio']:checked + label .ico-radio {
      background-color: setup.$c-white;
    }
  }
  .checkbox-item-2 {
    [type='checkbox']:not(:checked) + label::before,
    [type='checkbox']:checked + label::before {
      border: 1px solid setup.$c-white;
    }

    .checkbox-circle {
      background: setup.$c-white;
    }

    [type='checkbox']:not(:checked) + label .checkbox-circle,
    [type='checkbox']:checked + label .checkbox-circle {
      color: setup.$c-white;
    }
  }
}

.checkbox-item [type='checkbox']:not(:checked) + label::before,
.checkbox-item [type='checkbox']:checked + label::before {
  background-color: #fff;
}
