/* Keymap Styles - 严格参考原始 KeyMap.html 的样式 */
@import url("https://fonts.googleapis.com/css2?family=Segoe+UI:wght@400;500;600&display=swap");

/* Color groups for different key types - Fluent Design inspired */
/* CapsLock和`键 - 玫红色 */
.capslock-group {
	background: rgba(232, 17, 75, 0.12) !important;
	border-color: rgba(232, 17, 75, 0.2) !important;
	color: #e8114b !important;
}

/* 导航键 UIOPHJKLWB和Alt/Option - 蓝色 */
.navigation-group {
	background: rgba(0, 120, 212, 0.12) !important;
	border-color: rgba(0, 120, 212, 0.2) !important;
	color: #0078d4 !important;
}

/* 编辑键 ZXCVAY - 绿色 */
.edit-group {
	background: rgba(16, 124, 16, 0.12) !important;
	border-color: rgba(16, 124, 16, 0.2) !important;
	color: #107c10 !important;
}

/* 应用启动键 QRT - 橙色 */
.app-group {
	background: rgba(255, 140, 0, 0.12) !important;
	border-color: rgba(255, 140, 0, 0.2) !important;
	color: #ff8c00 !important;
}

/* 删除键 NM,./ - 红色 */
.delete-group {
	background: rgba(196, 43, 28, 0.12) !important;
	border-color: rgba(196, 43, 28, 0.2) !important;
	color: #c42b1c !important;
}

/* 未激活的按键 - 灰色 */
.inactive {
	background: rgba(96, 94, 92, 0.08) !important;
	border-color: rgba(96, 94, 92, 0.15) !important;
	color: #605e5c !important;
	opacity: 0.7;
	pointer-events: none;
}

/* Tooltip styles */
[data-tooltip] {
	position: relative;
}

[data-tooltip]::after {
	content: attr(data-tooltip);
	position: absolute;
	bottom: 100%;
	left: 50%;
	transform: translateX(-50%);
	margin-bottom: 8px;
	padding: 10px 14px;
	background: rgba(0, 0, 0, 0.9);
	color: white;
	font-family:
		"JetBrains Mono", "Fira Code", "Cascadia Code", "SF Mono", "Monaco", "Inconsolata", "Roboto Mono", "Source Code Pro", "Ubuntu Mono", "Liberation Mono", monospace;
	font-size: 13px;
	font-weight: 500;
	border-radius: 8px;
	opacity: 0;
	visibility: hidden;
	transition:
		opacity 0.3s ease,
		visibility 0.3s ease,
		transform 0.3s ease;
	pointer-events: none;
	z-index: 1000;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
	min-width: 8rem;
	max-width: 500px;
	white-space: nowrap;
	text-align: center;
	line-height: 1.4;
	letter-spacing: 0.02em;
}

[data-tooltip]::before {
	content: "";
	position: absolute;
	bottom: 100%;
	left: 50%;
	transform: translateX(-50%);
	margin-bottom: 2px;
	border: 4px solid transparent;
	border-top-color: rgba(0, 0, 0, 0.9);
	opacity: 0;
	visibility: hidden;
	transition:
		opacity 0.3s ease,
		visibility 0.3s ease;
	pointer-events: none;
	z-index: 1000;
}

[data-tooltip]:hover::after,
[data-tooltip]:hover::before {
	opacity: 1;
	visibility: visible;
	transform: translateX(-50%) translateY(-2px);
}

/* Keymap specific styles */
#board {
	background: rgba(255, 255, 255, 0.9);
	backdrop-filter: blur(10px);
	width: 62rem;
	max-width: 95vw;
	border-radius: 1.5rem;
	box-sizing: border-box;
	padding: 2rem 1.5rem;
	position: relative;
	box-shadow:
		0 8px 32px rgba(0, 0, 0, 0.1),
		0 2px 8px rgba(0, 0, 0, 0.05);
	border: 1px solid rgba(255, 255, 255, 0.2);
	margin: 0 auto;
}

.row {
	display: flex;
	justify-content: space-between;
	margin-bottom: 0.5rem;
}

