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

/* Origin: css/components/workspace_identity_v1.css; structure and behavior preserved */
/* Mahin V2 - Unified Header and Sidebar Identity */

#sidebar .sidebar-brand {
    display: flex;
    align-items: center;
    position: relative;
    box-sizing: border-box;
    min-width: 0;
    min-height: 72px;
    overflow: hidden;
}

/* Never display the business logo inside the sidebar identity. */
#sidebar .sidebar-brand img,
#sidebar .sidebar-brand picture,
#sidebar .sidebar-brand .mi-business-logo,
#sidebar .sidebar-brand .business-logo,
#sidebar .sidebar-brand .brand-symbol,
#sidebar .sidebar-brand > span:not(.mi-brand-toggle) {
    display: none !important;
}

#sidebar .sidebar-brand .mi-brand-toggle {
    background-image: none !important;
    flex-shrink: 0;
    z-index: 2;
}

#miUserIdentity {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    align-items: center;
    gap: 10px;
    padding: 8px 4px;
    box-sizing: border-box;
    overflow: hidden;
}

#miUserIdentity[hidden] {
    display: none !important;
}

#miUserIdentity .mi-user-avatar {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    flex: 0 0 40px;
    border-radius: 50%;
    background: #dce9ff;
    color: #173b78;
    font-size: 16px;
    font-weight: 700;
    overflow: hidden;
}

#miUserIdentity .mi-user-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
    gap: 4px;
}

#miUserIdentity .mi-user-name,
#miUserIdentity .mi-user-role {
    display: block;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#miUserIdentity .mi-user-name {
    font-size: 13px;
    font-weight: 700;
}

#miUserIdentity .mi-user-role {
    font-size: 11px;
    opacity: .75;
}

/* Compact sidebar */
#miUserIdentity.is-compact {
    justify-content: center;
    padding-inline: 0;
}

#miUserIdentity.is-compact .mi-user-details {
    display: none !important;
}

/* Prefer layout state over delayed pixel measurement. */
@media (min-width: 751px) and (max-width: 1100px) {
    #appScreen:not(.mi-nav-expanded) #miUserIdentity {
        justify-content: center;
        gap: 0;
        padding-inline: 0;
    }

    #appScreen:not(.mi-nav-expanded)
    #miUserIdentity .mi-user-details {
        display: none !important;
    }
}

/* Remove old numeric label from desktop header. */
#topbar #userInfo {
    display: none !important;
}

/* Mobile header retains the existing dynamic header controller. */
@media (max-width: 750px) {
    #topbar.topbar {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        height: auto;
        min-height: 0;
        gap: 8px;
        padding: 10px 12px;
        box-sizing: border-box;
    }

    #topbar > div:first-child {
        display: flex;
        align-items: center;
        gap: 10px;
        min-width: 0;
        width: 100%;
    }

    #topbar #headerBusiness {
        min-width: 0;
        flex: 1;
        font-size: 15px;
        line-height: 1.35;
        overflow-wrap: anywhere;
        white-space: normal;
    }

    #topbar .topbar-actions {
        display: flex;
        justify-content: flex-end;
        align-items: center;
        flex-wrap: wrap;
        width: 100%;
        gap: 7px;
    }
}
/* Mahin V2 - Sidebar profile spacing refinement */
#sidebar .sidebar-brand {
    min-height: 58px !important;
    height: auto !important;
    padding-top: 6px !important;
    padding-bottom: 6px !important;
    margin-top: 0 !important;
    margin-bottom: 6px !important;
    align-items: center !important;
}

#sidebar #miUserIdentity {
    padding-top: 2px !important;
    padding-bottom: 2px !important;
    margin-top: 0 !important;
}

#sidebar .nav-label {
    margin-top: 4px;
}

/* MAHIN_PROFILE_TOP_V2 */
#sidebar {
    padding-top: 0 !important;
}

#sidebar .sidebar-brand {
    min-height: 0 !important;
    height: auto !important;
    padding: 0 8px 8px !important;
    margin: 0 0 8px !important;
    border-bottom: 1px solid rgba(255,255,255,.20);
    box-sizing: border-box;
    align-items: center !important;
}

#sidebar #miUserIdentity {
    min-height: 48px;
    padding: 2px 4px !important;
    margin: 0 !important;
    cursor: pointer;
    border-radius: 9px;
}

#miUserIdentity:hover {
    background: rgba(255,255,255,.09);
}

#miUserIdentity:focus-visible {
    outline: 2px solid #93c5fd;
    outline-offset: -2px;
}

/* All Settings views are exclusive: account is a real detail route.
   Higher specificity is intentional to defeat shared overview grid display rules. */
html body #appScreen #settingsHubView.mi-v2-settings-ready.mi-user-account-open > :not(#miUserAccountPanel) {
    display: none !important;
}

#miUserAccountPanel {
    width: 100%;
    max-width: none;
    padding: 4px 0 24px;
}

#miUserAccountPanel[hidden] {
    display: none !important;
}

.mi-account-info {
    display: grid;
    gap: 12px;
    margin-top: 20px;
}

