// SPDX-FileCopyrightText: 2018 Icinga GmbH <https://icinga.com>
// SPDX-License-Identifier: GPL-3.0-or-later

.controls > a {
  color: @icinga-blue;

  &:hover::before {
    text-decoration: none;
  }
}

div.cube {
  div.cube-dimension0 {
    > .header {
      font-size: 1.2em;
      font-weight: bold;
      border-bottom: 1px solid @text-color;
    }

    &.critical {
      > .header {
        color: @color-critical;
        border-color: @color-critical;
      }

      &.handled > .header {
        color: @color-critical-handled;
        border-color: @color-critical-handled;
      }
    }

    &.warning {
      > .header {
        color: @color-warning;
        border-color: @color-warning;
      }

      &.handled > .header {
        color: @color-warning-handled;
        border-color: @color-warning-handled;
      }
    }

    &.unknown {
      > .header {
        color: @color-unknown;
        border-color: @color-unknown;
      }

      &.handled > .header {
        color: @color-unknown-handled;
        border-color: @color-unknown-handled;
      }
    }

    &.unreachable {
      > .header {
        color: @color-unreachable;
        border-color: @color-unreachable;
      }

      &.handled > .header {
        color: @color-unreachable-handled;
        border-color: @color-unreachable-handled;
      }
    }

    &.pending {
      > .header {
          color: @color-pending;
          border-color: @color-pending;
      }
    }

    &.ok {
      > .header {
          color: @color-ok;
          border-color: @color-ok;
      }
    }
  }

  div.cube-dimension1 > .header,
  div.cube-dimension2 {
    width: 10em;
    padding: 0.2em;
    margin: 0.3em 0 0;
    overflow: hidden;
  }

  div.cube-dimension1 {
    display: flex;
    border-left: 0.5em solid transparent;

    &:not(:last-child) {
      padding-bottom: .2em;
    }

    > .header {
      display: flex;
      flex: 0 0 10em;
      font-weight: bold;
      text-align: center;
      padding-left: 0;

      > a:first-child {
        flex: 1;
        max-width: 8em;
        word-wrap: break-word;
      }
    }

    > .body {
      display: flex;
      column-gap: .3em;
      flex-wrap: wrap;
    }

    &.critical {
      border-left-color: @color-critical;

      &.handled {
        border-left-color: @color-critical-handled;
      }
    }

    &.warning {
      border-left-color: @color-warning;

      &.handled {
        border-left-color: @color-warning-handled;
      }
    }

    &.unknown {
      border-left-color: @color-unknown;

      &.handled {
        border-left-color: @color-unknown-handled;
      }
    }

    &.unreachable {
      border-left-color: @color-unreachable;

      &.handled {
        border-left-color: @color-unreachable-handled;
      }
    }

    &.pending {
      border-left-color: @color-pending;
    }

    &.ok {
      border-left-color: @color-ok;
    }
  }

  div.cube-dimension2 {
    background: @color-ok;
    height: 10em;

    > .header {
      display: flex;
      text-align: center;
      color: @text-color-on-icinga-blue;
      margin-bottom: 0.5em;

      > a:first-child {
        flex: 1;
        max-width: 8em;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
    }

    &.critical, &.warning, &.unknown, &.unreachable {
      span.sum {
        font-size: 1em;
      }
    }

    &.critical {
      background: @color-critical;

      &.handled {
        background: @color-critical-handled;
      }
    }

    &.warning {
      background: @color-warning;

      &.handled {
        background: @color-warning-handled;
      }
    }

    &.unknown {
      background: @color-unknown;

      &.handled {
        background: @color-unknown-handled;
      }
    }

    &.unreachable {
      background: @color-unreachable;

      &.handled {
        background: @color-unreachable-handled;
      }
    }

    &.pending {
      background: @color-pending;
    }

    &.ok {
      background: @color-ok;
    }

    > .body {
      text-align: center;
    }
  }

  div.dimension-2-container {
    display: flex;
    column-gap: .3em;
    flex-wrap: wrap;
  }

  span {
    &.critical, &.warning, &.unknown, &.unreachable, &.pending, &.ok {
      display: inline;
      border-radius: 0.1em;
      padding: 0.05em 0.2em;
      color: @text-color-on-icinga-blue;
      font-size: 3em;
    }

    &.critical {
      background: @color-critical;

      &.handled {
        background: @color-critical-handled;
      }
    }

    &.warning {
      background: @color-warning;

      &.handled {
        background: @color-warning-handled;
      }
    }

    &.unknown {
      background: @color-unknown;

      &.handled {
        background: @color-unknown-handled;
      }
    }

    &.unreachable {
      background: @color-unreachable;

      &.handled {
        background: @color-unreachable-handled;
      }
    }

    &.pending {
      background: @color-pending;
    }

    &.ok {
      background: @color-ok;
    }
  }

  .state-badge {
    font-size: 1.6em;

    &.handled {
      &.state-down {
        background-color: @color-down-handled;
      }

      &.state-critical {
        background-color: @color-critical-handled;
      }

      &.state-warning {
        background-color: @color-warning-handled;
      }

      &.state-unknown {
        background-color: @color-unknown-handled;
      }
    }
  }

  .others {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;

    span {
      font-size: 0.9em;
      &:not(.state-badge) {
        margin-left: 0.2em;
      }
    }
  }
}

fieldset.dimensions {
  margin: 0;
  padding: 0;

  span {
    min-width: 18em;
    display: inline-block;
  }

  button[type=submit] {
    border: none;
    color: @text-color;
    background: none;

    padding-left: .75em;
    padding-right: .75em;

    i:before {
      margin-right: 0;
    }

    &:not([disabled]):hover, &:focus {
      .rounded-corners();
      background-color: @icinga-blue;
      color: @text-color-on-icinga-blue;
    }

    &:focus {
      outline: 3px solid fade(@icinga-blue, 50%);
      outline-offset: 1px;
    }
  }

  button[type=submit][disabled] {
    color: @disabled-gray;
    background-color: @body-bg-color;
    cursor: auto;
  }

  &:first-of-type button[type=submit]:nth-of-type(2) {
    margin-left: 2.50em;
  }

  &:not(:first-of-type) {
    button[type=submit]:nth-of-type(2):last-of-type {
      margin-right: 2.50em;
    }
  }

  &:last-of-type {
    margin-bottom: 0.5em;
  }
}

.dimension-name {
  font-weight: bold;
  margin-left: 1em;
}

ul.action-links {
  list-style-type: none;
  margin: 0;
  padding: 0;
}

ul.action-links {
  li {
    margin: 0;
    padding: 0;
    float: left;
    display: inline-block;
    width: 18em;
    min-height: 10em;
    overflow: hidden;
  }

  li.error {
    background-color: @color-critical;
    color: @text-color-on-icinga-blue;
    padding: 1em;
    font-weight: bold;
    text-align: center;
  }

  a {
    width: 100%;
    height: 100%;
    padding: 0.5em 1em;
    display: block;
    text-decoration: none;
    color: @gray;

    .title {
      display: inline-block;
      margin-left: 5em;
      font-weight: bold;
      color: @link-color;
    }

    p {
      margin-left: 5em;
    }

    i {
      position: absolute;
      font-size: 3em;
      display: inline-block;
    }

    &:hover {
      background: @tr-hover-color;
      text-decoration: none;
    }
  }
}

/** Form **/

.content form {
  margin-bottom: 2em;

  button[type=submit] {
    margin-top: 0.5em;
  }

  select {
    width: 100%;
  }
}

.controls .icinga-form .toggle-switch {
  margin-top: .25em;
  margin-bottom: .25em;
}
