@use 'libs/components/theme/src/lib/styles/variables' as variables;
@use './variables' as sky-ag-grid-variables;

.ag-theme-sky-data-grid-default {
  border-top: sky-ag-grid-variables.$sky-standard-border;

  .ag-cell:not(.ag-cell-wrap-text) .ag-cell-wrapper {
    align-items: flex-start;
  }

  @include sky-ag-grid-variables.skyux-cell-wrap-text(
    sky-ag-grid-variables.$sky-cell-wrap-text-padding-default,
    sky-ag-grid-variables.$sky-cell-wrap-text-line-height-default
  );

  .ag-cell.sky-ag-grid-cell-invalid {
    border: 1px solid var(--sky-highlight-color-danger);
  }

  .ag-row:not(.ag-row-first) {
    border-top: none;
  }

  .ag-row {
    border-bottom-style: dotted;

    + .ag-row-last {
      border-bottom-style: dotted;
    }
  }
}

.ag-theme-sky-data-entry-grid-default {
  border-top: sky-ag-grid-variables.$sky-standard-border;
  border-left: sky-ag-grid-variables.$sky-standard-border;

  .ag-popup {
    .ag-popup-editor {
      background-color: transparent;
    }

    .ag-select-list {
      box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.3);

      .ag-select-list-item {
        cursor: pointer;
        padding-top: 5px;
        padding-bottom: 5px;
        height: 30px;

        &:last-of-type {
          padding-bottom: 10px;
          height: 35px;
        }

        &:focus-visible,
        &:hover,
        &.ag-active-item {
          background-color: var(--sky-background-color-selected);
        }
      }
    }
  }

  .ag-picker-field-wrapper {
    border-radius: 0;
  }

  .ag-cell:not(.ag-cell-wrap-text) .ag-cell-wrapper {
    align-items: flex-start;
  }

  @include sky-ag-grid-variables.skyux-cell-wrap-text(
    sky-ag-grid-variables.$sky-cell-wrap-text-padding-default,
    sky-ag-grid-variables.$sky-cell-wrap-text-line-height-default
  );

  .ag-cell {
    border-block-end: none;
    border-block-start: none;
  }

  .ag-cell.sky-ag-grid-cell-invalid {
    border: 1px solid var(--sky-highlight-color-danger);
  }

  .sky-ag-grid-cell-editable {
    background-color: var(--sky-background-color-page-default);

    .ag-select {
      .ag-picker-field-display {
        margin-top: 2px;
        margin-left: 9px;
      }
    }
  }

  .sky-ag-grid-cell-uneditable {
    background-color: var(--sky-background-color-neutral-light);
  }

  .ag-row:not(.ag-row-first) {
    border-top: none;
  }

  .ag-row {
    border-bottom-style: solid;

    &.ag-row-focus {
      z-index: 1;
    }

    .ag-cell.ag-cell-focus {
      z-index: 1;
      outline-offset: -2px;
      outline: var(--ag-range-selection-border-color) solid 2px;
    }
  }
}

.ag-theme-sky-data-grid-default,
.ag-theme-sky-data-entry-grid-default {
  .ag-header .ag-header-cell .ag-header-cell-label-sortable {
    color: var(--sky-text-color-deemphasized);

    &:hover {
      color: var(--sky-text-color-default);
    }
  }

  input.ag-checkbox-input[type='checkbox'] {
    border: 1px solid variables.$sky-background-color-disabled;
    border-radius: variables.$sky-border-radius;
    color: var(--sky-text-color-default);

    &:disabled {
      border-color: var(--sky-background-color-disabled);
      border-width: 2px;
    }

    &:checked:not(:disabled) {
      background-color: var(--sky-background-color-input-selected);
      border-color: var(--sky-highlight-color-info);
      border-width: 2px;
    }

    &:focus:not(:disabled) {
      border-color: var(--sky-text-color-default);
      border-width: 2px;
    }

    &:checked:before {
      width: 1em;
      height: 1em;
      clip-path: polygon(
        49.372% 71.425%,
        32.182% 52.751%,
        32.182% 52.751%,
        31.26% 52.724%,
        29.741% 53.568%,
        27.799% 55.088%,
        25.607% 57.088%,
        23.34% 59.373%,
        21.171% 61.747%,
        19.275% 64.015%,
        17.824% 65.982%,
        16.993% 67.452%,
        16.956% 68.229%,
        46.535% 100%,
        46.535% 100%,
        47.14% 100.571%,
        47.802% 101.016%,
        48.507% 101.333%,
        49.24% 101.523%,
        49.988% 101.587%,
        50.736% 101.523%,
        51.469% 101.333%,
        52.174% 101.016%,
        52.836% 100.571%,
        53.44% 100%,
        100% 49.061%,
        100% 49.061%,
        99.916% 48.228%,
        99.021% 46.804%,
        97.5% 44.958%,
        95.536% 42.861%,
        93.314% 40.682%,
        91.017% 38.59%,
        88.83% 36.755%,
        86.935% 35.345%,
        85.519% 34.532%,
        84.763% 34.484%,
        49.372% 71.425%
      );
    }
  }
}
