@mixin element($element) {
  &__#{$element} {
    @content;
  }
}

@mixin modifier($modifier) {
  &--#{$modifier} {
    @content;
  }
}

@function calculateRem($size) {
  $remSize: $size / 16px;
  @return #{$remSize}rem;
}

$item-height: 30px;
//Panel
.panel {
  width: var(--px-context-browser-panel-width, calculateRem(320px)); //Panel body
  &-body {
    display: block;
    position: relative;
    width: var(--px-context-browser-panel-width, 320px);
    border-style: solid;
    border-width: 1px;
    border-color: var(--px-context-browser-panel-border-color, lightgray);
    background-color: var(--px-context-browser-panel-background-color, white);
  }
}

.context-browser {
  //Context Header
  &-header {
    display: none;
    flex-direction: row;
    position: relative;
    height: 40px;
    background-color: var( --px-context-browser-header-background-color, whiteSmoke);
    border-bottom: 1px solid var(--px-context-browser-header-border-color, lightgray);
    padding-left: 15px;
    padding-right: 15px;
    z-index: 2;
    &.active {
      display: flex;
    }
    &.collapsed {
      background-color: var(--px-context-browser-header-background-color, white);
      border-bottom: 1px solid var(--px-context-browser-header-border-color, lightgray);
    }
    &-label {
      display: flex;
      align-items: center;
      color: var(--px-context-browser-header-text-color, teal);
      cursor: pointer;
      user-select: none;
      min-width: 0;
      flex: 1 1 auto;
      &__arrow {
        flex: 0 0 auto;
        margin-right: calculateRem(5px);
        display: inline-flex;
      }
      &__link {
        flex: 1 1 auto;
        font-weight: 700;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
    }
    &__actions {
      flex: 0 0 auto;
      margin-left: .66667rem;
      display: flex;
      align-items: center;
    }
  } //Item
  &-item {
    display: flex;
    height: 30px;
    color: var(--px-context-browser-item-text-color, black);
    transition: background-color 0.2s ease-in-out;
  }
  &-item {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    cursor: pointer;
    min-width: 0;
    &:hover,
    &:focus {
      background-color: var( --px-context-browser-item-background-color--hover, whitesmoke);
    }
    &:active {
      background-color: var( --px-context-browser-item-background-color--hover, whitesmoke);
    }
    &.selected {
      background-color: var( --px-context-browser-item-background-color--selected, steelblue);
      color: var(--px-context-browser-item-text-color--selected, white);
    }
  } //Text
  &-text {
    display: block;
    width: 100%;
    flex: 1 1 auto;
    padding-left: 15px;
    padding-right: 15px;
    cursor: pointer;
    user-select: none;
    min-width: 0;
    &__label {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    &__breadcrumbs {
      color: var(--px-context-browser-item-breadcrumbs-color, gray);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }
}

.columns {
  display: block;
  position: relative;
  overflow: hidden;
  min-height: 30px;
  transition: min-height 350ms;
  padding-top: 1px;
  &[data-visible-count="4"] {
    min-height: 121px;
  }
  &[data-visible-count] {
    min-height: 301px;
  }
  &[data-visible-count] {
    min-height: ($item-height*10) + 1px;
  }
  &[data-visible-count="1"] {
    min-height: $item-height + 1px;
  }
  &[data-visible-count="2"] {
    min-height: ($item-height*2) + 1px;
  }
  &[data-visible-count="3"] {
    min-height: ($item-height*3) + 1px;
  }
  &[data-visible-count="4"] {
    min-height: ($item-height*4) + 1px;
  }
  &[data-visible-count="5"] {
    min-height: ($item-height*5) + 1px;
  }
  &[data-visible-count="6"] {
    min-height: ($item-height*6) + 1px;
  }
  &[data-visible-count="7"] {
    min-height: ($item-height*7) + 1px;
  }
  &[data-visible-count="8"] {
    min-height: ($item-height*8) + 1px;
  }
  &[data-visible-count="9"] {
    min-height: ($item-height*9) + 1px;
  }
}

//Columns
.column {
  display: block;
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow-y: hidden;
  &.active {
    overflow-y: auto;
  }
  &.animating {
    overflow-y: hidden;
  } // Column Animations
  &-animation {
    >*:not(.active):not(.animating) {
      display: none !important;
    }
    >.animating {
      opacity: 0;
    }
    >.fade-in-right {
      animation-name: fadeInRight;
      animation-duration: 350ms;
    }
    >.fade-in-left {
      animation-name: fadeInLeft;
      animation-duration: 350ms;
    }
    >.fade-out-right {
      animation-name: fadeOutRight;
      animation-duration: 350ms;
    }
    >.fade-out-left {
      animation-name: fadeOutLeft;
      animation-duration: 350ms;
    }
  }
}

.actions {
  margin-left: auto;
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
  display: none;
  flex: 0 0 auto;
}

// Pointer
.pointer {
  height: 0;
  width: 0;
  margin-left: 15px;
  position: relative;
  z-index: 1;
  border-left: 16px solid transparent;
  border-right: 16px solid transparent;
  border-bottom: 16px solid var(--px-context-browser-panel-border-color, lightgray);
  &:after {
    content: "";
    position: absolute;
    left: -15px;
    top: 2px;
    width: 0;
    height: 0;
    border-left: 15px solid transparent;
    border-right: 15px solid transparent;
    border-bottom: 15px solid var(--px-context-browser-panel-background-color, white);
    z-index: 1;
  }
}

/** Animations */

@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(-100%);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes fadeOutRight {
  from {
    opacity: 1;
    transform: none;
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes fadeOutLeft {
  from {
    opacity: 1;
    transform: none;
  }
  to {
    opacity: 0;
    transform: translateX(-100%);
  }
}

.actions {
  flex: 0 0 auto;
  margin-left: calculateRem(10px);
  display: flex;
  align-items: center;
}

.action {
  flex: 0 0 auto;
  padding: calculateRem(1px);
  width: calculateRem(20px);
  height: calculateRem(20px);
  margin-left: calculateRem(5px);
  margin-right: calculateRem(5px);
  cursor: pointer;
  color: var(--px-context-browser-icon-stroke, dimgray);
}

.action--last {
  margin-right: 0;
}
