/* FoodServe Admin application shell and navigation layout.

   This file owns the persistent MainLayout structure: content viewport, sidebar,
   navigation states and the mobile Admin shell. Page-level app bars, grids and cards
   belong in components.css and should not be recreated here.

   The 1000px shell breakpoint is intentionally shared with the navigation change.
   If that breakpoint changes, update --fs-breakpoint-admin-shell in tokens.css as
   documentation and keep all matching numeric media queries aligned. */

/* Main content viewport
   The shell provides the canvas and bottom safe area. Individual pages should begin
   with .fs-appbar followed by one or more .fs-grid elements. */
.layout {
    z-index: 1;
    overflow-x: visible !important;
}

    .layout .header {
        display: flex;
        align-items: center;
        padding: var(--fs-space-5);
    }

    .layout .content {
        background: var(--fs-color-canvas);
        padding: var(--fs-space-3) 50px;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        height: 100%;
        min-height: 0;
    }

    .layout .main-content {
        display: flex;
        flex: 1 1 auto;
        flex-direction: column;
        min-height: 0;
        min-width: 0;
        padding-bottom: max(var(--fs-space-2), env(safe-area-inset-bottom));
        box-sizing: border-box;
    }

@media (max-width: 576px) {
    /* Use a compact page gutter on phones while retaining a small visible edge
       around cards and respecting their own internal padding. */
    .layout .content {
        padding: 5px !important;
    }
}

.layout .footer {
    text-align: center;
    margin-top: auto;
    margin-bottom: var(--fs-space-5);
    padding: var(--fs-space-5);
}

.layout .sidebar .menu .menu-header,
.layout .sidebar .menu .menu-item a,
.sidebar-footer .sf-name,
.sidebar-footer .sf-role {
    font-family: var(--ff-body);
}

/* Desktop sidebar shell
   Sidebar colours are aliases from tokens.css so future shell themes can change
   without altering the page/component colour system. */
.sidebar {
    color: var(--sidebar-text);
    position: relative;
    /*box-shadow: 2px 0 24px rgba(0,0,0,.12);*/ /* x-offset > 0 = shadow to the right */
    border-right: 1px solid var(--sidebar-border);
}

.layout .sidebar.collapsed {
    box-shadow: var(--fs-shadow-sidebar);
    border-right-color: var(--sidebar-border);
}

@media (max-width: 999.98px) {
    /* The sidebar becomes an overlay below the Admin shell breakpoint, so its
       desktop edge shadow and border must not remain visible when closed. */
    .sidebar {
        box-shadow: 2px 0 24px rgba(0,0,0,0); /* x-offset > 0 = shadow to the right */
        border-right: 1px solid rgba(0, 0, 0, 0);
    }

    .layout .sidebar.collapsed {
        box-shadow: 1px 0 16px rgba(0,0,0,0);
        border-right-color: rgba(0, 0, 0, 0);
    }
}

.sidebar::-webkit-scrollbar {
    width: 6px;
    background-color: var(--sidebar-bg);
}

.sidebar::-webkit-scrollbar-thumb {
    border-radius: var(--fs-radius-xs);
}

.sidebar:hover::-webkit-scrollbar-thumb {
    background-color: var(--sidebar-muted);
}

.sidebar .image-wrapper {
    overflow: hidden;
    position: absolute;
    inset: 0;
    z-index: 1;
    display: none;
}

    .sidebar .image-wrapper > img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: center;
    }

.sidebar.has-bg-image .image-wrapper {
    display: block;
}

