/* ── Context Menu 容器 ── */
.wk-contextmenus {
    position: fixed;
    top: 100px;
    left: 0;
    background: #FFFFFF;
    border: 1px solid #E5E6EB;
    z-index: 99;
    min-width: 160px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 0;
    transform: scale(0.92);
    opacity: 0;
    transition: opacity 0.15s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.15s cubic-bezier(0.16, 1, 0.3, 1);
    visibility: hidden;
}

body[theme-mode=dark] .wk-contextmenus {
    background: var(--wk-bg-surface);
    box-shadow: var(--wk-shadow-lg), var(--wk-shadow-sm);
}

.wk-contextmenus-open {
    transform: scale(1);
    opacity: 1;
    visibility: visible;
}

/* ── 菜单列表 ── */
.wk-contextmenus ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

/* ── 菜单项 ── */
.wk-contextmenus li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px;
    height: 40px;
    cursor: pointer;
    font-size: 14px;
    font-family: var(--wk-font-sans, -apple-system, sans-serif);
    color: #1D2129;
    transition: background 0.15s ease;
    position: relative;
    user-select: none;
}

.wk-contextmenus li:hover {
    background: #F2F3F5;
}

body[theme-mode=dark] .wk-contextmenus li {
    color: var(--wk-text-primary);
}

body[theme-mode=dark] .wk-contextmenus li:hover {
    background: var(--wk-bg-hover);
}

/* ── 图标 ── */
.wk-contextmenus li .ctx-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    stroke: #4E5969;
    stroke-width: 1.7;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ── 危险项 ── */
.wk-contextmenus li.wk-ctx-danger {
    color: var(--wk-color-error);
}

.wk-contextmenus li.wk-ctx-danger .ctx-icon {
    stroke: var(--wk-color-error);
}

/* ── 子菜单箭头 ── */
.wk-ctx-arrow {
    margin-left: auto;
    width: 12px;
    height: 12px;
    stroke: #4E5969;
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

/* ── 子菜单 ── */
.wk-ctx-submenu {
    position: absolute;
    left: calc(100% + 4px);
    right: auto;
    top: 0;
    background: #FFFFFF;
    border: 1px solid #E5E6EB;
    min-width: 160px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 0;
    z-index: 100;
    display: none;
}

body[theme-mode=dark] .wk-ctx-submenu {
    background: var(--wk-bg-surface);
    box-shadow: var(--wk-shadow-lg), var(--wk-shadow-sm);
}

.wk-contextmenus li:hover > .wk-ctx-submenu {
    display: block;
}

/* 隐形桥接：覆盖父项与子菜单之间的 4px 间隙，
   防止鼠标对角线移动时短暂离开父 li 触发 :hover 失效、子菜单消失 */
.wk-ctx-submenu::before {
    content: "";
    position: absolute;
    top: -4px;
    bottom: -4px;
    left: -8px;
    width: 8px;
}

/* 子菜单向左展开（靠近右侧视口边缘时） */
.wk-contextmenus-flip-submenu li:hover > .wk-ctx-submenu {
    left: auto;
    right: calc(100% + 4px);
}

.wk-contextmenus-flip-submenu .wk-ctx-submenu::before {
    left: auto;
    right: -8px;
}

.wk-ctx-submenu li {
    padding: 0 16px;
    height: 40px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: #1D2129;
    transition: background 0.15s ease;
}

.wk-ctx-submenu li:hover {
    background: #F2F3F5;
}

body[theme-mode=dark] .wk-ctx-submenu li {
    color: var(--wk-text-primary);
}

body[theme-mode=dark] .wk-ctx-submenu li:hover {
    background: var(--wk-bg-hover);
}

/* ── 分隔线 ── */
.wk-ctx-sep {
    height: 1px;
    background: #F2F3F5;
    margin: 4px 0;
}

/* ── Mask ── */
.wk-contextmenus-mask {
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
    visibility: hidden;
    z-index: 98;
}
