@import '../../_style/animation/variables.scss';

$md-checkbox-size: 20px;
$md-checkbox-touch-size: 48px;

.md-checkbox {
  width: auto;
  margin: 16px 16px 16px 0;
  display: inline-flex;
  position: relative;
  cursor: pointer;

  &.md-disabled {
    cursor: default;
    opacity: 0.38;
  }

  .md-checkbox-container {
    width: $md-checkbox-size;
    min-width: $md-checkbox-size;
    height: $md-checkbox-size;
    position: relative;
    border-radius: 2px;
    border: 2px solid var(--md-on-surface-medium);
    transition: $md-transition-stand;

    &:focus {
      outline: none;
    }

    &::before,
    &::after {
      position: absolute;
      transition: $md-transition-drop;
      content: ' ';
    }

    &::before {
      width: $md-checkbox-touch-size;
      height: $md-checkbox-touch-size;
      top: 50%;
      left: 50%;
      z-index: 11;
      border-radius: 50%;
      transform: translate(-50%, -50%);
    }

    &::after {
      width: 4px;
      height: 12px;
      top: 0;
      left: 5px;
      z-index: 12;
      border: 2px solid transparent;
      border-top: 0;
      border-left: 0;
      opacity: 0;
      transform: rotate(45deg) scale3d(0.15, 0.15, 1);
    }

    .md-ripple {
      width: $md-checkbox-touch-size !important;
      height: $md-checkbox-touch-size !important;
      top: 50% !important;
      left: 50% !important;
      transform: translate(-50%, -50%);
      border-radius: 50%;
    }

    input {
      position: absolute;
      left: -999em;
    }
  }

  .md-checkbox-label {
    height: $md-checkbox-size;
    padding-left: 16px;
    position: relative;
    line-height: $md-checkbox-size;
  }
}

.md-checkbox.md-checked {
  .md-ripple {
    color: var(--md-secondary);
  }

  .md-checkbox-container {
    background-color: var(--md-secondary);
    border-color: var(--md-secondary);

    &::after {
      opacity: 1;
      transform: rotate(45deg) scale3d(1, 1, 1);
      transition: $md-transition-stand;
      border-color: var(--md-background);
    }
  }

  &.md-primary {
    .md-checkbox-container {
      background-color: var(--md-primary);
      border-color: var(--md-primary);
    }

    .md-ripple {
      color: var(--md-primary);
    }
  }
}

// .md-checkbox.md-disabled {
//   .md-checkbox-container {
//     border-color: var(--md-outline);
//   }

//   &.md-checked {
//     .md-checkbox-container {
//       border-color: var(--md-outline);
//       background-color: var(--md-on-surface-disabled);
//     }
//   }
// }

.md-checkbox.md-required {
  label::after {
    position: absolute;
    top: 2px;
    right: 0;
    transform: translateX(calc(100% + 2px));
    content: '*';
    line-height: 1em;
    vertical-align: top;
  }
}
