@import 'vars';

// for v4a-v4b;
$input-bg-disabled: $input-disabled-bg;

//custom mixin for .form-control-validation
@mixin typeahead-form-control($border-color: #ccc) {
  border-color: $border-color;
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075); // Redeclare so transitions work
  &:focus {
    $shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px lighten($border-color, 20%);
    border-color: darken($border-color, 10%);
    box-shadow: $shadow;
  }
}

//main styles for control
.tt-input, .tt-hint {
  .twitter-typeahead & {
    //validation states
    .has-warning & {
      @include typeahead-form-control($state-warning-text);
    }

    .has-error & {
      @include typeahead-form-control($state-danger-text);
    }

    .has-success & {
      @include typeahead-form-control($state-success-text);
    }
  }

  //border
  .input-group .twitter-typeahead:first-child & {
    @include border-left-radius($border-radius);
    width: 100%;
  }

  .input-group .twitter-typeahead:last-child & {
    @include border-right-radius($border-radius);
    width: 100%;
  }

  //sizing - small:size and border
  .input-group.input-group-sm .twitter-typeahead & {
    @include input-size($input-height-sm, $padding-small-vertical, $padding-small-horizontal, $font-size-sm, $line-height-sm, $border-radius-small);
  }

  .input-group.input-group-sm .twitter-typeahead:not(:first-child):not(:last-child) & {
    border-radius: 0;
  }

  .input-group.input-group-sm .twitter-typeahead:first-child & {
    @include border-left-radius($border-radius-small);
    @include border-right-radius(0);
  }

  .input-group.input-group-sm .twitter-typeahead:last-child & {
    @include border-left-radius(0);
    @include border-right-radius($border-radius-small);
  }

  //sizing - large:size and border
  .input-group.input-group-lg .twitter-typeahead & {
    @include input-size($input-height-lg, $padding-large-vertical, $padding-large-horizontal, $font-size-lg, $line-height-lg, $border-radius-large);
  }

  .input-group.input-group-lg .twitter-typeahead:not(:first-child):not(:last-child) & {
    border-radius: 0;
  }

  .input-group.input-group-lg .twitter-typeahead:first-child & {
    @include border-left-radius($border-radius-large);
    @include border-right-radius(0);
  }

  .input-group.input-group-lg .twitter-typeahead:last-child & {
    @include border-left-radius(0);
    @include border-right-radius($border-radius-large);
  }
}

//for wrapper
.twitter-typeahead {
  float: left;
  width: 100%;

  .input-group & {
    //overwrite `display:inline-block` style
    display: table-cell !important;
  }
}

//particular style for each other
.twitter-typeahead .tt-hint {
  color: $text-muted;//color - hint
}

.twitter-typeahead .tt-input {
  z-index: 2;
  //disabled status
  //overwrite inline styles of .tt-query
  &[disabled], &[readonly], fieldset[disabled] & {
    cursor: not-allowed;
    //overwirte inline style
    background-color: $input-bg-disabled !important;
  }
}

//dropdown styles
.tt-dropdown-menu, .tt-menu {
  //dropdown menu
  position: absolute;
  top: 100%;
  left: 0;
  z-index: $zindex-dropdown;
  width: 100%;
  min-width: 160px;
  padding: 5px 0;
  margin: 2px 0 0;
  font-size: $font-size-base;
  list-style: none;
  background-color: $dropdown-bg;
  background-clip: padding-box;
  border: 1px solid $dropdown-fallback-border;
  border: 1px solid $dropdown-border-color;
  border-radius: $border-radius;
  box-shadow: $dropdown-box-shadow;
  // *border-right-width: 2px;
  // *border-bottom-width: 2px;

  .tt-suggestion {
    //item
    display: block;
    padding: 3px 20px;
    clear: both;
    font-weight: $font-weight-normal;
    line-height: $line-height-base;
    color: $dropdown-link-color;

    &.tt-cursor, &:hover {
      color: $dropdown-link-hover-color;
      text-decoration: none;
      //item selected
      cursor: pointer;
      background-color: $dropdown-link-hover-bg;
      outline: 0;

      a {
        //link in item selected
        color: $dropdown-link-hover-color;
      }
    }

    p {
      margin: 0;
    }
  }
}
