/* ============================================================
   Mass Actions Menu V2 — Selection bar + dropdown popover
   Scope: ONLY /employeeslist-v2 (V1 list is untouched).
   Namespace prefix: mam-* (Mass Actions Menu).

   Popover height adapts to viewport: JS measures the room between
   the trigger and the viewport edge and sets `max-height` inline.
   Content scrolls internally when the option list would overflow
   the available space.
   ============================================================ */

/* ─── Selection bar (above the grid, conditionally rendered) ── */
.mam-selbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 10px;
    background: var(--is-brand-blue-100);
    border: 1px solid #cfe4f4;
    border-radius: var(--is-radius-md);
    font-family: var(--is-font-sans);
    color: var(--is-fg-1);
}

.mam-selbar__left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    min-width: 0;
}

.mam-selbar__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 26px;
    padding: 0 10px;
    background: var(--is-brand-blue);
    color: #fff;
    font: 700 12px var(--is-font-mono);
    border-radius: 999px;
    flex-shrink: 0;
}

.mam-selbar__text {
    font: 600 13.5px var(--is-font-sans);
    color: var(--is-brand-blue-700);
}

.mam-selbar__text small {
    font: 500 12px var(--is-font-sans);
    color: var(--is-fg-3);
    margin-left: 6px;
}

.mam-selbar__selectall {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 0;
    padding: 0;
    color: var(--is-brand-blue-700);
    font: 600 12.5px var(--is-font-sans);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.mam-selbar__selectall:hover { color: var(--is-brand-blue); }

.mam-selbar__right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Mass actions trigger button + chevron */
.mam-trigger-wrap {
    position: relative;
    display: inline-flex;
}

.mam-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--is-brand-blue);
    color: #fff;
    border: 0;
    font: 700 13px var(--is-font-sans);
    padding: 8px 16px;
    border-radius: var(--is-radius-sm);
    cursor: pointer;
    transition: background .12s;
    white-space: nowrap;
}
.mam-trigger:hover { background: var(--is-brand-blue-700); }
.mam-trigger:focus-visible {
    outline: 2px solid var(--is-action-blue);
    outline-offset: 2px;
}
.mam-trigger > i { font-size: 11px; }
.mam-trigger__chev { margin-left: 2px; font-size: 9px; }

/* ─── Dropdown popover ──────────────────────────────────────── */
.mam-menu {
    position: absolute;
    z-index: 9000;
    width: 340px;
    max-width: calc(100vw - 16px);
    padding: 8px;
    background: #fff;
    border: 1px solid var(--is-border-1);
    border-radius: var(--is-radius-md);
    box-shadow: var(--is-shadow-3);
    font-family: var(--is-font-sans);
    color: var(--is-fg-1);
    /* Static viewport-bounded max-height applied from the FIRST paint
       so the popover never extends past the viewport bottom and never
       causes a transient page-level scrollbar. The 320 px reserve
       covers the page header + filter bar above the trigger plus a
       small safety margin; on a 1080 px screen this still gives the
       popover ~760 px which fits all 11 options without internal
       scroll, on a 768 px screen it caps at ~448 px and the content
       scrolls internally. Scroll inside the popover is whitelisted in
       the JS scroll handler so it does NOT close the menu. */
    max-height: calc(100vh - 320px);
    overflow-y: auto;
}

/* Default placement = bottom-end (right edge aligned with button) */
.mam-menu--bottom-end {
    top: calc(100% + 4px);
    right: 0;
    bottom: auto;
    left: auto;
}

/* Auto-flip = top-end (above button, right edge aligned) */
.mam-menu--top-end {
    bottom: calc(100% + 4px);
    right: 0;
    top: auto;
    left: auto;
}

.mam-menu__head {
    padding: 8px 10px 10px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--is-border-1);
}
.mam-menu__head h4 {
    margin: 0 0 2px;
    font: 700 13px var(--is-font-sans);
    color: var(--is-fg-1);
}
.mam-menu__head p {
    margin: 0;
    font: 500 11.5px var(--is-font-sans);
    color: var(--is-fg-3);
}

.mam-menu__group {
    padding: 6px 10px 4px;
    font: 700 10px var(--is-font-sans);
    color: var(--is-fg-3);
    text-transform: uppercase;
    letter-spacing: .06em;
}

.mam-menu__opt {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 0;
    background: transparent;
    width: 100%;
    text-align: left;
    border-radius: var(--is-radius-sm);
    cursor: pointer;
    color: var(--is-fg-1);
    font-family: var(--is-font-sans);
}
.mam-menu__opt:hover,
.mam-menu__opt:focus-visible {
    background: var(--is-bg-surface-3);
    outline: none;
}
.mam-menu__opt.is-focused { background: var(--is-bg-surface-3); }

.mam-menu__opt-icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: var(--is-radius-sm);
    background: var(--is-bg-surface-3);
    color: var(--is-fg-2);
    display: inline-grid;
    place-items: center;
    font-size: 12px;
}

.mam-menu__opt-text {
    flex: 1;
    min-width: 0;
}
.mam-menu__opt-text b {
    display: block;
    font: 600 12.5px var(--is-font-sans);
    color: var(--is-fg-1);
}
.mam-menu__opt-text small {
    display: block;
    margin-top: 1px;
    font: 500 11px var(--is-font-sans);
    color: var(--is-fg-3);
}

/* Danger zone — red icon tile + red row tint on hover */
.mam-menu__opt.is-danger .mam-menu__opt-icon {
    background: var(--is-danger-bg);
    color: var(--is-danger);
}
.mam-menu__opt.is-danger .mam-menu__opt-text b { color: var(--is-danger); }
.mam-menu__opt.is-danger:hover,
.mam-menu__opt.is-danger:focus-visible,
.mam-menu__opt.is-danger.is-focused { background: var(--is-danger-bg); }

/* NEW badge on the right edge of an option */
.mam-newchip {
    display: inline-flex;
    align-items: center;
    height: 18px;
    padding: 0 7px;
    margin-left: auto;
    background: var(--is-brand-orange-100);
    color: var(--is-brand-orange-600);
    font: 700 9.5px var(--is-font-sans);
    letter-spacing: .04em;
    text-transform: uppercase;
    border-radius: 999px;
    flex-shrink: 0;
}

/* ─── Responsive ─────────────────────────────────────────────
   Tablet keeps inline layout (flex-wrap handles overflow).
   Mobile (≤600px) per MobileLayoutStandards §6:
   - selection bar: full-width, stacked count/label/cta column.
   - popover: capped at calc(100vw - 16px), anchored under trigger.
*/
@media (max-width: 600px) {
    .mam-selbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px;
    }
    .mam-selbar__left {
        justify-content: flex-start;
    }
    .mam-selbar__right { width: 100%; }
    .mam-trigger-wrap { width: 100%; }
    .mam-trigger {
        width: 100%;
        justify-content: center;
        padding: 10px 16px;
        min-height: 40px;
    }
    .mam-menu {
        width: calc(100vw - 16px);
        max-width: calc(100vw - 16px);
        right: auto;
        left: 0;
        /* Tighter reserve on mobile — the page header collapses to
           a smaller footprint so the popover gets a bit more room. */
        max-height: calc(100vh - 240px);
    }
    .mam-menu__opt { min-height: 44px; }
}
