.backgrid th, .backgrid td {
  text-align: left;
  line-height: $line-height-base;
}

.backgrid td {
  font-weight: normal!important;
  &.editable {
    & > .display-text {
      overflow: hidden;
      text-overflow: ellipsis;
      @extend .form-control;
    }
  }
}

.backgrid.table th.sortable > button {
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.backgrid .ascending .sort-caret {
    border-bottom-color: $color-fg;
}

.backgrid .descending .sort-caret {
    border-top-color: $color-fg;
}

.backgrid.backgrid-striped tbody {
  & tr:nth-child(even) {
    background: $table-bg;

    & td.editor {
      background: $table-bg;
      outline: none;
    }
  }
  & tr:nth-child(odd) {
    background: $table-bg;
    & td.editor {
      background: $table-bg;
      outline: none;
    }
  }
}
.backgrid tbody tr.empty td {
  display: table-cell;
  font-style: normal;
  color: $text-muted;
}

.backgrid .textarea-cell {
    text-align: left;
}

.backgrid .textarea-cell.editor textarea {
    width: 100%;
    height: auto;
}

/* Override Backgrid's default z-index */
.dashboard-tab-container .backgrid-filter .search {
  z-index: 10 !important;
}

.dashboard-tab-container .backgrid-filter .clear {
  z-index: 10 !important;
}

.backgrid td.editor {
  & input[type=text], & input[type=password] {
    @extend .form-control;
  }
}

.backgrid .string-cell.editor input[type=password] {
  text-align: left;
}

.backgrid > tbody > td.editor input[type=password] {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0 5px;
  margin: 0;
  background-color: transparent;
  border: 0;
  outline: 0;
  -webkit-box-shadow: none;
     -moz-box-shadow: none;
          box-shadow: none;
  -webkit-box-sizing: border-box;
     -moz-box-sizing: border-box;
          box-sizing: border-box;
  -webkit-appearance: none;
     -moz-appearance: none;
}

.backgrid {
  border-radius: inherit;
}

.backgrid thead td,
.backgrid thead th{
  background: $table-bg;
  background-color: $table-bg !important;
  text-align: left;
}

.backgrid:not(.presentation) td.renderable:not(.editable):not(.delete-cell) {
    // if transparent border then setting color will help
    border-bottom-color: $color-gray-lighter;
}

.backgrid tr.header td.renderable:not(.editable):not(.delete-cell) {
    background-color: $color-gray-light;
}

.sql-editor-grid-container .backgrid > thead > th.renderable,
.sql-editor-grid-container .backgrid > tbody > td.renderable {
    white-space: pre-wrap;
}

.backgrid > thead > th.renderable {
  font-weight: bold;
}

table.backgrid {
  position: initial;
  overflow: auto;
}

.backgrid td.editor input[type=password] {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0 5px;
  margin: 0;
  background-color: transparent;
  border: 0;
  outline: 0;
  -webkit-box-shadow: none;
     -moz-box-shadow: none;
          box-shadow: none;
  -webkit-box-sizing: border-box;
     -moz-box-sizing: border-box;
          box-sizing: border-box;
  -webkit-appearance: none;
     -moz-appearance: none;
}

.backgrid td.editor input[type=password]::-ms-clear {
  display: none;
}

.enable-selection, .form-control, .backgrid td, .ajs-content {
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

/* Latest backgrid adds column name like `label` to td element, override color*/
.backgrid td.label {
  color: $color-fg;
  font-size: $font-size-base;
  font-weight: normal;
}

.backgrid tr:hover {
  .label {
    color: $grid-hover-fg-color;
  }
}

.subnode {
  border: $panel-border;
  background: $color-bg;
}

.subnode-noouter-border {
  border: none !important;
}

.subnode > table.backgrid > thead > tr > th:last-child {
  border-right-color: $color-primary;
}

.subnode > table.backgrid {
    width: 100%;
    margin: 0px;
    padding: 0;
}

.subnode-header button {
  border-left: 1px solid $border-color;
  border-bottom-width: 0px !important;
  border-top-width: 0px !important;
  border-right-width: 0px !important;
  border-radius: 0px !important;
  text-align: center !important;
  padding: 8px 8px !important;
  min-height: 31px !important;
  margin: 0px !important;
}

.subnode-header .control-label {
  min-height: 31px;
  font-weight: bold;
}

.subnode-footer {
  text-align: right;
  border-color: $color-gray-light;
  border-style: inset inset inset solid;
  border-width: 2px 1px 0;
  margin: 0px, 15px;
  margin-top: -10px;
  height: 38px;
  min-height: 40px;
  vertical-align: bottom;
}
.subnode-footer .ajs-button {
  margin: 2px 2px 0;
}


/* Sub-Node */

.edit-cell, .delete-cell {
    text-align:center !important;
    width:25px;
    height:29px !important;
}

.subnode-header {
    background-color: $header-bg;
    color: $color-fg;
    border-bottom: $panel-border;
}

.subnode-header > button.add {
    float: right;
    margin-right: 3px;
    margin-bottom: 3px;
    margin-top: 5px;
}

.subnode-dialog {
    bottom: 0;
    left: 0;
    overflow-x: auto;
    overflow-y: auto;
    right: 0;
    height: auto;
    margin-top: 0px;
}
.subnode-body {
    height: auto;
    overflow: inherit;
    background-color: $color-bg;
    border: 1px solid $border-color;
    border-radius: $panel-border-radius;

    & .tab-pane {
      padding: 0.5rem;
    }

    & .tab-content {
      padding: 0px;
    }

    fieldset.inline-fieldset {
      background: $color-bg;
    }
}

.sub-node-form {
    height: auto;
    padding-left: 0rem !important;
    padding-right: 0rem !important;
}

.sub-node-form > ul.tab-content{
    background-color: $color-bg;
    padding-left: 15px;
    left: 1px;
}

.subnode-header-form {
    background-color: $color-gray-lighter;
    padding: 7px;
    border-bottom: $panel-border;
}

.subnode-header-form button.add {
    float: right;
    margin-right: 0px;
}

.subnode-error .help-block {
    color: $color-danger;
}

.backgrid tbody {
  & td.edit-cell.editor {
    background-color: $color-gray-light !important;
    border-bottom-color: $color-gray-light !important;
    outline: none !important;
  }

  & td.editor {
    background-color: $color-bg !important;
    color: $color-fg !important;

    & input {
        color: $color-fg !important;
    }
  }

  & td.edit-cell.editor:focus {
    outline: $input-focus-border-color auto 5px !important;
  }

  & td.select-cell.editor select{
    outline: none !important;
    height: 100% !important;
    width: 100% !important;
  }

  tr.editor-row  {
    background-color: $color-gray-light !important;
    & > td {
      padding: 15px !important;
      background-color: $color-gray-light !important;
      border-top: none !important;
      border-bottom-color: $color-gray-light !important;
    }
  }
}

table tr th button {
  font-weight: bold;
}

.custom-control.custom-checkbox.custom-checkbox-no-label {
   padding-left: 0;

   .custom-control-label {
     // set same width/height as before and after
     width: 1em;
     height: 1em;

     &::before,
     &::after {
       left: 0;
     }
   }
}

.backgrid .sql-cell .CodeMirror-scroll {
  overflow: hidden !important;
}

.backgrid .sql-cell .cm-s-default {
  height: 50px !important;
}

.backgrid .sql-cell .CodeMirror-hscrollbar > div {
  width: 100% !important;
}

.backgrid .sql-cell .CodeMirror-hscrollbar {
  overflow-x: hidden !important;
}

.backgrid .sql-cell .CodeMirror-vscrollbar {
  overflow-y: hidden !important;
}

.backgrid .sql-cell .CodeMirror-sizer {
  padding-bottom: 0 !important;
}

.backgrid .sql-cell .CodeMirror-scrollbar-filler {
  display: none !important;
}
