/**
 *
 * @ai-apps/angular v2.152.0 | _flatpickr.scss
 *
 * Copyright 2014, 2023 IBM
 *
 * 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.
 */


//
// Copyright IBM Corp. 2016, 2018
//
// This source code is licensed under the Apache-2.0 license found in the
// LICENSE file in the root directory of this source tree.
//

@import '../../globals/scss/typography';
@import '../../globals/scss/helper-mixins';

@keyframes fpFadeInDown {
  from {
    transform: translate3d(0, -20px, 0);
    opacity: 0;
  }
  to {
    transform: translate3d(0, 0, 0);
    opacity: 1;
  }
}

@keyframes fpSlideLeft {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(-100%, 0, 0);
  }
}

@keyframes fpSlideLeftNew {
  from {
    transform: translate3d(100%, 0, 0);
  }
  to {
    transform: translate3d(0, 0, 0);
  }
}

@keyframes fpSlideRight {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(100%, 0, 0);
  }
}

@keyframes fpSlideRightNew {
  from {
    transform: translate3d(-100%, 0, 0);
  }
  to {
    transform: translate3d(0, 0, 0);
  }
}

@keyframes fpFadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes fpFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@mixin flatpickr {
  .flatpickr-calendar {
    position: absolute;
    box-sizing: border-box;
    width: rem(315px);
    max-height: 0;
    padding: 0;
    overflow: hidden;
    direction: ltr;
    text-align: center;
    border: 0;
    border-radius: 0;
    visibility: hidden;
    opacity: 0;
    animation: none;
    touch-action: manipulation;
  }

  .flatpickr-calendar.open,
  .flatpickr-calendar.inline {
    max-height: rem(640px);
    overflow: visible;
    visibility: inherit;
    opacity: 1;
  }

  .flatpickr-calendar.open {
    @include box-shadow;

    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: rem(288px);
    height: rem(336px);
    margin-top: rem(-2px);
    padding: $carbon--spacing-02 $carbon--spacing-02 $carbon--spacing-03
      $carbon--spacing-02;
    overflow: hidden;
    background-color: $ui-01;
    border: none;

    &:focus {
      @include focus-outline('border');
    }
  }

  .flatpickr-calendar.animate.open {
    animation: fpFadeInDown $duration--fast-02 motion(entrance, productive);
  }

  .flatpickr-calendar.inline {
    position: relative;
    top: rem(2px);
    display: block;
  }

  .flatpickr-calendar.static {
    position: absolute;
    top: calc(100% + 2px);
  }

  .flatpickr-calendar.static.open {
    z-index: 999;
    display: block;
  }

  .flatpickr-calendar.hasWeeks {
    width: auto;
  }

  .dayContainer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    height: rem(246px);
    padding: 0;
    outline: 0;
  }

  .flatpickr-calendar .hasWeeks .dayContainer,
  .flatpickr-calendar .hasTime .dayContainer {
    border-bottom: 0;
    border-bottom-right-radius: 0;
    border-bottom-left-radius: 0;
  }

  .flatpickr-calendar .hasWeeks .dayContainer {
    border-left: 0;
  }

  .flatpickr-calendar.showTimeInput.hasTime .flatpickr-time {
    height: rem(40px);
    border-top: 1px solid #e6e6e6;
  }

  .flatpickr-calendar.noCalendar.hasTime .flatpickr-time {
    height: auto;
  }

  .flatpickr-calendar:focus {
    outline: 0;
  }

  .flatpickr-months {
    display: flex;
    justify-content: space-between;
    width: 100%;
  }

  .flatpickr-month {
    @include type-style('productive-heading-01');

    display: flex;
    align-items: center;
    height: rem(40px);
    color: $text-01;
    line-height: 1;
    text-align: center;
    background-color: transparent;
  }

  .flatpickr-prev-month,
  .flatpickr-next-month {
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    width: rem(40px);
    height: rem(40px);
    padding: 0;
    line-height: 16px;
    text-decoration: none;
    transform: scale(1, 1) #{'/*rtl: scale(-1,1)*/'};
    cursor: pointer;
    transition: background-color $duration--fast-01 motion(standard, productive);
    fill: $icon-01;

    &:hover {
      background-color: $hover-ui;
    }
  }

  .flatpickr-next-month.disabled svg,
  .flatpickr-prev-month.disabled svg {
    cursor: not-allowed;
    fill: $ui-05;
  }

  .flatpickr-next-month.disabled:hover svg,
  .flatpickr-prev-month.disabled:hover svg {
    fill: $ui-05;
  }

  .flatpickr-current-month {
    @include type-style('productive-heading-01');

    display: flex;
    align-items: center;
    justify-content: center;
    height: rem(28px);
    text-align: center;
  }

  .flatpickr-current-month .cur-month {
    margin-right: $carbon--spacing-02;
    margin-left: $carbon--spacing-02;

    &:hover {
      background-color: $hover-ui;
    }
  }

  .numInputWrapper {
    position: relative;
    width: rem(60px);

    &:hover {
      background-color: $hover-ui;
    }
  }

  .numInputWrapper .numInput {
    display: inline-block;
    width: 100%;
    margin: 0;
    padding: $carbon--spacing-02;
    color: $text-01;
    font-weight: 600;
    font-size: inherit;
    font-family: inherit;
    background-color: $field-01;
    border: none;
    cursor: default;
    // Added in when upgraded to Flatpickr 4.5.5 (#1977)
    -moz-appearance: textfield; /* Firefox */

    &::-webkit-outer-spin-button,
    &::-webkit-inner-spin-button {
      margin: 0; /* <-- Apparently some margin are still there even though it's hidden */
      // Added in when upgraded to Flatpickr 4.5.5 (#1977)
      -webkit-appearance: none;
    }

    &:focus {
      @include focus-outline('border');
    }

    &[disabled],
    &[disabled]:hover {
      color: $disabled-02;
      background-color: $ui-01;
      pointer-events: none;
    }
  }

  .numInputWrapper .arrowUp {
    top: rem(4px);
    border-bottom: 0;

    &::after {
      border-bottom: rem(4px) solid $icon-01;
    }
  }

  .numInputWrapper .arrowDown {
    top: rem(11px);

    &::after {
      border-top: rem(4px) solid $icon-01;
    }
  }

  .numInputWrapper .arrowUp,
  .numInputWrapper .arrowDown {
    position: absolute;
    left: 2.6rem;
    width: rem(12px);
    height: 50%;
    padding: 0 rem(4px) 0 rem(2px);
    line-height: 50%;
    border: none;
    cursor: pointer;
    opacity: 0;

    &::after {
      position: absolute;
      top: 33%;
      display: block;
      border-right: rem(4px) solid transparent;
      border-left: rem(4px) solid transparent;
      content: '';
    }

    &:hover::after {
      border-top-color: $interactive-01;
      border-bottom-color: $interactive-01;
    }

    &:active::after {
      border-top-color: $interactive-04;
      border-bottom-color: $interactive-04;
    }
  }

  .numInput[disabled] ~ .arrowUp::after {
    border-bottom-color: $disabled-02;
  }

  .numInput[disabled] ~ .arrowDown::after {
    border-top-color: $disabled-02;
  }

  .numInputWrapper:hover .arrowUp,
  .numInputWrapper:hover .arrowDown {
    opacity: 1;
  }

  .numInputWrapper:hover .numInput[disabled] ~ .arrowUp,
  .numInputWrapper:hover .numInput[disabled] ~ .arrowDown {
    opacity: 0;
  }

  .flatpickr-weekdays {
    display: flex;
    align-items: center;
    height: rem(40px);
  }

  .flatpickr-weekdaycontainer {
    display: flex;
    width: 100%;
  }

  .flatpickr-weekday {
    @include type-style('body-short-01');

    flex: 1;
    color: $text-01;
    cursor: default;
  }

  .flatpickr-days:focus {
    outline: 0;
  }

  .flatpickr-calendar.animate .dayContainer.slideLeft {
    animation: fpFadeOut 400ms cubic-bezier(0.23, 1, 0.32, 1),
      fpSlideLeft 400ms cubic-bezier(0.23, 1, 0.32, 1);
  }

  .flatpickr-calendar.animate .dayContainer.slideLeft,
  .flatpickr-calendar.animate .dayContainer.slideLeftNew {
    transform: translate3d(-100%, 0, 0);
  }

  .flatpickr-calendar.animate .dayContainer.slideLeftNew {
    animation: fpFadeIn 400ms cubic-bezier(0.23, 1, 0.32, 1),
      fpSlideLeft 400ms cubic-bezier(0.23, 1, 0.32, 1);
  }

  .flatpickr-calendar.animate .dayContainer.slideRight {
    transform: translate3d(100%, 0, 0);
    animation: fpFadeOut 400ms cubic-bezier(0.23, 1, 0.32, 1),
      fpSlideRight 400ms cubic-bezier(0.23, 1, 0.32, 1);
  }

  .flatpickr-calendar.animate .dayContainer.slideRightNew {
    animation: fpFadeIn 400ms cubic-bezier(0.23, 1, 0.32, 1),
      fpSlideRightNew 400ms cubic-bezier(0.23, 1, 0.32, 1);
  }

  .flatpickr-day {
    @include type-style('body-short-01');

    display: flex;
    align-items: center;
    justify-content: center;
    width: rem(40px);
    height: rem(40px);
    color: $text-01;
    cursor: pointer;
    transition: all $duration--fast-01 motion(standard, productive);

    &:hover {
      background: $hover-ui;
    }

    &:focus {
      @include focus-outline('outline');

      outline-color: $interactive-01;
    }
  }

  .nextMonthDay,
  .prevMonthDay {
    color: $text-05;
  }

  .flatpickr-day.today {
    position: relative;
    color: $link-01;
    font-weight: 600;

    &::after {
      position: absolute;
      bottom: rem(7px);
      left: 50%;
      display: block;
      width: rem(4px);
      height: rem(4px);
      background-color: $link-01;
      transform: translateX(-50%);
      content: '';
    }
  }

  .flatpickr-day.today.no-border {
    border: none;
  }

  .flatpickr-day.today.selected {
    @include focus-outline('outline');

    &::after {
      display: none;
    }
  }

  .flatpickr-day.inRange {
    color: $text-01;
    background-color: $highlight;
  }

  .flatpickr-day.selected {
    color: $text-04;
    background-color: $interactive-01;

    &:focus {
      outline: rem(1px) solid $ui-02;
      outline-offset: rem(-3px);
    }
  }

  .flatpickr-day.startRange.selected {
    z-index: 2;
    box-shadow: none;
  }

  .flatpickr-day.startRange.inRange:not(.selected),
  .flatpickr-day.endRange.inRange {
    @include focus-outline('outline');

    z-index: 3;
    background: $ui-01;
  }

  .flatpickr-day.endRange:hover {
    @include focus-outline('outline');

    color: $text-01;
    background: $ui-01;
  }

  .flatpickr-day.endRange.inRange.selected {
    color: $text-04;
    background: $interactive-01;
  }

  .flatpickr-day.flatpickr-disabled {
    color: $disabled-02;
    cursor: not-allowed;

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

  .flatpickr-input[readonly] {
    cursor: pointer;
  }

  // Windows HCM fix
  .flatpickr-prev-month,
  .flatpickr-next-month {
    @include high-contrast-mode('icon-fill');
  }

  .flatpickr-day.selected {
    @include high-contrast-mode('focus') {
      outline-style: dotted;
    }
  }

  .flatpickr-day.today,
  .flatpickr-day.inRange {
    @include high-contrast-mode {
      color: Highlight;
    }
  }

  .flatpickr-calendar {
    @include high-contrast-mode('outline');
  }
}
