/*
 * Copyright (C) 2026 Fluxer Contributors
 *
 * This file is part of Fluxer.
 *
 * Fluxer is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Fluxer is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
 */

.contextMenuOverlay {
	position: fixed;
	inset: 0;
	z-index: var(--z-index-contextmenu);
	background: transparent;
	pointer-events: none;
}

.backdrop {
	position: absolute;
	inset: 0;
	background: transparent;
	pointer-events: auto;
	z-index: -1;
}

.contextMenu {
	pointer-events: auto;
	min-width: 220px;
	max-width: 360px;
	width: max-content;
	padding: 8px;
	background-color: var(--background-primary);
	border: 1px solid var(--background-modifier-accent);
	border-radius: 4px;
	box-shadow: 0 8px 16px rgba(0, 0, 0, 0.24);
	outline: none;
	box-sizing: border-box;
	overflow-x: hidden;
	scrollbar-width: thin;
	scrollbar-color: var(--background-modifier-accent) transparent;
	-webkit-app-region: no-drag;
}

.contextMenu::-webkit-scrollbar {
	width: 8px;
}

.contextMenu::-webkit-scrollbar-track {
	background: transparent;
}

.contextMenu::-webkit-scrollbar-thumb {
	background-color: var(--background-modifier-accent);
	border-radius: 4px;
	border: 2px solid transparent;
	background-clip: padding-box;
}

.contextMenu::-webkit-scrollbar-thumb:hover {
	background-color: var(--background-modifier-hover);
}

.item {
	all: unset;
	display: grid;
	grid-template-columns: 18px 1fr auto;
	align-items: center;
	gap: 12px;
	padding: 6px 8px;
	margin: 1px 0;
	border-radius: 3px;
	font-size: 14px;
	font-weight: 500;
	line-height: 18px;
	color: var(--text-secondary);
	cursor: pointer;
	box-sizing: border-box;
	min-height: 32px;
	width: 100%;
}

.item:has(.itemShortcut) {
	padding-right: 0;
}

.item:hover:not(.disabled) {
	background-color: var(--background-modifier-hover);
	color: var(--text-primary);
}

.item:focus-visible:not(.disabled) {
	background-color: var(--background-modifier-hover);
	color: var(--text-primary);
}

.item.disabled {
	color: var(--interactive-muted);
	cursor: not-allowed;
	opacity: 0.5;
}

.item.danger {
	color: var(--status-danger);
}

.item.danger:hover:not(.disabled) {
	background-color: var(--button-danger-fill);
	color: var(--button-danger-text);
}

.item.danger:focus-visible:not(.disabled) {
	background-color: var(--button-danger-fill);
	color: var(--button-danger-text);
}

.item.danger:is([data-highlighted], [data-hovered], [data-focused], [data-focus-visible], [data-selected]):not(
		.disabled
	):not([data-disabled]) {
	background-color: var(--button-danger-fill);
	color: var(--button-danger-text);
}

.itemIcon {
	width: 18px;
	height: 18px;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	grid-column: 1;
}

.itemIcon > svg {
	width: 16px;
	height: 16px;
	display: block;
	flex-shrink: 0;
}

.itemLabel {
	grid-column: 2;
	display: flex;
	align-items: center;
	min-height: 18px;
	min-width: 0;
	overflow: hidden;
}

.itemShortcut {
	grid-column: 3;
	color: var(--text-muted);
	font-size: 12px;
	font-family: var(--font-mono);
	white-space: nowrap;
	margin-left: auto;
	padding-left: 24px;
}

.item.danger:is(
		:hover,
		:focus-visible,
		[data-highlighted],
		[data-hovered],
		[data-focused],
		[data-focus-visible],
		[data-selected],
		[data-open]
	):not(.disabled):not([data-disabled])
	.itemShortcut {
	color: var(--button-danger-text);
}

