@import 'base';

$field-width: 150px;

.filterable-table {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background-color: white;

  &__top {
    display: flex;
    padding: 30px 0;
    align-items: flex-end;
    justify-content: space-between;

    &-title {
      font-size: 24px;
    }

    &-actions {
      display: flex;
      align-items: center;

      &-secondary {
        margin: 0 20px;
        padding: 6px;
        z-index: auto;
        position: relative;

        &.filterable-table__top-actions-secondary_active {
          span {
            color: color(action);
          }
        }

        span {
          font-size: 16px;
          color: color(black, bright);
        }

        &-dropdown {
          visibility: hidden;
          position: absolute;
          left: 0;
          top: 100%;
          width: 200px;
          z-index: 1;
          background-color: white;
          box-shadow: 0 1px 2px 1px color(black, bright);
          padding: 5px 0;

          &.filterable-table__top-actions-secondary-dropdown_visible {
            visibility: visible;
          }

          &-action {
            padding: 8px 14px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            @extend %link;

            &:hover {
              opacity: 1;
              background-color: color(black, pale);
            }

            &-loading {
              width: 20px;
              height: 20px;
              position: relative;
            }

            &-badge {
              @include circle(20px);
              display: flex;
              justify-content: center;
              align-items: center;
              color: white;
              background-color: color(action);
            }
          }
        }
      }
    }
  }

  &__action {
    margin-right: 10px;
  }

  &.filterable-table_selectable {
    .filterable-table__card-header {
      width: 438px;
    }
  }

  .filterable-table__main {
    @extend %block;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    position: relative;
  }

  .filterable-table__header {
    position: absolute;
    top: 0;
    left: 0;
    background-color: white;
    z-index: 2;
    border-bottom: solid 1px color(black, pale);
    display: flex;
    align-items: center;
    overflow: visible;
    min-width: 100vw;
  }

  .filterable-table__all-items {
    display: flex;
    flex-direction: column;
    align-items: flex-start;

    .filterable-table__items-count {
      align-self: center;
      padding-left: 10px;
      color: color('black', 'light');
      font-size: 10px;
    }
  }

  .filterable-table__rows {
    flex: 1;
    display: flex;
    padding-top: 35px;
    z-index: 1;
  }

  .filterable-table__card-header {
    flex-grow: 0;
    flex-shrink: 0;
    width: 468px;
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
  }

  .filterable-table__card-name-arrange {
    flex: 1;
    display: flex;
    flex-direction: row;
    align-items: stretch;
  }

  .filterable-table__select-all-checkbox {
    display: flex;
    align-items: center;
    padding-left: 10px;

    &.filterable-table__select-all-checkbox_selected {
      color: color(primary, light);
    }
  }

  .filterable-table__sort-name {
    font-size: 15px;
    padding: 5px 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;

    @extend %link;
  }

  .filterable-table__search-bar-container {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    position: relative;
  }

  .filterable-table__search-bar {
    position: absolute;
    background-color: white;
    z-index: 1;
    left: 2px;
    bottom: 2px;
  }

  .filterable-table__card-filters {
    flex-shrink: 1;
    display: flex;
    flex-direction: row;
    align-items: center;
  }

  .filterable-table__fields-header {
    flex-shrink: 1;
    display: flex;
    flex-direction: row;
    align-items: center;
  }

  .filterable-table__filter {
    &.filterable-table__filter_sortable {
      @extend %link;
    }

    &.filterable-table__filter_field {
      flex-shrink: 0;
      width: $field-width;
      transform: translateX(8px);
    }

    &.filterable-table__filter_no-dropdown {
      padding: 0px 5px;
    }
  }

  .filterable-table__field {
    flex-shrink: 0;
    width: $field-width;
    background-color: white;
    display: flex;
    align-items: flex-start;
    justify-content: center;
  }

  .filterable-table__filter-value {
    z-index: 2;
    padding: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;

    &-name {
      display: flex;
    }

    .filterable-table__filter-value__icon {
      margin-right: 8px;
    }

    &.filterable-table__filter-value_selected {
      background-color: color(primary, light);
      color: white;

      &:hover {
        background-color: color(primary, light);
        opacity: 0.54;
      }
    }

    &.filterable-table__filter-value_locked {
      $color: color(primary);
      background-color: $color;
      color: white;

      &:hover {
        background-color: $color;
        opacity: 1;
      }
    }

    &:hover {
      background-color: color(black, pale);
    }
  }

  .filterable-table__filter-value-tick {
    flex-shrink: 0;
    width: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-left: 5px;
  }

  .filterable-table__item {
    height: 60px;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    overflow: visible;
    border-top: solid 1px color(black, pale);
  }

  .filterable-table__card {
    padding: 0px 10px;
    flex-shrink: 0;

    @extend %link;

    &.filterable-table__card_selected {
      background-color: color(primary, light);
      color: color(white);
    }
  }

  .filterable-table__filter-search-bar {
    flex-shrink: 0;
    margin: 3px;
  }

  .filterable-table__filter-values-placeholder {
    align-items: center;
    color: color(black, bright);
    display: flex;
    font-style: italic;
    justify-content: center;
    padding: 5px;
  }

  .filterable-table__filter-place {
    width: 400px;
  }

  .filterable-table__filter-place-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;

    .filterable-table__filter-place-radius-input {
      @extend %complex-input;
    }
  }

  .filterable-table__filter-place-label {
    flex: 1;
    white-space: normal;
    margin-right: 10px;
  }

  .filterable-table__filter-place-input {
    flex: 2;
    display: flex;
    align-items: center;
  }

  .filterable-table__filter-place-radius-unit {
    margin-left: 10px;
  }

  &__filter-date {
    display: flex;
    padding: 10px;
    align-items: center;

    &-title {
      font-weight: bold;
      width: 70px;
      flex-shrink: 0;
    }

    &-input-group {
      display: flex;
      align-items: center;
    }

    &-input {
      width: 150px;
      @extend %simple-input;
      margin-left: 5px;
      margin-right: 10px;
      border-radius: 5px;
      border: solid 1px color(black, pale);
      padding: 4px 6px;

      &:focus {
        border-color: color(primary, light);
      }
    }
  }

  &__filter-values {
    &.filterable-table__filter-values_long {
      height: 240px;
      overflow: scroll;
    }
  }

  .filterable-table__add-field-button {
    margin: 0px 10px;
  }

  &__export-missions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 500px;
    margin-top: 20px;

    &-button {
      display: flex;
      justify-content: center;
    }
  }
}
