@charset "UTF-8";
@import "./common/var.css";

@component-namespace el {

  @b checkbox {
    color: var(--checkbox-color);
    position: relative;
    cursor: pointer;
    display: inline-block;
    white-space: nowrap;
    @utils-user-select none;

    @e input {
      white-space: nowrap;
      cursor: pointer;
      outline: none;
      display: inline-block;
      line-height: 1;
      position: relative;
      vertical-align: middle;

      @when disabled {
        .el-checkbox__inner {
          background-color: var(--checkbox-disabled-input-fill);
          border-color: var(--checkbox-disabled-input-border-color);
          cursor: not-allowed;

          &::after {
            cursor: not-allowed;
            border-color: var(--checkbox-disabled-icon-color);
          }

          & + .el-checkbox__label {
            cursor: not-allowed;
          }
        }
        &.is-checked {
          .el-checkbox__inner {
            background-color: var(--checkbox-disabled-checked-input-fill);
            border-color: var(--checkbox-disabled-checked-input-border-color);

            &::after {
              border-color: var(--checkbox-disabled-checked-icon-color);
            }
          }
        }
        &.is-indeterminate {
          .el-checkbox__inner {
            background-color: var(--checkbox-disabled-checked-input-fill);
            border-color: var(--checkbox-disabled-checked-input-border-color);

            &::before {
              border-color: var(--checkbox-disabled-checked-icon-color);
            }
          }
        }
        & + .el-checkbox__label {
          color: var(--disabled-color-base);
          cursor: not-allowed;
        }
      }
      @when checked {
        .el-checkbox__inner {
          background-color: var(--checkbox-checked-input-fill);
          border-color: var(--checkbox-checked-input-border-color);

          &::after {
            transform: rotate(45deg) scaleY(1);
          }
        }
      }
      @when focus {
        .el-checkbox__inner {
          border-color: var(--checkbox-input-border-color-hover);
        }
      }
      @when indeterminate {
        .el-checkbox__inner {
          background-color: var(--checkbox-checked-input-fill);
          border-color: var(--checkbox-checked-input-border-color);

          &::before {
            content: '';
            position: absolute;
            display: block;
            border: 1px solid var(--checkbox-checked-icon-color);
            margin-top: -1px;
            left: 3px;
            right: 3px;
            top: 50%;
          }

          &::after {
            display: none;
          }
        }
      }
    }
    @e inner {
      display: inline-block;
      position: relative;
      border: var(--checkbox-input-border);
      border-radius: var(--checkbox-input-border-radius);
      box-sizing: border-box;
      rect: var(--checkbox-input-width) var(--checkbox-input-height) var(--checkbox-input-fill);
      z-index: var(--index-normal);
      transition: border-color .25s cubic-bezier(.71,-.46,.29,1.46),
                  background-color .25s cubic-bezier(.71,-.46,.29,1.46);

      &:hover {
        border-color: var(--checkbox-input-border-color-hover);
      }

      &::after {
        box-sizing: content-box;
        content: "";
        border: 2px solid var(--checkbox-checked-icon-color);
        border-left: 0;
        border-top: 0;
        height: 8px;
        left: 5px;
        position: absolute;
        top: 1px;
        transform: rotate(45deg) scaleY(0);
        width: 4px;
        transition: transform .15s cubic-bezier(.71,-.46,.88,.6) .05s;
        transform-origin: center;
      }
    }

    @e original {
      opacity: 0;
      outline: none;
      position: absolute;
      margin: 0;
      size: 0;
      left: -999px;
    }

    @e label {
      font-size: var(--checkbox-font-size);
      padding-left: 5px;
    }

    & + .el-checkbox {
      margin-left: 15px;
    }
  }

  @b checkbox-button {
    position: relative;
    display: inline-block;

    @e inner {
      display: inline-block;
      line-height: 1;
      white-space: nowrap;
      vertical-align: middle;
      cursor: pointer;
      background: var(--button-default-fill);
      border: var(--border-base);
      border-left: 0;
      color: var(--button-default-color);
      -webkit-appearance: none;
      text-align: center;
      box-sizing: border-box;
      outline: none;
      margin: 0;
      position: relative;
      cursor: pointer;
      transition: var(--all-transition);
      @utils-user-select none;

      @mixin button-size var(--button-padding-vertical), var(--button-padding-horizontal), var(--button-font-size), 0;

      &:hover {
        color: var(--color-primary);
      }

      & [class*="el-icon-"] {
        line-height: 0.9;

        & + span {
          margin-left: 5px;
        }
      }
    }

    @e original {
      opacity: 0;
      outline: none;
      position: absolute;
      margin: 0;
      visibility: hidden;
      left: -999px;
    }

    &.is-checked {
      & .el-checkbox-button__inner {
        color: var(--checkbox-button-checked-color);
        background-color: var(--checkbox-button-checked-fill);
        border-color: var(--checkbox-button-checked-border-color);
        box-shadow: -1px 0 0 0 var(--checkbox-button-checked-border-color);
      }
    }

    &.is-disabled {
      & .el-checkbox-button__inner {
        color: var(--button-disabled-color);
        cursor: not-allowed;
        background-image: none;
        background-color: var(--button-disabled-fill);
        border-color: var(--button-disabled-border);
        box-shadow: none;
      }
    }
    
    &.is-focus {
      & .el-checkbox-button__inner {
        border-color: var(--checkbox-button-checked-border-color);
      }
    }


    &:first-child {
      .el-checkbox-button__inner {
        border-left: var(--border-base);
        border-radius: var(--border-radius-base) 0 0 var(--border-radius-base);
        box-shadow: none !important;
      }
    }
    &:last-child {
      .el-checkbox-button__inner {
        border-radius: 0 var(--border-radius-base) var(--border-radius-base) 0;
      }
    }
    @m large {
      & .el-checkbox-button__inner {
        @mixin button-size var(--button-large-padding-vertical), var(--button-large-padding-horizontal), var(--button-large-font-size), 0;
      }
    }
    @m small {
      & .el-checkbox-button__inner {
        @mixin button-size var(--button-small-padding-vertical), var(--button-small-padding-horizontal), var(--button-small-font-size), 0;
      }
    }
    @m mini {
      & .el-checkbox-button__inner {
        @mixin button-size var(--button-mini-padding-vertical), var(--button-mini-padding-horizontal), var(--button-mini-font-size), 0;
      }
    }
  }
}
