@import '../../style/mixins/index';
@import '../../style/themes/default';

@listPrefixCls: am-list-item;
@radioWarpPrefixCls: am-radio;
@radioItemPrefixCls: ~"@{radioWarpPrefixCls}-item";
@radioInnerPrefixCls: ~"@{radioWarpPrefixCls}-inner";
@icon-size: 22px;
@font-size: 17px;

.@{radioWarpPrefixCls} {

  position: relative;
  display: inline-block;
  vertical-align: middle;
  width: @icon-size-xxs;
  height: @icon-size-xxs;

  &-inner {
    position: absolute;
    right: 0;
    width: @icon-size-xxs;
    height: @icon-size-xxs;
    box-sizing: border-box;
    transform: rotate(0deg);

    &:after {
      position: absolute;
      display: none;
      top: -2.5 * @hd;
      right: 5 * @hd;
      z-index: 999;
      width: 7 * @hd;
      height: 14 * @hd;
      border-style: solid;
      border-width: 0 1.5 * @hd 1.5 * @hd 0;
      content: '\0020';
      transform: rotate(45deg);
    }
  }

  &-input {
    display: none;
  }

  &-item {
    cursor: pointer;
    &&-icon-check {
      .@{listPrefixCls}-title {
        & > .@{radioItemPrefixCls}-label {
          flex: 1;
        }
      }
    }
    &&-selected {
      cursor: default;
      &.@{radioWarpPrefixCls}-item-icon-check {
        .@{listPrefixCls}-title {
          color: var(--adm-color-primary);
        }
      }
    }
    &&-readonly {
      cursor: default;
    }
    &&-disabled {
      cursor: not-allowed;
    }
    &&-disabled,
    &&-readonly&-selected {
      .@{radioWarpPrefixCls}-icon {
        opacity: 0.45;
      }
    }
    .@{listPrefixCls}-error-extra {
      position: absolute;
      top: 15px;
      right: 15px;
    }
    .@{radioWarpPrefixCls}-icon {
      background-color: #fff;
      color: var(--adm-color-primary);
      flex: none;
      border: 1px solid var(--adm-color-light);
      border-radius: @icon-size;
      box-sizing: border-box;
      width: @icon-size;
      height: @icon-size;
      margin-right: 8px;
      path {
        display: none;
      }
    }

    &&-selected {
      .@{listPrefixCls}-content {
        .@{listPrefixCls}-title {
          .@{radioWarpPrefixCls}-icon {
            path {
              display: initial;
            }
          }
        }
      }
    }
  }

  &.@{radioWarpPrefixCls}-checked {
    .@{radioInnerPrefixCls} {
      border-width: 0;

      &:after {
        display: block;
        border-color: @brand-primary;
      }
    }
  }

  &.@{radioWarpPrefixCls}-disabled {
    &.@{radioWarpPrefixCls}-checked {
      .@{radioInnerPrefixCls} {
        &:after {
          display: block;
          border-color: @color-text-disabled;
        }
      }
    }
  }
}

.@{listPrefixCls} {
  &.@{radioWarpPrefixCls}-item {
    .@{listPrefixCls}-line {
      .@{listPrefixCls}-extra {
        flex: 0;

        .@{radioWarpPrefixCls} {
          position: absolute;
          top: 0;
          left: 0;
          right: 0;
          bottom: 0;
          width: 100%;
          height: @list-item-height;
          overflow: visible;

          &-inner {
            right: @v-spacing-lg;
            top: @h-spacing-lg;
          }
        }
      }
    }

    &.@{radioWarpPrefixCls}-item-disabled {
      .@{listPrefixCls}-title {
        color: @color-text-disabled;
      }
    }
  }
}

.am-radio-popup-list {
  &.am-list-item-horizontal {
    .am-list-item-control {
      justify-content: flex-end;
    }
  }
}
