// Import any global variables from "../../../variables/*.json"
@import "../../../variables/colors.json";
@import "../../../variables/spacing.json";
@import "../../../variables/fonts.json";

.inputBox {
  display: block;
  padding-left: 14px;
  height: (43px - 7px);
  line-height: (43px - 4px);
  padding-top: 4px;
  resize: none;

  font-family: $font-base;
  font-size: $font-size-base;

  color: $gray-darker;
  background-color: #fff;

  border: 1px solid $gray-light;
  border-radius: $border-radius-base;

  // Remove shadow on inside of boxes on ios
  -webkit-appearance: none;

  // On active, remove outline and add a border color.
  // NOTE: does this have accessibility concerns?
  outline: none;
  &:focus {
    border-color: $brand-primary;
  }
  &::placeholder { color: $gray; }
}
.inputBoxTextarea {
  line-height: $line-height-base;
  padding-top: 16px;
  padding-bottom: 16px;
}
.inputboxDisabled {
  border-color: transparent;
  background-color: $gray-lightest;
  color: $gray;

  &::placeholder,
  &::-webkit-input-placeholder,
  &::-moz-placeholder,
  &:-ms-input-placeholder,
  &:-moz-placeholder {
    color: $gray;
    opacity: 1; // Placeholders in firefox have opacity by default. Undo that.
  }
}


// Extract common styles into a placeholder selector for selectbox menu list and value
%inputBoxSelectCommon {
  font-family: $font-base;

  width: calc(100% - 15px - 15px);

  background-color: #fff;
  border: 1px solid $gray-light;
  border-radius: 4px;

  padding-left: 15px;
  padding-right: 15px;

  user-select: none;
}

.inputBoxSelect {
  &Box {
    position: relative;
    width: 200px;

    font-weight: normal;
  }

  // Select box value - this is the always visible region that shows the currently selected item.
  &BoxValue {
    @extend %inputBoxSelectCommon;
    height: (43px - 1px - 1px); /* (for borders) */

    font-size: $font-size-base;
    color: $gray-cinder;

    display: flex;
    flex-direction: row;
    align-items: center;

    cursor: pointer;
    outline: none;

    & > span {
      margin-right: auto;

      &:active {
        opacity: 0.9;
      }
    }

    &Caret { height: 12px; }
    // When focused, flip the caret.
    &CaretOpened  { transform: rotate(180deg); }

    &Opened {
      border-color: $brand-primary;
    }

    // When disabled, a selectbox is grayed out and can't be clicked.
    &Disabled {
      background-color: $gray-lighter;
      pointer-events: none;
    }
  }

  // Select box menu - this is the menu that is hidden and shown when the user clicks on the select
  // box value.
  &BoxMenu {
    @extend %inputBoxSelectCommon;

    position: absolute;
    top: 50px;
    padding-top: 10px;
    padding-bottom: 10px;
    padding-left: 0px;
    padding-right: 0px;

    width: 100%;

    z-index: 100;
    color: $gray-cinder;
    box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 100ms ease-in-out;
    user-select: none;

    // When opened, fade in the select box and enable pointer events.
    // NOTE: when the select box is closed, it isn't given `display: none`, because giving it that
    // would make the animation difficult. Instead, it's given `pointer-events: none`, which causes
    // any clicks to not occur on that element and instead be handled by the element underneath it.
    opacity: 0;
    pointer-events: none;
    &Opened {
      opacity: 1;
      pointer-events: all;
    }
  }

  &BoxMenuUl {
    list-style-type: none;
    padding-left: 0px;
    margin: 0px;
  }

  &BoxMenuLi {
    line-height: 36px;
    font-size: $font-size-base;
    cursor: pointer;

    padding-left: 15px;
    padding-right: 15px;
    outline: none;

    &:focus {
      color: $brand-primary;
    }

    &:hover {
      background-color: $gray-lightest;
    }

    &Disabled {
      color: $gray-dark;
    }
  }

  &BoxItemHighlight {
    margin-left: 10px;
    color: $gray-dark;
    font-style: italic;
  }

  &Placeholder {
    color: $gray;
  }
}
