/**
* 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 '../custom.less';
@import './vars.less';

@collapse-item-prefix-cls: ~'@{css-prefix}collapse-item';

.@{collapse-item-prefix-cls} {
  .inject-CollapseItem-vars();
  background-color: var(--tv-CollapseItem-bg-color);
  color: var(--tv-CollapseItem-text-color);
  border-top: 1px solid var(--tv-CollapseItem-header-border-color);

  &__header {
    display: flex;
    align-items: center;
    min-height: 40px;
    background-color: var(--tv-CollapseItem-header-bg-color);
    font-size: var(--tv-CollapseItem-header-font-size);
    outline: 0;
    cursor: pointer;
    transition: border-bottom-color 0.3s;
    padding: 12px 20px;

    .@{collapse-item-prefix-cls}__word-overflow {
      white-space: nowrap;
      overflow: hidden;
      line-height: 1.5;
      text-overflow: ellipsis;
      display: inline-block;
      cursor: pointer;
    }

    .@{collapse-item-prefix-cls}__arrow {
      margin-right: 12px;
      order: -1;
      transition: transform 0.3s;
      transform: rotate(90deg);

      svg {
        width: var(--tv-CollapseItem-icon-size);
        height: var(--tv-CollapseItem-icon-size);
        fill: var(--tv-CollapseItem-icon-color);
      }
    }

    .@{collapse-item-prefix-cls}__title__right {
      margin-left: auto;
      color: var(--tv-CollapseItem-title-right-text-color);
      fill: var(--tv-CollapseItem-title-right-icon-color);

      &:hover {
        text-decoration: underline;
      }
    }

    &.is-active {
      .@{collapse-item-prefix-cls}__arrow {
        transform: rotate(-90deg);
      }
    }
  }

  &.is-disabled &__header {
    color: var(--tv-CollapseItem-disabled-text-color);
    background-color: var(--tv-CollapseItem-disabled-header-bg-color);
    cursor: not-allowed;
  }

  &.is-disabled &__arrow svg {
    fill: var(--tv-CollapseItem-disabled-text-color);
  }

  &.is-disabled &__word-overflow {
    cursor: not-allowed;
  }

  &:not(.is-disabled) {
    .@{collapse-item-prefix-cls}__arrow:hover {
      svg {
        fill: var(--tv-CollapseItem-arrow-hover-text-color);
      }
    }
  }

  &__wrap {
    will-change: height;
    overflow: hidden;
    box-sizing: border-box;
  }

  &__content {
    padding: 24px 20px;
    font-size: var(--tv-CollapseItem-content-font-size);
    line-height: 1.5;
    border-top: 1px solid var(--tv-CollapseItem-header-border-color);
  }
}
