/* ==========================================================================
   宝之通增长中台 · layout.css — 顶栏 / 侧栏 / 主体容器
   ========================================================================== */

/* ==========================================================================
   TOC（章节锥点）— grep '=== \[<id>\]' 可直接跳转：
     [brand]              品牌头部
     [sidebar]            侧边栏
     [topbar]             顶部导航栏
     [main-content]       主体容器
     [mobile-bottom-nav]  移动端底部导航
     [responsive-mobile]  响应式移动端（抽屛/隐藏侧栏/主内容 padding-bottom）
   ========================================================================== */

/* === [brand] 品牌头部 === */
.brand {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1002;
    width: var(--sidebar-width);
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 18px;
    background: var(--sidebar-bg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--surface);
    font-size: 0.92rem;
    font-weight: 600;
    letter-spacing: 0.15px;
}

.brand i {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--surface);
    background: var(--accent);
    font-size: 0.82rem;
}

.brand-logo {
    width: 24px;
    height: 24px;
    margin-right: 8px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    flex: 0 0 24px;
}

.brand > span:not(.brand-role-pill) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-role-pill {
    display: none;
    margin-left: auto;
    flex: 0 0 auto;
    align-items: center;
    min-height: 20px;
    padding: 0 7px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.65rem;
    font-weight: 700;
    white-space: nowrap;
}

.body-role-platform .brand-role-pill {
    border-color: rgba(252, 165, 165, 0.4);
    background: rgba(220, 38, 38, 0.2);
}
.body-role-manager .brand-role-pill {
    border-color: rgba(147, 197, 253, 0.4);
    background: rgba(37, 99, 235, 0.2);
}
.body-role-sales .brand-role-pill {
    border-color: rgba(110, 231, 183, 0.4);
    background: rgba(5, 150, 105, 0.2);
}

/* === [sidebar] 侧边栏 === */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1000;
    width: var(--sidebar-width);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-top: var(--topbar-height);
    background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-light));
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-nav-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-bottom: 8px;
    scrollbar-width: thin;
}

.sidebar .nav { padding: 8px; gap: 1px; }

.sidebar .nav-section {
    display: block;
    margin: 16px 0 6px;
    padding: 0 12px;
    color: rgba(148, 163, 184, 0.65);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    pointer-events: none;
    user-select: none;
}
.sidebar .nav-section:first-child { margin-top: 8px; }

.sidebar .nav-link {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 36px;
    padding: 6px 12px 6px 14px;
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.82rem;
    font-weight: 500;
    line-height: 1.25;
    transition: color var(--motion-base) var(--easing),
                background var(--motion-base) var(--easing);
}

.sidebar .nav-link i {
    width: 20px;
    margin-right: 10px;
    text-align: center;
    font-size: 0.92rem;
    color: rgba(255, 255, 255, 0.55);
    transition: color var(--motion-base) var(--easing);
}

.sidebar .nav-link:hover {
    color: var(--surface);
    background: rgba(255, 255, 255, 0.07);
}
.sidebar .nav-link:hover i { color: var(--surface); }

.sidebar .nav-link.active {
    color: var(--surface);
    background: rgba(37, 99, 235, 0.18);
    box-shadow: inset 3px 0 0 var(--accent-line);
}
.sidebar .nav-link.active i { color: var(--accent-line); }

.sidebar .nav-link.text-danger { color: rgba(248, 113, 113, 0.9); }
.sidebar .nav-link.text-danger:hover {
    color: var(--danger-light);
    background: rgba(220, 38, 38, 0.12);
}

.nav-badge {
    margin-left: auto;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--danger);
    color: var(--surface);
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}

.sidebar-footer {
    flex: 0 0 auto;
    padding: 10px;
    background: linear-gradient(180deg, transparent, var(--sidebar-light));
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* === [topbar] 顶部导航栏 === */
.topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    z-index: 1001;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--surface-border);
    backdrop-filter: saturate(180%) blur(10px);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
}

.topbar-subtitle {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.topbar-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 0 1 auto;
}

.topbar-divider {
    width: 1px;
    height: 20px;
    background: var(--surface-border);
}

.topbar-icon-btn {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    position: relative;
    transition: background var(--motion-fast) var(--easing),
                color var(--motion-fast) var(--easing),
                border-color var(--motion-fast) var(--easing);
}
.topbar-icon-btn:hover {
    color: var(--accent);
    background: var(--accent-soft);
    border-color: var(--accent-line);
}
.topbar-icon-btn:active { transform: scale(0.96); }

.topbar-notif-dot {
    position: absolute;
    top: 3px;
    right: 3px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--danger);
    color: var(--surface);
    font-size: 0.6rem;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
}

