/**
 * Row action menus in tables, modernised without touching the 41 pages that build them (LXP-2605): Metronic's
 * "Actions ▾" button and its dropdown (data-kt-menu-trigger + .menu-sub-dropdown inside a table) take the look of the
 * shared ⋯ menu (components.css .ux2-menu). Only menus inside tables; the header's own menus are left alone.
 *   html.ux2-rowmenu        the dropdown: rounded, soft shadow, roomy rows with grey icons, brand on hover; Delete /
 *                           Remove (.text-danger, or a trash icon) in red at the bottom, after a divider
 *   html.ux2-rowmenu-dots   the trigger as a quiet ⋯ icon (the word "Actions" stays for screen readers); without it,
 *                           "Actions ▾" as a ghost button
 * Pages move to the real ⋯ trigger and .ux2-menu one by one with the Metronic clean-up (LXP-2598).
 */

/* ---------- The trigger ---------- */
html.ux2-rowmenu table [data-kt-menu-trigger].btn {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    min-height: 32px;
    padding: 4px 10px 4px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ux2k-ink-2, #3f4254) !important;
    background: #fff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgb(15 23 42 / .06);
    transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease, color .15s ease;
}

html.ux2-rowmenu table [data-kt-menu-trigger].btn:hover,
html.ux2-rowmenu table [data-kt-menu-trigger].btn.show,
html.ux2-rowmenu table [data-kt-menu-trigger].btn.active,
html.ux2-rowmenu table [data-kt-menu-trigger].btn.menu-dropdown {
    color: var(--ux2k-ink, #010b13) !important;
    background: #f8fafc !important;
    border-color: #cbd5e1 !important;
}

html.ux2-rowmenu table [data-kt-menu-trigger].btn .svg-icon svg {
    width: 14px;
    height: 14px;
}

/* ⋯ instead of "Actions ▾": the label is kept (font-size 0) so it's still announced. The same white key as the
   question bank's ⋯ (.ux2-btn-ghost with btn-rich.css), at rest, pointed at and pressed (LXP-2653).
   "body" and :not(.ux2-btn) outrank the tables' own row-action look (datatables.css, loaded later) and Metronic's
   shadow-less .btn; the new .ux2-btn ⋯ already looks like this. */
html.ux2-rowmenu.ux2-rowmenu-dots body table [data-kt-menu-trigger].btn:not(.ux2-btn) {
    gap: 0; /* the hidden label is still a flex item: a gap would push the dots off centre */
    justify-content: center;
    width: 32px !important;
    min-width: 32px;
    height: 32px !important;
    min-height: 32px;
    padding: 0 !important;
    line-height: 1;
    font-size: 0;
    color: var(--ux2k-ink-2, #3f4254) !important;
    background: linear-gradient(180deg, #fff 0%, #fafbfc 100%) !important;
    border: 1px solid var(--ux2k-line, #e4e7ec) !important;
    border-radius: 8px;
    box-shadow: inset 0 -1px 0 rgb(9 10 12 / .05), 0 1px 2px rgb(9 10 12 / .08) !important;
}

/* One ⋯ only: the tables' script adds its own dots icon (datatables.js .ux2-act-dots); the ::before below is the one */
html.ux2-rowmenu.ux2-rowmenu-dots body table [data-kt-menu-trigger].btn .svg-icon,
html.ux2-rowmenu.ux2-rowmenu-dots body table [data-kt-menu-trigger].btn > :is(i, svg) {
    display: none !important;
}

html.ux2-rowmenu.ux2-rowmenu-dots body table [data-kt-menu-trigger].btn::before {
    font-family: bootstrap-icons !important;
    display: block;
    font-size: 14px;
    line-height: 1;
    content: "\f5d4"; /* bi-three-dots */
}

/* Pointed at or open: the white key lifts onto a soft slate shadow; pressed, it sinks in (btn-rich.css) */
html.ux2-rowmenu.ux2-rowmenu-dots body table [data-kt-menu-trigger].btn:hover,
html.ux2-rowmenu.ux2-rowmenu-dots body table [data-kt-menu-trigger].btn.show,
html.ux2-rowmenu.ux2-rowmenu-dots body table [data-kt-menu-trigger].btn.active,
html.ux2-rowmenu.ux2-rowmenu-dots body table [data-kt-menu-trigger].btn.menu-dropdown {
    color: var(--ux2k-ink, #010b13) !important;
    background: linear-gradient(180deg, #fff 0%, #f8fafc 100%) !important;
    border-color: #e2e8f0 !important;
    box-shadow: inset 0 -1px 0 rgb(15 23 42 / .05), 0 2px 4px rgb(15 23 42 / .06), 0 6px 14px -6px rgb(15 23 42 / .16) !important;
}

html.ux2-rowmenu.ux2-rowmenu-dots body table [data-kt-menu-trigger].btn:active {
    background: #fff !important;
    box-shadow: inset 0 1px 3px rgb(9 10 12 / .12) !important;
}

/* ---------- The menu ---------- */
html.ux2-rowmenu table .menu-sub-dropdown {
    min-width: 200px;
    padding: 6px !important;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 12px 32px -8px rgb(15 23 42 / .18), 0 2px 6px rgb(15 23 42 / .06);
}

html.ux2-rowmenu table .menu-sub-dropdown .menu-item {
    padding: 0 !important;
}

html.ux2-rowmenu table .menu-sub-dropdown .menu-link {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 0 !important;
    padding: 8px 10px !important;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--ux2k-ink-2, #3f4254);
    border-radius: 8px;
}

html.ux2-rowmenu table .menu-sub-dropdown .menu-link > :is(i, svg),
html.ux2-rowmenu table .menu-sub-dropdown .menu-link .menu-icon :is(i, svg) {
    width: 18px;
    padding: 0 !important;
    margin: 0 !important;
    font-size: 15px;
    text-align: center;
    color: #64748b;
}

/* Tabler draws inside a 24 grid with room around it, and a Metronic size class must not squash it */
html.ux2-rowmenu table .menu-sub-dropdown .menu-link > svg.sko-i,
html.ux2-rowmenu table .menu-sub-dropdown .menu-link .menu-icon svg.sko-i {
    width: 18px;
    height: 18px;
}

html.ux2-rowmenu table .menu-sub-dropdown .menu-link:hover,
html.ux2-rowmenu table .menu-sub-dropdown .menu-link:focus-visible,
html.ux2-rowmenu table .menu-sub-dropdown .menu-link.active {
    color: var(--ux2k-ink, #010b13) !important;
    background: #f1f5f9 !important;
}

html.ux2-rowmenu table .menu-sub-dropdown .menu-link:hover .menu-title {
    color: inherit !important;
}

html.ux2-rowmenu table .menu-sub-dropdown .menu-link:hover > :is(i, svg) {
    color: var(--sko-primary, #1e5f69);
}

/* Delete / Remove: red, at the bottom, after a divider (the first such item gets the line) */
html.ux2-rowmenu table .menu-sub-dropdown .menu-link.text-danger,
html.ux2-rowmenu table .menu-sub-dropdown .menu-link:has(> .bi-trash, > .bi-trash3, > .bi-trash-fill) {
    color: #b91c1c !important;
}

html.ux2-rowmenu table .menu-sub-dropdown .menu-link.text-danger > :is(i, svg),
html.ux2-rowmenu table .menu-sub-dropdown .menu-link:has(> .bi-trash, > .bi-trash3, > .bi-trash-fill) > :is(i, svg) {
    color: #b91c1c;
}

html.ux2-rowmenu table .menu-sub-dropdown .menu-link.text-danger:hover,
html.ux2-rowmenu table .menu-sub-dropdown .menu-link:has(> .bi-trash, > .bi-trash3, > .bi-trash-fill):hover {
    background: #fff1f2 !important;
}

html.ux2-rowmenu table .menu-sub-dropdown .menu-item:not(:has(.text-danger, .bi-trash, .bi-trash3, .bi-trash-fill)) + .menu-item:has(> .menu-link.text-danger, > .menu-link > .bi-trash, > .menu-link > .bi-trash3, > .menu-link > .bi-trash-fill) {
    margin-top: 4px;
    padding-top: 4px !important;
    border-top: 1px solid #eef2f6;
}

/* ---------- Phones: the menu as a bottom sheet; touch: a bigger ⋯ ----------
   Anchored to a ⋯ at the far right of a wide table, the dropdown would hang off a phone's screen: on phones it opens as
   a sheet along the bottom, full width, with rows easy to tap and the page dimmed behind (tap outside still closes it,
   as Metronic's menu does). On touch screens the ⋯ is 40px, a finger-sized target. */
@media (pointer: coarse) {
    html.ux2-rowmenu.ux2-rowmenu-dots body table [data-kt-menu-trigger].btn {
        width: 40px !important;
        min-width: 40px;
        height: 40px !important;
        min-height: 40px;
    }
}

@media (max-width: 575.98px) {
    html.ux2-rowmenu table .menu-sub-dropdown.show {
        position: fixed !important;
        inset: auto 8px 8px 8px !important;
        z-index: 1080 !important;
        width: auto !important;
        min-width: 0;
        max-height: 70vh;
        padding: 8px !important;
        overflow-y: auto;
        border-radius: 16px;
        transform: none !important;
        box-shadow: 0 0 0 100vmax rgb(15 23 42 / .38), 0 -8px 24px rgb(15 23 42 / .18);
        animation: ux2-rm-sheet .22s cubic-bezier(.2, .8, .2, 1);
    }

    html.ux2-rowmenu table .menu-sub-dropdown.show .menu-link {
        min-height: 48px;
        padding: 12px 14px !important;
        font-size: 15px;
    }

    @keyframes ux2-rm-sheet {
        from { transform: translateY(16px); opacity: 0; }
        to { transform: none; opacity: 1; }
    }
}

@media (max-width: 575.98px) and (prefers-reduced-motion: reduce) {
    html.ux2-rowmenu table .menu-sub-dropdown.show {
        animation: none;
    }
}

html.ux2-calm table .menu-sub-dropdown.show {
    animation: none !important;
}
