@import '../../style/variables.less';

.pro-table {
  .pro-tooltip .singleLine {
    transition: none;
  }
  &.pro-table-draggable-only {
    .ant-table-tbody {
      .anticon {
        margin-right: 0;
      }
    }
    .@{ant-prefix}-table-row-expand-icon {
      position: absolute;
      left: -16px;
    }
  }
  .@{ant-prefix}-table-cell-with-append {
    position: relative;
    z-index: 100;
    white-space: nowrap;
    > div {
      display: inline-block;
    }
  }

  .@{ant-prefix}-table-content {
    > table {
      .@{ant-prefix}-table-cell-fix-left-last:after {
        width: 8px;
      }
      .@{ant-prefix}-table-summary {
        color: var(--zaui-text, #343434);
        font-weight: 600;
        background-color: var(--zaui-table-header-bg, #f2f3f5);

        .@{ant-prefix}-table-cell-fix-left,
        .@{ant-prefix}-table-cell-fix-right {
          background-color: var(--zaui-table-header-bg, #f2f3f5);
        }
      }

      th.@{ant-prefix}-table-selection-column {
        width: 48px;
      }

      td {
        .pro-form-view-container_nowrap {
          white-space: normal;
        }
        &.@{ant-prefix}-table-row-expand-icon-cell {
          display: flex;
          justify-content: center;
          align-items: center;
          > button.@{ant-prefix}-table-row-expand-icon {
            position: relative;
            left: auto;
            top: auto;
            transform: none;
          }
        }
      }

      .@{ant-prefix}-table-thead
        > tr
        > th:not(.@{ant-prefix}-table-selection-column):not(
          .@{ant-prefix}-table-row-expand-icon-cell
        ):not([colspan]).is-required {
        &.is-required-right {
          .pro-edit-table-title {
            &::before {
              position: static;
              top: 0;
              display: inline-block;
              color: #ff5050;
              font-size: var(--zaui-font-size-md, 14px);
              line-height: 1;
              text-indent: -8px;
              content: '*';
            }
          }
        }
        &.is-required-left {
          .pro-edit-table-title {
            &::after {
              position: static;
              top: 0;
              display: inline-block;
              width: auto;
              margin-left: var(--zaui-space-size-xs, 4px);
              color: #ff5050;
              font-size: 14px;
              line-height: 1;
              content: '*';
            }
          }
        }
      }
    }
  }
  .pro-table-drag-wrapper {
    display: flex;
    justify-content: flex-end;
    margin-right: 8px;
    .@{ant-prefix}-btn:hover {
      background: #fff !important;
    }
    .anticon {
      cursor: pointer;
      font-size: 18px;
      color: #949599;
    }
  }
  .pro-table-drag-wrapper.no-check {
    .anticon {
      margin-right: 0;
    }
  }

  &.pro-table-bordered {
    .@{ant-prefix}-table .@{ant-prefix}-table-thead > tr > th {
      border-bottom: 1px solid #f0f0f0;
    }

    .@{ant-prefix}-table > .@{ant-prefix}-table-container > .@{ant-prefix}-table-content > table,
    .@{ant-prefix}-table > .@{ant-prefix}-table-container > .@{ant-prefix}-table-header > table {
      border-top: 1px solid rgba(0, 0, 0, 0.06);
    }

    .@{ant-prefix}-table
      > .@{ant-prefix}-table-container
      > .@{ant-prefix}-table-content
      > table
      > thead
      > tr
      > th,
    .@{ant-prefix}-table
      > .@{ant-prefix}-table-container
      > .@{ant-prefix}-table-header
      > table
      > thead
      > tr
      > th,
    .@{ant-prefix}-table
      > .@{ant-prefix}-table-container
      > .@{ant-prefix}-table-body
      > table
      > thead
      > tr
      > th,
    .@{ant-prefix}-table
      > .@{ant-prefix}-table-container
      > .@{ant-prefix}-table-summary
      > table
      > thead
      > tr
      > th,
    .@{ant-prefix}-table
      > .@{ant-prefix}-table-container
      > .@{ant-prefix}-table-content
      > table
      > tbody
      > tr
      > td,
    .@{ant-prefix}-table
      > .@{ant-prefix}-table-container
      > .@{ant-prefix}-table-header
      > table
      > tbody
      > tr
      > td,
    .@{ant-prefix}-table
      > .@{ant-prefix}-table-container
      > .@{ant-prefix}-table-body
      > table
      > tbody
      > tr
      > td,
    .@{ant-prefix}-table
      > .@{ant-prefix}-table-container
      > .@{ant-prefix}-table-summary
      > table
      > tbody
      > tr
      > td,
    .@{ant-prefix}-table
      > .@{ant-prefix}-table-container
      > .@{ant-prefix}-table-content
      > table
      > tfoot
      > tr
      > th,
    .@{ant-prefix}-table
      > .@{ant-prefix}-table-container
      > .@{ant-prefix}-table-header
      > table
      > tfoot
      > tr
      > th,
    .@{ant-prefix}-table
      > .@{ant-prefix}-table-container
      > .@{ant-prefix}-table-body
      > table
      > tfoot
      > tr
      > th,
    .@{ant-prefix}-table
      > .@{ant-prefix}-table-container
      > .@{ant-prefix}-table-summary
      > table
      > tfoot
      > tr
      > th,
    .@{ant-prefix}-table
      > .@{ant-prefix}-table-container
      > .@{ant-prefix}-table-content
      > table
      > tfoot
      > tr
      > td,
    .@{ant-prefix}-table
      > .@{ant-prefix}-table-container
      > .@{ant-prefix}-table-header
      > table
      > tfoot
      > tr
      > td,
    .@{ant-prefix}-table
      > .@{ant-prefix}-table-container
      > .@{ant-prefix}-table-body
      > table
      > tfoot
      > tr
      > td,
    .@{ant-prefix}-table
      > .@{ant-prefix}-table-container
      > .@{ant-prefix}-table-summary
      > table
      > tfoot
      > tr
      > td {
      border-right: 1px solid rgba(0, 0, 0, 0.06);
    }

    .@{ant-prefix}-table
      .@{ant-prefix}-table-tbody
      > tr:not(.@{ant-prefix}-table-measure-row)
      > td {
      border-bottom: 1px solid #f0f0f0;
    }

    .@{ant-prefix}-table > .@{ant-prefix}-table-container {
      border-left: 1px solid rgba(0, 0, 0, 0.06);
    }
  }

  .column-config .right-actions .@{ant-prefix}-btn {
    &:hover,
    &:visited,
    &:focus {
      color: #333 !important;
      background: #fff !important;
      border: 1px solid #d9d9d9 !important;
    }
  }

  .custom-column-btn {
    display: inline-flex;
    align-items: center;
    .anticon {
      height: 16px;
    }
  }

  .@{ant-prefix}-table-tbody {
    .@{ant-prefix}-table-cell-fix-left,
    .@{ant-prefix}-table-cell-fix-right {
      background: unset !important;
    }
  }

  .@{ant-prefix}-table table tbody.@{ant-prefix}-table-tbody,
  .@{ant-prefix}-table.@{ant-prefix}-table-scroll-horizontal table tbody.@{ant-prefix}-table-tbody {
    tr.@{ant-prefix}-table-row.new-cell,
    tr.@{ant-prefix}-table-row.new-cell:hover {
      background-color: var(--zaui-contract-bg-add; #d2fff4) !important;
      td.@{ant-prefix}-table-cell {
        background-color: var(--zaui-contract-bg-add; #d2fff4) !important;
        border-bottom: 1px solid var(--zaui-form-control-line, #dcdcdc);
        &.@{ant-prefix}-table-cell-fix-right {
          background-color: var(--zaui-contract-bg-add; #d2fff4) !important;
          border-bottom: 1px solid var(--zaui-form-control-line, #dcdcdc);
        }
        &.@{ant-prefix}-table-cell-fix-left {
          background-color: var(--zaui-contract-bg-add; #d2fff4) !important;
          border-bottom: 1px solid var(--zaui-form-control-line, #dcdcdc);
        }
      }
    }

    .@{ant-prefix}-table-cell {
      .varied-cell {
        display: block;
        margin-left: -8px;
        padding: var(--zaui-space-size-xs, 4px) var(--zaui-space-size-sm, 8px);
        background-color: var(--zaui-contract-bg; #fffaa1) !important;
        border-radius: var(--zaui-border-radius, 8px);
        .pro-form-view-container {
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
        }
      }
      .add-cell {
        display: block;
        margin-left: -8px;
        padding: var(--zaui-space-size-xs, 4px) var(--zaui-space-size-sm, 8px);
        background-color: var(--zaui-contract-bg-add, #d2fff4) !important;
        border-radius: var(--zaui-border-radius, 8px);
        .pro-form-view-container {
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
        }
      }
    }

    .@{ant-prefix}-table-cell .@{ant-prefix}-typography-ellipsis {
      .pro-form-view-container {
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
    }

    .varied-cell.empty-cell {
      width: 24.5px;
    }
  }

  .copyable-table-cell {
    .@{ant-prefix}-typography {
      display: flex;
      align-items: center;
      margin-bottom: 0;
    }

    .drag-icon {
      & > div {
        display: flex;
        align-items: center;
      }
    }

    .@{ant-prefix}-typography-copy-success {
      svg {
        fill: var(--zaui-success, #00ae4d);
      }
    }

    svg {
      display: inline-block;
      width: 16px;
      height: 16px;
      fill: var(--zaui-brand, #006aff);
    }
  }

  &.pro-table-no-stripe {
    .@{ant-prefix}-table.@{ant-prefix}-table-scroll-horizontal
      .@{ant-prefix}-table-tbody
      .@{ant-prefix}-table-row:nth-child(n)
      > td {
      background: var(--zaui-base-bg, #ffffff);
    }
  }

  .@{ant-prefix}-table-thead {
    .@{ant-prefix}-dropdown-trigger {
      &.@{ant-prefix}-dropdown-open {
        .anticon-down {
          transform: rotateZ(180deg);
          transition: transform 0.3s;
        }
      }
    }
  }

  .pro-table-container {
    position: relative;

    .pro-table-resizable-line {
      position: absolute;
      top: 0;
      left: 100px;
      width: 0;
      height: 100%;
      border-left: 1px solid var(--zaui-brand, #006aff);
    }
  }

  .@{ant-prefix}-table-thead {
    tr th {
      &:last-child {
        .react-resizable-handle {
          display: none;
        }
      }
    }
  }

  .@{ant-prefix}-space {
    gap: var(--zaui-space-size-sm, 8px) !important;
  }

  .@{ant-prefix}-btn-link {
    padding: 0 var(--zaui-space-size-xs, 4px);

    &:first-child {
      padding-left: 0;
    }
  }

  .column-config {
    display: flex;
    justify-content: space-between;
    margin-bottom: calc(var(--zaui-space-size-md; 16px) * var(--zaui-size; 1));

    .right-actions {
      display: flex;
      align-items: center;

      > .@{ant-prefix}-btn {
        &:hover,
        &:visited,
        &:focus {
          color: unset;
          background: unset;
          border: 1px solid #d9d9d9;
        }
      }

      .custom-column-btn {
        margin-left: var(--zaui-space-size-sm, 8px);
      }
    }
  }

  .pro-table-empty {
    margin: 0;
    color: rgba(0, 0, 0, 0.25);
    font-size: var(--zaui-font-size-md, 14px);
    text-align: center;

    .empty-image {
      height: 80px;

      img {
        height: 100%;
      }
    }
  }

  .@{ant-prefix}-table .@{ant-prefix}-table-thead > tr > th {
    background: var(--zaui-table-header-bg, #f2f3f5);
    border-bottom: 0;

    .pro-table-th-cell {
      width: 100%;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }

    &::before {
      width: 0 !important;
    }

    &.react-resizable {
      &::before {
        width: 1px !important;
      }
    }

    .pro-table-tooltip {
      display: inline-flex;
      align-items: center;

      .icon-tip {
        margin-left: 8px;
        div {
          width: 14px;
          height: 14px;

          svg {
            width: 14px;
            height: 14px;
            margin-left: 8px;
            fill: #909090;
          }
        }
      }
    }
  }

  .@{ant-prefix}-table.@{ant-prefix}-table-bordered {
    .@{ant-prefix}-table-thead > tr > th {
      border-bottom: 1px solid #f0f0f0;
    }

    .@{ant-prefix}-table-tbody > tr:not(.@{ant-prefix}-table-placeholder) > td {
      border-bottom: 1px solid #f0f0f0;
    }

    .@{ant-prefix}-table-tbody > tr:not(.@{ant-prefix}-table-measure-row) > td {
      border-bottom: 1px solid #f0f0f0;
    }
  }

  .@{ant-prefix}-table-tbody .@{ant-prefix}-table-placeholder {
    background: var(--zaui-base-bg, #ffffff) !important;
  }

  .@{ant-prefix}-table-tbody > tr:not(.@{ant-prefix}-table-placeholder) > td {
    border-bottom: 0;
  }

  .@{ant-prefix}-table-tbody > tr:not(.@{ant-prefix}-table-measure-row) > td {
    border-bottom: 0;
  }

  .react-resizable {
    position: relative;
    background-clip: padding-box;

    .@{ant-prefix}-table-filter-trigger {
      margin-right: 0;
    }
  }

  .react-resizable-handle {
    position: absolute;
    right: -5px;
    bottom: 0;
    z-index: 1;
    width: 10px;
    height: 100%;
    cursor: col-resize;

    &::before {
      position: absolute;
      top: 50%;
      left: 50%;
      width: 1px;
      height: 18px;
      background: #dcdcdc;
      transform: translateY(-50%);
      content: '';
    }

    &.active::before,
    &:hover::before {
      position: absolute;
      bottom: 0;
      left: 50%;
      height: 100%;
      border-left: 5px solid var(--zaui-brand, #006aff);
      content: '';
    }
  }

  .@{ant-prefix}-table-tbody tr td .@{ant-prefix}-checkbox-wrapper-checked.checkbox-disabled {
    cursor: not-allowed;
    opacity: 0.5;
    pointer-events: none;
  }

  .@{ant-prefix}-pagination-options-quick-jumper input {
    min-width: 32px;
    height: 32px;
    background: #fafafa;
    border: unset;
  }

  .@{ant-prefix}-pagination .@{ant-prefix}-pagination-item-active a {
    color: #ffffff;
    background: var(--zaui-brand, #006aff) !important;
    border-radius: var(--zaui-border-radius, 8px);
  }

  .pro-table-footer {
    &.no-page {
      margin-top: var(--zaui-space-size-md, 16px);
    }

    &.has-page {
      margin: -50px 0 var(--zaui-space-size-md, 16px) 0;
    }
  }

  .@{ant-prefix}-table-summary {
    background-color: var(--zaui-table-header-bg, #f2f3f5);
    td {
      padding: calc(4px + var(--zaui-size) * 8px);
    }
    .@{ant-prefix}-table-cell {
      font-weight: 500;
      background-color: var(--zaui-table-header-bg, #f2f3f5);
      border: none;
    }
  }

  // 嵌套子表格缩进样式（针对展开行中的 ProTable）
  .@{ant-prefix}-table-tbody {
    > tr.@{ant-prefix}-table-expanded-row {
      > td {
        > .pro-table {
          margin-inline: calc(
              var(--ant-control-interactive-size) + 2 * var(--ant-padding) -
                var(--ant-table-cell-padding-inline)
            )
            calc(-1 * var(--ant-table-cell-padding-inline));
        }
      }
    }
  }
}

.@{ant-prefix}-dropdown-placement-bottomLeft {
  .@{ant-prefix}-dropdown-menu-vertical.@{ant-prefix}-dropdown-menu-light {
    .@{ant-prefix}-dropdown-menu-item-only-child {
      &:hover {
        background: rgba(0, 106, 255, 0.08);
      }
    }
  }
}

.@{ant-prefix}-table {
  .original-value-tooltip {
    position: fixed;
    &.@{ant-prefix}-tooltip > @{ant-prefix}-tooltip-content > @{ant-prefix}-tooltip-inner {
      width: max-content;
    }
  }
}