.mi-account-field {
    padding: 14px 16px;
    border: 1px solid var(--border-color, #d9e2f0);
    border-radius: 12px;
    background: var(--surface, transparent);
    overflow-wrap: anywhere;
}

.mi-account-field small {
    display: block;
    margin-bottom: 5px;
    opacity: .7;
}

.mi-account-field strong {
    display: block;
}

.mi-account-back {
    margin-bottom: 16px;
}
/* MAHIN_SIDEBAR_ALIGNMENT_V3 */

/* Balanced profile positioning */
#sidebar .sidebar-brand {
    position: relative !important;
    width: 100%;
    min-height: 76px !important;
    height: auto !important;
    padding: 12px 12px 13px !important;
    margin: 0 0 10px !important;
    box-sizing: border-box;
    display: flex !important;
    align-items: center !important;
    overflow: visible !important;
    border-bottom: 1px solid rgba(255,255,255,.16);
}

/* Profile occupies available space without clipping */
#sidebar #miUserIdentity {
    min-width: 0;
    max-width: 100%;
    min-height: 42px;
    padding: 2px 0 !important;
    margin: 0 !important;
    box-sizing: border-box;
}

/* Expand/collapse is an independent control */
#sidebar .sidebar-brand > .mi-brand-toggle {
    position: absolute !important;
    top: auto !important;
    bottom: -12px !important;
    right: 10px !important;
    left: auto !important;
    transform: none !important;
    z-index: 20 !important;
    flex: none !important;
    margin: 0 !important;
    width: 25px !important;
    height: 25px !important;
    min-width: 25px !important;
    min-height: 25px !important;
    display: grid !important;
    place-items: center !important;
    border-radius: 50% !important;
}

/* Keep the real navigation control working */
#sidebar .sidebar-brand > .mi-brand-toggle:hover {
    transform: scale(1.05) !important;
}

/* Compact sidebar: balanced avatar and arrow */
@media (min-width: 751px) {
    #sidebar #miUserIdentity.is-compact {
        width: 100%;
        justify-content: center !important;
        padding: 2px 0 !important;
    }

    #sidebar #miUserIdentity.is-compact .mi-user-avatar {
        flex: 0 0 36px;
        width: 36px;
        height: 36px;
        min-width: 36px;
    }

    #sidebar:has(#miUserIdentity.is-compact)
    .sidebar-brand {
        padding: 13px 4px 15px !important;
        min-height: 78px !important;
    }

    #sidebar:has(#miUserIdentity.is-compact)
    .sidebar-brand > .mi-brand-toggle {
        right: 4px !important;
        bottom: -10px !important;
    }
}

/* Mobile: preserve the close control and profile layout */
@media (max-width: 750px) {
    #sidebar .sidebar-brand {
        padding: 12px 44px 13px 14px !important;
    }

    #sidebar .sidebar-brand > .mi-brand-toggle {
        display: none !important;
    }
}
/* MAHIN_EXPAND_VISIBILITY_FIX_V4 */

/* Full desktop sidebar needs no expand control. */
@media (min-width: 1101px) {
    html:not([data-mi-sidebar-preference="compact"])
    #sidebar .sidebar-brand > .mi-brand-toggle {
        display: none !important;
    }
}

/* Explicit expanded preference also hides it. */
html[data-mi-sidebar-preference="expanded"]
#sidebar .sidebar-brand > .mi-brand-toggle {
    display: none !important;
}

/* Mobile uses its separate menu/drawer controls. */
@media (max-width: 750px) {
    #sidebar .sidebar-brand > .mi-brand-toggle {
        display: none !important;
    }
}
/* MAHIN_COMPACT_BUTTON_IN_AVATAR_V5 */

/* Compact sidebar: replace avatar with expand button. */
@media (min-width: 751px) {

    #sidebar:has(#miUserIdentity.is-compact)
    .sidebar-brand {
        position: relative !important;
        display: grid !important;
        place-items: center !important;
        min-height: 76px !important;
        padding: 12px 4px !important;
    }

    #sidebar:has(#miUserIdentity.is-compact)
    #miUserIdentity {
        display: none !important;
    }

    #sidebar:has(#miUserIdentity.is-compact)
    .sidebar-brand > .mi-brand-toggle {
        display: grid !important;
        place-items: center !important;
        position: relative !important;
        top: auto !important;
        right: auto !important;
        bottom: auto !important;
        left: auto !important;
        transform: none !important;

        width: 42px !important;
        height: 42px !important;
        min-width: 42px !important;
        min-height: 42px !important;
        margin: 0 auto !important;

        border-radius: 50% !important;
        background: #dce9ff !important;
        color: #173b78 !important;
        box-shadow: none !important;
    }

    #sidebar:has(#miUserIdentity.is-compact)
    .sidebar-brand > .mi-brand-toggle:hover {
        transform: scale(1.06) !important;
        background: #c5dbff !important;
    }

    #sidebar:has(#miUserIdentity.is-compact)
    .sidebar-brand > .mi-brand-toggle:focus-visible {
        outline: 2px solid #93c5fd !important;
        outline-offset: 3px !important;
    }

    /* Expanded temporary sidebar restores user profile. */
    #appScreen.mi-nav-expanded #miUserIdentity {
        display: flex !important;
    }

    #appScreen.mi-nav-expanded
    .sidebar-brand > .mi-brand-toggle {
        display: none !important;
    }
}
