/* tvs panel */
#modx-tv-tabs {
  width: 100%;
  @extend %clearfix;
}

/* top area around the tab strip */
.x-tab-panel-noborder {
  border: 1px solid #E2E3DE;
  margin: 20px 0 20px;
  overflow: visible;

  /* background behind a button bar */
  .x-tab-panel-body-noborder {
    background-color: $white;
    border-radius: $borderRadius;
  }
}

/* main tabs */
.x-tab-panel-header,
.x-tab-panel-footer {
  border: 0;
  position: relative;
}

.x-tab-panel-header ul.x-tab-strip {
  background-color: $tabStripBg !important; /* override !important extjs default theme style */
  border: 0; /* prevent overflowing border, add to .x-tab-strip-wrap if necessary */
  margin: 0; /* was -1px */
  /*width: auto; /* this prevents tabs from triggering the scroll functionality */
  position: relative;
  top: 1px;
}

.x-tab-panel-header-plain .x-tab-strip-spacer,
.x-tab-panel-footer-plain .x-tab-strip-spacer {
  /*background-color: $white*/
  border: none;
  height: 0;
}

.x-tab-panel {

  /* take care of nested tab panels as seen in MIGX */
  .x-tab-panel {
    padding-top: 18px;  /* 15px + 3px for the active tab box-shadow on top */

    &.vertical-tabs-panel {
      padding-top: 0; /* do not add that padding to vertical tabs panels */
    }

    .x-tab-strip-wrap {
      .x-tab-strip {
        background-color: $lightestGray !important; /* override !important rule defined by extjs default theme */
      }
    }

  }
}

.x-tab-panel-header,
.x-tab-strip {
  padding-left: 0; /* was 1px */
}

.x-tab-panel-bwrap {
  border-radius: $borderRadius;
  overflow: visible; /* prevent cut off box-shadow */

  /* no box-shadows on nested tab panels, MIGX for example */
  .x-tab-panel-bwrap {
    box-shadow: none;
  }
}

ul.x-tab-strip li {
  background-color: $tabInactiveBg;
  color: $tabInactiveText;
  border-top-left-radius: $borderRadius;
  border-top-right-radius: $borderRadius;
  cursor: pointer;
  font: $tabFont;
  line-height: 2.2;
  margin-left: 0;
  padding: 0 12px;
  position: relative;
  z-index: 5;

  html[dir="rtl"] & {
    float: right;
  }

  &:hover {
    background-color: $tabInactiveBgHover;
    color: $tabInactiveTextHover;
  }

  &.x-tab-strip-active {
    color: $tabActiveText;
    background-color: $tabActiveBg;
    cursor: default;

    .vertical-tabs-header & {
      border-radius: 0;
    }

    &:hover {
      background-color: $tabActiveBgHover;
    }
  }

  &.x-tab-edge {
    height: 0;
    visibility: hidden; /* display none makes the tab scroll buttons appear somehow */
  }
}

.x-tab-strip-wrap,
.x-tab-panel-header,
.x-tab-panel {
  overflow: visible;
  border: none;
}

.x-tab-strip-wrap {
  overflow: hidden;
  padding: 2px 0 0;
  margin: 0;
}

.x-tab-strip-closable {
  padding-right: 15px !important;
}

.x-tab-strip .x-tab-strip-closable a.x-tab-strip-close {
  right: 2px;
  background-image: url($imgPath + 'modx-theme/tabs/tab-close.gif');
}

ul.x-tab-strip-top li:first-child {
  margin-left: 0;
}

ul.x-tab-strip-bottom {
  background-color: $wildSand;
  border-top-color: $alto;

  & .x-tab-right {
    background-image: url($imgPath + 'modx-theme/tabs/tab-btm-inactive-right-bg.gif');

    & .x-tab-right {
      background-image: url($imgPath + 'modx-theme/tabs/tab-btm-right-bg.gif');
    }

    & .x-tab-left {
      background-image: url($imgPath + 'modx-theme/tabs/tab-btm-left-bg.gif');
    }
  }

  & .x-tab-left {
    background-image: url($imgPath + 'modx-theme/tabs/tab-btm-inactive-left-bg.gif');
  }

}

.x-tab-panel-body {
  background-color: $white;
  border: 0;
  overflow: visible;
}

.x-tab-scroller-left,
.x-tab-scroller-right {
  border: 0;

  &:before {
    @extend %pseudo-font;

    box-sizing: border-box;
    color: $treeColor;
    content: '';
    font-size: 28px;
    margin-top: -20px; /* half of the height to center vertically with top 50% */
    opacity: 1;
    filter: alpha(opacity=100); /* for IE <= 8 */
    position: absolute;
    top: 50%;
    right: 0;
    text-align: center;
    width: 18px;
    transition: opacity .25s;
  }

  &-over {
    &:before {
      color: $colorSplash;
    }
  }

  &-disabled {
    cursor: default;

    &:before {
      color: $treeColor;
      opacity: .4;
      filter: alpha(opacity=100); /* for IE <= 8 */
    }
  }
}

