/* 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/. */

@import "variables.less";

:root {
  --context-menu-single-max-width: 400px;
}

.contextMenu {
  border-radius: @borderRadius;
  box-sizing: border-box;
  color: black;
  cursor: default;
  display: flex;
  font-size: @contextMenuFontSize;
  &.contextMenuScrollable {
    overflow-y: scroll;
  }
  // This is a reasonable max height and also solves problems for bookmarks menu
  // and bookmarks overflow menu reaching down too low.
  height: 100%;
  width: 100%;
  @usedUpChrome: @navbarHeight + @bookmarksToolbarWithFaviconsHeight;
  max-height: calc(~'100% - @{usedUpChrome}');
  overflow: auto;
  position: absolute;
  z-index: @zindexContextMenu;
  -webkit-user-select: none;
  &.reverseExpand {
    flex-direction: row-reverse;
  }

  .contextMenuSingle {
    background-color: rgba(238, 238, 238, 0.97);
    border: 1px solid rgba(204, 204, 204, 0.54);
    box-shadow: 1px 4px 8px -3px rgba(0, 0, 0, 0.5);
    border-radius: @borderRadius;
    box-sizing: border-box;
    display: table;
    min-width: 220px;
    max-width: var(--context-menu-single-max-width);

    &.isSubmenu {
      position: relative;
    }
  }

  .selectedByKeyboard {
    background-color: lighten(@menuSelectionColor, 5%);
    color: white;
  }

  .contextMenuIcon {
    font-size: 14px;
    margin-right: 8px;
    &.hasFaIcon {
      color: @darkGray;
    }
  }
}

.contextMenuItem {
  max-width: 420px;
  padding: 6px 10px 6px 20px;
  &.hasIcon {
    padding-left: 10px;
    &.hasFaIcon {
      padding-left: 12px;
    }
  }
  &.checkedMenuItem {
    padding-left: 4px;

    .contextMenuCheckIndicator {
      padding-right: 4px;
    }
  }
  box-sizing: border-box;
  display: flex;
  align-items: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  -webkit-user-select: none;

  &.multiContextMenuItem {
    display: flex;

    .contextMenuSubItem {
      border: 1px solid #aaaaaa;
      border-radius: @borderRadius;
      background-color: #fbfbfb;
      color: black;
      flex-grow: 1;
      margin: 1px;
      padding: 4px;
      text-align: center;
    }

    .multiItemTitle {
      margin-top: auto;
      margin-bottom: auto;
      padding-right: 10px;
    }
  }

  &.contextMenuSeparator {
    padding: 1px 0px;

    hr {
      background-color: #bbb;
      border: none;
      height: 1px;
      width: 100%;
    }
  }

 &:not([disabled]) {
    &:not(.contextMenuSeparator) {
      &:hover {
        background-color: lighten(@menuSelectionColor, 5%);
        color: white;

        .accelerator,
        .submenuIndicator {
          color: #fff;
        }
      }
    }
  }
  &[disabled] {
    color: #bbb;
  }

  .contextMenuItemText {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .submenuIndicatorContainer {
    display: flex;
    margin: auto 0 auto auto;

    .submenuIndicatorSpacer {
      flex-grow: 1;
    }

    .submenuIndicator {
      color: #676767;
      font-size: 10px;
      float: right;
      margin: auto 0 auto 5px;
    }
    .accelerator {
      .submenuIndicator;
      font-size: @contextMenuFontSize;
      margin-left: 10px;
    }
  }

  .fa {
    font-size: @bookmarksFolderIconSize;
  }
}


// Make context menu style match menubar (Windows only- for use w/ slim titlebar)
.platform--win32 {
  .contextMenuItem {
    font: menu;
    font-size: 12px;
  }

  .accelerator {
    font: menu;
    font-size: 12px !important;
  }
}