.sidebar .sidebar-layout {
    height: auto;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: var(--sidebar-bg);
    z-index: 2;
}

    .sidebar .sidebar-layout .sidebar-header {
        height: auto;
        min-height: 0px;
        display: flex;
        align-items: center;
        padding: 0 20px;
    }

        .sidebar .sidebar-layout .sidebar-header > span {
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }

    .sidebar .sidebar-layout .sidebar-content {
        flex-grow: 1;
        padding: 10px 0;
    }

    .sidebar .sidebar-layout .sidebar-footer {
        height: 230px;
        min-height: 230px;
        display: flex;
        align-items: center;
        padding: 0 20px;
        background: var(--footer-bg);
        border-top: 1px solid var(--sidebar-border);
    }

        .sidebar .sidebar-layout .sidebar-footer > span {
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }

    /* Logo panel (keep old look) */
    /* Make header + logo-area span full width */
    .sidebar .sidebar-layout .sidebar-header {
        padding: 0; /* remove side padding so logo-area can be full width */
    }

/* Full-width logo panel */
.logo-area {
    width: 100%;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 var(--fs-space-4);
    /*    margin: 0 0 1rem;
*/ background: var(--sidebar-bg);
    box-shadow: none;
    transition: height .25s ease, padding .25s ease, margin .25s ease;
}

/* Logo scales with container */
.sidebar-logo {
    width: 80%;
    object-fit: contain;
    transition: max-width .25s ease, max-height .25s ease, transform .25s ease;
    display: block;
    margin-inline: auto;
}

/* When sidebar is collapsed, shrink the logo-area + image */
.layout .sidebar.collapsed .logo-area {
    height: 56px;
}

/* Navigation menu
   Rules below style the expanded hierarchy first. Collapsed-mode adjustments are
   grouped later so the default state remains easy to understand. */
.layout .sidebar .menu ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

.layout .sidebar .menu .menu-header {
    font-weight: 700;
    padding: 10px 20px;
    font-size: 0.8em;
    letter-spacing: 2px;
    color: var(--sidebar-muted);
}

.layout .sidebar .menu .menu-item a {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 0 16px;
    gap: 10px;
    color: var(--sidebar-text);
    font-weight: 700;
    background-color: transparent;
    transition: color .2s, background-color .2s;
}

    .layout .sidebar .menu .menu-item a .menu-icon {
        font-size: 1.2rem;
        width: 37px;
        min-width: 37px;
        height: 28px;
        line-height: 28px;
        text-align: center;
        display: inline-block;
        margin-right: 0;
        border-radius: var(--fs-radius-sm);
        transition: color .2s, background-color .2s;
        background-color: var(--sidebar-icon-bg);
        color: var(--sidebar-muted);
    }

        .layout .sidebar .menu .menu-item a .menu-icon i {
            display: inline-block;
        }

    .layout .sidebar .menu .menu-item a .menu-title {
        font-size: 0.95em;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        flex-grow: 1;
        transition: color .2s;
        color: inherit;
    }

    .layout .sidebar .menu .menu-item a .menu-prefix,
    .layout .sidebar .menu .menu-item a .menu-suffix {
        display: inline-block;
        padding: 5px;
        opacity: 1;
        transition: opacity .2s;
    }

    /* Hover/active */
    .layout .sidebar .menu .menu-item a:hover {
        background-color: var(--sidebar-hover);
        color: var(--sidebar-text);
    }

    .layout .sidebar .menu .menu-item a:hover .menu-icon {
        color: var(--sidebar-text);
        background-color: var(--sidebar-icon-bg);
    }

    .layout .sidebar .menu .menu-item a:hover::after {
        border-color: var(--sidebar-text) !important;
    }

/* Submenus
   Expanded sidebars reveal nested links in normal flow. Collapsed sidebars turn the
   same list into a flyout without requiring a second navigation implementation. */
.layout .sidebar .menu .menu-item.sub-menu {
    position: relative;
}

    .layout .sidebar .menu .menu-item.sub-menu > a::after {
        content: "";
        transition: transform .2s;
        border-right: 2px solid currentcolor;
        border-bottom: 2px solid currentcolor;
        width: 5px;
        height: 5px;
        transform: rotate(-45deg);
    }

    .layout .sidebar .menu .menu-item.sub-menu > .sub-menu-list {
        display: none;
        overflow: hidden;
        z-index: 999;
        background-color: var(--submenu-bg);
        border-left: 3px solid var(--sidebar-border);
    }

    .layout .sidebar .menu .menu-item.sub-menu.open > a {
        color: var(--sidebar-text);
    }

        .layout .sidebar .menu .menu-item.sub-menu.open > a::after {
            transform: rotate(45deg);
        }

