.dateField {
  display: inline-flex;

  width: 106px;
  min-width: 35px;
  max-width: 100%;
  height: calc(var(--size--formField) + 2 * var(--borderWidth--line));
  padding: var(--padding--xs);

  font-family: var(--fontFamily--caption);
  font-size: var(--fontSize--caption-small);
  font-weight: var(--fontWeight--caption-small);
  line-height: var(--lineHeight--caption-small);
  color: rgb(var(--foreground--neutral-full-default--light));
  letter-spacing: var(--letterSpacing--caption-small);

  background-color: rgb(var(--background--neutral-base-default--light));
  border: 1px solid rgb(var(--border--neutral-low-default--light));
  border-radius: var(--borderRadius--formField);

  &::placeholder, [data-placeholder="true"] {
    color: rgb(var(--foreground--neutral-medium-default--light));
  }

  &:focus {
    background-color: rgb(var(--background--neutral-base-default--light));
    border-color: rgb(var(--border--controls-medium-selected--light));
    outline: 0;
    box-shadow: var(--shadow--focus--light);
  }

  &:disabled {
    background-color: rgb(var(--background--neutral-low-default--light));
  }

  &.warning-field,
  &.warning-field:focus {
    border-color: rgb(var(--border--warning-medium-default--light));
  }

  &.error-field,
  &.error-field:focus {
    border-color: rgb(var(--border--critical-high-default--light));
  }
}

.dateField__container {
  width: 132px;

  &.sm {
    width: 132px;
  }
  &.md {
    width: 220px;
  }
}

.dateField__containerInner {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;

  & > .dateField {
    flex: 1;
  }
}

.dateField__segment {
  &:focus,
  .dateField__containerInner[data-all-selected='true'] & {
    color: rgb(var(--foreground--neutral-full-default--dark));
    background-color: rgb(var(--background--controls-medium-selected--light));
    border-radius: var(--borderRadius--xxs);
    outline: 0;
  }
}

.dateField__dialog {
  overflow-y: auto;
  max-height: inherit;
  background-color: rgb(var(--background--neutral-base-default--light));
  box-shadow: var(--shadow--medium-soft--light);
}

.dateField__calendar {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--gap--xl);

  // Ratio of calendar with 6 weeks
  aspect-ratio: 0.8739;
  // Min height of calendar with 6 weeks
  min-height: 357px;
  padding: var(--padding--lg);
}

.dateField__calendarHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;

  & > [slot='previous'] {
    order: -1;
  }

  & > [slot='next'] {
    order: 1;
  }
}

.dateField__calendarHeaderTitle {
  margin: 0 !important;
}

.dateField__calendarGrid {
  & td {
    padding: 0;
  }
}

.dateField__calendarGridHeaderCell {
  height: 28px;
  padding: .7em .3em;

  font-weight: var(--fontWeight--body-small);
  color: rgb(var(--foreground--neutral-high-default--light));
  text-align: center;
}

.dateField__calendarGridCell {
  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;

  aspect-ratio: 1;
  min-width: 40px;
  min-height: 40px;

  color: rgb(var(--foreground--neutral-full-default--light));
}

.dateField__calendarGridCell--outsideMonth {
  cursor: default;
  color: rgb(var(--foreground--neutral-high-default--light));
}

.dateField__calendarGridCell--unavailable {
  cursor: not-allowed;
  color: rgb(var(--foreground--neutral-medium-default--light));
}

.dateField__calendarGridCell--focused {
  color: rgb(var(--foreground--neutral-full-default--dark));
  background-color: rgb(var(--background--controls-medium-selected--light));
  outline: 0;
}

.dateField__calendarGridCell--hovered {
  color: rgb(var(--foreground--neutral-full-default--light));
  background-color: rgb(var(--background--neutral-low-hovered--light));
}
