/* ==========================================================================
  Buttons
  Define alternative buttons here.
 ========================================================================== */

/* General fixes
 ========================================================================== */

a.button,
button.button {
  border-width: 0;
  border-image-width: 0;
  line-height: 2.3;

  i {
    padding-right: 1rem;
  }

  i.button__icon {
    padding-right: 0;
  }
}

a.button.button--disabled,
button.button.button--disabled {
  color:  $blue-gray-dark-contrast;
  background-color: $blue-gray-lighter;
  pointer-events: none !important;

  table.data-table tbody tr:hover & {
    background-color: #eeeeee;
  }
}


// TODO: put in styleguide
// TODO: review CSS, too many importants
a,
button {
  &.button.button--overflow-hidden,
  &.button.button--alt.button--overflow-hidden,
  &.button.button--small.button--overflow-hidden,
  &.button.button--tiny.button--overflow-hidden {
    white-space: nowrap;
    overflow: hidden !important;
    text-overflow: ellipsis;

    &.button--block {
      padding: 0 0.5rem;
    }
  }
}


button.button--link,
button,
a {
  cursor: pointer;
  transition: all 200ms;
}

a,
button {
  &.button,
  &.button.button--block,
  &.button.button--narrow,
  &.button.button--secondary,
  &.button.button--alt,
  &.button.button--warning,
  &.button.button--large,
  &.button.button--small,
  &.button.button--tiny {
    position: relative;
    overflow: visible !important;
  }

}


/* Link icon
 ========================================================================== */

a[class^="link--icon--"]:before {
  overflow: visible;
}

.link--icon .fa {
  font-size: 1.7rem;
  position: absolute;
  color: $gray-dark;
  left: 0;
  top: -.2rem;
  line-height: 1;
  overflow: hidden;
}

.link-group.link-group--tiny .link--icon {
  font-size: 1.4rem;
  line-height: 1;
  padding: 0.5rem 1rem 0.5rem 2rem;
  margin-right: 0.4rem;
}

.link-group.link-group--tiny.link-group--dark .link--icon {
  color: $gray;
}

.link-group.link-group--tiny .link--icon i {
  color: $primary-blue;
  padding-left: 0.15rem;
}

.link-group.link-group--tiny .link--icon.link--disabled i {
  color: $gray-dark;
}

.link--disabled {
  opacity: 0.8;
  cursor: not-allowed;
}

.link--icon.link--icon--tiny.link--disabled i,
.link--icon.link--icon--tiny.link--disabled i.vi,
.link--icon.link--icon--tiny.link--disabled i.fa {
  color: $gray;
  top: 0.5rem;
}

/* Other sizes
 ========================================================================== */

a.button.button--tiny,
button.button.button--tiny {
  font-size: 0.7em;
  padding: 0 0.5em 0.1em;
  height: 2em;
  line-height: 2;
}

.form-group--inline--small a.button,
.form-group--inline--small button.button,
a.button.button--small,
button.button.button--small {
  font-size: 0.8em;
  padding: 2px 0.5em 0.2em;
  height: 2.1em;
  line-height: 2;

  .vi.vi-u-link-after:before,
  .vi.vi-u-link:before {
    font-size: 0.7em;
    margin-right: 0.5rem;
  }
}

a.button.button--large,
button.button.button--large {
  line-height: 2.6;
}

.form-group--inline--large a.button,
.form-group--inline--large button.button {
  line-height: 2.6;
  height: 4.5rem;
  font-size: 1.8rem;
}

a.button.button--x-large,
button.button.button--x-large {
  font-size: 2.1rem;
  padding: 0.2rem 1.5rem;
  height: 5rem;
  line-height: 2;
}

a.button.button--huge,
button.button.button--huge {
  font-size: 2.4rem;
  padding: 0.5rem 1.5rem;
  height: 5.5rem;
  line-height: 1.9;
}

/* Other styles
 ========================================================================== */

a.button.button--secondary,
button.button.button--secondary {
  border-width: 3px;
  line-height: 1.9;
  background-color: $white;

  &.button--tiny {
    border-width: 1px;
    line-height: 1.9;
  }

  &.button--small {
    border-width: 2px;
    line-height: 1.7;
  }

  &.button--large {
    line-height: 2.2;
  }

  &.button--x-large {
    line-height: 1.9;
  }

  &.button--huge {
    border-width: 4px;
    line-height: 1.6;
  }
}

a.button.button--dark,
button.button.button--dark {
  background-color: lighten($gray-dark, 5%);
  color: $white;
  border: 1px solid $gray-dark;
  line-height: 1.7;

  &:hover {
    background-color: $gray-dark;
    color: $white;
  }

  &:focus,
  &:active {
    background-color: darken($gray-dark, 5%);
    color: $white;
  }

  &.button--disabled {
    background-color: $blue-gray-light;
    color: $white;
  }

  &.button--tiny {
    line-height: 1.9;
  }

  &.button--small {
    line-height: 1.5;
  }
}


a.button.button--dark {
  line-height: 2.1;

  &.button--small {
    line-height: 1.8;
  }

  &.button--large {
    line-height: 2.5;
  }

  &.button--huge {
    line-height: 1.8;
  }
}

