/**
 * Copyright Aquera Inc 2023
 *
 * This source code is licensed under the BSD-3-Clause license found in the
 * LICENSE file in the root directory of this source tree.
 */

import { css } from 'lit';

/**
 * DatePicker CSS
 */
export const styles = css`
  :host {
    display: inline-block;
  }
  
  .base {
    background-color: var(
      --nile-colors-white-base,
      var(--ng-colors-bg-primary)
    );
    border-radius: var(--nile-radius-radius-sm, var(--ng-radius-2xl));
    width: var(--nile-width-288px, var(--ng-width-312));
    border: 1px solid
      var(--nile-colors-neutral-400, var(--ng-colors-border-secondary-alt));
    box-shadow: var(
      --nile-box-shadow-15,
      0px 20px 24px -4px var(--ng-colors-effects-shadow-xl-01)
    ); // Need to fix the token for this
    border: var(
      --nile-spacing-spacing-none,
      1px solid var(--ng-colors-border-secondary-alt)
    );
    -webkit-font-smoothing: var(
      --nile-webkit-font-smoothing,
      var(--ng-webkit-font-smoothing)
    );
    -moz-osx-font-smoothing: var(
      --nile-moz-osx-font-smoothing,
      var(--ng-moz-osx-font-smoothing)
    );
    text-rendering: var(--nile-text-rendering, var(--ng-text-rendering));
  }

  .calendar-container {
    font-family: var(--nile-font-family-serif, var(--ng-font-family-body));
    width: 100%;
    height: auto;
    text-align: center;
    background: white;
    border-radius: var(--nile-radius-radius-xl, var(--ng-radius-2xl));
  }

  .calendar-wrapper {
    background: var(--nile-colors-white-base, var(--ng-colors-bg-primary));
    display: flex;
    justify-content: space-between;
    width: 100%;
    border-radius: var(--nile-radius-radius-xl, var(--ng-radius-2xl));
  }

  .calendar-header {
    display: flex;
    justify-content: space-between;
    padding: var(--nile-spacing-22px, var(--ng-spacing-2xl))
      var(--nile-spacing-2xl, var(--ng-spacing-2xl));
    font-size: var(--nile-type-scale-3, var(--ng-font-size-text-sm));
    font-weight: var(
      --nile-font-weight-semi-bold,
      var(--ng-font-weight-semibold)
    );
    line-height: var(--nile-line-height-xsmall, var(--ng-line-height-text-sm));
    letter-spacing: 0.2px;
  }

  .calendar-header__month-navigation {
    cursor: pointer;
  }

  /* Date CSS_START */

  .days_container {
    display: grid;
    padding: var(--nile-spacing-none, var(--ng-spacing-none))
      var(--nile-spacing-lg, var(--ng-spacing-lg))
      var(--nile-spacing-lg, var(--ng-spacing-lg))
      var(--nile-spacing-lg, var(--ng-spacing-lg));
    grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
    grid-row-gap: var(--nile-spacing-xs, var(--ng-spacing-xs));
  }

  .day_date,
  .day_name {
    font-family: var(
      --nile-font-family-serif-colfax-medium,
      var(--ng-font-family-body)
    );
    font-style: normal;
    font-size: var(--nile-type-scale-2, var(--ng-font-size-text-sm));
    line-height: var(--nile-line-height-20px, var(--ng-line-height-text-sm));
    text-align: center;
    width: 100%;
    height: var(--nile-width-32px, var(--ng-width-10));
    display: grid;
    place-items: center;
  }

  .day_name {
    font-weight: var(
      --nile-font-weight-semi-bold,
      var(--ng-font-weight-semibold)
    );
    font-family: var(
      --nile-font-family-serif-colfax-medium,
      var(--ng-font-family-body)
    );
  }

  .day_date {
    font-weight: var(--nile-font-weight-regular, var(--ng-font-weight-regular));
    font-family: var(--nile-font-family-serif, var(--ng-font-family-body));
    user-select: none;
    cursor: pointer;
  }

  .current__date__dot {
    background-color: var(
      --nile-colors-primary-600,
      var(--ng-colors-text-white)
    );
    position: absolute;
    border-radius: 50%;
    height: 5px;
    width: 5px;
    left: 25%;
    top: 90%;
  }

  .day_date:not(.range-start, .selected-date, .range-end) .current__date__dot {
    background-color: var(
      --nile-colors-primary-600,
      var(--ng-colors-bg-brand-solid)
    );
  }

  .day_date:hover {
    background-color: var(
      --nile-colors-neutral-100,
      var(--ng-colors-bg-secondary-hover)
    );
  }

  .filler {
    color: var(--nile-colors-dark-500, var(--ng-colors-text-disabled));
    pointer-events: none;
  }

  .selected-date {
    color: white;
    border-radius: var(--nile-radius-radius-xs, var(--ng-radius-xs));
    background: var(--nile-colors-primary-600, var(--ng-colors-bg-brand-solid));
  }

  .selected-date:hover {
    background: var(--nile-colors-primary-600, var(--ng-colors-bg-brand-solid));
  }

  .selected-date,
  .range-start,
  .range-end {
    cursor: pointer;
    border-radius: var(--nile-radius-radius-xs, var(--ng-radius-xs));
    background: var(--nile-colors-blue-400, var(--ng-colors-bg-brand-solid));
    color: var(--nile-colors-dark-900, var(--ng-colors-text-white));
    font-weight: var(
      --nile-font-weight-semi-bold,
      var(--ng-font-weight-regular)
    );
    font-family: var(--nile-font-family-serif, var(--ng-font-family-body));
  }

  .selected-date:hover,
  .range-start:hover,
  .range-end:hover,
  .day_date.in-range:hover {
    background: var(
      --nile-colors-blue-500,
      var(--ng-colors-bg-brand-solid-hover)
    );
  }

  .range-start.in-range {
    background: var(--nile-colors-blue-400, var(--ng-colors-bg-brand-solid));
    border-radius: var(--nile-radius-radius-xs, var(--ng-radius-xs))
      var(--nile-radius-radius-none, var(--ng-radius-none))
      var(--nile-radius-radius-none, var(--ng-radius-none))
      var(--nile-radius-radius-xs, var(--ng-radius-xs));
    color: var(--nile-colors-dark-900, var(--ng-colors-bg-primary));
    font-family: var(--nile-font-family-serif, var(--ng-font-family-body));
    font-weight: var(
      --nile-font-weight-semi-bold,
      var(--ng-font-weight-regular)
    );
  }

  .range-end {
    cursor: pointer;
    background: var(--nile-colors-blue-400, var(--ng-colors-bg-brand-solid));
    border-radius: var(--nile-radius-radius-none, var(--ng-radius-none))
      var(--nile-radius-radius-xs, var(--ng-radius-xs))
      var(--nile-radius-radius-xs, var(--ng-radius-xs))
      var(--nile-radius-radius-none, var(--ng-radius-none));
    color: var(--nile-colors-dark-900, var(--ng-colors-bg-primary));
    font-size: var(--nile-type-scale-2, var(--ng-font-size-text-sm));
    letter-spacing: 0.2px;
    font-family: var(--nile-font-family-serif, var(--ng-font-family-body));
    font-weight: var(
      --nile-font-weight-semi-bold,
      var(--ng-font-weight-regular)
    );
  }

  .range-middle {
    background: var(--nile-colors-primary-600, var(--ng-colors-bg-brand-solid));
    color: var(--nile-colors-white-base, var(--ng-colors-bg-primary));
    border-radius: var(--nile-radius-radius-none, var(--ng-radius-none));
  }

  .day_date.selected {
    background: var(--nile-colors-primary-600, var(--ng-colors-bg-brand-solid));
    color: var(--nile-colors-white-base, var(--ng-colors-bg-primary));
    border-radius: var(--nile-radius-radius-xs, var(--ng-radius-xs));
  }

  .day_date.in-range:not(.range-start, .range-end, .selected-date) {
    background: var(--nile-colors-neutral-100, var(--ng-colors-bg-active));
  }

  .selected-date {
    color: var(--nile-colors-dark-900, var(--ng-colors-bg-primary));
    border-radius: var(--nile-radius-radius-xs, var(--ng-radius-xs));
    background: var(--nile-colors-blue-400, var(--ng-colors-bg-brand-solid));
  }

  .not-allowed {
    color: var(--nile-colors-dark-500, var(--ng-colors-text-disabled));
    pointer-events: none;
  }

  /* Date CSS_END */

  .calender-input {
    box-sizing: border-box;
    padding: var(--nile-spacing-none, var(--ng-spacing-none))
      var(--nile-spacing-xl, var(--ng-spacing-xl));
    width: 100%;
    justify-content: space-between;
    display: flex;
    gap: var(--nile-spacing-md, var(--ng-spacing-md));
    flex-wrap: wrap;
  }

  .from {
    display: flex;
    justify-content: space-between;
    gap: var(--nile-spacing-md, var(--ng-spacing-md));
    width: auto;
    align-items: flex-end;
    gap: var(--nile-spacing-md, var(--ng-spacing-md));
    flex-wrap: nowrap;
    width: 100%;
  }

  .manual-input-label {
    color: var(--nile-colors-dark-500);
    font-family: Colfax-regular;
    font-size: var(--nile-type-scale-2, var(--ng-font-size-text-xs));
    font-weight: var(--nile-font-weight-medium, var(--ng-font-weight-medium));
    line-height: 12px;
    letter-spacing: 0.2px;
  }

  .button-container {
    width: 100%;
    display: flex;
    justify-content: end;
    gap: var(--nile-spacing-xl, var(--ng-spacing-lg));
    padding: var(--nile-spacing-xl, var(--ng-spacing-lg))
      var(--nile-spacing-spacing-xl, var(--ng-spacing-xl))
      var(--nile-spacing-spacing-xl, var(--ng-spacing-xl))
      var(--nile-spacing-spacing-xl, var(--ng-spacing-xl));
    box-sizing: border-box;
  }

  .calendar-config {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  nile-tab::part(base) {
    padding-bottom: 12px;
    justify-content: center;
    font-size: var(--nile-type-scale-3, var(--ng-font-size-text-md));
    font-family: var(
      --nile-font-family-serif-colfax-medium,
      var(--ng-font-family-body)
    );
    font-weight: var(
      --nile-font-weight-semi-bold,
      var(--ng-font-weight-semibold)
    );
  }

  .calendar-switcher {
    width: 100%;
    margin-top: var(--nile-spacing-xl, var(--ng-spacing-xl));
  }

  .units-wrapper {
    width: min-content;
    margin: auto;
  }

  .unit-container {
    display: flex;
    flex-direction: column;
    gap: var(--nile-spacing-xl, var(--ng-spacing-xl));
  }
  :host([disabled]) .unit-container {
    user-select: none;
    -webkit-user-select: none;
    pointer-events: none;
  }

  .unit-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .duration-name {
    display: flex;
    align-items: center;
    font-family: var(
      --nile-font-family-serif-colfax-medium,
      var(--ng-font-family-body)
    );
    font-size: var(--nile-type-scale-3, var(--ng-font-size-text-sm));
    font-style: normal;
    font-weight: var(
      --nile-font-weight-semi-bold,
      var(--ng-font-weight-semibold)
    );
    line-height: var(--nile-line-height-small, var(--ng-line-height-text-sm));
  }

  .duration-units {
    display: flex;
    font-family: var(--nile-font-family-serif, var(--ng-font-family-body));
    font-size: var(--nile-type-scale-3, var(--ng-font-size-text-sm));
    font-style: normal;
    font-weight: var(--nile-font-weight-regular, var(--ng-font-weight-regular));
    line-height: var(--nile-line-height-small, var(--ng-line-height-text-sm));
    gap: 6px;
  }

  .duration__value {
    display: grid;
    place-items: center;
    width: var(--nile-width-32px, var(--ng-width-10));
    height: var(--nile-width-32px, var(--ng-width-10));
    cursor: pointer;
    border-radius: var(--nile-radius-radius-xs, var(--ng-radius-md));
    border: 1px solid
      var(--nile-colors-neutral-500, var(--ng-colors-border-primary));
  }

  .duration__value:hover {
    background: var(--nile-colors-neutral-400, var(--ng-colors-bg-quaternary));
  }

  .duration__value--selected {
    background-color: var(
      --nile-colors-blue-400,
      var(--ng-colors-bg-brand-solid)
    );
    color: var(--nile-colors-dark-900, var(--ng-colors-text-white));
    font-weight: var(
      --nile-font-weight-semi-bold,
      var(--ng-font-weight-semi-bold)
    );
    border: 1px solid transparent;
    font-family: var(--nile-font-family-serif, var(--ng-font-family-body));
  }

  .duration__value--selected:hover {
    background: var(
      --nile-colors-blue-500,
      var(--ng-colors-bg-brand-solid-hover)
    );
    font-weight: var(
      --nile-font-weight-semi-bold,
      var(--ng-font-weight-semi-bold)
    );
    font-family: var(--nile-font-family-serif, var(--ng-font-family-body));
  }

  nile-input::part(input)::-webkit-inner-spin-button,
  nile-input::part(input)::-webkit-outer-spin-button {
    -webkit-appearance: none;
  }

  .hidden {
    display: none !important;
  }

  .unit-input-container {
    display: flex;
    line-height: 0;
    justify-content: space-between;
    gap: var(--nile-spacing-md, var(--ng-spacing-md));
    padding: var(--nile-spacing-none, var(--ng-spacing-none))
      var(--nile-spacing-xl, var(--ng-spacing-xl))
      var(--nile-spacing-none, var(--ng-spacing-xl))
      var(--nile-spacing-xl, var(--ng-spacing-xl));
  }

  .duration-input,
  .time-input,
  .manual-input {
    width: 125px;
  }

  /* New Styles */

  nile-dropdown[open] > span[slot='trigger'] .calendar-header__caret {
    transform: rotate(180deg);
  }

  .calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 600;
    line-height: 14px;
    letter-spacing: 0.2px;
    font-feature-settings: 'liga' off, 'clig' off;
  }

  .calendar-header__center {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(
      --nile-font-family-serif-colfax-medium,
      var(--ng-font-family-body)
    );
  }

  .calendar-header__trigger {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    background: transparent;
    color: var(--nile-colors-dark-900, var(--ng-colors-text-primary-900));
    font-family: var(--nile-font-family-medium, var(--ng-font-family-body));
  }

  .calendar-header__caret {
    width: 16px;
    height: 16px;
    transition: transform 0.2s ease;
    transform-origin: center;
  }

  .calendar-menu {
    max-height: 194px;
    overflow-y: auto;
    width: 100px;
  }

  .month-scroll-wrapper {
    max-height: 196px;
    overflow-y: auto;
    width: 100px;
    overflow-x: hidden;
  }

  .month-dropdown nile-menu {
    overflow-y: auto;
    padding: var(--nile-spacing-spacing-lg) var(--nile-spacing-spacing-none);
    box-shadow: 0px 4px 8px 0px rgba(119, 125, 130, 0.15);
  }

  .year-scroll-wrapper {
    max-height: 196px;
    overflow-y: auto;
    width: 65px;
    overflow-x: hidden;
  }

  .year-dropdown nile-menu {
    overflow-y: auto;
    padding: var(--nile-spacing-spacing-lg) var(--nile-spacing-spacing-none);
    box-shadow: 0px 4px 8px 0px rgba(119, 125, 130, 0.15);
  }

  .month-dropdown nile-menu-item::part(base) {
    padding: 0px 12px;
    font-family: var(--nile-font-family-serif, var(--ng-font-family-body));
  }
  .year-dropdown nile-menu-item::part(base) {
    padding: 0px 12px;
    font-family: var(--nile-font-family-serif, var(--ng-font-family-body));
  }
  nile-menu-item[selected] {
    background: var(--nile-colors-primary-100);
  }

  nile-menu-item[selected]::part(base):hover {
    background: var(--nile-colors-primary-100);
    border-radius: 0px;
  }

  nile-icon[disabled] {
    opacity: 0.4;
    pointer-events: none;
  }

  .units-wrapper {
    display: flex;
    flex-direction: column;
    gap: var(--nile-spacing-xl, var(--ng-spacing-xl));
    padding: var(--nile-spacing-xl, var(--ng-spacing-xl));
    width: auto;
  }

  .calendar-input {
    display: flex;
    flex-direction: column;
    gap: var(--nile-spacing-md, var(--ng-spacing-md));
    padding: var(--nile-spacing-lg, var(--ng-spacing-xl)) var(--nile-spacing-xl, var(--ng-spacing-3xl))
      var(--nile-spacing-none, var(--ng-spacing-none)) var(--nile-spacing-xl, var(--ng-spacing-3xl));
    box-sizing: border-box;
  }

  .manual-input {
    flex: 1;
    min-width: 120px;
  }

  .date-input nile-input::part(base),
  .time-input nile-input::part(base) {
    width: 100%;
  }

  .manual-input-label {
    font-size: var(--nile-type-scale-2, var(--ng-font-size-text-xs));
    font-weight: var(--nile-font-weight-medium, var(--ng-font-weight-medium));
  }

  .day_date.in-range:hover:not(.range-start):not(.range-end) {
    background-color: var(
      --nile-colors-neutral-400,
      var(--ng-colors-bg-quaternary)
    );
    color: var(--nile-colors-dark-900, var(--ng-colors-text-primary-900));
  }

  nile-input.date-input::part(base),
  .from-date {
    width: var(--nile-width-150px, var(--ng-width-164));
  }

  nile-input.time-input::part(base),
  .from-time {
    width: var(--nile-width-99px, var(--ng-width-108));
  }

  .month-dropdown, .year-dropdown {
    cursor: pointer;
  }



:host([disabled]) .calendar-header__month-navigation,
:host([disabled]) .calendar-header__trigger,
:host([disabled]) .day_date {
  cursor: not-allowed;
  color: var(--nile-colors-dark-500, var(--ng-colors-fg-disabled));
}



:host([disabled]) .base {
  background-color:  var(--nile-colors-dark-200, var(--ng-colors-bg-disabled-subtle));
  cursor: not-allowed;
  color: var(--nile-colors-dark-500, var(--ng-colors-fg-disabled));
}

:host([disabled]) .calendar-container {
  background-color: var(--nile-colors-dark-200, var(--ng-colors-bg-disabled-subtle));
  user-select: none;
  -webkit-user-select: none;
}

:host([disabled]) .day_name {
  color: var(--nile-colors-dark-500, var(--ng-colors-fg-disabled));
}

:host([disabled]) nile-input::part(form-control-label) {
  color: var(--nile-colors-dark-500, var(--ng-colors-fg-disabled));
}
:host([disabled]) nile-select::part(form-control-label) {
  color: var(--nile-colors-dark-500, var(--ng-colors-fg-disabled));
}



:host([disabled]) .calendar-switcher {
  pointer-events: none;
  opacity:var(--nile-opacity-50, var(--ng-opacity-50));
}


:host([disabled]) .day_date{
  pointer-events:none;
}
:host([disabled]) .day_date:not(.range-start, .selected-date, .range-end) .current__date__dot {
  background-color: var(--nile-colors-dark-500, var(--ng-colors-fg-disabled));
}

:host([disabled]) .duration_unit{
 background-color: var(--nile-colors-dark-200, var(--ng-colors-bg-disabled-subtle));
}
:host([disabled]) .duration__value {
  cursor: not-allowed;
}
`;

export default [styles];
