/**
* 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';

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

.@{card-item-prefix-cls} {
  .component-css-vars-card-item();

  transition: all 200ms ease;
  transition-property: left, top, right, transform;
  background: var(--ti-card-item-bg-color);
  box-shadow: 0 0 0 transparent;
  border: 1px solid var(--ti-card-item-border-color);
  border-radius: 0;
  right: auto;
  overflow: hidden;
  margin: 6px;

  &.resizing {
    opacity: 0.6;
    z-index: 3;
  }

  &.dragging {
    user-select: none;
    transition: none;
    z-index: 3;
  }

  &.placeholder {
    background: var(--ti-card-item-placeholder-bg-color);
    border: 1px dashed var(--ti-card-item-placeholder-border-color);
    transition-duration: 100ms;
    z-index: 2;
    user-select: none;

    & .resizableIcon,
    .remove {
      display: none;
    }
  }

  & > .resizableIcon {
    position: absolute;
    width: 6px;
    height: 6px;
    bottom: 2px;
    right: 2px;
    box-sizing: border-box;
    cursor: se-resize;

    &:before {
      position: absolute;
      content: '';
      width: 6px;
      height: 6px;
      bottom: 2px;
      right: 2px;
      border-right: 1px solid var(--ti-card-item-resize-icon-color);
      border-bottom: 1px solid var(--ti-card-item-resize-icon-color);
      box-sizing: border-box;
    }
  }

  & .remove {
    position: absolute;
    width: 22px;
    height: 22px;
    top: 0;
    right: 0;
    padding: 0 3px 3px 0;
    box-sizing: border-box;
    cursor: pointer;
    opacity: 0.5;
    background: var(--ti-card-item-remove-icon-bg-color);
    transition: all 0.5s;

    &:hover {
      background: var(--ti-card-item-remove-icon-hover-bg-color);

      &:before,
      &:after {
        background: var(--ti-card-item-remove-icon-hover-text-color);
      }
    }
  }

  &:hover .remove {
    opacity: 1;
  }

  & .remove:before {
    position: absolute;
    top: 10px;
    right: 6px;
    content: '';
    background: var(--ti-card-item-remove-icon-color, rgba(0, 0, 0, 0.5));
    height: 1px;
    width: 10px;
    transform: rotate(45deg);
    transition: background 0.5s;
  }

  & .remove:after {
    position: absolute;
    top: 10px;
    left: 6px;
    content: '';
    background: var(--ti-card-item-remove-icon-color, rgba(0, 0, 0, 0.5));
    height: 1px;
    width: 10px;
    transform: rotate(-45deg);
    transition: background 0.5s;
  }

  .card-header {
    font-size: var(--ti-card-item-header-font-size);
    color: var(--ti-card-item-header-text-color);
    height: var(--ti-card-item-header-height);
    line-height: var(--ti-card-item-header-height);
    width: 100%;
    padding: 0 30px 0 0;
    box-sizing: border-box;

    & > .card-title {
      height: 13px;
      line-height: 13px;
      border-left: 3px solid var(--ti-card-item-header-title-border-color);
      margin: 0 0 0 12px;
      padding: 0 0 0 5px;
      width: 100%;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      display: inline-block;
    }
  }

  .card-body {
    height: calc(100% - var(--ti-card-item-header-height));
    position: relative;

    &:nth-child(1) {
      height: 100%;
    }
  }
}