.itemLabelContainer {
	grid-column: 2;
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.itemLabelText {
	display: flex;
	align-items: center;
	min-height: 18px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.itemHint {
	color: var(--text-tertiary-muted);
	font-size: 12px;
	line-height: 16px;
	margin-top: 2px;
	white-space: nowrap;
}

.submenuCaret {
	width: 16px;
	height: 16px;
	flex-shrink: 0;
	color: var(--text-secondary);
	grid-column: 3;
	display: flex;
	align-items: center;
	justify-content: center;
}

.item[data-open] {
	background-color: var(--background-modifier-hover);
	color: var(--text-primary);
}

.item.danger[data-open] {
	background-color: var(--button-danger-fill);
	color: var(--button-danger-text);
}

.item:not(:has(.itemIcon)) {
	grid-template-columns: 18px 1fr auto;
}

.item:not(:has(.itemIcon)) .itemLabel {
	grid-column: 1 / 3;
}

.item:not(:has(.itemIcon)) .submenuCaret {
	grid-column: 3;
}

.separator {
	height: 1px;
	margin: 6px 0;
	background-color: var(--background-modifier-accent);
	opacity: 0.3;
}

.separator:last-child {
	display: none;
}

.checkboxItem {
	display: grid !important;
	grid-template-columns: 18px 1fr auto !important;
	align-items: center;
	gap: 12px;
}

.checkboxItem .itemLabel {
	grid-column: 2;
}

.menuItemCheckboxLabel {
	display: flex;
	flex-direction: column;
	gap: 0.125rem;
	min-width: 0;
	overflow: hidden;
}

.menuItemCheckboxLabelPrimary {
	line-height: 1.2;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.menuItemCheckboxDescription {
	font-size: 0.75rem;
	color: var(--text-tertiary);
}

.checkboxIndicator {
	width: 20px;
	height: 20px;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	grid-column: 3;
}

.checkbox {
	width: 20px;
	height: 20px;
	border: 2px solid var(--background-header-secondary);
	border-radius: 3px;
	background-color: transparent;
	display: flex;
	align-items: center;
	justify-content: center;
	position: relative;
}

.checkboxChecked {
	background-color: var(--brand-primary);
	border-color: var(--brand-primary);
}

.checkboxChecked::after {
	content: '';
	position: absolute;
	left: 50%;
	top: 50%;
	width: 5px;
	height: 10px;
	border: solid white;
	border-width: 0 2.5px 2.5px 0;
	transform: translate(-50%, -60%) rotate(45deg);
}

.item.danger:hover .checkbox {
	border-color: #ffffff;
	background-color: transparent;
}

.item.danger:hover .checkboxChecked {
	background-color: #ffffff;
	border-color: #ffffff;
}

.item.danger:hover .checkboxChecked::after {
	border-color: var(--status-danger);
}

.group {
	display: flex;
	flex-direction: column;
}

.groupLabel {
	padding: 6px 8px 2px;
	margin-top: 2px;
	font-size: 11px;
	font-weight: 600;
	line-height: 16px;
	text-transform: uppercase;
	letter-spacing: 0.02em;
	color: var(--text-secondary);
}

.ariaMenu {
	outline: none;
}

.submenuPopover {
	pointer-events: auto !important;
	z-index: 2147483647 !important;
	min-width: 220px;
	max-width: 360px;
	width: max-content;
	padding: 8px;
	background-color: var(--background-primary);
	border: 1px solid var(--background-modifier-accent);
	border-radius: 4px;
	box-shadow: 0 8px 16px rgba(0, 0, 0, 0.24);
	outline: none;
	box-sizing: border-box;
	overflow-x: hidden;
	scrollbar-width: thin;
	scrollbar-color: var(--background-modifier-accent) transparent;
	-webkit-app-region: no-drag;
}

.submenuPopover::-webkit-scrollbar {
	width: 8px;
}

.submenuPopover::-webkit-scrollbar-track {
	background: transparent;
}

.submenuPopover::-webkit-scrollbar-thumb {
	background-color: var(--background-modifier-accent);
	border-radius: 4px;
	border: 2px solid transparent;
	background-clip: padding-box;
}

.submenuPopover::-webkit-scrollbar-thumb:hover {
	background-color: var(--background-modifier-hover);
}
