@import './../theme/vars.scss';
@import './../mixins/reset.scss';
@import './../mixins/scrollbar.scss';

$paramPrefix: param;

$formBuilderCls: #{$vender-prefix}-form-builder;
$stdFormCls: #{$vender-prefix}-std-form;
$stdFormRowCls: #{$vender-prefix}-stdform-row;
$bgPositionCls: #{$paramPrefix}-background-position;
$formLabelCls: #{$vender-prefix}-form-label;

$formGroupCls: #{$vender-prefix}-formgroup;
$brackets-size: 10px;
$brackets-item-height: calc(50% - 10px);
$brackets-subitem-top: calc(50% + 10px);

$formTipIconFontSize: 14px;

@mixin genFormTip() {
  .aficon-tip {
    font-size: $formTipIconFontSize;
    vertical-align: middle;
  }
}

.#{$formBuilderCls} {
  @include reset-component2;

  &-field {
    padding: 0.5em 1em;

    &-label {
      @include genFormTip();

      padding-left: 0.5em;
      margin-bottom: 0.5em;
    }

    &-content {
      &-explain {
        font-size: 12px;
        color: var(--error-color);
      }
    }

    &.horizontal {
      display: flex;
      flex-direction: row;
      align-items: center;
      justify-content: space-between;

      .#{$formBuilderCls}-field-label {
        margin-bottom: 0;
      }

      .#{$formBuilderCls}-field-content {
        flex: 1;
      }
    }

    &.required {
      .#{$formBuilderCls}-field-label::before {
        @include formitem-required;
      }
    }
  }

  .#{$vender-prefix}-input-number-control {
    width: 1.5em;

    .#{$vender-prefix}-input-number-add {
      padding: 0;

      &::after {
        width: 6px;
        height: 6px;
      }
    }

    .#{$vender-prefix}-input-number-sub {
      padding: 0;

      &::after {
        width: 6px;
        height: 6px;
        margin-top: -3px;
      }
    }
  }

  &.#{$formBuilderCls}-has-checker {
    .#{$formBuilderCls}-field {
      padding: 0.8em 1em;

      &-content {
        position: relative;

        &-explain {
          position: absolute;
          z-index: 1;
        }
      }
    }
  }
}

// std form
.#{$stdFormCls} {
  @include reset-component2;

  display: flex;
  align-items: center;
  height: 4em;
  padding: 0.5em 0;
  justify-content: space-between;

  &-label {
    @include genFormTip();

    display: inline-block;
    width: 6em;
    padding: 5px 0;
    padding-right: 0.5em;
    font-size: 14px;
    color: #333;
    text-align: start;

    #{$common-iconfont-tag} {
      display: inline-block;
      vertical-align: middle;
    }
  }

  &.#{$stdFormCls}-right {
    .#{$stdFormCls}-label {
      text-align: end;
    }
  }

  &-inner {
    :not([class*=-group]) {
      .amos-btn {
        padding: 0 0.5em;

        &:last-child {
          margin-left: 0.5em;
        }
      }
    }
  }

  &.#{$stdFormCls}-tight {
    justify-content: start;
  }

  &.#{$stdFormCls}-half {
    height: 3em;
    padding: 0;

    .#{$stdFormCls}-label {
      align-self: flex-start;
      width: 35%;
      overflow: hidden;
      line-height: 24px;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .#{$stdFormCls}-content {
      flex: 1;
    }
  }

  &.#{$stdFormCls}-nolabel {
    .#{$stdFormCls}-content {
      flex: 1;
      display: flex;
      align-items: center;
      justify-content: space-between;
    }
  }

  &-tipin-content {
    .#{$stdFormCls}-inner {
      @include genFormTip();
    }
  }
}

.#{$stdFormCls}-vertical {
  padding: 0.5em 0;

  &-label {
    display: block;
    margin-bottom: 0.5em;
    font-size: 14px;
    color: #333;
  }

  &-inner {
    :not([class*=-group]) {
      .amos-btn {
        padding: 0 1em;

        &:last-child {
          margin-left: 0.5em;
        }
      }
    }
  }
}


.#{$bgPositionCls}-toggle {
  display: flex;
  padding: 0.5em 0;
  align-items: center;
  justify-content: space-between;

  label {
    margin-right: 2em;
  }
}

.#{$bgPositionCls}-custom {
  display: flex;
  width: 100%;

  .amos-input {
    flex: 1;
    width: 50%;
  }
}

// form label
.#{$formLabelCls} {
  vertical-align: middle;

  .aficon {
    font-size: 12px;
    color: #333;
  }
}

