/* Mahin Inventory | Navigation
   Live source grouped by responsibility. Keep shared values in components.css. */

/* Origin: css/components/responsive_navigation.css; structure and behavior preserved */
/* Mahin Inventory V2 - Adaptive production navigation */

#appScreen {
    --mi-sidebar-wide: 250px;
    --mi-sidebar-rail: 72px;
    --mi-nav-ease: cubic-bezier(.22, 1, .36, 1);
}

#appScreen .sidebar {
    box-sizing: border-box;
    position: sticky;
    top: 0;
    width: var(--mi-sidebar-wide);
    min-width: var(--mi-sidebar-wide);
    flex: 0 0 var(--mi-sidebar-wide);
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 25;
    transition:
        width 230ms var(--mi-nav-ease),
        transform 260ms var(--mi-nav-ease);
}

#appScreen .sidebar-brand {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    position: relative;
    gap: 10px;
    min-height: 56px;
    padding: 8px 7px 16px;
}

#appScreen .sidebar-brand .brand-symbol {
    flex: 0 0 39px;
}

#appScreen .sidebar-brand > span {
    display: block;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

#appScreen .sidebar .nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

#appScreen .mi-sidebar-icon {
    flex: 0 0 19px;
}

#appScreen .mi-nav-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#appScreen .mi-brand-toggle,
#appScreen .mi-drawer-close,
#appScreen .mi-sidebar-backdrop {
    display: none;
}

#appScreen .topbar .sidebar-toggle {
    display: none !important;
}

#appScreen .mi-brand-toggle,
#appScreen .mi-drawer-close {
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    padding: 0;
    border: 1px solid rgba(255,255,255,.23);
    border-radius: 9px;
    background: rgba(255,255,255,.12);
    color: white;
    cursor: pointer;
}

#appScreen .mi-brand-toggle:hover,
#appScreen .mi-drawer-close:hover {
    background: rgba(255,255,255,.22);
}

#appScreen .mi-brand-arrow {
    display: block;
    width: 9px;
    height: 9px;
    border-top: 2px solid currentColor;
    border-right: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform 180ms ease;
}

#appScreen .mi-brand-toggle.is-expanded .mi-brand-arrow {
    transform: rotate(225deg);
}

#appScreen .mi-brand-toggle:focus-visible,
#appScreen .mi-drawer-close:focus-visible {
    outline: 2px solid #a8d0ff;
    outline-offset: 2px;
}

/* Medium desktop: compact rail with overlay expansion. */
@media (min-width: 751px) and (max-width: 1100px) {
    #appScreen .sidebar {
        width: var(--mi-sidebar-rail);
        min-width: var(--mi-sidebar-rail);
        flex-basis: var(--mi-sidebar-rail);
        padding-left: 7px;
        padding-right: 7px;
        overflow: visible;
    }

    #appScreen .sidebar-brand {
        min-height: 60px;
        padding: 8px 0 17px;
        justify-content: center;
    }

    #appScreen .sidebar-brand > span,
    #appScreen .sidebar .nav-label,
    #appScreen .sidebar .mi-nav-text {
        display: none;
    }

    #appScreen .mi-brand-toggle {
        display: flex;
        position: absolute;
        right: -3px;
        bottom: 9px;
        width: 20px;
        height: 20px;
        min-width: 20px;
        flex-basis: 20px;
        border-radius: 50%;
        background: #2d68c0;
        box-shadow: 0 2px 7px rgba(0,0,0,.18);
    }

    #appScreen .mi-brand-arrow {
        width: 6px;
        height: 6px;
    }

    #appScreen .sidebar a.nav-item,
    #appScreen .sidebar button.nav-item {
        justify-content: center;
        padding-left: 7px;
        padding-right: 7px;
    }

    #appScreen.mi-nav-expanded .sidebar {
        width: var(--mi-sidebar-wide);
        min-width: var(--mi-sidebar-wide);
        flex-basis: var(--mi-sidebar-rail);
        padding-left: 11px;
        padding-right: 11px;
        box-shadow: 12px 0 32px rgba(0,0,0,.18);
    }

    #appScreen.mi-nav-expanded .sidebar-brand {
        justify-content: flex-start;
        padding: 8px 3px 17px;
    }

    #appScreen.mi-nav-expanded .sidebar-brand > span,
    #appScreen.mi-nav-expanded .sidebar .nav-label,
    #appScreen.mi-nav-expanded .sidebar .mi-nav-text {
        display: block;
    }

    #appScreen.mi-nav-expanded .mi-brand-toggle {
        position: static;
        width: 30px;
        height: 30px;
        flex-basis: 30px;
        border-radius: 9px;
    }

    #appScreen.mi-nav-expanded .sidebar a.nav-item,
    #appScreen.mi-nav-expanded .sidebar button.nav-item {
        justify-content: flex-start;
        padding-left: 13px;
        padding-right: 13px;
    }
}

