/* Popup menus and context menus */

@import "popups-contents.css";
@namespace xul "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";

/* Style menus */
menupopup, panel {
	-moz-appearance: none !important;
	--panel-background: var(--gnome-menu-background) !important;
	--panel-border-radius: 12px !important;
	--panel-padding: 6px !important;
	--panel-shadow: var(--gnome-popover-shadow), 0 0 0 1px var(--gnome-popover-border-color) !important;
	/* --panel-shadow-margin: 3px 8px 13px !important; */
	--panel-separator-color: var(--gnome-popover-separator-color) !important;
	--panel-border-color: transparent !important;
	--panel-color: var(--gnome-toolbar-color) !important;
	--arrowpanel-border-radius: 12px !important;
	--arrowpanel-background: var(--gnome-menu-background) !important;
	--arrowpanel-border-color: transparent !important;
	--arrowpanel-color: var(--gnome-toolbar-color) !important;
	color: var(--gnome-toolbar-color) !important;
	padding: 2px 4px 9px !important;
}

menupopup {
	--panel-shadow: var(--gnome-popover-shadow), 0 0 0 1px var(--gnome-menu-border-color) !important;
}

.panel-arrowcontent {
	border: none !important;
}

@media (prefers-color-scheme: dark) {
	menupopup, panel {
		--panel-border-color: rgba(255, 255, 255, 0.06) !important;
		--arrowpanel-border-color: rgba(255, 255, 255, 0.06) !important;
	}

	.panel-arrowcontent {
		border: 1px solid rgba(255, 255, 255, 0.06) !important;
	}
}

menupopup label {
	color: var(--gnome-toolbar-color) !important;
}

menubar > menu > menupopup {
	border-top-left-radius: 0 !important;
	border-top-right-radius: 0 !important;
}

menuitem, menupopup menu {
	box-shadow: none !important;
}

menuitem[type="checkbox"] image,
menuitem[type="radio"] image {
	visibility: visible !important;
}

@media (-moz-gtk-non-native-menus) or (-moz-non-native-content-theme) {
	menuitem:is([type="checkbox"], [checked="true"]) .menu-iconic-icon {
		appearance: none !important;
		-moz-default-appearance: none !important;
	}

	menuitem[type="radio"] .menu-iconic-icon {
		appearance: none !important;
		-moz-default-appearance: none !important;
	}
}

menupopup menu[disabled="true"],
menuitem[disabled="true"]:hover,
menupopup menu[disabled="true"]:hover {
	background-image: none !important;
	background-color: transparent !important;
	color: var(--gnome-inactive-toolbar-color) !important;
}

/* Bookmarks Folder Popup */
#PlacesToolbar menupopup[placespopup="true"]::part(content),
#PlacesToolbar menupopup[placespopup="true"]::part(arrowscrollbox),
#PlacesToolbar menupopup {
	background: none !important;
	padding: 3px 4px 6px !important;
	margin: -3px 0 0 -12px !important;
}

/* Bookmarks Button Popup */
#BMB_bookmarksPopup {
	margin: 10px -18px !important;
	box-shadow: none !important;
}

#BMB_bookmarksPopup menupopup {
	padding: 6px !important;
}

panel:not([remote]), #BMB_bookmarksPopup {
	--arrowpanel-background: var(--gnome-popover-background) !important;
}

/* Adjust popovers position */
panel[type="arrow"] {
	appearance: none !important;
	background-color: transparent !important;
	margin: 0 -18px !important;
}

/* Style popovers */
.panel-arrowcontent .panel-arrowcontent,
.panel-header, .PanelUI-subView,
.panel-subview-body, #widget-overflow-mainView, #protections-popup-footer,
panelview {
	background: none !important;
}

panelview {
	padding: var(--panel-padding) !important;
}

#customization-panelWrapper > .panel-arrowcontent {
	box-shadow: var(--gnome-popover-shadow) !important;
	border-radius: 12px !important;
	background: var(--gnome-menu-background) !important;
}