/* Icon shape helpers */
.layout .sidebar .menu.icon-shape-circle .menu-item a .menu-icon {
    border-radius: 50%;
}

.layout .sidebar .menu.icon-shape-rounded .menu-item a .menu-icon {
    border-radius: var(--fs-radius-sm);
}

.layout .sidebar .menu.icon-shape-square .menu-item a .menu-icon {
    border-radius: 0;
}

/* Keep expanded layout behavior */
.layout .sidebar:not(.collapsed) .menu > ul > .menu-item.sub-menu > .sub-menu-list {
    visibility: visible !important;
    position: static !important;
    transform: translate(0,0) !important;
}

/* Collapsed desktop states
   Hide text-only affordances and position submenu flyouts beside the icon rail. */
.layout .sidebar.collapsed .menu > ul > .menu-header {
    opacity: 0;
}

.layout .sidebar.collapsed .menu > ul > .menu-item > a .menu-prefix,
.layout .sidebar.collapsed .menu > ul > .menu-item > a .menu-suffix {
    opacity: 0;
}

.layout .sidebar.collapsed .menu > ul > .menu-item.sub-menu > a::after {
    content: "";
    width: 5px;
    height: 5px;
    background-color: currentcolor;
    border-radius: 50%;
    display: inline-block;
    position: absolute;
    right: 10px;
    top: 50%;
    border: none;
    transform: translateY(-50%);
}

.layout .sidebar.collapsed .menu > ul > .menu-item.sub-menu > .sub-menu-list {
    width: 200px;
    margin-left: 3px !important;
    border-radius: var(--fs-radius-sm);
    display: block !important;
    box-shadow: var(--fs-shadow-flyout);
}

.sidebar.collapsed {
    overflow: visible !important;
}

.layout .sidebar.collapsed .menu > ul > .menu-item.sub-menu.open > .sub-menu-list {
    position: absolute;
    left: 80px;
    top: 0;
    transform: translateY(calc(-50% + 25px));
}

/* Account/company identity block shown near the lower portion of the sidebar. */
.layout .sidebar .pro-sidebar-logo {
    display: flex;
    align-items: center;
}

.layout.fixed-sidebar .sidebar {
    overflow-x: hidden;
}

.admin-shell-body > .sidebar {
    height: 100%;
}

.admin-shell-body > .layout {
    min-width: 0;
}

@media (min-width: 1000px) {
    .admin-shell-body > .sidebar.collapsed {
        width: 80px;
        min-width: 80px;
        overflow: visible !important;
    }

    .layout .sidebar.collapsed .menu > ul > .menu-item > a .menu-title {
        display: none;
    }

    .layout .sidebar.collapsed .menu > ul > .menu-item > a {
        justify-content: center;
    }

    .layout .sidebar.collapsed .menu > ul > .menu-item > a .menu-prefix,
    .layout .sidebar.collapsed .menu > ul > .menu-item > a .menu-suffix {
        display: none;
    }
}

/* Original floating chevron at the desktop sidebar edge. */
.layout .sidebar .sidebar-collapser {
    position: fixed;
    left: 260px;
    top: 40px;
    width: 20px;
    height: 20px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--fs-color-brand);
    color: var(--fs-color-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    transform: translateX(50%);
    transition: left .3s;
    z-index: 111;
    cursor: pointer;
    box-shadow: 1px 1px 4px rgba(0, 0, 0, .2);
}

.layout .sidebar.collapsed .sidebar-collapser {
    left: 60px;
}

