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

@split-prefix-cls: ~'@{css-prefix}split';

.@{split-prefix-cls} {
  &-wrapper {
    .inject-Split-vars();

    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: var(--tv-Split-wrapper-radius-size);
    border: 1px solid var(--tv-Split-wrapper-border-color);

    // 无边框模式
    &.no-border {
      border: none;
    }

    // split嵌套使用内部不需要圆角和边框
    & & {
      border-radius: 0;
      border: none;
    }
  }

  &-pane {
    position: absolute;

    &.left-pane,
    &.right-pane {
      top: 0;
      bottom: 0;
      overflow: hidden;
    }

    &.left-pane {
      left: 0;
    }

    &.right-pane {
      right: 0;
    }

    &.top-pane,
    &.bottom-pane {
      left: 0;
      right: 0;
      overflow: hidden;
    }

    &.top-pane {
      top: 0;
    }

    &.bottom-pane {
      bottom: 0;
    }
  }

  &-trigger {
    &-con {
      position: absolute;
      transform: translate(-50%, -50%);
      z-index: 10;
    }

    &-bar-con {
      position: absolute;
      background: transparent;

      &.vertical {
        top: 50%;
        width: 16px;
        transform: translate(-4px, -50%);

        svg {
          transform: translateX(5px);
          fill: var(--tv-Split-trigger-icon-line-color);
        }
      }

      &.horizontal {
        left: 50%;
        width: 16px;
        transform: translate(-50%, 0);

        svg {
          transform: translateY(2px);
          fill: var(--tv-Split-trigger-icon-line-color);
        }
      }
    }

    &-vertical {
      width: 1px;
      height: 100%;
      background: var(--tv-Split-wrapper-border-color);
      cursor: e-resize;

      .@{split-prefix-cls}-trigger-bar {
        width: 4px;
        height: 4px;
        background: var(--tv-Split-wrapper-border-color);
        float: left;
        margin-top: 4px;
      }
    }

    &-horizontal {
      height: 1px;
      width: 100%;
      background: var(--tv-Split-wrapper-border-color);
      cursor: n-resize;

      .@{split-prefix-cls}-trigger-bar {
        height: 4px;
        width: 4px;
        background: var(--tv-Split-wrapper-border-color);
        float: left;
        margin-left: 4px;
        border-radius: 50%;
      }
    }
  }

  &-horizontal {
    .@{split-prefix-cls}-trigger-con {
      top: 50%;
      height: 100%;
      width: 0;

      .@{split-prefix-cls}-trigger-button {
        width: 14px;
        height: 26px;
        position: absolute;
        top: 50%;

        &:hover {
          width: 18px;
        }
      }

      .@{split-prefix-cls}-trigger-left-button {
        transform: translate(0, -50%);
        left: -6px;
        border-right: 0;
      }

      .@{split-prefix-cls}-trigger-left-button:hover {
        left: -10px;
      }

      .@{split-prefix-cls}-trigger-right-button {
        transform: translate(0, -50%);
        left: 9px;
        border-left: 0;
      }
    }

    .@{split-prefix-cls}-trigger-con.@{split-prefix-cls}-trigger-con-disabled {
      .@{split-prefix-cls}-trigger-vertical,
      .@{split-prefix-cls}-trigger-horizontal {
        cursor: not-allowed;
      }
    }

    .@{split-prefix-cls}-trigger-con.@{split-prefix-cls}-trigger-con-left-active {
      margin-left: -1px;
    }

    .@{split-prefix-cls}-vertical .@{split-prefix-cls}-trigger-con {
      left: 50%;
      height: 0;
      width: 100%;
    }

    .@{split-prefix-cls}-trigger-con-drag {
      cursor: e-resize;
    }

    .@{split-prefix-cls}-pane-moving {
      cursor: e-resize;
    }
  }

  &-vertical {
    .@{split-prefix-cls}-trigger-con {
      left: 50%;
      height: 0;
      width: 100%;

      .@{split-prefix-cls}-trigger-button {
        width: 26px;
        height: 14px;
        position: absolute;
        left: 50%;

        &:hover {
          height: 18px;
        }
      }

      .@{split-prefix-cls}-trigger-top-button {
        transform: translate(-50%, 0);
        top: -6px;
        border-bottom: 0;

        .@{css-prefix}svg {
          transform: rotate(90deg);
        }
      }

      .@{split-prefix-cls}-trigger-top-button:hover {
        top: -10px;
      }

      .@{split-prefix-cls}-trigger-bottom-button {
        transform: translate(-50%, 0);
        border-top: 0;
        top: 9px;

        .@{css-prefix}svg {
          transform: rotate(90deg);
        }
      }
    }

    .@{split-prefix-cls}-trigger-con.@{split-prefix-cls}-trigger-con-disabled {
      .@{split-prefix-cls}-trigger-vertical,
      .@{split-prefix-cls}-trigger-horizontal {
        cursor: not-allowed;
      }
    }

    .@{split-prefix-cls}-trigger-con.@{split-prefix-cls}-trigger-con-top-active {
      margin-top: -1px;
    }

    .@{split-prefix-cls}-horizontal .@{split-prefix-cls}-trigger-con {
      top: 50%;
      height: 100%;
      width: 0;
    }

    .@{split-prefix-cls}-trigger-con-drag {
      cursor: n-resize;
    }

    .@{split-prefix-cls}-pane-moving {
      cursor: n-resize;
    }
  }

  .no-select {
    .user-select(none);
  }

  &-trigger-button {
    display: flex;
    justify-content: center;
    align-items: center;
    visibility: hidden;

    .@{css-prefix}svg {
      fill: var(--tv-Split-trigger-icon-line-color);
    }

    &:hover {
      cursor: pointer;

      .@{css-prefix}svg {
        fill: var(--tv-Split-trigger-icon-line-color-hover);
      }
    }
  }

  &-trigger-button-show {
    visibility: visible;
  }


  &-trigger-con-vertical.@{split-prefix-cls}-trigger-con-simple {
    padding: 0 8px;
    cursor: e-resize;
  }

  &-trigger-con-horizontal.@{split-prefix-cls}-trigger-con-simple {
    padding: 8px 0;
    cursor: n-resize;
  }

  &-trigger-con-simple {
    .@{split-prefix-cls}-trigger-vertical {
      width: 1px;
    }

    .@{split-prefix-cls}-trigger-horizontal {
      height: 1px;
    }

    &:hover {
      .@{split-prefix-cls}-trigger {
        background: var(--tv-Split-trigger-line-bg-hover);
      }
    }
  }
}