#customization-panelWrapper > .panel-arrowbox > .panel-arrow[side="top"] {
	fill: var(--gnome-menu-background) !important;
	stroke: transparent !important;
}

.PanelUI-subView toolbarseparator:not([orient="vertical"]) {
	margin: 10px 2px !important;
}

.panel-header {
	padding: 0 0 10px 0 !important;
}
.panel-header + toolbarseparator,
#identity-popup-mainView-panel-header + toolbarseparator,
#permission-popup-mainView-panel-header + toolbarseparator,
#protections-popup-mainView-panel-header-section + toolbarseparator {
	display: none !important;
}
.panel-footer {
	background-color: transparent !important;
	display: flex;
	justify-content: flex-end;
	padding-top: 0px !important;
}
.panel-footer.panel-footer-menulike {
	border-top: 0 !important;
	margin-top: 8px !important;
}
.panel-footer toolbarseparator {
	display: none !important;
}
.proton-zap {
	border-image: unset !important;
}
.panel-subview-body,
.panel-subview-body > .panel-subview-body {
	padding: 0 !important;
}
.panel-subview-footer {
	margin-top: 10px !important;
}

/* Remove unwanted separators */
.panel-header + toolbarseparator,
#identity-popup-mainView-panel-header + toolbarseparator,
#permission-popup-mainView-panel-header + toolbarseparator,
#protections-popup-mainView-panel-header-section + toolbarseparator {
	display: none !important;
}

/* Style popovers menu buttons */
menuitem, menupopup menu,
.subviewbutton:not(#appMenu-fxa-label2, #downloadsHistory),
.toolbarbutton-1,
.protections-popup-footer-button,
.protections-popup-category,
.identity-popup-content-blocking-category,
#downloadsPanel-mainView .download-state {
	-moz-appearance: none !important;
	border-radius: 6px !important;
	color: var(--gnome-toolbar-color) !important;
	font: menu !important;
	padding: 0 6px !important;
	min-height: 28px !important;
}

#downloadsHistory {
	border-radius: 6px !important;
}

.toolbar-menupopup :is(menu, menuitem) {
	margin: 0 !important;
}

#downloadsPanel-mainView .download-state .downloadButton {
	border: none !important;
	background: none !important;
	box-shadow: none !important;
	--button-hover-bgcolor: var(--gnome-popover-button-hover-background) !important;
	--button-active-bgcolor: var(--gnome-popover-button-active-background) !important;
}

.subviewbutton,
.protections-popup-footer-button,
.protections-popup-category,
.identity-popup-content-blocking-category,
#PlacesToolbar menupopup[placespopup="true"] .bookmark-item,
.openintabs-menuitem,
.widget-overflow-list .toolbarbutton-1 {
	padding: 5px !important;
	margin: 0 !important;
}

.subviewbutton[shortcut]:after {
	opacity: 0.5 !important;
}

.subviewbutton {
  @media not (prefers-contrast) {
    &[shortcut]:not([disabled])::after {
      color: var(--gnome-toolbar-color) !important;
      opacity: 0.5 !important;
    }
  }
}

.bookmark-item .menu-right {
	fill-opacity: 1 !important;
}

/* Menu buttons disabled */
menuitem[disabled="true"],
menupopup menu[disabled="true"],
menuitem[disabled="true"][_moz-menuactive],
menupopup menu[disabled="true"][_moz-menuactive],
.subviewbutton[disabled="true"],
.subviewbutton:not(#appMenu-fxa-label2)[disabled="true"],
.toolbarbutton-1[disabled="true"],
.protections-popup-category[disabled="true"],
.identity-popup-content-blocking-category[disabled="true"] {
	opacity: 0.35 !important;
	background-image: none !important;
	background-color: transparent !important;
}

#context-navigation menuitem.menuitem-iconic[disabled="true"] {
	opacity: 1 !important;
	color: var(--gnome-inactive-toolbar-color) !important;
	background-image: var(--gnome-button-disabled-background) !important;
	border-color: var(--gnome-button-disabled-border-color) !important;
	box-shadow: none !important;
}

