@mixin duration-color($color: $color-primary) {
  @for $i from 0 through 5 {
    &.depth-#{$i} .duration {
      @if $i == 0 {
        background: rgba($color, 0.1);
      } @else {
        background: rgba($color, $i * 0.1);
      }
    }
  }
}

.trace-detail-container {
  padding: 20px;
  background-color: $white;

  .form-filter-container {
    margin-bottom: 30px;
    background-color: $white;
    border: 1px solid $color-border;
    border-radius: 5px;

    .ant-row {
      padding: 10px;
    }
  }

  .json-detail {
    position: fixed;
    top: 61px;
    right: -30%;
    z-index: 2;
    width: 30%;
    height: calc(100% - 61px);
    padding: 20px;
    overflow: auto;
    color: #e6db74;
    background-color: #3c444f;
    transition: transform 0.3s;

    .json-detail-btn {
      position: fixed;
      top: 30px;
      right: 30px;
      display: none;

      &:nth-child(1) {
        right: 90px;
      }
    }

    &.slide-in {
      transform: translateX(-100%);

      .json-detail-btn {
        display: inline-block;
      }
    }
  }

  .filter-top {
    border-bottom: 1px solid $gainsboro;
  }

  .trace-detail-filter-tab {
    margin-bottom: 24px;
  }

  .trace-items-cont {
    min-height: 400px;
    overflow-x: auto;
  }

  .binary-annotation {
    display: none;
  }

  .rect-element {
    position: absolute;
    z-index: 1;
    border-width: medium;
    border-style: dashed;
    border-color: $color-danger;
  }

  .span {
    position: relative;
    display: block;
    margin-bottom: 3px;
    border-top: solid 1px $white;
    border-bottom: solid 1px $white;
    cursor: pointer;

    &:after {
      display: block;
      clear: both;
      height: 0;
      line-height: 0;
      visibility: hidden;
      content: '.';
    }
    @include duration-color();

    .handle {
      float: left;
      width: 150px;
      height: 24px;
      overflow: hidden;
      white-space: nowrap;
      opacity: 0.4;

      .service-name {
        &:after {
          visibility: hidden;
          content: '.';
        }
        height: 24px;
        padding-left: 2px;
        color: $white;
        line-height: 24px;
        background: $color-primary;
        border-radius: 3px;

        .service-name-text {
          display: inline-block;
          width: 100%;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
        }
      }

      .expander {
        position: relative;
        top: -8px;
        margin-right: 0.25em;
        margin-left: -1.1em;
        padding: 2px;
        color: $black;
      }
    }

    .duration-container {
      position: relative;
      margin-left: 155px;
    }

    .time-marker {
      position: absolute;
      color: $navy;
    }

    .time-marker-0 {
      left: 0;
    }

    .time-marker-1 {
      left: 20%;
    }

    .time-marker-2 {
      left: 40%;
    }

    .time-marker-3 {
      left: 60%;
    }

    .time-marker-4 {
      left: 80%;
    }

    .time-marker-5 {
      left: 99.5%;
    }

    .duration,
    .span-name {
      position: absolute;
      width: 100%;
      height: 23px;
      padding-left: 4px;
      //overflow: hidden;
      //text-overflow: ellipsis;
      line-height: 23px;
      white-space: nowrap;
      background: $lightnavy;
      border-radius: 3px;

      .annotation {
        position: absolute;
        top: 0;
        width: 0;
        height: 23px;
        border-left: solid 1px $black;
      }

      .annotation.core {
        display: none;
      }

      .annotation[data-value='error'] {
        background: #ff0000;
        border: solid 1px #ff0000;
      }

      .tooltip {
        white-space: normal;
      }
    }

    .span-name {
      background-color: transparent;
    }
  }

  .service-span {
    &:hover {
      background: $platinum;

      .handle {
        opacity: 1;
      }
    }
  }

  .span.highlight {
    .handle {
      opacity: 1;
    }
  }

  #timeLabel.span {
    display: block;
    overflow: visible;
    white-space: nowrap;

    .handle {
      opacity: 1;
    }

    .time-marker {
      margin-left: -3%;

      &:first-child {
        margin-left: 0;
      }
    }
  }

  .span[data-error-type='transient'] {
    .handle .service-name {
      background: $color-warning;
    }
    @include duration-color($color-warning);
  }

  .span[data-error-type='critical'] {
    .handle .service-name {
      background: $color-danger;
    }
    @include duration-color($color-danger);
  }
}

#trace-controls {
  form {
    margin-bottom: 10px;
  }

  .nav-pills {
    a {
      color: $black;
      background: $white;
      cursor: default;
    }

    .badge {
      background: $color-primary-light;
    }
  }
}

#spanPanel {
  tr.anno-error-transient {
    color: $color-warning;
    background: #fcf8e3;
  }

  tr.anno-error-critical {
    color: $color-danger;
    background: #f2dede;
  }

  #binaryAnnotations {
    td.value {
      max-width: 75%;
      word-break: break-all;
    }
  }
}

.trace-nav {
  line-height: 34px;

  li + li {
    margin-left: 40px;
  }

  .badge {
    padding: 2px 10px;
    color: $white;
    background-color: $color-primary;
    border-radius: 20px;
  }
}

.modal-header {
  .save {
    float: right;
    margin-right: 5px;
  }
}

.save {
  opacity: 0.2;
}

.span-detail-modal {
  .title {
    width: 97%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .sub-title {
    color: $color-text;
  }

  .second-table {
    margin-top: 40px;
    margin-bottom: 10px;
  }

  table {
    width: 100%;

    th {
      padding: 8px;
    }

    tbody {
      td {
        min-width: 120px;
        padding: 8px;
        word-break: break-all;
      }
    }
  }
}
