/*
 * Copyright (C) 2017-2019 Dremio Corporation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
@import "../../styles/constants/index.scss";

.input-root {
  padding-top: map-get($map: $gutter-sizes, $key: half);
  padding-bottom: map-get($map: $gutter-sizes, $key: half);
  position: relative;

  .input__container {
    border-radius: 4px;
    height: 32px;
    font-size: 14px;
    line-height: 20px;
    border: solid 1px var(--border--neutral--solid);
    display: flex;
    align-items: center;
    background-color: var(--fill--primary);

    &:hover {
      border: 1px solid var(--border--hover);

      .input__numberButtons {
        &.--disabled {
          .icon {
            display: none;
          }
        }

        .icon {
          display: block;
        }
      }
    }

    &:focus {
      border: 1px solid var(--border--focused);
    }

    &.--focused {
      border: 1px solid var(--border--focused);
    }

    &.--disabled {
      border-color: var(--border--neutral--solid);
      background-color: var(--fill--disabled);
      color: var(--text--disabled);

      input {
        background-color: var(--fill--disabled);
      }
    }

    &.--error {
      border-color: var(--fill--danger--solid);
    }

    .input__prefix {
      background-color: var(--fill--secondary);
      border-top-left-radius: $input-border-radius;
      border-bottom-left-radius: $input-border-radius;
      padding: 0px map-get($map: $gutter-sizes, $key: double);
      height: 100%;
      display: grid;
      align-content: center;
    }

    .input__numberButtons {
      width: 24px;
      padding: 3px 0;
      display: grid;
      grid-template-columns: repeat(1fr, 2);

      &.--focused {
        background-color: var(--fill--primary--hover);

        .input__numberButtons .icon {
          display: block;
        }
      }

      &.--disabled {
        background-color: var(--fill--disabled);
        .input__numberButtons .icon {
          display: none;
        }
      }

      .icon {
        width: 24px;
        height: 12px;
        display: none;
      }
    }

    input {
      height: 100%;
      border: none;
      border-radius: $input-border-radius;
      padding: 0px;
      padding-left: map-get($map: $gutter-sizes, $key: full);
      width: 100%;
      font-family: inherit;
      font-size: inherit;
      font-weight: inherit;
      color: inherit;
      background: inherit;

      &.--prefixed {
        border-top-left-radius: 0px;
        border-bottom-left-radius: 0px;
      }

      &:focus {
        outline: none;
      }
    }

    input[type="number"]::-webkit-inner-spin-button,
    input[type="number"]::-webkit-outer-spin-button {
      -webkit-appearance: none;
      appearance: none;
      margin: 0;
    }

    input[type="number"] {
      -moz-appearance: textfield;
    }

    input::placeholder {
      color: var(--text--placeholder);
      opacity: 1;
    }
  }

  .subtitle {
    margin-top: 0;
  }

  &__labelContainer {
    display: flex;
    align-items: center;
  }

  &--halfWidth {
    width: 50%;
  }

  &__label {
    flex-grow: 4;
  }
}
