/**
 * UX2 shell — navigation feedback and page transitions.
 *
 * Pairs with appjs/common/ux2/nav.js. Two parts:
 *   1. NProgress, restyled: a 3px bar in the brand colour, no spinner, no glow. Replaces nprogress.min.css.
 *   2. Cross-document View Transitions between app pages: the aside and header stay perfectly still,
 *      only #kt_content fades in (150–220ms, ease-out). Browsers without support navigate as before.
 * Must load in <head> on both pages of a navigation (the @view-transition opt-in is checked on each),
 * and should be paired with <link rel="expect" href="#kt_footer" blocking="render"> so the new page's
 * first frame has its content, not half of it.
 */

/* ============================================
   1. PROGRESS BAR (NProgress markup: #nprogress > .bar > .peg, + .spinner)
   ============================================ */
#nprogress {
    pointer-events: none;
}

#nprogress .bar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 2000;
    width: 100%;
    height: 6px;
    background: var(--sko-primary, #1e5f69);
    view-transition-name: sko-progress;
}

/* A soft lighter tip instead of NProgress's glowing peg */
#nprogress .peg {
    position: absolute;
    right: 0;
    display: block;
    width: 96px;
    height: 100%;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.55));
    opacity: 1;
    box-shadow: none;
    transform: none;
}

#nprogress .spinner {
    display: none;
}

.nprogress-custom-parent {
    position: relative;
    overflow: hidden;
}

.nprogress-custom-parent #nprogress .bar {
    position: absolute;
}

/* ============================================
   2. PAGE TRANSITIONS
   ============================================ */
@view-transition {
    navigation: auto;
}

#kt_aside {
    view-transition-name: sko-aside;
}

#kt_header {
    view-transition-name: sko-header;
}

#kt_content {
    view-transition-name: sko-content;
}

/* The shell swaps in place: no fade, no movement (the active menu item and page title just change) */
::view-transition-group(root),
::view-transition-group(sko-aside),
::view-transition-group(sko-header),
::view-transition-group(sko-progress),
::view-transition-group(sko-content) {
    animation: none;
}

::view-transition-new(root),
::view-transition-new(sko-aside),
::view-transition-new(sko-header),
::view-transition-new(sko-progress) {
    animation: none;
}

::view-transition-old(root),
::view-transition-old(sko-aside),
::view-transition-old(sko-header),
::view-transition-old(sko-progress) {
    display: none;
}

/* Only the workspace moves: out slightly up and away, in from 6px below */
::view-transition-old(sko-content) {
    animation: ux2-content-out 0.15s cubic-bezier(0.4, 0, 1, 1) both;
}

::view-transition-new(sko-content) {
    animation: ux2-content-in 0.22s cubic-bezier(0.2, 0, 0, 1) both;
}

@keyframes ux2-content-out {
    from { opacity: 1; transform: none; }
    to { opacity: 0; transform: translateY(-4px); }
}

@keyframes ux2-content-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

/* ============================================
   3. QUICK-JUMP (appjs/common/ux2/quickjump.js) — ⌘K / Ctrl+K
   ============================================ */
.ux2-qj-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 220px;
    height: 36px;
    padding: 0 8px 0 12px;
    font-size: 13px;
    color: #7e8299;
    background: #f5f6f8;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.12s cubic-bezier(0.2, 0, 0, 1), border-color 0.12s cubic-bezier(0.2, 0, 0, 1);
}

.ux2-qj-trigger:hover {
    background: #fff;
    border-color: #e4e6ef;
}

.ux2-qj-trigger > :is(i, svg) {
    font-size: 14px;
    color: inherit;
}

.ux2-qj-trigger-text {
    flex: 1;
    text-align: left;
}

.ux2-qj-trigger kbd,
.ux2-qj kbd {
    padding: 3px 6px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 500;
    line-height: 1;
    color: #5e6278;
    background: #fff;
    border: 1px solid #e4e6ef;
    border-bottom-width: 2px;
    border-radius: 5px;
    box-shadow: none;
}

@media (max-width: 991.98px) {
    .ux2-qj-trigger {
        justify-content: center;
        min-width: 0;
        width: 36px;
        padding: 0;
    }

    .ux2-qj-trigger-text,
    .ux2-qj-trigger kbd {
        display: none;
    }
}

.ux2-qj {
    position: fixed;
    inset: 0;
    z-index: 2100;
}

