/* Copyright 2024 Mozilla Foundation
 *
 * 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.
 */

.messageBar {
  --closing-button-icon: url(images/messageBar_closingButton.svg);
  --message-bar-close-button-color: var(--text-primary-color);
  --message-bar-close-button-color-hover: var(--text-primary-color);
  --message-bar-close-button-border-radius: 4px;
  --message-bar-close-button-border: none;
  --message-bar-close-button-hover-bg-color: rgb(21 20 26 / 0.14);
  --message-bar-close-button-active-bg-color: rgb(21 20 26 / 0.21);
  --message-bar-close-button-focus-bg-color: rgb(21 20 26 / 0.07);

  @media (prefers-color-scheme: dark) {
    --message-bar-close-button-hover-bg-color: rgb(251 251 254 / 0.14);
    --message-bar-close-button-active-bg-color: rgb(251 251 254 / 0.21);
    --message-bar-close-button-focus-bg-color: rgb(251 251 254 / 0.07);
  }

  @media screen and (forced-colors: active) {
    --message-bar-close-button-color: ButtonText;
    --message-bar-close-button-border: 1px solid ButtonText;
    --message-bar-close-button-hover-bg-color: ButtonText;
    --message-bar-close-button-active-bg-color: ButtonText;
    --message-bar-close-button-focus-bg-color: ButtonText;
    --message-bar-close-button-color-hover: HighlightText;
  }

  display: flex;
  position: relative;
  padding: 8px 8px 8px 16px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
  user-select: none;

  border-radius: 4px;

  border: 1px solid var(--message-bar-border-color);
  background: var(--message-bar-bg-color);
  color: var(--message-bar-fg-color);

  > div {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    align-self: stretch;

    &::before {
      content: "";
      display: inline-block;
      width: 16px;
      height: 16px;
      mask-image: var(--message-bar-icon);
      mask-size: cover;
      background-color: var(--message-bar-icon-color);
      flex-shrink: 0;
    }
  }

  button {
    cursor: pointer;

    &:focus-visible {
      outline: var(--focus-ring-outline);
      outline-offset: 2px;
    }
  }

  .closeButton {
    width: 32px;
    height: 32px;
    background: none;
    border-radius: var(--message-bar-close-button-border-radius);
    border: var(--message-bar-close-button-border);

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

    &::before {
      content: "";
      display: inline-block;
      width: 16px;
      height: 16px;
      mask-image: var(--closing-button-icon);
      mask-size: cover;
      background-color: var(--message-bar-close-button-color);
    }

    &:is(:hover, :active, :focus)::before {
      background-color: var(--message-bar-close-button-color-hover);
    }

    &:hover {
      background-color: var(--message-bar-close-button-hover-bg-color);
    }

    &:active {
      background-color: var(--message-bar-close-button-active-bg-color);
    }

    &:focus {
      background-color: var(--message-bar-close-button-focus-bg-color);
    }

    > span {
      display: inline-block;
      width: 0;
      height: 0;
      overflow: hidden;
    }
  }
}

#editorUndoBar {
  --text-primary-color: #15141a;

  --message-bar-icon: url(images/secondaryToolbarButton-documentProperties.svg);
  --message-bar-icon-color: #0060df;
  --message-bar-bg-color: #deeafc;
  --message-bar-fg-color: var(--text-primary-color);
  --message-bar-border-color: rgb(0 0 0 / 0.08);

  --undo-button-bg-color: rgb(21 20 26 / 0.07);
  --undo-button-bg-color-hover: rgb(21 20 26 / 0.14);
  --undo-button-bg-color-active: rgb(21 20 26 / 0.21);

  --undo-button-fg-color: var(--message-bar-fg-color);
  --undo-button-fg-color-hover: var(--undo-button-fg-color);
  --undo-button-fg-color-active: var(--undo-button-fg-color);

  @media (prefers-color-scheme: dark) {
    --text-primary-color: #fbfbfe;

    --message-bar-icon-color: #73a7f3;
    --message-bar-bg-color: #003070;
    --message-bar-border-color: rgb(255 255 255 / 0.08);

    --undo-button-bg-color: rgb(255 255 255 / 0.08);
    --undo-button-bg-color-hover: rgb(255 255 255 / 0.14);
    --undo-button-bg-color-active: rgb(255 255 255 / 0.21);
  }

  @media screen and (forced-colors: active) {
    --text-primary-color: CanvasText;

    --message-bar-icon-color: CanvasText;
    --message-bar-bg-color: Canvas;
    --message-bar-border-color: CanvasText;

    --undo-button-bg-color: ButtonText;
    --undo-button-bg-color-hover: SelectedItem;
    --undo-button-bg-color-active: SelectedItem;

    --undo-button-fg-color: ButtonFace;
    --undo-button-fg-color-hover: SelectedItemText;
    --undo-button-fg-color-active: SelectedItemText;
  }

  position: fixed;
  top: 50px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;

  padding-block: 8px;
  padding-inline: 16px 8px;

  font: menu;
  font-size: 15px;

  cursor: default;

  button {
    cursor: pointer;
  }

  #editorUndoBarUndoButton {
    border-radius: 4px;
    font-weight: 590;
    line-height: 19.5px;
    color: var(--undo-button-fg-color);
    border: none;
    padding: 4px 16px;
    margin-inline-start: 8px;
    height: 32px;

    background-color: var(--undo-button-bg-color);

    &:hover {
      background-color: var(--undo-button-bg-color-hover);
      color: var(--undo-button-fg-color-hover);
    }

    &:active {
      background-color: var(--undo-button-bg-color-active);
      color: var(--undo-button-fg-color-active);
    }
  }

  > div {
    align-items: center;
  }
}
