/*
 * SPDX-FileCopyrightText: 2025 Contributors to the CitrineOS Project
 *
 * SPDX-License-Identifier: Apache-2.0
 */

$small-padding: var(--ant-padding-xxs) var(--ant-padding-xs);

.generic-table {
  th.ant-table-cell {
    white-space: nowrap;
  }
  .ant-table-cell {
    &.column-createdAt,
    &.column-updatedAt {
      white-space: nowrap; // todo if we enhance generic table to take in a type/class schema, then this can be set globally based on date type
    }
  }
}

.editable-table {
  .ant-form-item-control-input {
    display: inline;
  }

  table {
    table-layout: auto;
    width: 100%;
  }

  .editable-row {
    &.ant-table-row {
      > .ant-table-cell-row-hover {
        transition: 300ms;
        background: var(--ant-white-0);
      }
      &.editing-row > .ant-table-cell-row-hover {
        background: var(--ant-geekblue-1);
      }
    }

    .ant-btn-default {
      &.save-button {
        background: var(--ant-cyan-2);
      }
      &.delete-button {
        color: var(--ant-color-error);
        border-color: var(--ant-color-error);
      }
    }
  }

  td,
  th {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  &.ant-table-wrapper {
    .ant-table-cell-fix-left,
    .ant-table-cell-fix-right {
      background: var(--ant-table-header-bg);
    }

    .ant-table-cell,
    .ant-table-tbody > tr > td,
    tfoot > tr > td {
      padding: 0;

      &.actions-column {
        padding: $small-padding;
      }
    }

    .ant-table-thead > tr > th,
    .ant-table-tbody > tr > th,
    tfoot > tr > th {
      padding: $small-padding;
    }

    .ant-input-number {
      .ant-input-number-input {
        min-width: 80px;
        padding: 0 var(--ant-padding-xs);
      }
    }

    .ant-select-selector,
    .ant-input {
      min-width: 140px;
    }
  }

  .editable-cell,
  .ant-table-cell .ant-form-item {
    padding: var(--ant-padding-xs) var(--ant-padding-xs);
  }

  .ant-table-cell .ant-form-item {
    border: 0;
  }

  .ant-col:empty {
    padding: 0 !important;
  }
}

.table-wrapper {
  .search-form {
    .ant-input {
      background: transparent;
      border: 0;
    }

    .ant-row {
      background: transparent;
      border: 0;
      box-shadow: none;
    }

    .ant-form-item {
      padding: 0 20px 0 0;
    }

    .search-icon {
      transform: translateX(-20px);
    }
  }
}