.topbar-identity {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    max-width: min(300px, 36vw);
    padding: 4px 10px 4px 4px;
    border: 1px solid var(--surface-border);
    border-radius: 999px;
    background: var(--surface-soft);
    color: var(--text-main);
    text-decoration: none;
    transition: background var(--motion-fast) var(--easing),
                border-color var(--motion-fast) var(--easing);
}
.topbar-identity:hover {
    color: var(--text-main);
    background: var(--surface);
    border-color: var(--border-strong);
}

.topbar-avatar {
    width: 26px;
    height: 26px;
    flex: 0 0 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid var(--accent-line);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}

.topbar-identity-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}
.topbar-identity-name {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-main);
    font-size: 0.8rem;
    font-weight: 600;
}
.topbar-identity-meta {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-muted);
    font-size: 0.68rem;
}

.topbar-notif-panel {
    width: 320px;
    max-height: 400px;
    padding: 0;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.topbar-notif-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--surface-soft);
    border-bottom: 1px solid var(--surface-border);
    color: var(--text-main);
    font-weight: 700;
    font-size: 0.82rem;
}
.topbar-notif-list { padding: 4px 0; max-height: 340px; overflow-y: auto; }

.topbar-role-pill {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 9px;
    border-radius: 999px;
    border: 1px solid var(--surface-border);
    background: var(--surface-soft);
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 700;
    white-space: nowrap;
}

.body-role-platform .topbar-role-pill {
    border-color: rgba(220, 38, 38, 0.2);
    background: rgba(254, 226, 226, 0.6);
    color: var(--danger-pressed);
}
.body-role-manager .topbar-role-pill {
    border-color: rgba(37, 99, 235, 0.2);
    background: rgba(219, 234, 254, 0.7);
    color: var(--accent-dark);
}
.body-role-sales .topbar-role-pill {
    border-color: rgba(5, 150, 105, 0.2);
    background: rgba(209, 250, 229, 0.7);
    color: var(--success-dark);
}

/* 侧栏 active 按角色着色 */
.body-role-platform .sidebar .nav-link.active {
    background: rgba(220, 38, 38, 0.18);
    box-shadow: inset 3px 0 0 var(--danger-light);
}
.body-role-platform .sidebar .nav-link.active i { color: var(--danger-light); }

.body-role-manager .sidebar .nav-link.active,
.body-role-sales .sidebar .nav-link.active {
    background: rgba(37, 99, 235, 0.18);
    box-shadow: inset 3px 0 0 var(--accent-line);
}
.body-role-manager .sidebar .nav-link.active i,
.body-role-sales .sidebar .nav-link.active i { color: var(--accent-line); }

/* === [main-content] 主体容器 === */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding: calc(var(--topbar-height) + 20px) 24px 32px;
    background: var(--page-bg);
    overflow-x: hidden;
}

.main-content > * {
    width: 100%;
    max-width: var(--content-max-width);
    min-width: 0;
    margin-left: auto;
    margin-right: auto;
}

/* 公司端工作台（经理/销售）数据页占满主内容区，避免宽屏两侧留白 */
.body-role-manager .main-content > *,
.body-role-sales .main-content > * {
    max-width: none;
    margin-left: 0;
    margin-right: 0;
}

@media (min-width: 901px) {
    .body-role-manager .main-content,
    .body-role-sales .main-content {
        padding-left: 18px;
        padding-right: 18px;
    }
}

/* === [mobile-bottom-nav] 移动端底部导航 === */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1003;
    align-items: stretch;
    justify-content: space-around;
    gap: 2px;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid var(--surface-border);
    box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.06);
    backdrop-filter: saturate(180%) blur(8px);
    -webkit-backdrop-filter: saturate(180%) blur(8px);
}

.mobile-nav-item {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 52px;
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 600;
    text-decoration: none;
    transition: color var(--motion-fast) var(--easing),
                background var(--motion-fast) var(--easing),
                transform var(--motion-fast) var(--easing);
}
.mobile-nav-item i { font-size: 1.15rem; }
.mobile-nav-item:active { transform: scale(0.96); }
.mobile-nav-item.active {
    color: var(--accent);
    background: var(--accent-soft);
}

/* === [responsive-mobile] 响应式移动端（隐藏侧栏 / 主内容 padding-bottom / mobile-bottom-nav 显示）=== */
@media (max-width: 900px) {
    :root {
        --sidebar-width: 0px;
        --topbar-height: 0px;
    }

    .brand {
        position: sticky;
        top: 0;
        width: 100%;
        height: 50px;
        z-index: 1002;
        justify-content: flex-start;
        gap: 8px;
        padding-right: 12px;
    }
    .brand > span:first-of-type { flex: 1 1 auto; min-width: 0; }
    .brand-role-pill { display: inline-flex; }

    .sidebar,
    .sidebar-footer { display: none !important; }

    .topbar { display: none !important; }

    .main-content {
        margin-left: 0;
        padding: 16px 12px 24px;
        padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px)) !important;
        scroll-padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px));
    }

    .mobile-bottom-nav { display: flex !important; min-height: 60px; }
}
