@import "../theme/variable";
@import "../theme/mixins";
@import "typography";

.qms-table {
  &.mat-mdc-table {
    .mat-mdc-row {
      font-family: inherit;
    }
  }

  .mat-mdc-checkbox.qms-group-options {
    /*TODO(mdc-migration): The following rule targets internal classes of checkbox that may no longer apply for the MDC version.*/
    .mat-checkbox-inner-container {
      width: 18px;
      height: 18px;
      margin: 0 !important;
    }
    /*TODO(mdc-migration): The following rule targets internal classes of checkbox that may no longer apply for the MDC version.*/
    &.mat-checkbox-indeterminate .mat-checkbox-background,
    &.mat-checkbox-checked .mat-checkbox-background {
      background-color: theme-apply($primary) !important;
    }
    /*TODO(mdc-migration): The following rule targets internal classes of checkbox that may no longer apply for the MDC version.*/
    &.mat-checkbox-checked {
      background: unset;
    }
  }

  .mat-mdc-header-cell:first-child {
    padding-left: 20px;
  }

  a {
    text-decoration: none;
    color: #323232;
    word-break: break-word;
    margin: -9px -2px;
    padding: 9px 2px;

    &:hover,
    &:focus-visible {
      outline: unset;
      color: theme-apply($primary);
      text-decoration: underline;
    }
  }

  .clickable-container {
    margin: 0;
    padding: 0 !important;
  }

  .clickable-content {
    padding: 8px 6px;
    border-radius: 5px;
    cursor: pointer;

    &:hover {
      outline: unset;
      background: rgba(0, 0, 0, 0.12);
    }
  }

  .qms-table-row {
    padding: 0px;
    background: #ffffff;
    border: 1px solid theme-apply($other-divider);
    border-radius: 4px;
    margin-top: 8px;
    min-height: 52px;
    font-size: 14px;
    line-height: 20px;
    font-family: "Open Sans";
    font-weight: normal;
    color: #323232;
    align-items: stretch;
    cursor: pointer;
    transition: background 0.2s;

    mat-cell:first-of-type {
      padding: 0 16px 0 16px;
    }

    mat-cell:last-of-type {
      padding: 0 16px 0 16px;
    }

    .mat-mdc-cell {
      min-height: 52px;
      border-bottom-width: 0px;
    }

    &[tabindex]:focus-visible {
      outline: 2px auto theme-apply($primary);
    }

    &:hover {
      background: rgba(0, 0, 0, 0.08);
    }

    &:active {
      background: theme-apply($primary-light-24-opacity);
    }

    &-selected {
      background: theme-apply($tab-focus-background);
      transition: background 0.2s;

      &:hover {
        background: rgba(40, 115, 223, 0.06);
      }

      &:active {
        background: rgba(40, 115, 223, 0.16);
      }
    }

    &-disabled {
      background: theme-apply($disabled);
      color: rgba(0, 0, 0, 0.38);
      pointer-events: none;

      mat-cell {
        opacity: 0.38;
      }
    }

    &-draft {
      border: 2px dashed rgba(0, 0, 0, 0.12);
    }

    .qms-btn-icon {
      width: 40px;
      height: 40px;
      line-height: 40px;

      .qms-btn-icon-wrapper .mat-icon {
        line-height: 20px;
      }
    }
  }

  //padding for table types
  &.qms-checkbox-table {
    .mat-mdc-header-cell:first-child {
      align-items: stretch !important;
      flex: unset;

      .qms-row-checkbox {
        padding: 0 19px;
        display: flex;
        align-items: center;
      }
    }

    .qms-table-row {
      .qms-row-checkbox-container:first-child {
        align-items: stretch !important;
        flex: unset;

        .qms-row-checkbox {
          padding: 0 19px;
          display: flex;
          align-items: center;
        }
      }
    }
  }

  &.qms-expand-table {
    .mat-mdc-header-cell {
      padding: 0 16px 0 16px;

      .expand-icon-header {
        margin-left: 15px;
      }
    }

    .qms-table-row {
      mat-cell.mat-mdc-cell {
        border-bottom-width: 0;
      }

      .expand-icon {
        user-select: none;
        transition: transform 0.2s;
        margin-right: 10px;
      }

      &.qms-row-expanded {
        background: #f2f7fd;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        transition: background 0.2s;

        &:hover {
          background: #e6effb;
        }

        &:active {
          background: rgba(40, 115, 223, 0.16);
        }

        .expand-icon {
          user-select: none;
          transition: transform 0.2s;
          transform: rotate(180deg);
        }

        mat-icon {
          color: theme-apply($primary);
        }
      }
    }

    .qms-row-detail {
      border: 1px solid theme-apply($other-divider);
      border-top: none;
    }

    .qms-row-child {
      flex: 1;
    }
  }

  &.qms-group-table {
    .mat-mdc-row {
      min-height: 0;
    }

    .qms-table-row {
      &.expandable-group {
        padding-left: 0 !important;
        border-left: 4px solid theme-apply($primary-light-32-opacity);
        border-radius: 4px 4px 0 0;
      }
    }

    .qms-collapse-group {
      border: 1px solid theme-apply($other-divider);
      border-left: 4px solid theme-apply($primary-light-32-opacity);
      border-bottom-left-radius: 4px;
      border-bottom-right-radius: 4px;
      border-top: none;
      padding-left: 12px;
      padding-top: 6px;
      background: theme-apply($background-area);

      cursor: pointer;

      &[tabindex]:focus-visible {
        outline: 2px auto theme-apply($primary);
      }

      .mat-icon {
        color: theme-apply($primary);
      }
      .qms-text-collapse {
        vertical-align: super;
        color: theme-apply($primary);
        font-weight: 600;
        font-size: 12px;
        line-height: 16px;
        font-family: Open Sans;
      }
    }

    .qms-row-children {
      margin-top: unset;
      border-radius: unset;
      padding-left: 0 !important;
      border-left: 4px solid theme-apply($primary-light-32-opacity);
    }
  }

  &.qms-checkbox-table.qms-expand-table {
    .qms-table-row .qms-row-checkbox {
      border-right: 1px solid rgba(0, 0, 0, 0.12);
      border-radius: 0;
    }
  }
}
