/**
* 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} {
  .component-css-vars-ip-address();

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

  &__input {
    position: relative;
    width: 100%;
    height: var(--ti-ip-address-normal-height);
    line-height: var(--ti-ip-address-line-height);
    border: 1px solid var(--ti-ip-address-normal-border-color);
    color: var(--ti-ip-address-normal-text-color);
    border-radius: var(--ti-ip-address-border-radius);
    background: var(--ti-ip-address-normal-bg-color);
    font-size: var(--ti-ip-address-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(--ti-ip-address-border-color-hover));
    .placeholder(@color: var(--ti-ip-address-normal-disabled-text-color)); //placeholder属性兼容处理

    &:hover {
      cursor: pointer;
      border: 1px solid var(--ti-ip-address-border-color-hover);
      color: var(--ti-ip-address-normal-text-color);
      .placeholder(@color: var(--ti-ip-address-normal-disabled-text-color));
    }

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

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

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

      .@{css-prefix}svg {
        fill: var(--ti-ip-address-normal-disabled-text-color);
      }
    }

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

      > input {
        font-size: var(--ti-ip-address-font-size);
        border: none;
        text-align: center;
        outline: none;
        background: none;
        color: var(--ti-ip-address-normal-text-color);
        font-family: var(--ti-ip-address-normal-font-family);
        width: var(--ti-ip-address-input-width);
        float: left;
        height: calc(var(--ti-ip-address-normal-height) - 2px);
        line-height: var(--ti-ip-address-line-height);
        padding: 0;

        &:focus,
        &:active,
        &.active,
        &[active] {
          color: var(--ti-ip-address-normal-text-color);
        }

        &:hover {
          cursor: pointer;
          color: var(--ti-ip-address-normal-text-color);
        }

        &.disabled,
        &[disabled] {
          color: var(--ti-ip-address-normal-disabled-text-color);
        }
      }

      svg {
        vertical-align: middle;
        fill: var(--ti-ip-address-icon-color);
        width: var(--ti-ip-address-icon-size);
        height: var(--ti-ip-address-icon-size);
      }

      &:last-child {
        margin-right: var(--ti-ip-address-padding-horizontal);
        > svg {
          display: none;
        }
      }

      &:first-child {
        margin-left: var(--ti-ip-address-padding-horizontal);
      }
    }

    &__ipv6-delimiter {
      width: var(--ti-ip-address-icon-width);
      text-align: center;
    }
  }
}