a.button.button--alt,
button.button.button--alt {
  background-color: $white;
  color: $gray-dark;
  border: 1px solid $blue-gray-light;
  line-height: 2.1;

  &:hover {
    color: $black;
    background-color: $blue-gray-lightest;
    border-color: $blue-gray-light;
  }

  &:focus,
  &:active {
    color: $black;
    background-color: darken($blue-gray-lightest, 3%);
    border-color: $blue-gray;
  }

  &.button--tiny {
    line-height: 1.9;
  }

  &.button--small {
    line-height: 1.7;
  }

  &.button--large {
    line-height: 2.5;
  }

  &.button--x-large {
    line-height: 1.8;
  }

  &.button--huge {
    line-height: 1.8;
  }

  &.button--disabled {
    color: $blue-gray-dark-contrast;
    border-color: $blue-gray-light;
  }
}

a.button.button--alt.button--alt--blue,
button.button.button--alt.button--alt--blue {
  color: $primary-blue;

  &:hover {
    color: lighten($primary-blue, 5%);
    background-color: $blue-gray-lightest;
    border-color: $blue-gray;
  }

  &:focus,
  &:active {
    color: lighten($primary-blue, 5%);
    background-color: darken($blue-gray-lightest, 3%);
    border-color: $blue-gray;
  }

  &.button--disabled {
    color: $blue-gray-light;
    border-color: $blue-gray-light;
  }
}

a.button.button--alt.button--alt--warning,
button.button.button--alt.button--alt--warning {
  color: $red;

  &:hover {
    color: $white;
    background-color: $red;
    border-color: $red;
  }

  &:focus,
  &:active {
    color: $white;
    background-color: $red-light;
    border-color: $red-light;
  }

  &.button--disabled {
    color: $blue-gray-light;
    border-color: $blue-gray-light;
  }
}

a.button.button--alt.button--alt--fancy,
button.button.button--alt.button--alt--fancy {
  border-bottom-color: $primary-blue;
  box-shadow: 0 2px 0 $primary-blue;

  &.button--tiny,
  &.button--small {
    box-shadow: 0 1px 0 $primary-blue;
  }

  &.button--tiny {
    line-height: 1.8;
  }

  &.button--small {
    line-height: 1.7;
  }

  &.button--large {
    line-height: 2.5;
  }

  &.button--x-large {
    line-height: 2;
  }

  &.button--x-large,
  &.button--huge {
    box-shadow: 0 3px 0 $primary-blue;
  }

  &:hover {
    background-color: $primary-blue;
    color: $white;
    border-color: $primary-blue;
  }

  &.button--disabled {
    color: $blue-gray-light;
    border-color: $blue-gray-light;
    box-shadow: 0 2px 0 $blue-gray-light;
  }
}

/* Link styles with button widths
 ========================================================================== */

a.button.button--link,
button.button.button--link {
  background-color: transparent;
  color: $primary-blue;
  border: none;
  text-decoration: underline;

  &:hover {
    text-decoration: underline;
    background-color: $white;
    color: lighten($primary-blue, 5%);
  }

  &:focus,
  &:active {
    text-decoration: underline;
    color: darken($primary-blue, 10%);
    background-color: $white;
  }

  &.button--disabled {
    color: $blue-gray;
  }
}

// TODO: review styleguide

a.button.button--link.button--link--dark,
button.button.button--link.button--link--dark {
  background-color: $white;
  color: $gray-dark;
  border: none;
  text-decoration: underline;

  &:hover {
    color: $primary-blue;
  }

  &:focus,
  &:active {
    color: darken($primary-blue, 5%);
  }

  &.button--disabled {
    color: $blue-gray;
  }
}

/* Link styles
 ========================================================================== */

a.link-dark,
a.link--dark {
  color: $gray-dark;
  // text-decoration: none;

  &:hover {
    // text-decoration: none;
    color: $primary-blue;
  }
}

a.link--dark--light,
a.link--dark--light i.vi {
  color: $gray;
  // text-decoration: none;

  &:hover {
    // text-decoration: none;
    color: $primary-blue;
  }
}

// TODO: double check where link-dark is used, with one dash


a.link--edit {
  position: relative;
  display: inline-block;
  padding-right: 3rem;
  color: $black;
  text-decoration: none;

  &:hover {
    text-decoration: underline;
    color: $primary-blue;
  }
}

.link--edit:after {
  content:"\E014";
  font-family: vlaanderen_iconfont !important;
  font-size: 70%;
  position: absolute;
  right: 0;
  text-align: right;
  color: $primary-blue;
  top: 15%;
}

.link--icon--close {
  appearance: none;
  border: 0;

  &:focus {
    outline: 2px solid $orange;
    outline-offset: .2rem;
  }
}


// /* Extra info inside or below button
//  ========================================================================== */

.button__info {
  font-size: 75%;
}

.button.button--tiny .button__info {
  font-size: 1rem;
}

.button .button__info--inside {
  position: relative;
  top: -1px;
  padding-left: 0.5rem;
}