.row:last-child {
	margin-bottom: 0;
}

#board button {
	height: 3.5rem;
	width: 3.5rem;
	border-radius: 0.5rem;
	color: #2c3e50;
	background: rgba(255, 255, 255, 0.8);
	margin: 0.2rem;
	font-size: 0.7rem;
	font-weight: 500;
	line-height: 1.3;
	box-sizing: border-box;
	border: 1px solid rgba(0, 0, 0, 0.08);
	cursor: pointer;
	outline: none;
	user-select: none;
	position: relative;
	font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
	transition: all 0.2s ease;
	backdrop-filter: blur(5px);
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	text-align: center;
	padding: 0.3rem;
}

#board button:hover {
	background: rgba(255, 255, 255, 0.95);
	transform: translateY(-1px);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#board button:active {
	transform: translateY(0);
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* 主题颜色 */
#board button.primary {
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	color: white;
	border: 1px solid rgba(255, 255, 255, 0.3);
}

#board button.primary:hover {
	background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
}

#board button.secondary {
	background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
	color: white;
	border: 1px solid rgba(255, 255, 255, 0.3);
}

#board button.secondary:hover {
	background: linear-gradient(135deg, #ed64a6 0%, #e53e3e 100%);
}

#board button.accent {
	background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
	color: white;
	border: 1px solid rgba(255, 255, 255, 0.3);
}

#board button.accent:hover {
	background: linear-gradient(135deg, #3182ce 0%, #0bc5ea 100%);
}

#board button.warning {
	background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
	color: #2d3748;
	border: 1px solid rgba(255, 255, 255, 0.3);
}

#board button.warning:hover {
	background: linear-gradient(135deg, #ed64a6 0%, #f6e05e 100%);
}

/* 不活跃按键样式 */
#board button.inactive {
	background: rgba(200, 200, 200, 0.4);
	color: #888;
	border: 1px solid rgba(0, 0, 0, 0.05);
}

#board button.inactive:hover {
	background: rgba(200, 200, 200, 0.5);
	transform: none;
	box-shadow: none;
}

/* 功能分组颜色 - Fluent Design风格 - 淡色版本 */
/* CapsLock相关 - 淡玫红色 */
#board button.capslock-group {
	background: linear-gradient(135deg, #f8bbd9 0%, #f48fb1 100%);
	color: #880e4f;
	border: 1px solid rgba(255, 255, 255, 0.5);
}

#board button.capslock-group:hover {
	background: linear-gradient(135deg, #f06292 0%, #e91e63 100%);
	color: white;
}

/* 导航组 (UIOPHJKLWB + Alt/Option) - 淡蓝色 */
#board button.navigation-group {
	background: linear-gradient(135deg, #bbdefb 0%, #90caf9 100%);
	color: #0d47a1;
	border: 1px solid rgba(255, 255, 255, 0.5);
}

#board button.navigation-group:hover {
	background: linear-gradient(135deg, #64b5f6 0%, #2196f3 100%);
	color: white;
}

/* 编辑组 (ZXCVAY) - 淡绿色 */
#board button.edit-group {
	background: linear-gradient(135deg, #c8e6c9 0%, #a5d6a7 100%);
	color: #1b5e20;
	border: 1px solid rgba(255, 255, 255, 0.5);
}

#board button.edit-group:hover {
	background: linear-gradient(135deg, #81c784 0%, #4caf50 100%);
	color: white;
}

/* 应用组 (QRT) - 淡紫色 */
#board button.app-group {
	background: linear-gradient(135deg, #e1bee7 0%, #ce93d8 100%);
	color: #4a148c;
	border: 1px solid rgba(255, 255, 255, 0.5);
}

#board button.app-group:hover {
	background: linear-gradient(135deg, #ba68c8 0%, #9c27b0 100%);
	color: white;
}

/* 删除组 (NM,./) - 淡橙色 */
#board button.delete-group {
	background: linear-gradient(135deg, #ffe0b2 0%, #ffcc80 100%);
	color: #bf360c;
	border: 1px solid rgba(255, 255, 255, 0.5);
}

