/********************************************************************************
 * Copyright (C) 2017, 2018 TypeFox and others.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v. 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0.
 *
 * This Source Code may also be made available under the following Secondary
 * Licenses when the conditions for such availability set forth in the Eclipse
 * Public License v. 2.0 are satisfied: GNU General Public License, version 2
 * with the GNU Classpath Exception which is available at
 * https://www.gnu.org/software/classpath/license.html.
 *
 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
 ********************************************************************************/

/*-----------------------------------------------------------------------------
| Variables
|----------------------------------------------------------------------------*/

:root {
  --theia-private-menubar-height: 32px;
  --theia-private-menu-item-height: 24px;
  --theia-menu-z-index: 10000;
}

/*-----------------------------------------------------------------------------
| MenuBar
|----------------------------------------------------------------------------*/

.lm-Widget.lm-MenuBar {
  display: flex;
  align-items: center; 
  padding-left: 5px;
  font-size: var(--theia-ui-font-size1);
}

.lm-MenuBar-menu {
  transform: translateY(calc(-2 * var(--theia-border-width)));
}

.lm-MenuBar-content {
  display: flex;
  align-items: center; 
}

.lm-MenuBar-item {
  padding: 0px 8px;
  line-height: var(--theia-content-line-height);
  border-radius: 4px;
}

.lm-MenuBar-item .lm-MenuBar-itemLabel {
  white-space: pre;
}

.lm-MenuBar-item.lm-mod-active {
  background: var(--theia-menubar-selectionBackground);
  color: var(--theia-menubar-selectionForeground);
  opacity: 1;
}

.lm-MenuBar.lm-mod-active .lm-MenuBar-item.lm-mod-active {
  z-index: calc(var(--theia-menu-z-index) - 1);
  background: var(--theia-menubar-selectionBackground);
  border-left: var(--theia-border-width) solid
    var(--theia-menubar-selectionBorder);
  border-right: var(--theia-border-width) solid
    var(--theia-menubar-selectionBorder);
}

.lm-MenuBar-item.lm-mod-disabled {
  opacity: var(--theia-mod-disabled-opacity);
}

.lm-MenuBar-item.lm-type-separator {
  margin: 2px;
  padding: 0;
  border: none;
  border-left: var(--theia-border-width) solid
    var(--theia-menu-separatorBackground);
}

.lm-MenuBar-itemMnemonic {
  text-decoration: underline;
}

#theia-top-panel {
  background: var(--theia-titleBar-activeBackground);
  color: var(--theia-titleBar-activeForeground);
  display: flex;
  min-height: var(--theia-private-menubar-height);
  border-bottom: 1px solid var(--theia-titleBar-border);
}
#theia-top-panel:window-inactive,
#theia-top-panel:-moz-window-inactive {
  background: var(--theia-titleBar-inactiveBackground);
  color: var(--theia-titleBar-inactiveForeground);
}

/*-----------------------------------------------------------------------------
| Menu
|----------------------------------------------------------------------------*/

.lm-Menu {
  z-index: var(--theia-menu-z-index);
  padding: 4px;
  background: var(--theia-menu-background);
  color: var(--theia-menu-foreground);
  font-size: var(--theia-ui-font-size1);
  box-shadow: 0px 1px 6px var(--theia-widget-shadow);
  border: 1px solid var(--theia-menu-border);
  border-radius: 5px;
}

/* Remove focus outline for menu and context menu items */
.lm-Menu:focus,
.lm-Menu-item:focus,
.lm-MenuBar-item:focus {
  outline: none;
}

.lm-Menu-item {
  min-height: var(--theia-private-menu-item-height);
  max-height: var(--theia-private-menu-item-height);
  padding: 0px;
  /** 
   * FireFox adds 0.5px to all menu items for some reason
   * Subtracting that amount fixes the behavior on FireFox and doesn't introduce issues on Chromium
   */
  line-height: calc(var(--theia-private-menu-item-height) - 0.5px);
  overflow: hidden;
}

.lm-Menu-item.lm-mod-active {
  color: var(--theia-menu-selectionForeground);
  border: thin solid var(--theia-menu-selectionBorder);
  opacity: 1;
  cursor: pointer;
}

/** 
 * We cannot apply border-radius on items with `display: table-row` 
 * So we apply it to its first and last child
 */

.lm-Menu-item.lm-mod-active > div {
  background: var(--theia-menu-selectionBackground);
}

.lm-Menu-item.lm-mod-active > div:first-child {
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
}

.lm-Menu-item.lm-mod-active > div:last-child {
  border-top-right-radius: 4px;
  border-bottom-right-radius: 4px;
}

.lm-Menu-item.lm-mod-disabled {
  opacity: var(--theia-mod-disabled-opacity);
}

.lm-Menu-itemIcon {
  width: 21px;
  padding: 0px 2px 0px 4px;
  height: var(--theia-private-menu-item-height);
}

.lm-Menu-itemLabel {
  padding: 0px 32px 0px 2px;
}

.lm-Menu-itemMnemonic {
  text-decoration: underline;
}

.lm-Menu-itemShortcut {
  padding: 0px;
}

.lm-Menu-itemSubmenuIcon {
  width: var(--theia-icon-size);
  padding: 0px 10px 0px 0px;
}

.lm-Menu-item[data-type="separator"] > div {
  padding: 0;
  height: 9px;
  opacity: 0.36;
}

.lm-Menu-item[data-type="separator"] > div::after {
  content: "";
  display: block;
  position: relative;
  top: 4px;
  border-top: var(--theia-border-width) solid
    var(--theia-menu-separatorBackground);
}

.lm-Menu-item[data-type="separator"] > div:first-child:after {
  margin-left: -4px;
}

.lm-Menu-item[data-type="separator"] > div:last-child::after {
  margin-right: -4px;
}

.lm-Menu-itemIcon::before,
.lm-Menu-itemSubmenuIcon::before {
  font: normal normal normal 16px/1 codicon;
  display: inline-block;
  text-decoration: none;
  text-rendering: auto;
  text-align: center;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  transform: translateY(20%);
}

.lm-Menu-item.lm-mod-toggled > .lm-Menu-itemIcon::before {
  content: "\eab2";
  transform: scale(0.8) translateY(20%);
}

.lm-Menu-item[data-type="submenu"] > .lm-Menu-itemSubmenuIcon::before {
  content: "\eab6";
}