/* Menu buttons hover */
menuitem:not([disabled="true"]):is(:hover, [_moz-menuactive]),
menupopup menu:not([disabled="true"]):is(:hover, [_moz-menuactive]),
.subviewbutton:not([disabled="true"], #appMenu-zoom-controls2, #appMenu-fxa-label2, #downloadsHistory):hover,
.protections-popup-footer-button:not([disabled="true"]):hover,
#protections-popup-show-report-stack:hover .protections-popup-footer-button,
.protections-popup-category:not([disabled="true"]):hover,
.identity-popup-content-blocking-category:not([disabled="true"]):hover,
#PlacesToolbar .bookmark-item:is(:hover, [open], [_moz-menuactive]),
#downloadsPanel-mainView .download-state:hover {
	background-image: none !important;
	background-color: var(--gnome-popover-button-hover-background) !important;
}

/* Menu buttons active */
.subviewbutton:not([disabled="true"], #appMenu-zoom-controls2, #appMenu-fxa-label2, #downloadsHistory):active,
.protections-popup-footer-button:not([disabled="true"]):active,
#protections-popup-show-report-stack:active .protections-popup-footer-button,
.protections-popup-category:not([disabled="true"]):active,
.identity-popup-content-blocking-category:not([disabled="true"]):active,
#downloadsPanel-mainView .download-state:active {
	background-image: none !important;
	background-color: var(--gnome-popover-button-active-background) !important;
}

/* Style popover separators */
toolbarseparator, menuseparator {
	appearance: none !important;
/*	border-color: var(--gnome-popover-separator-color) !important;*/
}
#PlacesToolbar menupopup[placespopup="true"] menuseparator {
	border: none !important;
	padding: 0 !important;
}
toolbarseparator, menuseparator::before {
	border-top: 1px solid var(--gnome-popover-separator-color) !important;
}
menupopup menuseparator {
	border: none !important;
	margin: 4px 0 !important;
}
toolbarseparator[orient="vertical"] {
	margin: 0 4px !important;
}
.panel-subview-body + toolbarseparator:not([orient="vertical"]) {
	margin: 0 0 4px !important;
}
panelview > toolbarseparator:not([orient="vertical"]),
#identity-popup-clear-sitedata-footer toolbarseparator:not([orient="vertical"]),
#identity-popup-more-info-footer toolbarseparator:not([orient="vertical"]){
	margin: 4px 6px !important;
}
#identity-popup-clear-sitedata-footer toolbarseparator:not([orient="vertical"]) {
	margin-top: 0 !important;
}

/* Auto complete popups */
panel[type="autocomplete-richlistbox"] {
	background: none !important;
	border: 0 !important;
	padding: 0 !important;
	color: var(--gnome-toolbar-color) !important;
	margin: 0 !important;
}

.autocomplete-richlistbox {
	margin: 0 !important;
}

#PopupAutoComplete > richlistbox > richlistitem {
	min-height: 20px;
	border: 0;
	border-radius: 3px !important;
	padding: 0 6px !important;
}

#PopupAutoComplete > richlistbox > richlistitem:hover {
	background: var(--theme-primary-color) !important;
	color: #ffffff !important;
}

.autocomplete-richlistitem:not([type="loginsFooter"]) {
	color: var(--gnome-toolbar-color) !important;
	font: menu !important;
	margin: 0 !important;
}
.autocomplete-richlistitem:not([type="loginsFooter"]) .ac-site-icon {
	fill: var(--gnome-toolbar-color) !important;
	opacity: 0.5;
}
.autocomplete-richlistitem:not([type="loginsFooter"]):hover {
	color: #fff !important;
	background-color: Highlight !important;
}
.autocomplete-richlistitem:not([type="loginsFooter"]):hover .ac-site-icon {
	fill: #fff !important;
}

/* Fixes for menu scrollbox */
arrowscrollbox.menupopup-arrowscrollbox {
	height: 100%;
}
