@use 'sass:map';
@use 'sass:list';

.theming-api-aquila {
  // creates the spacing of the group header border to the resize handles
  // by hiding parts of the border with the properly positioned pseudo elements
  // a bit hacky but works :)

  :where(.ag-ltr) .ag-header-cell:after {
    border-right: none;
  }

  .ag-header-cell {
    gap: 0;
  }

  .ag-header-group-cell {
    contain: none;

    &:before,
    &:after {
      content: ' ';
      width: 8px;
      position: absolute;
      height: 100%;
      background-color: var(--ag-background-color);
      top: 50%;
      z-index: 2;
      display: block;
      border-right: none;
    }

    &:before {
      left: 0;
    }

    &::after {
      right: 2px;
    }
  }

  // safari fix that the before and after from above are placed on top of the border
  .ag-header-row-column-group {
    z-index: 1;
  }

  .ag-header-row:has(+ .ag-header-row-column-filter) {
    --ag-header-column-resize-handle-height: 67px;

    .ag-header-cell {
      overflow: visible !important;
    }

    .ag-header-cell-resize::after {
      top: 12px;
      left: 3px;
    }

    .ag-header-cell.ag-header-span-height {
      .ag-header-cell-resize::after {
        height: 112px;
      }
    }
  }

  .ag-header-row-column-group:has(+ .ag-header-row) {
    .ag-header-cell-resize::after {
      height: calc(200% - var(--ag-spacing) * 4);
      left: 3px;
    }
  }

  .ag-cell-focus:not(.ag-cell-range-selected):focus-within {
    border-left-width: 2px;
    border-right-width: 2px;
  }

  .ag-floating-filter-button-button {
    color: var(--interactive-text);
  }

  .ag-floating-filter-input input {
    color: var(--formfield-input-color);
    font-weight: var(--formfield-outline-control-font-weight);
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
  }

  .ag-input-field-input {
    &:focus {
      color: var(--formfield-active-color);
    }
  }

  .ag-floating-filter-button {
    margin-left: 0;
    width: calc(var(--ag-icon-size) + 14px);
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: var(--ag-input-border);
    border-radius: var(--ag-border-radius);
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
  }

  .ag-floating-filter-input input {
    border-right: none;

    &:focus {
      border-right: var(--ag-input-border);
    }
  }

  .ag-floating-filter-input .ag-disabled {
    input:disabled {
      border-right: none;
      color: var(--formfield-disabled-text-color);
    }
  }

  .ag-selection-checkbox {
    margin-right: 16px;
  }

  // move the popup slightly away from the icon
  .ag-popup-child {
    margin-top: 8px;
  }

  .ag-header-row {
    font-weight: 600;
  }

  .ag-header {
    border-bottom: 2px solid var(--table-header-border-bottom-color);
  }

  .ag-root-wrapper {
    border: none;
    border-bottom: 2px solid var(--table-border-bottom-color);
  }

  .ag-row {
    font-size: var(--ag-font-size);
  }
  .ag-cell {
    -webkit-font-smoothing: antialiased;
  }

  input[class^='ag-'][type='text'] {
    min-height: 32px;
  }

  .ag-select .ag-picker-field-wrapper {
    min-height: 32px;
    border: var(--ag-input-border);
    border-radius: var(--ag-border-radius);

    & .ag-picker-field-icon {
      margin-right: 8px;
    }
  }

  .ag-floating-filter {
    border-top: none !important;
  }

  .ag-row-hover.ag-row-selected::before {
    background-color: var(--selectable-table-row-selected-hover-background-color);
    background-image: none;
  }

  // pagination
  .ag-paging-button {
    color: var(--pagination-link-color);
    &.ag-disabled {
      color: var(--pagination-link-disabled-color);
      cursor: not-allowed;
    }
  }

  .ag-paging-number,
  .ag-paging-row-summary-panel-number {
    font-weight: 700;
  }

  // hide the "1 to 100 of xxxxx" on mobile that the pagination doesn't line break
  @media (max-width: 475px) {
    .ag-paging-row-summary-panel {
      display: none;
    }
  }
}

.ag-dnd-ghost {
  box-shadow: 0 0 24px 0 rgba(65, 65, 65, 0.35);
  border: 0;
}