/* Small screens: mobile navigation drawer. */
@media (max-width: 750px) {
    #appScreen .topbar .sidebar-toggle {
        display: inline-flex !important;
    }

    #appScreen .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(280px, 86vw);
        min-width: 0;
        max-width: 86vw;
        height: 100dvh;
        z-index: 51;
        padding: 14px 10px;
        overflow-y: auto;
        transform: translate3d(-105%, 0, 0);
        -webkit-transform: translate3d(-105%, 0, 0);
    }

    #appScreen .sidebar.open {
        transform: translate3d(0, 0, 0);
        -webkit-transform: translate3d(0, 0, 0);
    }

    #appScreen .sidebar-brand {
        min-height: 55px;
        padding: 7px 3px 13px;
        margin-bottom: 5px;
    }

    #appScreen .mi-drawer-close {
        display: flex;
        margin-left: auto;
    }

    #appScreen .mi-drawer-close-icon {
        position: relative;
        width: 16px;
        height: 16px;
    }

    #appScreen .mi-drawer-close-icon::before,
    #appScreen .mi-drawer-close-icon::after {
        content: "";
        position: absolute;
        top: 7px;
        left: 0;
        width: 16px;
        height: 2px;
        border-radius: 2px;
        background: currentColor;
    }

    #appScreen .mi-drawer-close-icon::before {
        transform: rotate(45deg);
    }

    #appScreen .mi-drawer-close-icon::after {
        transform: rotate(-45deg);
    }

    #appScreen .mi-sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 50;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        background: rgba(7,17,32,.55);
        transition:
            opacity 210ms ease,
            visibility 210ms ease;
    }

    #appScreen .mi-sidebar-backdrop.is-open {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    #appScreen .sidebar,
    #appScreen .mi-sidebar-backdrop,
    #appScreen .mi-brand-arrow {
        transition: none !important;
    }
}


/* STEP 4.56 - INDEPENDENT APP SCROLLING */

/* The workspace fits inside the viewport. */
#appScreen.app {
    display: flex;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
}

/* Main and sidebar have independent vertical scrolling. */
#appScreen > .sidebar {
    height: 100%;
    max-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
}

#appScreen > .main {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
}

/* Header sticks to the top of the main scroll container. */
#appScreen .main > .topbar {
    position: sticky;
    top: 0;
    z-index: 20;
}

/* Mobile drawer remains independently scrollable. */
@media (max-width: 750px) {
    #appScreen > .sidebar {
        position: fixed;
        height: 100vh;
        height: 100dvh;
        max-height: 100dvh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    #appScreen > .main {
        width: 100%;
    }
}


/* STEP 4.57 - MOBILE DRAWER SCROLL LOCK */

/* The app already owns independent scrolling surfaces. */
body.mi-drawer-body-lock {
    overflow: hidden;
}

@media (max-width: 750px) {
    #appScreen.mi-drawer-open > .main {
        overflow: hidden !important;
        overscroll-behavior: none;
        touch-action: none;
    }

    #appScreen.mi-drawer-open > .sidebar {
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
    }

    #appScreen .mi-sidebar-backdrop.is-open {
        touch-action: none;
    }
}


/* Origin: css/components/hierarchical_navigation.css; structure and behavior preserved */
/* Hierarchical navigation and software footer */

#appScreen .sidebar {
    display: flex;
    flex-direction: column;
}

#appScreen .mi-sidebar-content {
    flex: 1 1 auto;
    min-height: 0;
}

#appScreen .mi-nav-parent {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 12px;
    padding: 11px 13px;
    border: 0;
    border-radius: 9px;
    color: inherit;
    background: transparent;
    text-align: left;
    cursor: pointer;
}

#appScreen .mi-nav-parent:hover,
#appScreen .mi-nav-parent.mi-parent-active {
    background: rgba(255, 255, 255, .11);
}

#appScreen .mi-parent-label {
    flex: 1;
    min-width: 0;
    font-weight: 550;
}

#appScreen .mi-nav-parent-icon,
#appScreen .mi-footer-icon {
    flex: 0 0 19px;
}

#appScreen .mi-parent-chevron {
    width: 8px;
    height: 8px;
    margin-right: 5px;
    border-right: 1.7px solid currentColor;
    border-bottom: 1.7px solid currentColor;
    transform: rotate(-45deg);
    transition: transform 180ms ease;
}

#appScreen .mi-nav-parent.is-expanded .mi-parent-chevron {
    transform: rotate(45deg);
}

#appScreen .mi-submenu[hidden] {
    display: none !important;
}

#appScreen .mi-submenu {
    padding: 4px 0 9px 29px;
}

#appScreen .mi-submenu .nav-item {
    min-height: 36px;
    padding: 8px 10px;
    font-size: 12px;
}

#appScreen .mi-sidebar-footer {
    flex: 0 0 auto;
    margin-top: auto;
    padding: 14px 5px 5px;
    border-top: 1px solid rgba(255, 255, 255, .14);
}

