@import '../../marketplace.css';

:root {
  --selectionHeight: 36px;
  --hoveredOverlayColor: rgba(255, 255, 255, 0.2);
  --datepickerDistanceToTop: 252px;
}

.inputRoot {
  /* Contain repainting to this component only */
  transform: translate3d(0, 0, 0);

  /* Override react-dates default styles to match input styles */

  & :global(.DateRangePicker) {
    display: block;
  }
  & :global(.DateRangePicker__picker--horizontal) {
    top: 36px;
    width: 100%;
    min-height: calc(100vh - var(--datepickerDistanceToTop));
    background-color: var(--marketplaceColor);

    @media (--viewportMedium) {
      top: 45px;
    }

    @media (--viewportMedium) {
      top: 42px;
      min-height: auto;
      box-shadow: var(--boxShadowPopup);
      border-radius: 0 0 2px 2px;
    }
  }
  & :global(.DateRangePickerInput) {
    width: 100%;
    display: flex;
    justify-content: space-between;
    border: none;
    background: none;
  }
  & :global(.DayPicker--horizontal) {
    margin: 0 auto;
    background-color: var(--marketplaceColor);
    box-shadow: none;
  }
  & :global(.CalendarMonthGrid) {
    background-color: transparent;
  }
  & :global(.DateInput) {
    display: block;
    width: 100%;
    padding: 5px 0 2px 0;

    @media (--viewportMedium) {
      padding: 6px 0 9px 0;
    }
  }
  & :global(.DayPicker__week-header) {
    color: var(--matterColorLight);
    top: 57px;
  }

  & :global(.DayPicker__week-header li) {
    font-weight: 400;
  }

  & :global(.CalendarMonth__caption) {
    color: var(--matterColorLight);
    @apply --marketplaceH2FontStyles;
    margin: 1px 0 14px;
    font-weight: 400;

    @media (--viewportMedium) {
      margin-top: 0;
      margin-bottom: 0;
    }
  }
  & :global(.DayPickerNavigation__prev),
  & :global(.DayPickerNavigation__next) {
    color: var(--matterColorLight);
    border: 0;
  }
  & :global(.CalendarDay__button) {
    border: 0;
    padding: 0;
    width: 100%;
    height: 100%;
  }
  & :global(.CalendarDay) {
    @apply --marketplaceH4FontStyles;
    color: var(--matterColorLight);
    border: 0;
    margin-top: 0;
    margin-bottom: 0;

    @media (--viewportMedium) {
      margin-top: 0;
      margin-bottom: 0;
    }
  }

  /* Add an underline for '.renderedDay' */
  & :global(.CalendarDay--today) {
    background-image: url("data:image/svg+xml;utf8,<svg width='14' height='2' viewBox='0 0 14 2' xmlns='http://www.w3.org/2000/svg'><path d='M0 0h14v2H0z' fill='%23FFF' fill-rule='evenodd'/></svg>");
    background-position: center 30px;
  }

  /* Remove default bg-color and use our extra span instead '.renderedDay' */
  & :global(.CalendarDay--hovered-span),
  & :global(.CalendarDay--selected-span) {
    background-image: transparent;
    background-color: transparent;
  }
  & :global(.CalendarDay--hovered-span .renderedDay) {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: var(--selectionHeight);
    background-color: var(--hoveredOverlayColor);
  }
  & :global(.CalendarDay--selected-span .renderedDay) {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: var(--selectionHeight);
    background-color: var(--successColor);
    transition: all 0.2s ease-out;
  }
  /* Remove default bg-color and use our extra span instead '.renderedDay' */
  & :global(.CalendarDay--selected-start) {
    background-color: transparent;
    background-image: none;
  }
  & :global(.CalendarDay--selected-start .renderedDay) {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: var(--selectionHeight);
    background-color: var(--successColor);
    border-top-left-radius: calc(var(--selectionHeight) / 2);
    border-bottom-left-radius: calc(var(--selectionHeight) / 2);
  }
  /* Remove default bg-color and use our extra span instead '.renderedDay' */
  & :global(.CalendarDay--after-hovered-start) {
    background-color: transparent;
  }
  & :global(.CalendarDay--after-hovered-start .renderedDay) {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: var(--selectionHeight);
    background-color: var(--hoveredOverlayColor);
  }
  /* Remove default bg-color and use our extra span instead '.renderedDay' */
  & :global(.CalendarDay--selected-end) {
    background-color: transparent;
  }
  & :global(.CalendarDay--selected-end .renderedDay) {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: var(--selectionHeight);
    background-color: var(--successColor);
    border-top-right-radius: calc(var(--selectionHeight) / 2);
    border-bottom-right-radius: calc(var(--selectionHeight) / 2);
  }
  /* Remove default bg-color and use our extra span instead '.renderedDay' */
  & :global(.CalendarDay--hovered) {
    background-color: transparent;
  }
  & :global(.CalendarDay--hovered .renderedDay) {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: var(--selectionHeight);
    background-color: var(--hoveredOverlayColor);
  }
  /* Remove default bg-color and use our extra span instead '.renderedDay' */
  & :global(.CalendarDay--blocked-out-of-range) {
    background-color: transparent;
    color: var(--marketplaceColorDark);
    border: 0;
  }
  & :global(.CalendarDay--blocked-out-of-range .renderedDay) {
    background-color: transparent;
  }
  & :global(.DateInput--with-caret::before) {
    display: none;
  }
  & :global(.DateInput--with-caret::after) {
    display: none;
  }
  & :global(.DateInput__display-text) {
    @apply --marketplaceDefaultFontStyles;
    padding: 0;
    color: var(--matterColorAnti);
  }
  & :global(.DateInput__display-text--focused) {
    background-color: transparent;
  }
  & :global(.DateInput__display-text--has-input) {
    color: var(--matterColor);
  }
}

/**
 * Mobile margins mean that labels, inputs (incl separate borders) get margins,
 * but calendar popup doesn't.
 */
.withMobileMargins {
  & :global(.DateRangePickerInput) {
    width: calc(100vw - 48px);
    margin: 0 24px 3px 24px;

    @media (--viewportMedium) {
      width: 100%;
      margin: 0;
    }
  }

  /* Create gutter between inputs */
  & :global(.DateInput) {
    width: calc(50% - 6px);
    background: none;

    @media (--viewportMedium) {
      width: calc(50% - 12px);
    }
  }

  & :global(.DateInput:first-of-type) {
    margin-right: 12px;

    @media (--viewportMedium) {
      margin-right: 24px;
    }
  }
}

.rootNextMonthIcon,
.rootPreviousMonthIcon {
  stroke: var(--matterColorLight);
  fill: var(--matterColorLight);
}
