/*
 * 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 {
	--menu-edge: rgba(0, 0, 0, 0.35);
	--menu-shadow: rgba(0, 0, 0, 0.2);
	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;
	filter: drop-shadow(0 2px 0 var(--menu-edge)) drop-shadow(0 4px 8px var(--menu-shadow))
		drop-shadow(0 8px 16px rgba(0, 0, 0, 0.12));
	outline: none;
	box-sizing: border-box;
	-webkit-app-region: no-drag;
}

:global(.theme-light) .contextMenu {
	--menu-edge: rgba(0, 0, 0, 0.1);
	--menu-shadow: rgba(0, 0, 0, 0.1);
}

.menuScroller {
	max-height: min(75vh, calc(100vh - 24px));
}

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

.item:is(:hover, [data-hovered], [data-focus-visible]):not(.disabled):not([data-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:is(:hover, [data-hovered], [data-focus-visible]):not(.disabled):not([data-disabled]) {
	background-color: var(--button-danger-fill);
	color: var(--button-danger-text);
}

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

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

.itemLabel {
	grid-column: 1;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 24px;
	min-height: 18px;
	min-width: 0;
	overflow: hidden;
}

.itemShortcut {
	color: var(--text-muted);
	font-size: 12px;
	font-family: var(--font-mono);
	white-space: nowrap;
	flex-shrink: 0;
}

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

.itemLabelContainer {
	grid-column: 1;
	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: 2;
	display: flex;
	align-items: center;
	justify-content: center;
}

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

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

.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: 1fr auto !important;
	align-items: center;
	gap: 12px;
}

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

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

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

.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 {
	--menu-edge: rgba(0, 0, 0, 0.35);
	--menu-shadow: rgba(0, 0, 0, 0.2);
	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;
	filter: drop-shadow(0 2px 0 var(--menu-edge)) drop-shadow(0 4px 8px var(--menu-shadow))
		drop-shadow(0 8px 16px rgba(0, 0, 0, 0.12));
	outline: none;
	box-sizing: border-box;
	-webkit-app-region: no-drag;
}

:global(.theme-light) .submenuPopover {
	--menu-edge: rgba(0, 0, 0, 0.1);
	--menu-shadow: rgba(0, 0, 0, 0.1);
}

.submenuScroller {
	max-height: min(75vh, calc(100vh - 24px));
}

.quickReactionsGroup {
	display: flex !important;
	flex-direction: row;
	align-items: center;
	gap: 4px;
	padding: 4px 6px 6px;
}

.quickReactionItem {
	all: unset;
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 1;
	aspect-ratio: 1;
	border-radius: 8px;
	cursor: pointer;
	background-color: var(--background-modifier-hover);
	transition: background-color 0.1s ease;
}

.quickReactionItem:hover,
.quickReactionItem[data-highlighted] {
	background-color: var(--background-modifier-selected);
}

.emojiSubmenuIcon {
	width: 22px;
	height: 22px;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.emojiSubmenuImg {
	width: 22px;
	height: 22px;
	object-fit: contain;
}

.emojiSubmenuNative {
	font-size: 22px;
	line-height: 1;
	font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
}