.ux2-qj[hidden] {
    display: none;
}

.ux2-qj-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(16, 20, 28, 0.32);
    animation: ux2-qj-fade 0.15s ease-out;
}

.ux2-qj-panel {
    position: relative;
    width: 600px;
    max-width: calc(100vw - 32px);
    margin: 12vh auto 0;
    overflow: hidden;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 24px 48px -12px rgba(16, 24, 40, 0.28), 0 0 0 1px rgba(16, 24, 40, 0.06);
    animation: ux2-qj-in 0.16s cubic-bezier(0.2, 0, 0, 1);
}

.ux2-qj-search {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 56px;
    padding: 0 16px;
    border-bottom: 1px solid #eff2f5;
}

.ux2-qj-search > :is(i, svg) {
    font-size: 16px;
    color: #a1a5b7;
}

.ux2-qj-search input {
    flex: 1;
    height: 100%;
    font-size: 15px;
    color: #181c32;
    background: transparent;
    border: 0;
    outline: 0;
}

/* No ring on the search field — the open panel and the caret show where focus is. !important + the class
   beat a11y-core.js on the dashboards, which outlines every *:focus-visible in lime (#c2f733) !important. */
.ux2-qj .ux2-qj-search input:focus,
.ux2-qj .ux2-qj-search input:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}

.ux2-qj-list {
    max-height: min(400px, 56vh);
    margin: 0;
    padding: 6px;
    overflow-y: auto;
    list-style: none;
}

.ux2-qj-group {
    padding: 10px 10px 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #a1a5b7;
}

.ux2-qj-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
}

