/**
 * ======================================================
 * 左侧菜单栏（对齐本地工具布局）
 * 桌面：232px 固定侧栏；≤1024 收成 72px 图标栏；≤768 抽屉 + 底部导航
 * ======================================================
 */
:root {
    --sb-w: 232px;
    --sb-w-mini: 72px;
}

.app-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sb-w);
    background: #fff;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    z-index: 1100;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.app-sidebar .sb-brand {
    height: 60px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 18px;
    font-weight: 700;
    font-size: 17px;
    color: #1e293b;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
    text-decoration: none;
}

.app-sidebar .sb-brand .logo {
    font-size: 22px;
    line-height: 1;
}

.app-sidebar .sb-brand .txt {
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sb-nav {
    padding: 10px 10px 18px;
    flex: 1;
}

.sb-group {
    font-size: 11px;
    letter-spacing: 1px;
    color: #9ca3af;
    padding: 14px 10px 6px;
}

.sb-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    color: #374151;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 2px;
    transition: background .15s, color .15s;
    position: relative;
    text-decoration: none;
}

.sb-item:hover {
    background: #f8fafc;
    color: #6d28d9;
}

.sb-item.active {
    background: #f5f3ff;
    color: #6d28d9;
    font-weight: 600;
}

.sb-item.active::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: #8b5cf6;
}

.sb-item .si {
    width: 22px;
    text-align: center;
    font-size: 17px;
    flex-shrink: 0;
}

.sb-item .si-arrow {
    margin-left: auto;
    color: #cbd5e1;
    font-size: 12px;
}

.sb-item .sb-badge {
    margin-left: auto;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 10px;
    padding: 1px 6px;
    line-height: 1.5;
}

.sb-item.danger {
    color: #dc2626;
}

.sb-item.danger:hover {
    background: #fef2f2;
    color: #b91c1c;
}

.sb-foot {
    margin-top: auto;
    border-top: 1px solid #f1f5f9;
    padding: 10px;
    flex-shrink: 0;
}

.sb-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 1099;
}

.sb-overlay.active {
    display: block;
}

/* 桌面：内容整体让出侧栏宽度 */
@media (min-width: 769px) {
    body.has-sidebar .page-content,
    body.has-sidebar .footer,
    body.has-sidebar .navbar {
        margin-left: var(--sb-w);
    }

    body.has-sidebar .navbar-brand {
        display: none;
    }

    body.has-sidebar .navbar .btn-desktop-only {
        display: none !important;
    }

    body.has-sidebar .navbar .navbar-nav {
        margin-left: auto;
    }
}

/* 平板：图标栏 */
@media (max-width: 1024px) and (min-width: 769px) {
    .app-sidebar {
        width: var(--sb-w-mini);
    }

    .app-sidebar .sb-brand {
        padding: 0;
        justify-content: center;
    }

    .app-sidebar .sb-brand .txt {
        display: none;
    }

    .sb-nav {
        padding: 8px 6px;
    }

    .sb-group {
        font-size: 0;
        height: 12px;
        padding: 0;
    }

    .sb-item {
        justify-content: center;
        padding: 10px 4px;
    }

    .sb-item .sl,
    .sb-item .si-arrow,
    .sb-item .sb-badge {
        display: none;
    }

    .sb-item.active::before {
        left: -6px;
    }

    .sb-item:hover::after {
        content: attr(data-label);
        position: absolute;
        left: 100%;
        top: 50%;
        transform: translateY(-50%);
        margin-left: 8px;
        background: #1f2937;
        color: #fff;
        font-size: 12px;
        padding: 4px 8px;
        border-radius: 6px;
        white-space: nowrap;
        z-index: 1200;
        pointer-events: none;
    }

    body.has-sidebar .page-content,
    body.has-sidebar .footer,
    body.has-sidebar .navbar {
        margin-left: var(--sb-w-mini);
    }

    body.has-sidebar .navbar-brand {
        display: none;
    }

    body.has-sidebar .navbar .btn-desktop-only {
        display: none !important;
    }
}

/* 手机：左侧抽屉 + 保留底部导航 */
@media (max-width: 768px) {
    .app-sidebar {
        width: 264px;
        max-width: 82%;
        transform: translateX(-100%);
        transition: transform .25s ease;
        z-index: 2001;
        box-shadow: 4px 0 30px rgba(0, 0, 0, .12);
    }

    .app-sidebar.active {
        transform: translateX(0);
    }

    .sb-overlay {
        z-index: 2000;
    }

    body.has-sidebar .page-content,
    body.has-sidebar .footer,
    body.has-sidebar .navbar {
        margin-left: 0;
    }

    body.has-sidebar .page-content {
        padding-bottom: 78px;
    }

    .app-sidebar .sb-brand {
        height: 56px;
    }
}
