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

@mixin el-tables-smart-table-theme() {

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

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

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

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

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

          font-weight: el-theme(smart-table-header-font-weight);

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

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

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

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

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

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

      &:nth-child(2n) {
        background-color: el-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: el-theme(smart-table-filter-padding);
        border-color: el-theme(smart-table-add-button-border-color);
        background-color: el-theme(smart-table-add-button-background-color);
        color: el-theme(smart-table-add-button-text-color);
        border-radius: 0.375rem;

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

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

        &:active {
          background-color: el-theme(smart-table-add-button-active-background-color);
          border-color: el-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: el-theme(smart-table-fg-secondary);

        &:not(:last-child) {
         border-right: 1px solid el-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: el-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: el-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: el-theme(smart-table-paging-hover);
          color: el-theme(smart-table-paging-disabled-text-color);
        }
      }

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

        li {
          overflow: hidden;

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

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

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

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

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

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

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

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