/* Pos.SharedUI — collapsible navigation rail (RTL, tablet/desktop). Loaded by SalesApp / Admin hosts. */

:root {
    --pos-nav-rail-w-expanded: min(15.5rem, 42vw);
    --pos-nav-rail-w-collapsed: 3.5rem;
    --pos-nav-rail-ease: cubic-bezier(0.4, 0, 0.2, 1);
}

.pos-shell-root {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    min-height: 0;
    flex: 1 1 auto;
    min-width: 0;
}

.pos-shell-root--checkout {
    flex-direction: column;
}

/*
 * Hub (shift, held invoices, sync, …): rail + MudLayout must share one full-height row.
 * Plain flex + percentage heights often leave the rail only as tall as its menu items while the main column grows.
 */
.pos-shell-root.pos-shell-root--hub {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: stretch;
    justify-items: stretch;
    width: 100%;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
}

.pos-shell-root.pos-shell-root--hub .pos-shell-rail-host {
    /* Pin the rail to a full viewport height and keep it visible while a long page scrolls beside it,
       so the dark rail always covers the full height (it previously stopped at content height and left
       a gap on long pages like Device Settings). */
    align-self: start;
    position: sticky;
    top: 0;
    height: 100dvh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.pos-shell-root.pos-shell-root--hub .pos-shell-rail-host .pos-nav-rail {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
}

.pos-shell-root.pos-shell-root--hub .pos-shell-mud-layout {
    min-height: 100%;
    min-width: 0;
}

@media (max-width: 767.98px) {
    .pos-shell-root.pos-shell-root--hub {
        grid-template-columns: 1fr;
    }
}

.pos-shell-mud-layout {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.pos-shell-rail-host {
    flex: 0 0 auto;
    z-index: 1205;
    display: none;
    min-height: 0;
    position: relative;
}

@media (min-width: 768px) {
    .pos-shell-rail-host {
        display: flex;
    }

    .pos-app-layout.pos-app-layout--with-rail .mud-main-content,
    .pos-app-layout--with-rail .mud-main-content {
        width: 100%;
    }
}

/* Mobile: keep overlay drawer; rail hidden */
@media (max-width: 767.98px) {
    .pos-shell-rail-host {
        display: none !important;
    }
}

/* Hide traditional drawer on tablet/desktop when rail is used */
@media (min-width: 768px) {
    .pos-app-shell-drawer--mobile-only {
        display: none !important;
        visibility: hidden !important;
        width: 0 !important;
        min-width: 0 !important;
        max-width: 0 !important;
        overflow: hidden !important;
        pointer-events: none !important;
    }

    /* Prevent invisible drawer / overlay from stealing clicks on tablet & desktop */
    .mud-layout .mud-drawer:not(.mud-drawer-open).pos-app-shell-drawer--mobile-only {
        pointer-events: none !important;
    }

    /*
     * Checkout grid (/ …): MainLayout does NOT render the left nav rail, but this media query
     * still forced display:none on the temporary MudDrawer (intended for hub pages that use the rail).
     * Result on tablet: drawer panel stayed hidden while MudDrawer temporary overlay could still
     * activate — dimmed UI and blocked taps (including MudMenu popovers). See MudDrawer Temporary variant:
     * https://mudblazor.com/components/drawer — restore visible panel when open under .pos-shell-root--checkout only.
     */
    .pos-shell-root--checkout .mud-layout .pos-app-shell-drawer--mobile-only.mud-drawer.mud-drawer--open,
    .pos-shell-root--checkout .mud-layout .pos-app-shell-drawer--mobile-only.mud-drawer.mud-drawer-open {
        display: flex !important;
        visibility: visible !important;
        width: min(20rem, 92vw) !important;
        min-width: min(20rem, 92vw) !important;
        max-width: min(20rem, 100vw) !important;
        overflow: auto !important;
        pointer-events: auto !important;
    }
}

/* Shell MudDrawer: single dark layer from NavigationRail only (wrapper stays transparent). */
.pos-app-shell-drawer-rail-wrap {
    height: 100%;
    min-height: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    margin: 0;
    background: transparent;
}

.pos-nav-rail--in-shell-drawer {
    flex: 1;
    min-height: 0;
    border-inline-end: none;
    box-shadow: none;
    border-radius: 0;
    align-self: stretch;
    /* Drawer panel is wider than default rail max — fill it so no empty second band */
    width: 100% !important;
    max-width: 100% !important;
}

/* Drawer surfaces — theme DrawerBackground was stacking under rail (two-tone strip) */
.mud-checkout-shell-drawer.mud-drawer {
    background: transparent !important;
}

.mud-checkout-shell-drawer .mud-drawer-content,
.mud-checkout-shell-drawer .mud-paper {
    padding: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    /* Stretch the MudBlazor drawer surfaces full height so the dark rail fills to the
       bottom instead of stopping under the last menu item. */
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    min-height: 100% !important;
    overflow: hidden !important;
}

.pos-nav-rail {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    color: #e2e8f0;
    border-inline-end: 1px solid rgba(148, 163, 184, 0.22);
    box-shadow: 4px 0 24px rgba(15, 23, 42, 0.12);
    width: var(--pos-nav-rail-w-collapsed);
    transition: width 0.28s var(--pos-nav-rail-ease);
    will-change: width;
}

.pos-nav-rail--expanded {
    width: var(--pos-nav-rail-w-expanded);
}

.pos-nav-rail__inner {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
    padding: 0.45rem 0.35rem 0.65rem;
    gap: 0.35rem;
}

.pos-nav-rail__header {
    display: flex;
    justify-content: flex-end;
    flex-shrink: 0;
    padding: 0.1rem 0.15rem 0.25rem;
}

.pos-nav-rail__toggle.mud-icon-button {
    color: #cbd5e1 !important;
    border-radius: 12px !important;
    min-width: 44px !important;
    min-height: 44px !important;
}

.pos-nav-rail__toggle:hover {
    background: rgba(255, 255, 255, 0.08) !important;
}

.pos-nav-rail__items {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 0.1rem 0.05rem 0.4rem;
    scrollbar-gutter: stable;
}

.pos-nav-rail__item {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 0.55rem;
    width: 100%;
    min-height: 48px;
    padding: 0.4rem 0.45rem;
    margin: 0;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: start;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
    -webkit-tap-highlight-color: transparent;
}

.pos-nav-rail__item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.pos-nav-rail__item:active {
    transform: scale(0.98);
    background: rgba(255, 255, 255, 0.1);
}

.pos-nav-rail__item--active {
    background: linear-gradient(135deg, rgba(74, 93, 150, 0.92) 0%, rgba(61, 78, 129, 0.72) 100%);
    color: #ffffff;
    box-shadow: 0 0 0 1px rgba(124, 140, 192, 0.45);
}

.pos-nav-rail__icon-wrap {
    flex: 0 0 auto;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
}

.pos-nav-rail__item--active .pos-nav-rail__icon-wrap {
    background: rgba(124, 140, 192, 0.45);
}

.pos-nav-rail__icon {
    color: #f8fafc !important;
}

.pos-nav-rail__label {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.88rem;
    font-weight: 800;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    max-width: 0;
    transition: opacity 0.22s var(--pos-nav-rail-ease), max-width 0.28s var(--pos-nav-rail-ease);
}

.pos-nav-rail--expanded .pos-nav-rail__label {
    opacity: 1;
    max-width: 24rem;
}

/* Tablet: start visually collapsed width unless expanded class */
@media (min-width: 768px) and (max-width: 1199.98px) {
    .pos-nav-rail:not(.pos-nav-rail--expanded) {
        width: var(--pos-nav-rail-w-collapsed);
    }
}

/*
 * MudBlazor 9 drawer scrim is .mud-drawer-overlay with .mud-drawer-overlay--open when active.
 * Older CSS targeted .mud-overlay-visible, which v9 overlays never add — so :not(.mud-overlay-visible)
 * matched OPEN scrims too, applying visibility:hidden + pointer-events:none and breaking the drawer + menu toggle UX.
 * Only neutralize scrims that are actually closed (no --open class).
 */
#app.hx-pos-app .mud-drawer-overlay:not(.mud-drawer-overlay--open) {
    visibility: hidden !important;
    pointer-events: none !important;
}
