/**
 * Copyright © 2016-2018 The Thingsboard Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

.tb-rulechain {
  .tb-fullscreen-button-style {
    z-index: 1;
  }
  .tb-rulechain-library {
    width: 250px;
    min-width: 250px;
    overflow-y: auto;
    overflow-x: hidden;

    .tb-rulechain-library-panel-group {
      .tb-panel-title {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
        min-width: 180px;
      }
      .fc-canvas {
        background: none;
      }
      md-icon.md-expansion-panel-icon {
        margin-right: 0px;
      }
      md-expansion-panel-collapsed, .md-expansion-panel-header-container {
        background: #e6e6e6;
        border-color: #909090;
        position: static;
      }
      md-expansion-panel {
        &.md-open {
          margin-top: 0;
          margin-bottom: 0;
        }
      }
      md-expansion-panel-content {
        padding: 0px;
      }
    }
  }
  .tb-rulechain-graph {
    overflow: auto;
  }
}

.fc-canvas {
  min-width: 100%;
  min-height: 100%;
  outline: none;
}

.tb-rule-node {
  display: flex;
  flex-direction: row;
  min-width: 150px;
  max-width: 150px;
  min-height: 28px;
  max-height: 28px;
  padding: 5px 10px;
  border-radius: 5px;
  background-color: #F15B26;
  color: #333;
  border: solid 1px #777;
  font-size: 12px;
  &.tb-input-type {
    background-color: #a3eaa9;
    user-select: none;
  }
  &.tb-filter-type {
    background-color: #f1e861;
  }
  &.tb-enrichment-type {
    background-color: #cdf14e;
  }
  &.tb-transformation-type {
    background-color: #79cef1;
  }
  &.tb-action-type {
    background-color: #f1928f;
  }
  &.tb-rule-chain-type {
    background-color: #d6c4f1;
  }
  md-icon {
    font-size: 20px;
    width: 20px;
    height: 20px;
    min-height: 20px;
    min-width: 20px;
    padding-right: 4px;
  }
  .tb-node-type {

  }
  .tb-node-title {
    font-weight: 600;
  }
  .tb-node-type, .tb-node-title {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
}

.fc-node {
  z-index: 1;
  outline: none;
  &.fc-hover, &.fc-selected {
    -webkit-filter: brightness(70%);
    filter: brightness(70%);
  }
  &.fc-dragging {
    z-index: 10;
  }
  p {
    padding: 0 15px;
    text-align: center;
  }
}

.fc-leftConnectors, .fc-rightConnectors {
  position: absolute;
  top: 0;
  height: 100%;

  display: flex;
  flex-direction: column;

  z-index: 0;
  .fc-magnet {
    align-items: center;
  }
}

.fc-leftConnectors {
  left: -20px;
}

.fc-rightConnectors {
  right: -20px;
}

.fc-magnet {
  display: flex;
  flex-grow: 1;
  height: 60px;
  justify-content: center;
}

.fc-connector {
  width: 14px;
  height: 14px;
  border: 1px solid #333;
  margin: 10px;
  border-radius: 5px;
  background-color: #ccc;
}

.fc-connector.fc-hover {
  background-color: #000;
}

.fc-edge {
  outline: none;
  stroke: gray;
  stroke-width: 4;
  fill: transparent;
  &.fc-selected {
    stroke: red;
    stroke-width: 4;
    fill: transparent;
  }
  &.fc-active {
    animation: dash 3s linear infinite;
    stroke-dasharray: 20;
  }
  &.fc-hover {
    stroke: gray;
    stroke-width: 6;
    fill: transparent;
  }
  &.fc-dragging {
    pointer-events: none;
  }
}

.edge-endpoint {
  fill: gray;
}

.fc-nodedelete {
  display: none;
}

.fc-selected .fc-nodedelete {
  outline: none;
  display: block;
  position: absolute;
  right: -13px;
  top: -16px;
  border: solid 2px white;
  border-radius: 50%;
  font-weight: 600;
  font-size: 18px;
  line-height: 18px;
  height: 20px;
  padding-top: 2px;
  width: 22px;
  background: #494949;
  color: #fff;
  text-align: center;
  vertical-align: bottom;
  cursor: pointer;
}

.fc-edge-label {
  position: absolute;
  user-select: none;
  pointer-events: none;
  opacity: 0.8;
}

.fc-edge-label-text {
  position: absolute;
  left: 50%;
  -webkit-transform: translateX(-50%);
  transform: translateX(-50%);
  white-space: nowrap;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  top: 5px;
  span {
    border: solid 2px #003a79;
    border-radius: 10px;
    color: #003a79;
    background-color: #fff;
    padding: 3px 5px;
  }
}

@keyframes dash {
  from {
    stroke-dashoffset: 500;
  }
}

.tb-rule-node-tooltip {
  font-size: 14px;
  width: 300px;
  color: #333;
  #tooltip-content {
    .tb-node-title {
      font-weight: 600;
    }
    .tb-node-description {
      font-style: italic;
      color: #555;
    }
    .tb-node-details {
      padding-top: 10px;
      padding-bottom: 10px;
    }
    code {
      padding: 0px 3px 2px 3px;
      margin: 1px;
      color: #AD1625;
      white-space: nowrap;
      background-color: #f7f7f9;
      border: 1px solid #e1e1e8;
      border-radius: 2px;
      font-size: 12px;
    }
  }
}