@import "../Tokens/tokens.scss";
@import "../../common/scss/helpers";

@import "~react-datepicker/dist/react-datepicker.css";

.datepicker-field {
  position: relative;
  padding-top: $baseUnit * 2;

  .react-datepicker-wrapper {
    width: 100%;
  }

  .react-datepicker {
    border-radius: 0;
    border: 1px solid #A3A3A3;
    box-shadow: 0 20px 13px 0 rgba(0,0,0,0.04);
    font: inherit;
    font-size: 14px;
    font-weight: bold;
  }

  .react-datepicker-popper {
    top: -10px !important;
  }

  .react-datepicker__navigation {
    top: 44px;
    border-width: 6px;

    @media (max-width: 1000px) {
      top: 34px;
    }

    &.react-datepicker__navigation--previous {
      left: 25px;
      border-right-color: #202020;
    }

    &.react-datepicker__navigation--next {
      right: 25px;
      border-left-color: #202020;
    }
  }

  .react-datepicker__triangle {
    display: none;
  }

  .react-datepicker__header {
    padding: 30px 20px 0 20px;
    background: #fff;
    border: 0;

    @media (max-width: 1000px) {
      padding: 20px 10px 0 10px;
    }

    .react-datepicker__current-month {
      background: #f0f5eb;
      padding: 10px 100px;
      margin-bottom: 20px;
      text-transform: capitalize;

      @media (max-width: 1000px) {
        padding: 10px 60px;
      }
    }
  }

  .react-datepicker__month {
    padding: 0 30px 30px 30px;

    @media (max-width: 1000px) {
      padding: 0 10px 10px 10px;
    }
  }

  .react-datepicker__day-name {
    margin: 0 8px;
    text-transform: capitalize;

    @media (max-width: 1000px) {
      margin: 0 5px;
    }
  }

  .react-datepicker__day {
    margin: 8px;
    border-radius: 0;

    @media (max-width: 1000px) {
      margin: 5px;
    }

    &.react-datepicker__day--outside-month {
      opacity: 0.4;
      font-weight: normal;
    }

    &.react-datepicker__day--selected {
      background: #b0ddeb;
      color: inherit;
      font-weight: bold
    }

    &.react-datepicker__day--today {
      &:not(.react-datepicker__day--selected) {
        background: #fff;
        border: 2px solid #ddd;
        color: inherit;
        font-weight: bold;
      }
    }
  }

  input {
    // reset
    background: none;
    border: 0;
    color: inherit;
    font: inherit;
    line-height: normal;
    overflow: visible;
    padding: 0;
    text-decoration: none;
    border-radius: 0;
    font-weight: normal;
    box-shadow: none;
    outline: 0;
    position: relative;
    font-size: 18px;
    line-height: 24px;
    position: relative;
    display: block;
    width: 100%;
    padding-bottom: $baseUnit * 2;
    padding-right: $baseUnit * 6;

    border-bottom: 1px solid #A3A3A3;

    &::placeholder {
      color: rgba(#1D1C28, 0.58);
      font-style: italic;
    }

    &:active,
    &:visited,
    &:focus {
        color: inherit;
    }

    &:active,
    &:focus {
      // box-shadow: 0 0 0 4px $lightBlue;
    }
  }

  .placeholder-label {
    font-size: 14px;
    font-weight: bold;
    position: relative;
    z-index: 0;
    color: rgba(#1D1C28, 0.4);
    position: absolute;
    top: -$baseUnit;
    left: 0;
  }

  .icon {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;

    svg {
      width: 18px;
      height: 18px;
      display: block;
    }
  }

  &.focused {
    &:after {
      content: "";
      position: absolute;
      top: calc(100% + 1px);
      left: 0;
      right: 0;
      border-bottom: 4px solid $lightBlue;
    }
  }

  &.error {
    // Rødt input-felt
    input,
    textarea {
      border-bottom: 1px solid $red;

      &::placeholder {
        color: $red;
      }
    }

    .error-message {
      display: inline-block;
      margin-top: $baseUnit;
      color: $red;
      font-size: 14px;
      font-weight: bold;
    }
  }

  .picker {
    :disabled {
      @include disabled();
    }

    .icon-disabled {
      @include disabled();
      pointer-events: none;
    }
  }

  .required-input::before {
    position: absolute;
    margin: 0px 0px 0px -10px;  
    @include required();
  }
}
