/**
 * @license
 * Copyright Akveo. All Rights Reserved.
 * Licensed under the MIT License. See License.txt in the project root for license information.
 */

@use '../../theming' as *;

@mixin nb-tables-smart-table-theme() {
  ng2-smart-table {
    table tr th,
    table tr th a {
      font-family: nb-theme(smart-table-header-font-family);
      font-size: nb-theme(smart-table-header-font-size);
      font-weight: nb-theme(smart-table-header-font-weight);
      line-height: nb-theme(smart-table-header-line-height);
      color: nb-theme(smart-table-header-fg);
    }

    table tr td {
      font-family: nb-theme(smart-table-font-family);
      font-size: nb-theme(smart-table-font-size);
      font-weight: nb-theme(smart-table-font-weight);
      line-height: nb-theme(smart-table-line-height);
      color: nb-theme(smart-table-fg);
    }

    table tr th,
    table tr td {
      position: relative;
      padding: nb-theme(smart-table-padding);
      border: 1px solid nb-theme(smart-table-separator);
      vertical-align: middle;
    }

    table tr.ng2-smart-titles {
      th {
        padding: nb-theme(smart-table-padding);
        @include nb-ltr(padding-right, 1.75rem);
        @include nb-rtl(padding-left, 1.75rem);
      }

      th a {
        &:hover,
        &:active,
        &:visited {
          color: nb-theme(smart-table-header-fg);
          text-decoration: none;
        }
        &.sort.asc,
        &.sort.desc {
          font-weight: nb-theme(smart-table-header-font-weight);

          &::after {
            border-bottom-color: nb-theme(smart-table-fg-secondary);
            border-width: 0.375rem;
            position: absolute;
            margin: 0;
            @include nb-ltr(right, 0.75rem);
            @include nb-rtl(left, 0.75rem);
            top: 50%;
            transform: translate(0, -50%);
          }

          &.desc::after {
            transform: translate(0, -50%) rotate(180deg);
          }
        }
      }
    }

    thead tr {
      background: nb-theme(smart-table-header-bg);

      &.ng2-smart-filters th {
        padding: nb-theme(smart-table-filter-padding);

        .ng2-smart-filter input {
          line-height: nb-theme(smart-table-line-height);
        }
      }
    }

    tbody tr {
      &.selected,
      &:hover {
        background: nb-theme(smart-table-bg-active) !important;
      }

      &:nth-child(2n) {
        background-color: nb-theme(smart-table-bg-even);
      }
    }

    // Actions
    th.ng2-smart-actions-title-add {
      a {
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.75rem !important;
        padding: nb-theme(smart-table-filter-padding);
        border-color: nb-theme(smart-table-add-button-border-color);
        background-color: nb-theme(smart-table-add-button-background-color);
        color: nb-theme(smart-table-add-button-text-color);
        border-radius: 0.375rem;

        &:focus {
          border-color: nb-theme(smart-table-add-button-focus-border-color);
        }

        &:hover {
          text-decoration: none;
          background-color: nb-theme(smart-table-add-button-hover-background-color);
          border-color: nb-theme(smart-table-add-button-hover-border-color);
        }

        &:active {
          background-color: nb-theme(smart-table-add-button-active-background-color);
          border-color: nb-theme(smart-table-add-button-active-border-color);
        }
      }
    }

    .ng2-smart-actions {
      padding: 0;
      // fix for 100% height child
      height: 1px;

      ng2-st-tbody-edit-delete,
      ng2-st-tbody-create-cancel,
      ng2-st-actions {
        display: flex;
        height: 100%;
      }

      a.ng2-smart-action {
        display: flex;
        align-items: center;
        justify-content: center;
        height: 100%;
        width: 100%;

        font-size: 2rem !important;
        color: nb-theme(smart-table-fg-secondary);

        &:not(:last-child) {
          border-right: 1px solid nb-theme(smart-table-separator);
        }

        &:hover {
          text-decoration: none;
        }
      }

      .ng2-smart-action-add-create:hover,
      .ng2-smart-action-edit-edit:hover,
      .ng2-smart-action-edit-save:hover {
        color: nb-theme(smart-table-action-add-edit-hover-text-color);
      }

      .ng2-smart-action-add-cancel:hover,
      .ng2-smart-action-delete-delete:hover,
      .ng2-smart-action-edit-cancel:hover {
        color: nb-theme(smart-table-action-cancel-delete-hover-text-color);
      }
    }

    // TODO: remove this hack, when it will be possible to identify the whole row in the edit state
    table-cell-edit-mode {
      display: block;
      margin: -7.5px -12px;
    }

    ng2-smart-table-pager {
      display: block;
    }

    //Paging
    nav.ng2-smart-pagination-nav {
      display: flex;
      justify-content: center;
      margin-top: 1.25rem;

      .ng2-smart-pagination {
        display: flex;
        padding: 0;

        .page-item.disabled .page-link,
        .page-item.disabled .page-link:focus,
        .page-item.disabled .page-link:hover {
          background-color: nb-theme(smart-table-paging-hover);
          color: nb-theme(smart-table-paging-disabled-text-color);
        }
      }

      .pagination {
        font-family: nb-theme(smart-table-paging-font-family);
        font-size: nb-theme(smart-table-paging-font-size);
        line-height: nb-theme(smart-table-paging-line-height);
        border: nb-theme(smart-table-paging-border-color) solid nb-theme(smart-table-paging-border-width);
        border-radius: nb-theme(smart-table-border-radius);

        li {
          overflow: hidden;

          &:not(:last-child) {
            @include nb-ltr(border-right, 1px solid nb-theme(smart-table-separator));
            @include nb-rtl(border-left, 1px solid nb-theme(smart-table-separator));
          }

          a.page-link-prev,
          a.page-link-next {
            font-size: nb-theme(smart-table-paging-font-size);
            line-height: nb-theme(smart-table-paging-line-height);
          }

          a,
          > span {
            font-size: nb-theme(smart-table-paging-font-size);
            line-height: nb-theme(smart-table-paging-line-height);
            background-color: transparent;
            color: nb-theme(smart-table-paging-page-text-color);
            padding: 0.75rem 1.25rem;
            border: none;

            &:focus {
              border-color: nb-theme(smart-table-paging-page-focus-border-color);
              color: nb-theme(smart-table-paging-page-focus-text-color);
            }

            &:hover {
              background-color: nb-theme(smart-table-paging-hover);
              border-color: nb-theme(smart-table-paging-hover-border-color);
              color: nb-theme(smart-table-paging-hover-text-color);
              text-decoration: none;
            }
          }

          &:first-child {
            a,
            > span {
              @include nb-ltr() {
                border-top-left-radius: nb-theme(smart-table-border-radius);
                border-bottom-left-radius: nb-theme(smart-table-border-radius);
              }
              @include nb-rtl() {
                border-top-right-radius: nb-theme(smart-table-border-radius);
                border-bottom-right-radius: nb-theme(smart-table-border-radius);
              }
            }
          }

          &:last-child {
            a,
            > span {
              @include nb-ltr() {
                border-top-right-radius: nb-theme(smart-table-border-radius);
                border-bottom-right-radius: nb-theme(smart-table-border-radius);
              }
              @include nb-rtl() {
                border-top-left-radius: nb-theme(smart-table-border-radius);
                border-bottom-left-radius: nb-theme(smart-table-border-radius);
              }
            }
          }

          &.active {
            a,
            a:hover,
            a:focus,
            > span,
            > span:hover,
            > span:focus {
              color: nb-theme(smart-table-paging-fg-active);
              background-color: nb-theme(smart-table-paging-bg-active);
            }
          }
        }
      }
    }
  }
}
