/* =========================================================
   MENU POPOVER
   顶部菜单弹框

   设计要点：
   1. 左侧内边距收紧：弹框 4px + 菜单项 8px，
      文字距离面板边缘约 12px（原来是 33px）。
   2. 勾选标记只在“可勾选菜单”里占位，
      普通菜单不再为隐藏的 ✓ 预留 17px 空白。
   3. 子菜单与一级菜单共用同一套外观，避免两处样式漂移。
   ========================================================= */


/* =========================================================
   POPOVER
   ========================================================= */

.menu-popover {
    position: fixed;

    top: 0;
    left: 0;

    z-index: 1000;

    min-width: 200px;
    max-width: 340px;
    max-height: calc(100vh - 16px);

    overflow-y: auto;

    padding: 4px;

    box-sizing: border-box;

    background: #ffffff;

    border: 1px solid #e3e7ef;

    border-radius: 10px;

    box-shadow:
        0 14px 34px rgba(23, 32, 51, .13),
        0 3px 8px rgba(23, 32, 51, .06);

    color: #334155;

    transform-origin: top left;

    animation:
        menuPopoverIn
        .12s
        ease-out;
}


/* =========================================================
   HIDDEN
   ========================================================= */

.menu-popover.hidden {
    display: none;
}


/* =========================================================
   SUBMENU
   ========================================================= */

.menu-submenu {
    z-index: 1000001;

    min-width: 184px;
    max-width: min(340px, calc(100vw - 16px));

    box-shadow:
        0 16px 38px rgba(23, 32, 51, .16),
        0 4px 10px rgba(23, 32, 51, .07);
}


/* =========================================================
   MENU ITEM
   ========================================================= */

.menu-popover button {
    width: 100%;
    min-height: 32px;

    display: flex;
    align-items: center;

    box-sizing: border-box;

    /* 左侧只留 8px，配合弹框 4px，文字距面板边缘 12px */
    padding: 0 8px;

    border: 0;
    border-radius: 6px;

    background: transparent;

    color: #3f4a5d;

    font-family: inherit;
    font-size: 13px;
    font-weight: 450;

    line-height: 1;

    text-align: left;

    cursor: pointer;

    white-space: nowrap;

    user-select: none;

    transition:
        background-color .12s ease,
        color .12s ease;
}


/* =========================================================
   HOVER
   ========================================================= */

.menu-popover button:hover {
    background: #f1f4f9;

    color: #1f2937;
}


/* =========================================================
   ACTIVE
   ========================================================= */

.menu-popover button:active {
    background: #e8edf6;
}


/* =========================================================
   FOCUS
   ========================================================= */

.menu-popover button:focus-visible {
    outline: none;

    box-shadow:
        inset 0 0 0 1px
        rgba(86, 103, 232, .35);
}


/* =========================================================
   MENU LABEL
   ========================================================= */

.menu-popover .menu-item-label {
    flex: 1;

    min-width: 0;

    overflow: hidden;

    text-overflow: ellipsis;

    white-space: nowrap;
}


/* =========================================================
   CHECKED
   勾选标记

   只有“可勾选菜单”才预留位置：
   menu.js 会给这类弹框加 data-checkable="true"。
   ========================================================= */

.menu-popover[data-checkable="true"] .menu-item-label::before {
    content: "✓";

    display: inline-block;

    width: 11px;

    margin-right: 5px;

    color: #4f46e5;

    font-size: 11px;
    font-weight: 700;

    visibility: hidden;
}


.menu-popover[data-checkable="true"] .menu-item.is-checked .menu-item-label::before {
    visibility: visible;
}


/* =========================================================
   SHORTCUT
   ========================================================= */

.menu-popover .menu-item-shortcut {
    margin-left: 22px;

    color: #98a0af;

    font-size: 11px;
    font-weight: 450;

    line-height: 1;

    letter-spacing: .1px;

    white-space: nowrap;
}


/* =========================================================
   SUBMENU ARROW
   ========================================================= */

.menu-popover .menu-item-arrow {
    margin-left: 12px;

    color: #9aa2b1;

    font-size: 14px;
    font-weight: 400;

    line-height: 1;

    transform: translateY(-1px);
}


/* =========================================================
   SEPARATOR
   ========================================================= */

.menu-popover .menu-separator {
    height: 1px;

    margin: 3px 4px;

    background: #edf0f5;
}


/* =========================================================
   DISABLED
   ========================================================= */

.menu-popover button.is-disabled,
.menu-popover button:disabled {
    color: #aeb4bf;

    cursor: default;

    pointer-events: none;
}


/* =========================================================
   UNAVAILABLE
   尚未实现的菜单项

   置灰但仍然可见，鼠标悬停时给出一句说明，
   避免用户以为是“点了没反应”。
   ========================================================= */

.menu-popover button.is-unavailable {
    color: #b7bec9;

    cursor: not-allowed;
}


.menu-popover button.is-unavailable:hover {
    background: transparent;

    color: #b7bec9;
}


.menu-popover button.is-unavailable .menu-item-shortcut,
.menu-popover button.is-unavailable .menu-item-arrow {
    opacity: .55;
}


/* =========================================================
   DANGER
   ========================================================= */

.menu-popover button.is-danger {
    color: #c94b5d;
}


.menu-popover button.is-danger:hover {
    background: #fff1f3;

    color: #b9384c;
}


/* =========================================================
   MENU OPEN STATE
   ========================================================= */

.menu-bar button.is-open {
    background: #e9edf5;

    color: #1f2937;
}


/* =========================================================
   ANIMATION
   ========================================================= */

@keyframes menuPopoverIn {

    from {
        opacity: 0;

        transform:
            translateY(-3px)
            scale(.985);
    }

    to {
        opacity: 1;

        transform:
            translateY(0)
            scale(1);
    }
}


/* =========================================================
   减少动画
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

    .menu-popover {
        animation: none;
    }

}