.x-tab-scroller-left {
  &:before {
    content: fa-content($fa-var-caret-left);
  }
}

.x-tab-scroller-right {
  &:before {
    content: fa-content($fa-var-caret-right);
  }
}

.x-tab-panel-bbar .x-toolbar,
.x-tab-panel-tbar .x-toolbar {
  border-color: $alto;
}

.x-tab-panel-body-noborder .x-panel-body-noheader:first-child {
  border-top: 0 none;
}

.x-tab-panel-bbar-noborder .x-toolbar {
  border-top-color: transparent;
}

.x-tab-panel-tbar-noborder .x-toolbar {
  border-bottom-color: transparent;
}

/* vertical tabs */
.vertical-tabs-panel {
  background-color: $white;
  margin: 0; /* remove top and bottom margin */
  overflow: hidden; /* dirty hack to make vertical tabs container stretch to bottom */

  &.wrapped {
    border: 1px solid $borderColor;
  }

  .vertical-tabs-header {
    background: $coreFieldBg !important; /* ovverride extjs default theme */
    border-right: 1px solid $borderColor !important; /* ovverride extjs default theme */
    float: left;
    margin-bottom: -10000px; /* dirty hack to make vertical tabs container stretch to bottom */
    padding-bottom: 10000px !important; /* dirty hack to make vertical tabs container stretch to bottom */
    width: 168px !important; /* aligns the vertical tabs with the TVs tab left edge, will not work that nicely with non-english langs */

    @include grid-media($desktop) {
      width: 80px !important;
    }

    .x-tab-strip-wrap {
      background-color: transparent; /* as vertical tab panels are nested ones too, do not apply the background color for nested tab panels */
      display: inline-block;
      line-height: 0;
      margin: 0; /* neutralize the horizontal tab scroller fix */
      padding: 0; /* neutralize the horizontal tab scroller fix */
      width: auto !important; /* Overrides extjs inline width */

      ul.x-tab-strip {
        border: 0; /* overrides extjs default theme */
        display: inline-block;
        top: 0; /* overrides extjs default theme style of 1px */
        width: auto;

        >li {
          border-right: 1px solid $borderColor;
          border-bottom: 1px solid $borderColor;
          color: $coreFieldLabelColor;
          float: none;
          line-height: 1;
          margin: 0; /* override default extjs theme value of 2px */
          overflow: hidden;
          padding: 10px 15px 10px 15px;
          transition: background-color .25s, color .25s;

          @include grid-media($desktop) {
            font-size: 12px;
            padding: 8px;
          }

          &:hover {
            background: $white;
          }

          &.x-tab-strip-active {
            background: $white;
            border-color: $borderColorHover;
            border-right-color: $white;
            box-shadow: none; /* removes the active tab strip on top */
            color: $tabActiveText;
            width: 168px; /* make the active li 1px more wide to cover the containers right border, this makes the right border on inactive tabs necessary as the whole tab-strip wrap gets wider */
          }

          @include grid-media($desktop) {
            &.x-tab-strip-active {
              width: 80px !important;
            }
          }

          &.x-tab-edge {
            height: 0;
            visibility: hidden; /* display none makes the tab scroll buttons appear somehow */

            .x-tab-strip-text {
              display: none; /* prevent 4px high space at the end of the tab strip */
            }
          }

          .x-tab-strip-text {
            line-height: 1.4;
            padding: 2px 0 2px 0;
            white-space: pre-wrap;
          }
        }
      }
    }

    /* the "categories" text */
    h4 {
      background: $white; /*border-right: 1px solid $borderColor;*/
      border-bottom: 1px solid $borderColor;
      color: $darkestGray;
      font-size: 16px;
      padding: 15px 0 15px 15px;
    }

    .x-tab-strip-spacer {
      display: none; /* added by extjs */
    }
  }

  /* this is the area where the TV form fields are displayed */
  .x-tab-panel-bwrap {
    box-shadow: none;

    .x-tab-panel-body {
      border-top: 0;
      width: auto !important; /* Overrides extjs inline width */
    }

    .vertical-tabs-body {
      border: 0; /* do not add the top border for nested tabs panels */
      padding: 15px 20px 15px 15px; /* 20px account for too wide form fields (no border-box) */
    }
  }
}

.tvs-wrapper {
  &.below-content {
    border-radius: $borderRadius;
    margin: 1rem;

    .vertical-tabs-panel {
      border-radius: $borderRadius;
    }
  }

  @include grid-media($desktop) {
    &.below-content {
      margin: 0;
    }
  }
}

.window-vtabs {
  .x-panel-mr {
    padding-right: 0;
  }

  .vertical-tabs-panel {
    width: 100% !important;
    margin: 0;
  }
}
