@function calc-top($line-height-base, $font-size, $component-height) {
  @return (($line-height-base * $font-size) - $component-height) / 2; // vertical center of line-height
}

// Emulate the less #contrast function
// TODO: this may be useful for the inverse theme, but if not, remove (it is unused after the removal of fullpalette)
// contrast-color and brightness borrowed from compass
// Copyright (c) 2009-2014 Christopher M. Eppstein
// Complies with license: https://github.com/Compass/compass/blob/stable/LICENSE.markdown
@function contrast-color($color, $dark: $contrasted-dark-default, $light: $contrasted-light-default, $threshold: null) {
  @if $threshold {
    // Deprecated in Compass 0.13
    @warn "The $threshold argment to contrast-color is no longer needed and will be removed in the next release.";
  }

  @if $color == null {
    @return null;
  } @else {
    $color-brightness: brightness($color);
    $dark-text-brightness: brightness($dark);
    $light-text-brightness: brightness($light);
    @return if(abs($color-brightness - $light-text-brightness) > abs($color-brightness - $dark-text-brightness), $light, $dark);
  }
}

@function brightness($color) {
  @if type-of($color) == color {
    @return (red($color) * 0.299 + green($color) * 0.587 + blue($color) * 0.114) / 255 * 100%;
  } @else {
    @return unquote("brightness(#{$color})");
  }
}

// To set background color
@mixin set-background-color($color){
  background-color: $color;
  @include set-sidebar-background($color);
  @include set-font-icon-color($color);
}

// To set active color
@mixin set-active-color($color){
  background-color: $color;
}

// To set sidebar background color
@mixin set-sidebar-background($color){
  $overlay-opacity: .9;
  @if $color == #000000 {
    $overlay-opacity: .8;
  }

  .sidebar-background{
    &:after{
      background: $color;
      opacity: $overlay-opacity;
    }
  } 
}

// To set gradient background color
@mixin set-gradient-background-color($start-color, $end-color){
  @include gradient-directional($start-color, $end-color);
  $overlay-opacity: .9;
  .sidebar-background{
    &:after{
      @include gradient-directional($start-color, $end-color);
      opacity: $overlay-opacity;
    }
  }
  @include set-font-icon-color($start-color);
}

// To set active gradient background color
@mixin set-active-gradient-color($start-color, $end-color){
  .navigation{
    li.active a{
      @include gradient-directional($start-color, $end-color);
    }
  }
}
// To set font icon color
@mixin set-font-icon-color($color){
  $sidebar-font-color : $white;
  @if $color == #ffffff {
    $sidebar-font-color: $black;
  }

  .navigation i, .navigation li > a{
    color: $sidebar-font-color;
  }

  .logo-text{
    color: $sidebar-font-color;
  }

  .sidebar-header a.nav-toggle{
    color: $sidebar-font-color;
  }

  .sidebar-header a.nav-close{
    color: $sidebar-font-color;
  }
}

// To set anchor color
@mixin set-anchor-color($color){
  .navigation{
    li{
      a{
        color: $color;
      }
      &.has-sub{
        .has-sub.open {
          > a{
            &:before{
              background-color: $color;
              border-color: $color;
            }
          }
        }
      }
    }
  }
}

// To set active anchor color
@mixin set-active-anchor-color($color){
  .navigation{
    > li.nav-collapsed-open{
      > a{
        color: $color;
        i{
            color: $color;
        }
      }
    }
  }
}

// To set logo text color
@mixin set-logo-text-color($color){
  .logo-text{
    color: $color;
  }
  .sidebar-header a.nav-toggle{
    color: $color;
  }
}

// To set user settings text color
@mixin set-user-settings-text-color($color){
  .user-settings-wrap{
    h5{
      color: $color !important;
    }
    .user-options a{
      color: $color !important;
    }
  }
}