#appScreen .mi-footer-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 9px;
    color: #dce9fb;
    font-size: 12px;
    font-weight: 650;
}

#appScreen .mi-footer-mark {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    border-radius: 8px;
    background: #2867ca;
    color: white;
    font-weight: 700;
}

#appScreen .mi-footer-about {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    padding: 10px 9px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #d7e5fa;
    text-align: left;
    cursor: pointer;
}

#appScreen .mi-footer-about:hover,
#appScreen .mi-footer-about.active {
    background: rgba(255, 255, 255, .12);
}

#appScreen .mi-footer-label {
    font-size: 12px;
}

#appScreen .mi-about-page {
    max-width: 1080px;
    margin: 0 auto;
    padding: 8px 0 35px;
}

#appScreen .mi-about-heading {
    margin: 15px 0 24px;
}

#appScreen .mi-about-heading h1 {
    margin-bottom: 9px;
}

#appScreen .mi-about-heading p {
    color: var(--muted, #728096);
}

#appScreen .mi-about-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

#appScreen .mi-about-card {
    padding: 23px;
    border: 1px solid var(--border, #dae2ee);
    border-radius: 14px;
    background: var(--surface, #fff);
}

#appScreen .mi-about-card h2 {
    margin: 0 0 10px;
    font-size: 16px;
}

#appScreen .mi-about-card p {
    margin: 0;
    line-height: 1.65;
    color: var(--muted, #728096);
}

@media (min-width: 751px) and (max-width: 1100px) {

    #appScreen:not(.mi-nav-expanded) .mi-parent-label,
    #appScreen:not(.mi-nav-expanded) .mi-parent-chevron,
    #appScreen:not(.mi-nav-expanded) .mi-footer-label,
    #appScreen:not(.mi-nav-expanded) .mi-footer-brand,
    #appScreen:not(.mi-nav-expanded) .mi-submenu {
        display: none !important;
    }

    #appScreen:not(.mi-nav-expanded) .mi-nav-parent,
    #appScreen:not(.mi-nav-expanded) .mi-footer-about {
        justify-content: center;
        padding-left: 7px;
        padding-right: 7px;
    }

    #appScreen.mi-nav-expanded .mi-submenu {
        display: block;
    }

    #appScreen.mi-nav-expanded .mi-sidebar-footer {
        padding-left: 4px;
        padding-right: 4px;
    }
}

@media (max-width: 750px) {
    #appScreen .mi-about-grid {
        grid-template-columns: 1fr;
    }

    #appScreen .mi-about-card {
        padding: 17px;
    }

    #appScreen .mi-submenu {
        padding-left: 24px;
    }
}

@media (prefers-reduced-motion: reduce) {
    #appScreen .mi-parent-chevron {
        transition: none !important;
    }
}

/* STEP 4.60 - SETTINGS ABOUT SHORTCUT */
#appScreen .mi-submenu-about-link {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 10px;
    cursor: pointer;
    text-align: left;
}

#appScreen .mi-submenu-about-link::before {
    /* Real Info SVG is supplied by settings_navigation_polish.js. */
    content: none;
    display: none;
}

#appScreen .mi-submenu-about-link.active {
    background: rgba(255,255,255,.15);
    color: #fff;
}

/* MAHIN_MOBILE_DRAWER_CLOSE_GLOBAL_V1_START
   Drawer close is anchored to the sidebar's own edge, independent of avatar
   width, translated background, font, theme, or mobile content scroll. */
@media (max-width: 750px) {
  #appScreen #sidebar .sidebar-brand {
    position: relative !important;
    width: 100% !important;
    box-sizing: border-box !important;
    min-height: 76px !important;
    padding-right: 56px !important;
  }
  #appScreen #sidebar .sidebar-brand > .mi-drawer-close {
    box-sizing: border-box !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: absolute !important;
    z-index: 50 !important;
    top: 50% !important;
    right: 10px !important;
    bottom: auto !important;
    left: auto !important;
    transform: translateY(-50%) !important;
    flex: 0 0 42px !important;
    width: 42px !important;
    min-width: 42px !important;
    max-width: 42px !important;
    height: 42px !important;
    min-height: 42px !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 12px !important;
    cursor: pointer;
  }
  #appScreen #sidebar .sidebar-brand > .mi-drawer-close > .mi-drawer-close-icon {
    position: relative !important;
    display: block !important;
    flex: 0 0 18px !important;
    width: 18px !important;
    height: 18px !important;
    margin: 0 !important;
    transform: none !important;
    pointer-events: none !important;
  }
  #appScreen #sidebar .sidebar-brand > .mi-drawer-close > .mi-drawer-close-icon::before,
  #appScreen #sidebar .sidebar-brand > .mi-drawer-close > .mi-drawer-close-icon::after {
    width: 18px !important;
    top: 8px !important;
    left: 0 !important;
    height: 2px !important;
  }
}
/* MAHIN_MOBILE_DRAWER_CLOSE_GLOBAL_V1_END */
