/* ==========================================================================
   宝之通增长中台 · 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.07);
    color: var(--surface);
    font-size: 0.95rem;
    font-weight: 650;
    letter-spacing: 0.2px;
}

.brand i {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: var(--surface);
    background: var(--brand-gradient);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.45);
    font-size: 0.85rem;
}

.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:
        radial-gradient(120% 60px at 18% 0%, rgba(59, 100, 235, 0.18), transparent 70%),
        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: 10px; gap: 2px; }

.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: 38px;
    padding: 6px 12px 6px 14px;
    border-radius: var(--radius-md);
    color: rgba(226, 232, 240, 0.74);
    font-size: 0.84rem;
    font-weight: 500;
    line-height: 1.25;
    transition: color var(--motion-base) var(--easing),
                background var(--motion-base) var(--easing),
                box-shadow var(--motion-base) var(--easing);
}

.sidebar .nav-link i {
    width: 20px;
    margin-right: 10px;
    text-align: center;
    font-size: 0.95rem;
    color: rgba(226, 232, 240, 0.5);
    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);
    font-weight: 600;
    background: var(--brand-gradient);
    box-shadow: 0 3px 12px rgba(37, 99, 235, 0.38);
}
.sidebar .nav-link.active i { color: var(--surface); }

.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);
}

/* 退出登录：默认中性灰，悬停才提示危险色，避免常驻红色干扰视线 */
.sidebar-footer .sidebar-logout { color: rgba(255, 255, 255, 0.55); }
.sidebar-footer .sidebar-logout:hover,
.sidebar-footer .sidebar-logout:focus-visible {
    color: #fca5a5;
    background: rgba(220, 38, 38, 0.12);
}

/* === [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-search {
    position: relative;
    display: flex;
    align-items: center;
    flex: 0 1 360px;
    min-width: 160px;
    margin: 0 16px;
}
.topbar-search > i {
    position: absolute;
    left: 11px;
    color: var(--text-faint);
    font-size: 0.82rem;
    pointer-events: none;
}
.topbar-search-input {
    width: 100%;
    min-height: 34px;
    padding: 4px 40px 4px 32px;
    border: 1px solid var(--surface-border);
    border-radius: 999px;
    background: var(--surface-soft);
    color: var(--text-main);
    font-size: 0.84rem;
    outline: none;
    transition: border-color var(--motion-fast) var(--easing),
                background var(--motion-fast) var(--easing),
                box-shadow var(--motion-fast) var(--easing);
}
.topbar-search-input::placeholder { color: var(--text-faint); }
.topbar-search-input:focus {
    background: var(--surface);
    border-color: var(--accent-line);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.topbar-search-kbd {
    position: absolute;
    right: 10px;
    padding: 1px 7px;
    border: 1px solid var(--surface-border);
    border-bottom-width: 2px;
    border-radius: 5px;
    background: var(--surface);
    color: var(--text-faint);
    font-size: 0.7rem;
    font-family: inherit;
    pointer-events: none;
}
.topbar-search-input:focus ~ .topbar-search-kbd { display: none; }

@media (max-width: 1100px) {
    .topbar-search { display: none; }
}

.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) + 8px) 24px 24px;
    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;
}

/* 公司端工作台（经理/销售）：普通宽屏占满；2K+ 大屏限宽居中，
   避免表格被拉到 2500px+ 后内容稀疏、视线横跨过长 */
.body-role-manager .main-content > *,
.body-role-sales .main-content > * {
    max-width: 1760px;
    margin-left: auto;
    margin-right: auto;
}

/* 2K 及以上：适当放大基准字号与留白，保持与 1080p 相近的视觉密度 */
@media (min-width: 2200px) {
    :root {
        --fs-base: 0.9375rem;  /* 15px */
        --fs-sm: 0.875rem;     /* 14px */
        --fs-xs: 0.8125rem;    /* 13px */
    }
    .main-content { padding-left: 40px; padding-right: 40px; }
}

@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: 56px;
    }
    .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: flex !important;
        top: 8px;
        right: 10px;
        left: auto;
        width: 34px;
        height: 34px;
        padding: 0;
        border: 0;
        background: transparent;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
    .topbar-subtitle,
    .topbar-meta > :not(.topbar-notif) { display: none !important; }
    .topbar-meta { gap: 0; }
    .topbar-notif-panel {
        position: fixed !important;
        top: 48px !important;
        right: 8px !important;
        left: auto !important;
        width: min(360px, calc(100vw - 16px));
        transform: 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; }
}