.layout .sidebar.collapsed .sidebar-collapser i {
    transform: rotate(180deg);
}

.layout .sidebar .sidebar-collapser:focus-visible {
    outline: 2px solid var(--fs-color-brand);
    outline-offset: 3px;
}

@media (max-width: 999.98px) {
    .layout .sidebar .sidebar-collapser {
        display: none;
    }
}

.layout .sidebar .pro-sidebar-logo > div {
    width: 35px;
    min-width: 35px;
    height: 35px;
    min-height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--fs-radius-sm);
    color: var(--fs-color-surface);
    font-size: 24px;
    font-weight: 700;
    background-color: var(--fs-color-brand);
    margin-right: 10px;
}

.layout .sidebar .pro-sidebar-logo > h5 {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 20px;
    line-height: 30px;
    transition: opacity .3s;
    opacity: 1;
    color: var(--fs-color-black);
}

/* Sidebar footer information panel. This is shell content, not the page footer. */
.layout .sidebar .footer-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 0.8em;
    padding: 20px 0;
    border-radius: var(--fs-radius-sm);
    width: 180px;
    min-width: 190px;
    margin: 0 auto;
    background-color: var(--fs-color-surface);
    border: 1px solid rgba(0,0,0,.06);
}

    .layout .sidebar .footer-box img.react-logo {
        width: 40px;
        height: 40px;
        margin-bottom: 10px;
    }

    .layout .sidebar .footer-box a {
        color: var(--fs-color-black);
        font-weight: 600;
        margin-bottom: 10px;
    }

/* Navigation badges. Status/data badges belong to utilities.css. */
.badge {
    display: inline-block;
    padding: .25em .4em;
    font-size: 75%;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: var(--fs-radius-xs);
    color: var(--fs-color-surface);
    background-color: var(--fs-color-text-muted);
}

    .badge.primary {
        background-color: var(--fs-color-brand);
    }

    .badge.secondary {
        background-color: var(--fs-color-black);
    }

/* Small shell-only helpers. */
.social-links a {
    margin: 0 10px;
    color: var(--fs-color-text);
}

@media (max-width: 999.98px) {
    /* Mobile Admin shell
       Reserve space for the fixed top navigation, size the content area beneath it,
       and allow pages to return to ordinary vertical scrolling. */
    .admin-shell-body > .sidebar.break-point-sm {
        position: fixed;
        left: -280px;
        width: 280px;
        min-width: 280px;
        top: var(--admin-navbar-height);
        height: calc(100dvh - var(--admin-navbar-height));
        z-index: 100;
    }

    .admin-shell-body .content {
        min-height: 0;
        height: 100%;
        box-sizing: border-box;
    }

    .admin-shell-body > .sidebar.break-point-sm.collapsed {
        left: -280px;
        width: 280px;
        min-width: 280px;
    }

    .admin-shell-body > .sidebar.break-point-sm.collapsed.toggled {
        left: 0;
    }

    .admin-shell-body > .sidebar.break-point-sm.toggled {
        left: 0;
    }

    .admin-shell-body > .sidebar.break-point-sm.toggled ~ .overlay {
        display: block;
    }

    .admin-shell-body > .overlay {
        top: var(--admin-navbar-height);
    }

    .layout .content {
        padding: 8px 12px 12px !important;
    }

    .sidebar .sidebar-layout .sidebar-content {
        padding: 6px 0 10px;
    }

    .layout .sidebar .menu .menu-header {
        padding: 8px 14px;
    }

    .layout .sidebar .menu .menu-item a {
        min-height: 44px;
        padding: 0 14px;
        gap: 8px;
    }

    .layout .sidebar .menu .menu-item a .menu-icon {
        width: 43px;
        min-width: 43px;
        height: 24px;
        line-height: 24px;
        font-size: 1.05rem;
    }

    .layout .sidebar .menu .menu-item a .menu-title {
        font-size: .94rem;
    }
}