.ux2-qj-option[aria-selected="true"] {
    background: var(--sko-primary-light, #d4e0e2);
}

.ux2-qj-icon {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    color: #7e8299;
    background: #f5f6f8;
    border-radius: 8px;
}

.ux2-qj-icon svg {
    width: 16px;
    height: 16px;
}

.ux2-qj-icon .svg-icon,
.ux2-qj-icon :is(i, svg) {
    font-size: 15px;
    line-height: 1;
    color: inherit;
}

.ux2-qj-option[aria-selected="true"] .ux2-qj-icon {
    color: var(--sko-primary, #1e5f69);
    background: #fff;
}

.ux2-qj-text {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.ux2-qj-title,
.ux2-qj-path {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.ux2-qj-title {
    font-size: 14px;
    font-weight: 500;
    color: #181c32;
}

.ux2-qj-title mark {
    padding: 0;
    font-weight: 600;
    color: var(--sko-primary, #1e5f69);
    background: none;
}

.ux2-qj-path {
    font-size: 12px;
    color: #7e8299;
}

.ux2-qj-enter {
    font-size: 13px;
    color: var(--sko-primary-dark, #154951);
    visibility: hidden;
}

.ux2-qj-option[aria-selected="true"] .ux2-qj-enter {
    visibility: visible;
}

.ux2-qj-empty {
    padding: 28px 16px;
    font-size: 13.5px;
    text-align: center;
    color: #7e8299;
}

.ux2-qj-foot {
    display: flex;
    gap: 16px;
    padding: 10px 16px;
    font-size: 12px;
    color: #7e8299;
    background: #fafbfc;
    border-top: 1px solid #eff2f5;
}

.ux2-qj-foot kbd {
    margin-right: 3px;
}

@keyframes ux2-qj-in {
    from { opacity: 0; transform: translateY(-6px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

@keyframes ux2-qj-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ============================================
   4. PRODUCT SWITCHER (appjs/common/ux2/products.js) — LXP-2091
   ============================================ */
.ux2-ps {
    position: relative;
}

.ux2-ps-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 10px 0 12px;
    font-size: 13px;
    font-weight: 500;
    color: #3f4254;
    background: #fff;
    border: 1px solid #e4e6ef;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.12s cubic-bezier(0.2, 0, 0, 1), border-color 0.12s cubic-bezier(0.2, 0, 0, 1);
}

.ux2-ps-trigger:hover,
.ux2-ps-trigger[aria-expanded="true"] {
    background: #f6f7f9;
    border-color: #d8dbe4;
}

.ux2-ps-trigger > :is(i, svg) {
    font-size: 14px;
    color: var(--sko-primary, #1e5f69);
}

.ux2-ps-trigger .ux2-ps-caret {
    font-size: 11px;
    color: #7e8299;
}

.ux2-ps-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 1100;
    width: 320px;
    padding: 6px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 16px 36px -8px rgba(16, 24, 40, 0.2), 0 0 0 1px rgba(16, 24, 40, 0.06);
    animation: ux2-ps-in 0.14s cubic-bezier(0.2, 0, 0, 1);
}

.ux2-ps-panel[hidden] {
    display: none;
}

.ux2-ps-head {
    display: flex;
    flex-direction: column;
    padding: 10px 10px 8px;
}

.ux2-ps-head b {
    font-size: 14px;
    font-weight: 600;
    color: #181c32;
}

.ux2-ps-head span {
    font-size: 12.5px;
    color: #6b6f85;
}

.ux2-ps-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.ux2-ps-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
    padding: 9px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.12s cubic-bezier(0.2, 0, 0, 1);
}

.ux2-ps-row:hover {
    background: #f6f7f9;
}

.ux2-ps-check {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.ux2-ps-icon {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    font-size: 16px;
    color: #6b6f85;
    background: #f3f4f7;
    border-radius: 8px;
}

.ux2-ps-icon :is(i, svg) {
    color: inherit;
}

.ux2-ps-row.is-on .ux2-ps-icon {
    color: var(--sko-primary, #1e5f69);
    background: var(--sko-primary-light, #d4e0e2);
}

.ux2-ps-text {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.ux2-ps-text b {
    font-size: 13.5px;
    font-weight: 600;
    color: #181c32;
}

.ux2-ps-text small {
    font-size: 12px;
    color: #6b6f85;
}

.ux2-ps-tick {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: transparent;
    border: 1px solid #c9cdd6;
    border-radius: 6px;
    transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}

.ux2-ps-tick :is(i, svg) {
    font-size: 13px;
    color: inherit;
}

.ux2-ps-row.is-on .ux2-ps-tick {
    color: #fff;
    background: var(--sko-primary, #1e5f69);
    border-color: var(--sko-primary, #1e5f69);
}

/* Keyboard focus on the hidden checkbox shows on its row */
.ux2-ps-check:focus-visible + .ux2-ps-icon {
    outline: 2px solid var(--sko-primary, #1e5f69);
    outline-offset: 2px;
}

.ux2-ps-row.is-locked {
    cursor: default;
}

.ux2-ps-row.is-locked:hover {
    background: none;
}

.ux2-ps-row.is-locked .ux2-ps-text b {
    color: #6b6f85;
}

.ux2-ps-talk {
    flex-shrink: 0;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--sko-primary, #1e5f69);
    border: 1px solid #e4e6ef;
    border-radius: 999px;
}

.ux2-ps-talk:hover {
    background: #f6f7f9;
}

.ux2-ps-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 4px;
    padding: 10px 10px 6px;
    border-top: 1px solid #eff2f5;
}

.ux2-ps-foot span {
    font-size: 12px;
    color: #6b6f85;
}

.ux2-ps-all {
    flex-shrink: 0;
    padding: 5px 12px;
    white-space: nowrap;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--sko-primary, #1e5f69);
    background: none;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
}

.ux2-ps-all:hover:not(:disabled) {
    background: #f6f7f9;
}

.ux2-ps-all:disabled {
    color: #a1a5b7;
    cursor: default;
}

/* Sidebar placement: a full-width row at the top of the sidebar */
.ux2-ps--aside {
    position: relative;
}

/* The slot keeps the button's room from the first draw (products.js fills it once the page has loaded); without it the
   menu below drops 40px on every page (LXP-2591) */
#kt_aside_products[data-ux2-products] {
    min-height: 50px;
}

.ux2-ps--aside .ux2-ps-trigger {
    width: 100%;
    height: 40px;
    justify-content: flex-start;
}

.ux2-ps--aside .ux2-ps-label {
    flex: 1;
    overflow: hidden;
    text-align: left;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.ux2-ps--aside .ux2-ps-panel {
    right: 0;
    left: 0;
    width: auto; /* the sidebar clips anything wider */
}

/* Minimized sidebar: the list opens beside the rail at its full width, level with the button (fixed with no top: it
   keeps its place in the flow vertically, so it follows the button). The button shows just its icon (LXP-2579) */
@media (min-width: 992px) {
    [data-kt-aside-minimize="on"] .ux2-ps--aside .ux2-ps-panel {
        position: fixed;
        top: auto;
        right: auto;
        left: 83px; /* the 75px rail + 8px */
        width: 320px;
        margin-top: -40px; /* the button's height: level with it, not below it */
    }

    [data-kt-aside-minimize="on"] .ux2-ps--aside .ux2-ps-label,
    [data-kt-aside-minimize="on"] .ux2-ps--aside .ux2-ps-caret {
        display: none;
    }

    [data-kt-aside-minimize="on"] .ux2-ps--aside .ux2-ps-trigger {
        justify-content: center;
        padding: 0;
    }
}

/* "Only": appears on the row on hover / keyboard focus */
.ux2-ps-item {
    position: relative;
}

.ux2-ps-only {
    position: absolute;
    top: 50%;
    right: 42px;
    z-index: 1;
    padding: 2px 8px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--sko-primary, #1e5f69);
    background: #fff;
    border: 1px solid #e4e6ef;
    border-radius: 999px;
    opacity: 0;
    transform: translateY(-50%);
    cursor: pointer;
    transition: opacity 0.12s cubic-bezier(0.2, 0, 0, 1);
}

.ux2-ps-item:hover .ux2-ps-only,
.ux2-ps-item:has(:focus-visible) .ux2-ps-only {
    opacity: 1;
}

/* Sections that come back after a switch fade in */
#kt_aside .menu-item.ux2-reveal {
    animation: ux2-reveal 0.26s cubic-bezier(0.2, 0, 0, 1);
}

@keyframes ux2-reveal {
    from { opacity: 0; translate: 0 -4px; }
    to { opacity: 1; translate: 0 0; }
}

/* "Soon" tag on a sidebar item that isn't built yet */
.ux2-soon {
    margin-left: auto;
    padding: 2px 7px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--sko-primary-dark, #154951);
    background: var(--sko-primary-light, #d4e0e2);
    border-radius: 999px;
}

/* Popular apps popover (header, Metronic KTMenu dropdown) */
.ux2-apps {
    padding: 6px !important;
}

.ux2-apps-head {
    display: flex;
    flex-direction: column;
    padding: 10px 10px 8px;
}

.ux2-apps-head b {
    font-size: 14px;
    font-weight: 600;
    color: #181c32;
}

.ux2-apps-head span {
    font-size: 12.5px;
    color: #6b6f85;
}

.ux2-app {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 10px;
    border-radius: 8px;
    transition: background-color 0.12s cubic-bezier(0.2, 0, 0, 1);
}

.ux2-app:hover,
.ux2-app:focus-visible {
    background: #f6f7f9;
}

.ux2-app-logo {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    background: var(--app, #1e5f69);
    border-radius: 9px;
}

/* apps/view.php: the card a Popular apps link pointed at */
.appcard.ux2-app-flash .card {
    animation: ux2-app-flash 1.6s ease-out 0.2s;
}

@keyframes ux2-app-flash {
    0%, 40% { box-shadow: 0 0 0 3px var(--sko-primary, #1e5f69); }
    100% { box-shadow: 0 0 0 3px transparent; }
}

.ux2-app-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ux2-app-text b {
    font-size: 13.5px;
    font-weight: 600;
    color: #181c32;
}

.ux2-app-text small {
    font-size: 12px;
    color: #6b6f85;
}

.ux2-apps-foot {
    margin-top: 4px;
    padding: 10px 10px 6px;
    border-top: 1px solid #eff2f5;
}

.ux2-apps-foot a {
    font-size: 13px;
    font-weight: 600;
    color: var(--sko-primary, #1e5f69);
}

@keyframes ux2-ps-in {
    from { opacity: 0; translate: 0 -4px; }
    to { opacity: 1; translate: 0 0; }
}

@media (max-width: 991.98px) {
    .ux2-ps-label,
    .ux2-ps-caret {
        display: none;
    }

    .ux2-ps-trigger {
        justify-content: center;
        width: 36px;
        padding: 0;
    }

    .ux2-ps--aside .ux2-ps-label,
    .ux2-ps--aside .ux2-ps-caret {
        display: inline;
    }

    .ux2-ps--aside .ux2-ps-trigger {
        justify-content: flex-start;
        width: 100%;
        padding: 0 10px 0 12px;
    }

    /* The button sits mid-header on small screens: pin the panel to the viewport so it never runs off the left */
    .ux2-ps:not(.ux2-ps--aside) .ux2-ps-panel {
        position: fixed;
        top: 62px;
        right: 12px;
        left: auto;
        width: min(340px, calc(100vw - 24px));
        max-height: calc(100vh - 80px);
        overflow-y: auto;
    }
}

/* ============================================
   REDUCED MOTION — plain navigation, bar without easing
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    @view-transition {
        navigation: none;
    }

    #nprogress .peg {
        display: none;
    }

    .ux2-qj-backdrop,
    .ux2-qj-panel,
    .ux2-ps-panel,
    #kt_aside .menu-item.ux2-reveal {
        animation: none;
    }
}

/* ============================================
   5. SIDEBAR — selected item (.ux2-aside on the menu wrapper, set by widgets/admin-aside-v2.php)
   ============================================ */
/* Replaces the CDN aside.css look (solid pill on the title text, ❯ glyph, dashed tree connectors) with a quiet
   "you are here": a soft tint across the whole row, brand text, and a short brand bar on a plain guide line.
   The group holding the current page opens with its title in ink and its icon in the brand colour. */
#kt_aside .ux2-aside .menu-link {
    border-radius: 8px;
    transition: background-color 0.12s ease, color 0.12s ease;
}

/* Rows inset from the sidebar edges; icons stay where they were (margin + padding = Metronic's 25px) */
#kt_aside .ux2-aside .menu > .menu-item > .menu-link {
    margin: 0 12px;
    padding-right: 13px;
    padding-left: 13px;
}

#kt_aside .ux2-aside .menu-link:hover:not(.active) {
    background-color: #f4f6f8 !important;
}

#kt_aside .ux2-aside .menu-link.active {
    background-color: var(--sko-secondary-light, #e9f0f1) !important;
}

#kt_aside .ux2-aside .menu-link.active .menu-title {
    font-weight: 600;
    color: var(--sko-primary, #1e5f69) !important;
}

#kt_aside .ux2-aside .menu-link.active .menu-icon :is(i, svg),
#kt_aside .ux2-aside .menu-accordion.here > .menu-link .menu-icon :is(i, svg) {
    color: var(--sko-primary, #1e5f69) !important;
}

#kt_aside .ux2-aside .menu-accordion.here > .menu-link .menu-title {
    font-weight: 600;
    color: #181c32 !important;
}

/* Guide line: one plain hairline, no connectors */
#kt_aside .ux2-aside .menu-sub.menu-sub-accordion {
    margin-left: 30px !important;
    padding: 2px 0 !important;
    border-left: 1px solid #e6e9ee !important;
}

#kt_aside .ux2-aside .menu-sub.menu-sub-accordion > .menu-item:last-child::after {
    content: none;
}

#kt_aside .ux2-aside .menu-sub.menu-sub-accordion > .menu-item > .menu-link {
    position: relative;
    margin-right: 12px;
    margin-left: 8px !important;
    padding-left: 12px !important;
}

/* The connector becomes the selection bar, sitting on the guide line */
#kt_aside .ux2-aside .menu-sub.menu-sub-accordion > .menu-item > .menu-link::before {
    top: 7px;
    bottom: 7px;
    left: -9px;
    width: 2px;
    background: transparent;
    border: 0 !important;
    border-radius: 2px;
    transform: none;
    transition: background-color 0.12s ease;
}

#kt_aside .ux2-aside .menu-sub.menu-sub-accordion > .menu-item > .menu-link.active::before {
    background: var(--sko-primary, #1e5f69);
}

/* ============================================
   6. HEADER — avatar menu (widgets/header-v2.php)
   ============================================ */
#kt_header_user_menu_toggle .menu-sub-dropdown .menu-link .menu-icon :is(i, svg) {
    color: #6b6f85;
    transition: color 0.12s ease;
}

#kt_header_user_menu_toggle .menu-sub-dropdown .menu-link:hover .menu-icon :is(i, svg),
#kt_header_user_menu_toggle .menu-sub-dropdown .menu-link:hover .menu-title {
    color: var(--sko-primary, #1e5f69) !important;
}

/* Sign Out: red on hover, the cue that you're leaving */
#kt_header_user_menu_toggle .menu-sub-dropdown .menu-link[href$="/logout"]:hover .menu-icon :is(i, svg),
#kt_header_user_menu_toggle .menu-sub-dropdown .menu-link[href$="/logout"]:hover .menu-title {
    color: #d92d20 !important;
}