// StdFormRow
.#{$stdFormRowCls} {
  display: flex;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px dashed $border-color-split;

  &-title {
    margin-right: 24px;
    font-size: $font-size-base;
    color: $heading-color;
    flex: 0 0 auto;
    text-align: right;

    & > span {
      display: inline-block;
      height: 32px;
      line-height: 32px;

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

  &-content {
    flex: 1 1 0;
  }

  &.#{$stdFormRowCls}-last {
    padding-bottom: 0;
    margin-bottom: 0;
    border: none;
  }

  &.required {
    .#{$stdFormRowCls}-title::before {
      @include formitem-required;
    }
  }
}

// form group

.#{$formGroupCls} {
  display: flex;
  align-items: center;
  justify-content: space-between;

  &-label {
    padding: 5px 0;
    padding-right: 6px;
    font-size: 14px;
    color: #333;
    text-align: end;
  }

  &-content {
    flex: 1;

    .#{$stdFormCls} {
      height: 36px;
      padding: 3px 0;
    }
  }

  &.#{$formGroupCls}-brackets {
    .#{$formGroupCls}-content {
      position: relative;
    }

    .#{$formGroupCls}-brackets-inner {
      &::before,
      &::after {
        top: 50%;
        left: 0;
      }
    }

    .#{$formGroupCls}-content::before,
    .#{$formGroupCls}-content::after,
    .#{$formGroupCls}-brackets-inner::before,
    .#{$formGroupCls}-brackets-inner::after {
      position: absolute;
      display: block;
      width: $brackets-size;
      height: $brackets-item-height;
      border: 0 solid black;
      content: '';
    }

    .#{$formGroupCls}-content::before {
      left: $brackets-size;
      border-left-width: 1px;
      border-top-left-radius: $brackets-size;
    }

    .#{$formGroupCls}-content::after {
      top: $brackets-size;
      left: 1px;
      border-right-width: 1px;
      border-bottom-right-radius: $brackets-size;
    }

    .#{$formGroupCls}-brackets-inner::before {
      left: 1px;
      border-right-width: 1px;
      border-top-right-radius: $brackets-size;
    }

    .#{$formGroupCls}-brackets-inner::after {
      top: $brackets-subitem-top;
      left: $brackets-size;
      border-left-width: 1px;
      border-bottom-left-radius: $brackets-size;
    }
  }
}

.#{$formGroupCls}-vertical {
  &-label {
    margin-bottom: 0.5em;
    font-size: 14px;
    color: #333;
  }

  &-content {
    padding-left: 1em;

    .#{$stdFormCls} {
      height: 3em;
      padding: 0.2em 0;
    }
  }
}

// form link
.form-link {
  padding: 0.5em;
  cursor: pointer;
}

.#{$paramPrefix}-divider {
  padding: 0 1em;

  &.amos-divider-horizontal.amos-divider-with-text {
    margin: 6px 0;
    font-size: 12px;
    color: #9e9e9e;
  }
}

// color with none
.#{$paramPrefix}-iptcolor-with-none {
  .amos-input-color-addon-after {
    i {
      margin-right: 4px;
    }
  }
}

// field group
.field-group {
  padding: 0.5em 1em 0.5em 1.5em;

  &-inner {

  }

  &-label {
    @include genFormTip();

    display: block;
    margin-bottom: 0.5em;
    font-size: 12px;
  }

  &-content {
    border: 1px solid #f1f1f1;
  }
}

// 组合类型的 param 均以 mixparams- 开头
.mixparams-chart-color {
  .amos-std-form {
    height: 3em;
    padding: 0.2em 0;

    &-label {
      width: 7em;
      font-size: 12px;
    }

    .amos-select {
      width: 200px;
    }
  }

  &-stops {
    &-item {
      display: flex;

      .amos-input-color,
      .amos-input-color-inner {
        width: 160px;
      }

      .amos-input-number .amos-input {
        font-size: 13px;
      }

      .amos-btn {
        height: 32px;
      }

      & + & {
        margin-top: 0.2em;
      }
    }
  }

  .chart-color-dom {
    width: 200px;
    padding-top: 12px;
    font-size: 12px;
    line-height: 1.5;
    color: #333;
  }
}

.color-stops-iptcolor {
  .amos-input-color-popover-content {
    width: 160px;
    padding: 5px 5px 0;
  }
}

