/**
 * jQuery Bracket
 *
 * Copyright (c) 2011-2018, Teijo Laine,
 * http://aropupu.fi/bracket/
 *
 * Licenced under the MIT licence
 */

$winColor: #da0;
$loseColor: #ccc;
$thirdColor: #963;
$fourthColor: #678;

$connectorColor: #666;

$boxHeight: 22px;
$boxPadding: 3px;

div.jQBracket {
  font-family: "Arial";
  font-size: 14px;
  position: relative;

  .tools {
    position: absolute;
    top: 0px;
    color: #fff;
  }

  .tools span {
    cursor: pointer;
    margin: 5px;
    display: block;
    text-align: center;
    width: 18px;
    height: 18px;
    background-color: #666;
  }

  .tools span:hover {
    background-color: #999;
  }

  .finals {
    float: right;
    right: 0px;
    clear: right;
    position: relative;
  }

  .bracket {
    float: right;
    clear: left;
  }

  .loserBracket {
    float: right;
    clear: left;
    position: relative;
  }

  .round {
    position: relative;
    float: left;
  }

  .match {
    position: relative;
  }

  .editable {
    cursor: pointer;
  }

  .team {
    position: relative;
    z-index: 1;
    float: left;
    background-color: #eee;
    cursor: default;

    &:first-child {
      border-bottom: 1px solid #999;
    }

    input {
      font-size: 14px;
      padding: 0;
      width: 100%;
      border: none;
      margin: 0;
      outline: none;
    }

    div.label {
      padding: $boxPadding;
      position: absolute;
      height: $boxHeight;
      white-space: nowrap;
      overflow: hidden;
      box-sizing: border-box;

      &[disabled] {
        cursor: default;
      }
    }

    div.score {
      float: right;
      padding: $boxPadding;
      background-color: rgba(255, 255, 255, 0.3);
      text-align: center;
      box-sizing: border-box;

      input {
        text-align: center;
      }

      &[disabled] {
        color: #999;
        cursor: default;
      }
    }

    div.label input.error,
    div.score input.error {
      background-color: #fcc;
    }

    &.np {
      background-color: #666;
      color: #eee;
    }

    &.na {
      background-color: #999;
      color: #ccc;
    }

    &.win {
      color: #333;
    }

    &.win div.score {
      color: #060;
    }

    &.lose div.score {
      color: #900;
    }

    &.lose {
      background-color: #ddd;
      color: #999;
    }

    &.tie div.score {
      color: #00f;
    }

    &.highlightWinner {
      background-color: $winColor;
      color: #000;
    }

    &.highlightLoser {
      background-color: $loseColor;
      color: #000;
    }

    &.highlight {
      background-color: #3c0;
      color: #000;
    }

    &.bye {
      background-color: #999;
      color: #ccc;
    }
  }

  .teamContainer {
    z-index: 1;
    position: relative;
    float: left;
  }

  .connector {
    border: 2px solid $connectorColor;
    border-left-style: none;
    position: absolute;
    z-index: 1;

    div.connector {
      border: none;
      border-bottom: 2px solid $connectorColor;
      height: 0px;
      position: absolute;
    }

    &.highlightWinner,
    div.connector.highlightWinner {
      border-color: $winColor;
    }

    &.highlightLoser,
    div.connector.highlightLoser {
      border-color: $loseColor;
    }

    &.highlight,
    div.connector.highlight {
      border-color: #0c0;
    }
  }

  .np .connector,
  .np .connector div.connector {
    border-color: #999;
  }

  .bubble {
    height: $boxHeight;
    line-height: $boxHeight;
    width: 30px;
    right: -35px;
    position: absolute;
    text-align: center;
    font-size: 11px;

    &:after {
      content: "";
      position: absolute;
      top: 6px;
      width: 0;
      height: 0;
      border-top: 5px solid transparent;
      border-left: 5px solid transparent;
      border-right: 5px solid transparent;
      border-bottom: 5px solid transparent;
    }

    &:after {
      left: -5px;
      border-left: 0;
    }
  }

  .win {
    .bubble {
      background-color: $winColor;
      color: #960;

      &:after {
        border-right-color: $winColor;
      }

      &.third {
        background-color: $thirdColor;
        color: #d95;

        &:after {
          border-right: 6px solid $thirdColor;
        }
      }
    }
  }

  .lose {
    .bubble {
      background-color: $loseColor;
      color: #333;

      &:after {
        border-right-color: $loseColor;
      }

      &.fourth {
        background-color: $fourthColor;
        color: #ccd;

        &:after {
          border-right: 6px solid $fourthColor;
        }
      }
    }
  }
}

div.jQBracket.rl {
  .finals {
    float: left;
    left: 0px;
    clear: left;
  }

  .bracket {
    float: left;
    clear: right;
  }

  .loserBracket {
    float: left;
    clear: right;
  }

  .round {
    margin-right: 0;
    float: right;
  }

  .team {
    float: right;

    div.label {
      right: 0;
    }

    div.score {
      float: left;
    }
  }

  .teamContainer {
    float: right;
  }

  .connector {
    border-left-style: solid;
    border-right-style: none;
    border-width: 2px;

    &.highlightWinner,
    div.connector.highlightWinner {
      border-color: $winColor;
    }

    &.highlightLoser,
    div.connector.highlightLoser {
      border-color: $loseColor;
    }

    &.highlight,
    div.connector.highlight {
      border-color: #0c0;
    }
  }

  .bubble {
    left: -35px;

    &.third {
      background-color: $thirdColor;
      color: #310;
    }

    &.fourth {
      background-color: $fourthColor;
      color: #ccd;
    }

    &:after {
      left: auto;
      right: -5px;
      border-left: 5px solid transparent;
      border-right: 0;
    }

    &.third:after {
      border-right: none;
      border-left: 6px solid $thirdColor;
    }

    &.fourth:after {
      border-right: none;
      border-left: 6px solid $fourthColor;
    }
  }

  .highlightWinner {
    .bubble {
      &:after {
        border-left-color: $winColor;
      }
    }
  }

  .highlightLoser {
    .bubble {
      &:after {
        border-left-color: $loseColor;
      }
    }
  }
}
