.ui-tab {
  &[data-active="false"],
  &[data-hide="true"] {
    display: none;
  }

  &__panel {
    display: grid;
    grid-area: content;
    grid-template-areas: "tabbar" "body";
    grid-template-rows: auto 1fr;

    &[data-align="top"] {
      .ui-tab__bar__wrapper .ui-tab__button {
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
      }
    }

    &[data-align="bottom"] {
      grid-template-areas: "body" "tabbar";
      grid-template-rows: 1fr auto;

      .ui-tab__bar {
        align-items: start;
        margin: -3px 0 0;
      }

      .ui-tab__bar__wrapper .ui-tab__button {
        border-top-left-radius: 0;
        border-top-right-radius: 0;
        margin: 0 2px 3px;
      }
    }
  }

  &__bar {
    align-items: end;
    display: grid;
    grid-area: tabbar;
    grid-template-columns: auto 1fr auto auto;
    justify-content: start;
    margin-bottom: -2px;

    &__wrapper {
      height: 100%;
      align-items: flex-end;
      display: flex;
      flex-flow: row nowrap;
      overflow: hidden;
    }

    &__start,
    &__end {
      padding: 0 0.25em;

      &:empty {
        display: none;
      }
    }
  }

  &__button {
    align-items: center;
    border-radius: $base-border-radius;
    cursor: pointer;
    display: grid;
    flex: 0 0 auto;
    grid-template-areas: "icon label close";
    grid-template-columns: auto auto auto;
    line-height: 1;
    margin: 3px 2px 0;
    max-width: 15rem;
    padding: 0.5em 0;
    position: relative;

    &__label {
      @include ellipsis();

      &:first-child {
        @include property-prefix(padding-start, 0.75em);
      }

      &:last-child {
        @include property-prefix(padding-end, 0.75em);
      }
    }

    &__icon {
      &:first-child {
        @include property-prefix(padding-start, 0.75em);
      }

      &:last-child {
        @include property-prefix(padding-end, 0.75em);
      }

      &:not(:last-child) {
        &::after {
          content: "\0020";
          display: inline-block;
        }
      }
    }

    &__close {
      font-size: 0.8rem;
      line-height: 0.1;
      margin: 0 0.5em;
      opacity: 0.5;

      &:hover {
        opacity: 0.8;
      }
    }

    &[data-active="true"] {
      font-weight: 500;
      z-index: 2;
    }

    &[data-disabled="true"] {
      box-shadow: none;

      &::before {
        content: "";
        cursor: not-allowed;
        opacity: 0.25;
        @include position(absolute, 0);
      }
    }
  }

  &__body {
    display: grid;
    grid-area: body;
    grid-template-areas: "content";
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    overflow: hidden;
    position: relative;
    z-index: 1;

    > .ui-section,
    > .ui-section__content,
    > .ui-router-view {
      z-index: 5;

      &:empty {
        display: none;
      }
    }
  }

  &__overflow {
    width: 100%;
    height: 100%;
  }

  &__preview {
    height: 50%;
    border: 2px solid var(--primary, $primary);
    border-radius: 1px 1px 0 0;
  }
}