/**
* Copyright (c) 2022 - present TinyVue Authors.
* Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/

@import '../mixins/input.less';
@import '../mixins/common.less';
@import '../custom.less';
@import './vars.less';

@ip-address-prefix-cls: ~'@{css-prefix}ip-address';

.@{ip-address-prefix-cls} {
  .inject-IpAddress-vars();

  width: var(--tv-IpAddress-normal-width);
  max-width: 100%;
  outline: 0;
  display: inline-table;
  text-align: left;
  box-sizing: border-box;

  &:has(> ul.disabled) {
    cursor: not-allowed;
  }

  &__input {
    position: relative;
    width: 100%;
    border: 1px solid var(--tv-IpAddress-normal-border-color);
    color: var(--tv-IpAddress-normal-text-color);
    border-radius: var(--tv-IpAddress-border-radius);
    background: var(--tv-IpAddress-normal-bg-color);
    font-size: var(--tv-IpAddress-font-size);
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    background-image: none;
    .user-select(auto);
    transition: border 0.3s;
    outline: 0;
    box-sizing: border-box;
    .input-readonly(@color: var(--tv-IpAddress-border-color-hover));
    .placeholder(@color: var(--tv-IpAddress-normal-disabled-text-color)); //placeholder属性兼容处理

    &:hover {
      border: 1px solid var(--tv-IpAddress-border-color-hover);
      color: var(--tv-IpAddress-normal-text-color);
      .placeholder(@color: var(--tv-IpAddress-normal-disabled-text-color));
    }

    &:focus,
    &:active,
    &.active,
    &[active] {
      border: 1px solid var(--tv-IpAddress-border-color-focus);
      color: var(--tv-IpAddress-normal-text-color);
    }

    &:focus {
      .placeholder(@color: #d9d9d9);
    }

    &.disabled,
    &[disabled] {
      cursor: not-allowed;
      pointer-events: none;
      border: 1px solid var(--tv-IpAddress-disabled-border-color);
      color: var(--tv-IpAddress-normal-disabled-text-color);
      background: var(--tv-IpAddress-disabled-bg-color);
      box-shadow: none;

      .@{css-prefix}svg {
        fill: var(--tv-IpAddress-normal-disabled-text-color);
      }
    }

    li {
      float: left;
      overflow: hidden;
      display: inline-flex;
      align-items: center;

      > input {
        font-size: var(--tv-IpAddress-font-size);
        border: none;
        text-align: center;
        outline: none;
        background: none;
        color: var(--tv-IpAddress-normal-text-color);
        font-family: var(--tv-IpAddress-normal-font-family);
        width: var(--tv-IpAddress-input-width);
        float: left;
        padding: 0;

        &:focus,
        &:active,
        &.active,
        &[active] {
          color: var(--tv-IpAddress-normal-text-color);
        }

        &:hover {
          color: var(--tv-IpAddress-normal-text-color);
        }

        &.disabled,
        &[disabled] {
          color: var(--tv-IpAddress-normal-disabled-text-color);
        }
      }

      svg {
        vertical-align: middle;
        fill: var(--tv-IpAddress-icon-color);
        width: var(--tv-IpAddress-icon-size);
        height: var(--tv-IpAddress-icon-size);
      }

      &:last-child {
        margin-right: var(--tv-IpAddress-padding-x);

        > svg {
          display: none;
        }
      }

      &:first-child {
        margin-left: var(--tv-IpAddress-padding-x);
      }
    }

    &__ipv6-delimiter {
      width: var(--tv-IpAddress-icon-width);
      text-align: center;
      margin: 0 var(--tv-IpAddress-ipv6-delimiter-margin-right);
    }

    &.medium li input {
      height: var(--tv-IpAddress-medium-height);
    }

    &.default li input {
      height: var(--tv-IpAddress-default-height);
    }

    &.small li input {
      height: var(--tv-IpAddress-small-height);
    }

    &.mini li input {
      height: var(--tv-IpAddress-mini-height);
    }
  }
}
