/*! Icinga Web 2 | (c) 2015 Icinga Development Team | GPLv2+ */

.box-shadow(@x: 0.2em; @y: 0.2em; @blur: 0.2em; @spread: 0; @color: rgba(83, 83, 83, 0.25)) {
  -webkit-box-shadow: @arguments;
     -moz-box-shadow: @arguments;
          box-shadow: @arguments;
}

.button(@background-color: @body-bg-color, @color: @icinga-blue) {
  .rounded-corners(3px);

  background-color: @background-color;
  border: 2px solid @color;
  color: @color;
  cursor: pointer;
  line-height: normal;
  outline: none;
  padding: @vertical-padding @horizontal-padding;

  // Transition mixin does not work w/ comma-separated transitions
  -webkit-transition: background 0.3s ease, color 0.3s ease;
     -moz-transition: background 0.3s ease, color 0.3s ease;
       -o-transition: background 0.3s ease, color 0.3s ease;
          transition: background 0.3s ease, color 0.3s ease;

  &:focus,
  &:hover {
    background-color: @color;
    color: @background-color;
  }

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

.clearfix {
  &:after {
    content: "";
    clear: both;
    display: table;
  }
}

.opacity(@opacity: 0.6) {
  opacity: @opacity;
}

.transform(@transform) {
  -webkit-transform: @transform;
     -moz-transform: @transform;
      -ms-transform: @transform;
       -o-transform: @transform;
          transform: @transform;
}

.rounded-corners(@border-radius: 0.4em) {
  border-radius: @border-radius;

  -webkit-background-clip: padding-box;
     -moz-background-clip: padding;
          background-clip: padding-box;
}

.transition (@transition) {
  -webkit-transition: @transition;
     -moz-transition: @transition;
       -o-transition: @transition;
          transition: @transition;
}

// Fadein animation

/* Chrome, WebKit */
@-webkit-keyframes fadein {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* FF < 16 */
@-moz-keyframes fadein {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* IE */
@-ms-keyframes fadein {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Opera < 12.1 */
@-o-keyframes fadein {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes fadein {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.fadein() {
  opacity: 0;

  -webkit-animation: fadein 2s ease-in; /* Chrome, WebKit */
     -moz-animation: fadein 2s ease-in; /* FF < 16 */
       -o-animation: fadein 2s ease-in; /* Opera < 12.1 */
          animation: fadein 2s ease-in;

  // Make sure that after animation is done we remain at the last keyframe value (opacity: 1)
  -webkit-animation-fill-mode: forwards;
     -moz-animation-fill-mode: forwards;
       -o-animation-fill-mode: forwards;
          animation-fill-mode: forwards;
}

// Mixin for stateful foreground colors, e.g. text or icons
.fg-stateful {
  &.state-ok {
    color: @color-ok;
  }
  &.state-up {
    color: @color-up;
  }
  &.state-warning {
    color: @color-warning;
    &.handled {
      color: @color-warning-handled;
    }
  }
  &.state-critical {
    color: @color-critical;
    &.handled {
      color: @color-critical-handled;
    }
  }
  &.state-down {
    color: @color-down;
    &.handled {
      color: @color-down-handled;
    }
  }
  &.state-unreachable {
    color: @color-unreachable;
    &.handled {
      color: @color-unreachable-handled;
    }
  }
  &.state-unknown {
    color: @color-unknown;
    &.handled {
      color: @color-unknown-handled;
    }
  }
  &.state-pending {
    color: @color-pending;
  }
}

// Mixin for stateful background colors
.bg-stateful {
  &.state-ok {
    background-color: @color-ok;
  }
  &.state-up {
    background-color: @color-up;
  }
  &.state-warning {
    background-color: @color-warning;
    &.handled {
      background-color: @color-warning-handled;
    }
  }
  &.state-critical {
    background-color: @color-critical;
    &.handled {
      background-color: @color-critical-handled;
    }
  }
  &.state-down {
    background-color: @color-down;
    &.handled {
      background-color: @color-down-handled;
    }
  }
  &.state-unreachable {
    background-color: @color-unreachable;
    &.handled {
      background-color: @color-unreachable-handled;
    }
  }
  &.state-unknown {
    background-color: @color-unknown;
    &.handled {
      background-color: @color-unknown-handled;
    }
  }
  &.state-pending {
    background-color: @color-pending;
  }
}
