/**
 *
 * @ai-apps/angular v2.152.0 | _date-picker.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/vars';
@import '../../globals/scss/typography';
@import '../../globals/scss/css--reset';
@import '../../globals/scss/helper-mixins';
@import '../../globals/scss/vendor/@carbon/elements/scss/import-once/import-once';
@import '../form/form';
@import 'flatpickr.scss';

@include flatpickr;

/// Date picker styles
/// @access private
/// @group date-picker
@mixin date-picker {
  .#{$prefix}--date-picker {
    display: flex;
  }

  // V11: Possibly deprecate
  .#{$prefix}--date-picker--light .#{$prefix}--date-picker__input {
    background: $field-02;
  }

  .#{$prefix}--date-picker ~ .#{$prefix}--label {
    order: 1;
  }

  .#{$prefix}--date-picker-container {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }

  .#{$prefix}--date-picker-input__wrapper {
    position: relative;
    display: flex;
    align-items: center;
  }

  .#{$prefix}--date-picker.#{$prefix}--date-picker--simple
    .#{$prefix}--date-picker__input,
  .#{$prefix}--date-picker.#{$prefix}--date-picker--simple .#{$prefix}--label {
    width: rem(120px);
  }

  .#{$prefix}--date-picker.#{$prefix}--date-picker--simple
    .#{$prefix}--date-picker-input__wrapper--invalid,
  .#{$prefix}--date-picker.#{$prefix}--date-picker--simple
    .#{$prefix}--date-picker-input__wrapper--warn {
    .#{$prefix}--date-picker__input,
    ~ .#{$prefix}--form-requirement {
      width: rem(152px);
    }
  }

  .#{$prefix}--date-picker.#{$prefix}--date-picker--simple.#{$prefix}--date-picker--short {
    .#{$prefix}--date-picker__input {
      width: 5.7rem;
    }
  }

  .#{$prefix}--date-picker.#{$prefix}--date-picker--single
    .#{$prefix}--date-picker__input {
    width: rem(288px);
  }

  .#{$prefix}--date-picker
    .#{$prefix}--date-picker-input__wrapper--warn
    ~ .#{$prefix}--form-requirement {
    color: $text-primary;
  }
  .#{$prefix}--date-picker__input {
    @include reset;
    @include type-style('code-02');
    @include focus-outline('reset');

    position: relative;
    display: block;
    height: rem(40px);
    padding: 0 $carbon--spacing-05;
    border: none;
    border-bottom: 1px solid $border-strong;
    background-color: $field;
    color: $text-primary;
    transition: $duration--fast-01 motion(standard, productive) all;

    &:focus,
    &.#{$prefix}--focused {
      @include focus-outline('outline');
    }

    &:disabled {
      border-bottom: 1px solid transparent;
      background-color: $field-disabled;
      color: $text-disabled;
      cursor: not-allowed;
    }

    &:disabled::placeholder {
      color: $text-disabled;
    }

    &:disabled:hover {
      border-bottom: 1px solid transparent;
    }

    &::placeholder {
      @include placeholder-colors;
    }
  }

  // Size variant styles
  // TODO V11: Remove xl selector
  .#{$prefix}--date-picker__input--xl,
  .#{$prefix}--date-picker__input--lg {
    height: rem(48px);
  }

  .#{$prefix}--date-picker__input--sm {
    height: rem(32px);
  }

  .#{$prefix}--date-picker__icon {
    position: absolute;
    z-index: 1;
    // vertically center icon within parent container on IE11
    top: 50%;
    right: 1rem;
    cursor: pointer;
    fill: $icon-primary;
    transform: translateY(-50%);
  }

  .#{$prefix}--date-picker__icon--invalid,
  .#{$prefix}--date-picker__icon--warn {
    cursor: auto;
  }

  .#{$prefix}--date-picker__icon--warn {
    fill: $support-warning;
  }

  // V11: Do we have an always black token?
  .#{$prefix}--date-picker__icon--warn path:first-of-type {
    fill: $carbon__black-100;
    opacity: 1;
  }

  .#{$prefix}--date-picker__icon--invalid {
    fill: $support-error;
  }

  .#{$prefix}--date-picker__icon ~ .#{$prefix}--date-picker__input {
    padding-right: $carbon--spacing-09;
  }

  .#{$prefix}--date-picker__input:disabled ~ .#{$prefix}--date-picker__icon {
    cursor: not-allowed;
    fill: $icon-disabled;
  }

  .#{$prefix}--date-picker--range
    > .#{$prefix}--date-picker-container:first-child {
    margin-right: rem(1px);
  }

  .#{$prefix}--date-picker--range .#{$prefix}--date-picker-container,
  .#{$prefix}--date-picker--range .#{$prefix}--date-picker__input {
    width: rem(143.5px);
  }

  // Skeleton State
  .#{$prefix}--date-picker.#{$prefix}--skeleton input,
  .#{$prefix}--date-picker__input.#{$prefix}--skeleton {
    @include skeleton;

    width: 100%;

    &::placeholder {
      color: transparent;
    }
  }

  .#{$prefix}--date-picker.#{$prefix}--skeleton .#{$prefix}--label {
    @include skeleton;

    width: rem(75px);
    height: rem(14px);
  }

  // Windows HCM fix
  // stylelint-disable-next-line no-duplicate-selectors
  .#{$prefix}--date-picker__icon {
    @include high-contrast-mode('icon-fill');
  }
}

@include exports('date-picker') {
  @include date-picker;
}