// theme color
.theme-color {
  display: inline-block;
  padding: 6px 0;

  &-result {
    position: relative;
    display: flex;
    width: 200px;
    height: 30px;
    padding: 5px 0;
    overflow: hidden;
    background-color: #f2f2e6;
    align-items: center;
    justify-content: space-between;

    &-item {
      display: inline-block;
      width: 20px;
      height: 20px;
      margin: 0 5px;
      border-radius: 100%;
    }

    &-list {
      display: inline-block;
      width: calc(100% - 20px);
      height: 20px;
      overflow: hidden;
      white-space: nowrap;
    }

    &-edit {
      display: inline-block;
      width: 20px;
      height: 20px;

      i {
        display: inline-block;
        vertical-align: bottom;
        cursor: pointer;

        &:hover {
          color: $primary-color-deeper;
        }
      }
    }
  }

  &-cancel-select {
    margin-left: 6px;
  }

  &-modal {
    .amos-modal-footer {
      .amos-btn + .amos-btn {
        margin-left: 6px;
      }
    }

    .amos-modal-content {
      overflow: hidden;
    }

    &-content {
      &-value {

      }

      &-reset {
        margin-top: 12px;

        &-cancel {
          margin-left: 0.5em;
        }
      }
    }
  }

  // modal value
  &-value {
    &-inner {
      display: inline-block;
      width: 260px;
      min-height: 252px;
      padding-top: 12px;
      padding-left: 12px;
      margin-right: 12px;
      vertical-align: top;
      border: 1px solid #efefef;
    }

    &-tip {
      margin-bottom: 6px;
      font-size: 13px;
      letter-spacing: 1px;
      color: #7f7f7f;
      word-break: break-word;
    }

    &-list {
      .color-item {
        position: relative;
        display: inline-block;
        width: 60px;
        height: 36px;
        padding: 6px;
        font-size: 14px;
        text-align: center;
        cursor: pointer;
        background: white;

        .color-item-core {
          display: block;
          width: 100%;
          height: 100%;
          color: #b4c6d6;
          border: 1px solid #b4c6d6;
          border-radius: 2px;
        }

        .color-item-del {
          position: absolute;
          top: 0;
          right: 0;
          display: none;
          width: 18px;
          height: 18px;
          font-size: 14px;
          line-height: 18px;
          color: white;
          background: #ff3e69;
          border: 1px solid white;
          border-radius: 100%;
        }

        &:hover {
          background: #d2dee8;

          .color-item-del {
            display: block;
          }
        }

        &.color-item-active {
          background: #d5d5d5;
        }
      }

      .color-add {
        display: inline-block;
        width: 36px;
        height: 36px;
        padding: 6px;
        overflow: hidden;
        text-align: center;
        cursor: pointer;
        background: white;

        &:hover {
          background: #d2dee8;

          .amosicon {
            color: green;
          }
        }
      }
    }

    &-setter {
      @include pretty-scrollbar(6px, 6px, $scrollOutColor, $scrollInnerColor, 5px);

      position: relative;
      display: inline-block;
      max-height: 20em;
      min-height: 252px;
      padding: 12px;
      padding-left: 18px;
      overflow: auto;
      border: 1px solid #efefef;

      .field-group {
        padding: 0;

        &-content {
          border: 0;
        }

        .amos-std-form-label {
          width: 7em;
        }
      }

      &-mask {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 9;
        background: rgba(231, 231, 231, 0.5);
      }
    }
  }
}

.property-3d-builder,
.margins-builder,
.boadrgrid-builder {
  .amos-form-builder-field-label {
    margin-top: 16px;
  }
}

// property 3d
.param-property3d {
  table {
    all: initial;
    text-align: center;
  }

  .amos-input {
    width: 65px;
  }
}

// margins
.param-margins {
  table {
    all: initial;
    text-align: center;
  }

  .amos-input {
    width: 50px;
  }
}

.param-boadrgrid {
  table {
    all: initial;
    text-align: center;
  }

  .amos-input-number {
    margin: 0 3px;
  }

  .amos-input {
    width: 80px;
  }

  .amos-switch {
    text-align: start;
  }
}

// form info
$formInfoCls: #{$vender-prefix}-forminfo;

.#{$formInfoCls} {
  &-item {
    display: flex;
    padding: 4px 0;

    &-label {
      flex: 0 0 5em;
      text-align: left;
    }
  }
}


// size select
.paper-size {
  .size-select {
    min-width: 100px;

    .amos-select-dropdown-iconable .amos-select-title {
      padding-right: 20px;
    }

    .amos-input-number input {
      padding-right: 18px;
    }

    .amos-select-dropdown-icon {
      right: 5px;
    }
  }
}

.size-select {
  // pop
  &-popover {
    .size-select-options {
      font-size: 12px;
    }

    .amos-select-option {
      padding: 0 20px 0 5px;

      &-icon-selected {
        right: 2px;
        transform: scale(0.8);
      }
    }
  }
}

// borderStyle
.param-borderstyle-item {
  display: inline-block;
  width: 100%;
  height: 22px;

  &-line {
    margin-top: 16px;
    border-top-color: #333;
    border-top-width: 4px;
  }
}