.button .button__info--below {
  position: absolute;
  display: block;
  color: $gray-dark;
  text-align: center;
  left: 0;
  right: 0;
  bottom: -26px;
  font-size: 1.4rem;
}

.button i {
  position: relative;
  padding: 0 0 0 1px;

  &.vi-arrow.vi-u-90deg {
    top: 1px;
  }
}

.button.button--tiny {

  i {
    padding-right: 0.2rem;
  }

  .button__info--below {
    bottom: -17px;
    font-size: 1rem;
  }
}

.button.button--small {

  i {
    padding-right: 0.5rem;
  }

  .button__info--below {
    bottom: -20px;
    font-size: 1.2rem;
  }
}

.button.button--alt {

  .button__info--below {
    bottom: -27px;
  }

  &.button--tiny .button__info--below {
    bottom: -18px;
  }

  &.button--small .button__info--below {
    bottom: -21px;
  }

  &.button--large .button__info--below {
    bottom: -30px;
  }

  &.button--x-large .button__info--below {
    bottom: -27px;
  }

  &.button--huge .button__info--below {
    bottom: -27px;
  }
}

.button.button--alt.button--alt--fancy {

  .button__info--below {
    bottom: -28px;
  }

  &.button--tiny .button__info--below {
    bottom: -20px;
  }

  &.button--small .button__info--below {
    bottom: -23px;
  }

  &.button--large .button__info--below {
    bottom: -32px;
  }

  &.button--x-large .button__info--below {
    bottom: -29px;
  }

  &.button--huge .button__info--below {
    bottom: -29px;
  }
}

.button.button--secondary {

  .button__info--below {
    bottom: -28px;
  }

  &.button--tiny .button__info--below {
    bottom: -18px;
  }

  &.button--small .button__info--below {
    bottom: -21px;
  }

  &.button--large .button__info--below {
    bottom: -31px;
  }

  &.button--x-large .button__info--below {
    bottom: -30px;
  }

  &.button--huge .button__info--below {
    bottom: -30px;
  }
}

.button.button--large {

  .button__info--below {
    bottom: -30px;
    font-size: 1.4rem;
  }
}

.button.button--x-large {

  .button__info--below {
    bottom: -28px;
    font-size: 1.4rem;
  }
}

.button.button--huge {

  .button__info--below {
    bottom: -28px;
    font-size: 1.4rem;
  }
}

/* Button group
 ========================================================================== */

.button-group > a.button:last-child,
.button-group > button.button:last-child,
.button-group > .popover.popover--left.js-popover:last-child button.button,
.button-group > .popover.popover--left.js-popover:last-child a.button {
  margin-right: 0;
}

.button-group__inline button.button,
.button-group__inline a.button {
  float: left;
  margin-left: 1px;
  margin-bottom: -1px;

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

  &.button--small,
  &.button--tiny {
    padding-right: 0.45rem;
    padding-left: 0.45rem;
  }

  &.button--alt,
  &.button--dark {
    margin-left: -3px;
  }

  &.button--active {
    background-color: darken($primary-blue, 7.5%);
    border-color: darken($primary-blue, 7.5%);
  }

  &.button--secondary {
    margin-left: -3px;

    &.button--active {
      background-color: $primary-blue;
      color: $white;
      border-color: $primary-blue;
    }
  }

  &.button--secondary.button--small {
    margin-left: -2px;
  }

  &.button--secondary.button--tiny {
    margin-left: -1px;
  }

  &.button--secondary.button--huge {
    margin-left: -4px;
  }

  &.button--alt.button--active {
    background-color: $gray-lightest;
    border-color: $blue-gray-light;

    &:hover {
      background-color: darken($gray-lighter, 7.5%);
    }

    &.button--alt--blue {
      background-color: $primary-blue;
      border-color: $primary-blue;
      color: $white;

      &:hover {
        background-color: lighten($primary-blue, 7.5%);
      }
    }

    &.button--alt--fancy {
      background-color: $primary-blue;
      border-color: $primary-blue;
      color: $white;

      &:hover {
        background-color: lighten($primary-blue, 7.5%);
      }
    }
  }

  &.button--dark.button--active {
    background-color: $white;
    color: $gray-dark;
    border: 1px solid $gray-dark;
  }
}

/* Save animation
 ========================================================================== */

.button.button--save:after {
  opacity: 0;
  content: "\E00C";
  font-family: vlaanderen_iconfont!important;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 0;
  z-index: 1;
  pointer-events: none;
  transition: all 150ms;
  color: $white;
}

.button.button--save.saved:after {
  opacity: 1;
  left: 0;
  right: auto;
  width: 100%;
  transition: all 200ms;
}

.button.button--save:before {
  content: "";
  transition: all 150ms;
  width: 0;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  background-color: darken($primary-blue, 5%);
  pointer-events: none;
  opacity: 0;
}

.button.button--save.saved:before {
  width: 100%;
  left: 0;
  right: auto;
  opacity: 1;
  transition: all 200ms;
}



/* Table button
 ========================================================================== */

[class^="u-background--"] .data-table__action__toggle {
  background-color: $white;
}
