/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

.datetimebox {
  display: flex;
  line-height: normal;
  white-space: nowrap;
  /* TODO: Enable selection once bug 1455893 is fixed */
  user-select: none;
}

.datetime-input-box-wrapper {
  display: inline-flex;
  flex: 1;
  background-color: inherit;
  min-width: 0;
  justify-content: space-between;
  align-items: center;
}

.datetime-input-edit-wrapper {
  overflow: hidden;
  flex-grow: 1;
}

.datetime-edit-field {
  display: inline;
  text-align: center;
  padding: 1px 3px;
  border: 0;
  margin: 0;
  ime-mode: disabled;
  outline: none;

  &:focus {
    background-color: Highlight;
    color: HighlightText;
    outline: none;
  }
}

.datetime-picker-button {
  -moz-context-properties: fill;
  color: color-mix(in srgb, currentColor 65%, transparent);
  font-size: inherit;
  fill: currentColor;
  background-color: transparent;
  border: none;
  border-radius: 0.2em;
  flex: none;
  margin-block: 0;
  margin-inline: 0.075em 0.15em;
  padding: 0 0.15em;
  line-height: 1;

  &:focus-visible {
    outline: 0.15em solid SelectedItem;
  }

  &:focus-visible,
  &:hover {
    color: inherit;
  }

  @media (prefers-contrast) {
    background-color: ButtonFace;
    color: ButtonText;

    > svg {
      background-color: ButtonFace;
      -moz-context-properties: fill;
      fill: ButtonText;
    }

    &:focus-visible,
    &:hover {
      background-color: SelectedItem;

      > svg {
        background-color: SelectedItem;
        -moz-context-properties: fill;
        fill: SelectedItemText;
      }
    }
  }
}

.datetime-calendar-button-svg,
.datetime-time-button-svg {
  pointer-events: none;
  /* When using a very small font-size, we don't want the button to take extra
   * space (which will affect the baseline of the form control) */
  max-width: 1em;
  max-height: 1em;
}

.datetime-time-button-svg {
  display: none;
}

:host([type="time"]) .datetime-picker-button {
  display: none;
}

:host(:is(:disabled, :read-only)) .datetime-edit-field {
  user-select: none;
  pointer-events: none;
  -moz-user-focus: none;
}

@media -moz-pref("dom.forms.datetime.timepicker") {
  :host([type="time"]) {
    .datetime-calendar-button-svg {
      display: none;
    }
    .datetime-picker-button,
    .datetime-time-button-svg {
      display: initial;
    }
  }
}

/* Must stay below the dom.forms.datetime.timepicker @media block to override its display: initial for disabled/read-only states. */
:host(:is(:disabled, :read-only)) .datetime-picker-button {
  display: none;
}