#board button.delete-group:hover {
	background: linear-gradient(135deg, #ffb74d 0%, #ff9800 100%);
	color: white;
}

.key-description {
	font-size: 0.66rem;
	font-weight: 500;
	margin-bottom: 0.2rem;
	overflow: hidden;
	display: -webkit-box;
	line-clamp: 2;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	line-height: 1.1;
	transform-origin: center;
	white-space: normal;
	text-align: center;
	width: 100%;
}

/* 长文本自动缩放 */
.key-description.long-text {
	font-size: 0.55rem;
	line-clamp: 3;
	-webkit-line-clamp: 3;
}

.key-description.extra-long-text {
	font-size: 0.45rem;
	line-clamp: 3;
	-webkit-line-clamp: 3;
}

.key-description.super-long-text {
	font-size: 0.4rem;
	line-clamp: 4;
	-webkit-line-clamp: 4;
	line-height: 1;
}

.physical-key {
	position: absolute;
	bottom: 0.2rem;
	right: 0.3rem;
	font-size: 0.5rem;
	font-weight: 600;
	opacity: 0.7;
	background: rgba(0, 0, 0, 0.05);
	padding: 0.1rem 0.3rem;
	border-radius: 0.2rem;
}

/* 特殊按键样式 */
#board button.text {
	font-size: 0.7rem;
	font-weight: 600;
	display: flex;
	align-items: center;
	justify-content: center;
}

.left {
	text-align: left;
	padding-left: 1rem;
	justify-content: flex-start;
}

.right {
	text-align: right;
	padding-right: 1rem;
	justify-content: flex-end;
}

/* SVG 图标样式 */
#board button svg {
	width: 1.2rem;
	height: 1.2rem;
}

/* 主题选择器 */
.theme-selector {
	position: absolute;
	top: -1rem;
	right: 1rem;
	display: flex;
	gap: 0.5rem;
}

.theme-btn {
	width: 2rem;
	height: 2rem;
	border-radius: 50%;
	border: 2px solid rgba(255, 255, 255, 0.8);
	cursor: pointer;
	transition: all 0.2s ease;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 0.8rem;
	font-weight: 600;
	color: #fff;
}

.theme-btn:hover {
	transform: scale(1.1);
}

.theme-btn.active {
	border-color: #2c3e50;
	box-shadow: 0 0 0 2px rgba(44, 62, 80, 0.3);
}

.theme-mac {
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.theme-windows {
	background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

/* 按键尺寸变体 */
#board button.wide {
	width: 5rem;
}

#board button.wider {
	width: 6rem;
}

#board button.widest {
	width: 7rem;
}

#board button.space {
	width: 12rem;
}

/* 原版的尺寸样式，使用 flex 代替固定宽度 */
#board button[style*="flex:1"] {
	flex: 1;
}

#board button[style*="flex:2"] {
	flex: 2;
}

#board button[style*="flex:3"] {
	flex: 3;
}

#board button[style*="flex:8"] {
	flex: 8;
}

#board button[style*="flex:9"] {
	flex: 9;
}

#board button[style*="flex:2.0"] {
	flex: 2;
}

/* 响应式设计 */
@media (max-width: 1200px) {
	#board {
		width: 55rem;
		padding: 1.5rem 1rem;
	}
}

@media (max-width: 768px) {
	#board {
		width: 100%;
		max-width: 90vw;
		padding: 1rem 0.5rem;
		border-radius: 1rem;
	}

	#board button {
		height: 2.8rem;
		width: 2.8rem;
		font-size: 0.7rem;
		margin: 0.1rem;
	}

	.theme-selector {
		top: -2.5rem;
		right: 0.5rem;
	}

	.theme-btn {
		width: 1.5rem;
		height: 1.5rem;
		font-size: 0.5rem;
	}
}

/* 方向键样式 */
.arrows {
	display: flex;
	flex-direction: column;
}

.arrows .row {
	justify-content: center;
	margin-bottom: 0;
}
