@import 'md-edit-dialog';
@import 'md-table-pagination';
@import 'md-table-select';
@import 'md-table-toolbar';
@import 'md-variables';

md-card {
  > md-toolbar.md-table-toolbar:first-child,
  > md-table-container:first-child {
    border-top-left-radius: 2px;
    border-top-right-radius: 2px;
  }

  > md-toolbar.md-table-toolbar:last-child,
  > md-table-container:last-child {
    border-bottom-left-radius: 2px;
    border-bottom-right-radius: 2px;
  }
}

md-table-container {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.md-table {
  width: 100%;
  border-spacing: 0;
  overflow: hidden;

  thead.md-head > tr.md-row {
    height: 56px;
  }

  tbody.md-body > tr.md-row,
  tfoot.md-foot > tr.md-row {
    height: 48px;
  }

  thead.md-head + .md-table-progress md-progress-linear {
    top: -3px;
  }

  .md-table-progress th {
    padding: 0;

    md-progress-linear {
      height: 0;
      transition: opacity 1s;

      &.ng-hide {
        opacity: 0;
      }

      > .md-container {
        height: 3px;
        top: 0;
        transition: none;

        > .md-bar {
          height: 3px;
        }
      }
    }
  }

  th.md-column {
    color: @md-dark-secondary;
    font-size: 12px;
    font-weight: bold;
    white-space: nowrap;

    &.md-sort {
      cursor: pointer;
    }

    md-icon {
      height: 16px;
      width: 16px;
      font-size: 16px !important;
      line-height: 16px !important;

      &.md-sort-icon {
        color: @md-dark-disabled;
        opacity: 0;
        transition: transform 0.25s, opacity 0.25s;

        &.md-asc {
          transform: rotate(0deg);
        }

        &.md-desc {
          transform: rotate(180deg);
        }
      }

      &:not(:first-child) {
        margin-left: 8px;
      }

      &:not(:last-child) {
        margin-right: 8px;
      }
    }

    &.md-active,
    &.md-active md-icon {
      color: @md-dark;
    }

    &:hover md-icon.md-sort-icon,
    &.md-active md-icon.md-sort-icon {
      opacity: 1;
    }
  }

  tr.md-row {
    &[ng\:repeat].ng-leave,
    &[ng-repeat].ng-leave,
    &[x-ng-repeat].ng-leave,
    &[data-ng-repeat].ng-leave {
      display: none;
    }
  }

  &.md-row-select tbody.md-body > tr.md-row {
    transition: background-color 0.2s;

    &:not([disabled]):hover {
      background-color: @md-dark-row-hover !important;
    }

    &.md-selected {
      background-color: @md-dark-row-select;
    }
  }

  &.md-row-select td.md-cell,
  &.md-row-select th.md-column {
    &:first-child {
      width: 20px;
      padding: 0 0 0 24px;
    }

    &:nth-child(2) {
      padding: 0 24px;
    }

    &:nth-child(n+3):nth-last-child(n+2) {
      padding: 0 56px 0 0;
    }
  }

  &:not(.md-row-select) td.md-cell,
  &:not(.md-row-select) th.md-column {
    &:first-child {
      padding: 0 24px;
    }

    &:nth-child(n+2):nth-last-child(n+2) {
      padding: 0 56px 0 0;
    }
  }

  td.md-cell,
  th.md-column {
    vertical-align: middle;
    text-align: left;

    > * {
      vertical-align: middle;
    }

    &:last-child {
      padding: 0 24px 0 0;
    }

    &.md-clickable {
      cursor: pointer;

      &:focus {
        outline: none;
      }
    }

    &.md-numeric {
      text-align: right;
    }

    md-checkbox {
      margin: 0;
      width: 20px;
    }
  }

  td.md-cell {
    color: @md-dark;
    font-size: 13px;
    border-top: 1px @md-dark-divider solid;
    
    &.md-numeric md-select {
      justify-content: flex-end;

      .md-select-value {
        flex: 0 0 auto;
      }
    }

    &.md-placeholder {
      color: @md-dark-disabled;
    }

    md-select > .md-select-value > span.md-select-icon {
      justify-content: flex-end;
      color: @md-dark-secondary;
      width: 18px;
      text-align: right;

      &:after {
        transform: scaleY(0.4) scaleX(0.8);
      }
    }
  }
}