/* Lightning Design System 0.9.1 */
// Copyright (c) 2015, salesforce.com, inc. All rights reserved.

// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
// Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
// Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
// Neither the name of salesforce.com, inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.



.#{$css-prefix}dropdown {
  margin-top: $spacing-xxx-small;
  padding: $spacing-xx-small 0;
  z-index: $z-index-dropdown;
  float: left;
  position: absolute;
  min-width: $size-xx-small;
  max-width: $size-medium;
  left: 50%;
  transform: translateX(-50%);
  border: $border-width-thin solid $color-border;
  border-radius: $border-radius-medium;
  box-shadow: $shadow-drop-down;
  background: $color-background-alt;

  &--left {
    left: 0;
    transform: translateX(0);
  }

  &--right {
    left: auto;
    right: 0;
    transform: translateX(0);
  }

  &--small {
    min-width: $size-small;
  }

  &--medium {
    min-width: $size-medium;
  }

  &--large {
    min-width: $size-large;
    max-width: $max-width-action-overflow-menu;
  }

  mark {
    background-color: transparent;
    font-weight: $font-weight-bold;
  }

  &--nubbin-top {
    @include nubbin(top, "before");
    @include nubbin(top);
    margin-top: ($square-tooltip-nubbin / 2);

    &:before {
      background: $color-background-alt;
    }

    &:after {
      background: $color-background-alt;
      box-shadow: -1px -1px 0 0px rgba(0, 0, 0, .16);
      z-index: -1;
    }

    &.#{$css-prefix}dropdown--left {
      left: -#{$spacing-medium};

      &:before,
      &:after {
        left: $spacing-large;
        margin-left: 0;
      }
    }

    &.#{$css-prefix}dropdown--right {
      right: -#{$spacing-medium};

      &:before,
      &:after {
        left: auto;
        right: $spacing-large;
        margin-left: 0;
      }
    }
  }

  &__header {
    padding: $spacing-x-small $spacing-small;
  }

  &__item {
    line-height: $line-height-text;

    > a,
    > span {
      display: block;
      padding: $spacing-x-small $spacing-small;
      color: $color-text-default;
      position: relative;
      white-space: nowrap;
      cursor: pointer;

      &:hover,
      &:focus {
        outline: 0;
        text-decoration: none;
        background-color: $color-background-row-hover;
      }

      &:active {
        text-decoration: none;
        background-color: $color-background-row-active;
      }

      &[aria-disabled="true"] {
        color: $color-text-button-default-disabled;
        cursor: default;

        &:hover {
          background-color: transparent;
        }
      }
    }

    &.#{$css-prefix}is-selected .#{$css-prefix}icon {
      fill: $color-text-icon-default-hover;
    }

    .#{$css-prefix}icon {
      @include square($square-icon-medium-content);
      position: absolute;
      top: 50%;
      margin-top: (($square-icon-medium-content / 2) * -1);
      fill: $color-text-icon-default;

      &--left {
        left: $spacing-small;
      }

      &--right {
        right: $spacing-small;
      }
    }
  }

  .#{$css-prefix}has-icon {
    position: relative;

    &--left > a,
    &--left > span {
      padding-left: $spacing-x-large;
    }

    &--right > a,
    &--right > span {
      padding-right: $spacing-x-large;
    }

    &--left-right > a,
    &--left-right > span {
      padding: {
        left: $spacing-x-large;
        right: $spacing-x-large;
      }
    }
  }
}

.#{$css-prefix}dropdown-trigger {
  position: relative;
  display: inline-block;

  .#{$css-prefix}dropdown {
    visibility: hidden;
    opacity: 0;
    transition: opacity $duration-quickly linear, visibility $duration-quickly linear;
  }

  &:hover,
  &:focus {
    outline: 0;

    .#{$css-prefix}dropdown {
      visibility: visible;
      opacity: 1;
      transition: opacity $duration-quickly linear, visibility $duration-quickly linear;
    }
  }
}
