// ==================== Shared Layouts 样式 ====================
// 所有样式都用根类名包裹，避免全局污染

$brand-color: #0055AA;
$brand-color-light: #EBF5FF;
$brand-color-hover: #004488;

// ==================== SubSidebarLayout ====================
.sidebar-layout {
    display: flex;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    background: #f8fafc;
    font-family: 'Inter', 'Noto Sans SC', sans-serif;

    .sidebar {
        width: 224px;
        height: 100%;
        background: #fff;
        display: flex;
        flex-direction: column;
        color: #333;
        flex-shrink: 0;
        transition: all 0.3s ease;
        border-right: 1px solid #f1f5f9;
        position: relative;
        
        &.collapsed {
            width: 64px;
            overflow: visible;
            
            .sidebar-header {
                padding: 16px 0;
                justify-content: center;
                .logo { display: none; }
                .collapse-btn { display: flex; }
            }
            
            .nav-item {
                justify-content: center;
                padding: 10px;
                margin: 2px 8px;
                span { display: none; }
                .expand-icon { display: none; }
                &:hover .nav-tooltip { opacity: 1; visibility: visible; }
            }
            
            .nav-child-item { display: none; }
            .user-section { justify-content: center; padding: 16px 8px; }
        }
    }

    .sidebar-header {
        height: 64px;
        padding: 0 16px;
        border-bottom: 1px solid #f1f5f9;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .collapse-btn {
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px;
        cursor: pointer;
        color: #94a3b8;
        background: transparent;
        border: none;
        transition: all 0.2s;
        flex-shrink: 0;
        
        &:hover { background: #f1f5f9; color: #64748b; }
        svg { width: 20px; height: 20px; }
    }

    .expand-toggle {
        position: absolute;
        right: -12px;
        top: 80px;
        width: 24px;
        height: 24px;
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
        transition: all 0.2s;
        z-index: 10;
        
        &:hover { background: #f8fafc; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); }
    }

    .logo {
        display: flex;
        align-items: center;
        gap: 8px;
        
        .logo-img {
            width: 100%;
            height: 32px;
            border-radius: 8px;
            object-fit: contain;
        }
        
        .logo-text {
            font-size: 15px;
            font-weight: 600;
            color: #1e293b;
            white-space: nowrap;
        }
    }

    .nav-menu {
        flex: 1;
        padding: 8px 0;
        
        &::-webkit-scrollbar { width: 4px; }
        &::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.1); border-radius: 4px; }
        &::-webkit-scrollbar-track { background: transparent; }
    }

    .nav-section { padding: 0; }
    .nav-group { margin-bottom: 4px; }
    .nav-children { padding-left: 12px; }
    .nav-child-wrapper { margin-bottom: 2px; }
    .nav-sub-children { padding-left: 12px; }

    .nav-item {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        padding: 10px 16px;
        margin: 2px 8px;
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.2s ease;
        color: #64748b;
        font-size: 14px;
        font-weight: 500;
        
        &:hover { background: #f8fafc; color: #475569; }
        &.active { background: $brand-color-light; color: $brand-color; }
        &.has-children { cursor: pointer; }
        
        span {
            flex: 1;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        
        .expand-icon {
            font-size: 14px;
            color: #94a3b8;
            transition: transform 0.2s;
        }
        
        .nav-tooltip {
            position: absolute;
            left: calc(100% + 16px);
            top: 50%;
            transform: translateY(-50%);
            background: #1e293b;
            color: #fff;
            padding: 6px 12px;
            border-radius: 6px;
            font-size: 12px;
            white-space: nowrap;
            z-index: 100;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
            opacity: 0;
            visibility: hidden;
            transition: all 0.2s;
            pointer-events: none;
            
            .tooltip-arrow {
                position: absolute;
                right: 100%;
                top: 50%;
                transform: translateY(-50%);
                border: 5px solid transparent;
                border-right-color: #1e293b;
            }
        }
    }

    .nav-child-item {
        padding: 8px 16px 8px 40px;
        margin: 1px 8px;
        border-radius: 6px;
        font-size: 13px;
        font-weight: 400;
        
        &:hover { background: #f8fafc; color: #475569; }
        &.active {
            background: $brand-color;
            color: #fff;
            font-weight: 500;
        }
    }

    .nav-sub-child-item {
        padding: 6px 16px 6px 56px;
        margin: 1px 8px;
        border-radius: 6px;
        font-size: 13px;
        font-weight: 400;
        color: #64748b;
        
        &:hover { background: #f8fafc; color: #475569; }
        &.active { background: $brand-color; color: #fff; }
    }

    .main-content {
        flex: 1;
        height: 100%;
        overflow: hidden;
        background: #f8fafc;
        position: relative;
        padding: 0px;
    }

    &.no-sidebar .main-content {
        width: 100%;
    }

    // 响应式
    @media (max-width: 768px) {
        .sidebar {
            width: 64px;
            
            &:not(.collapsed) {
                width: 224px;
                position: fixed;
                left: 0;
                top: 0;
                z-index: 1000;
                box-shadow: 4px 0 16px rgba(0, 0, 0, 0.1);
            }
        }
    }
}

// ==================== BlankLayout ====================
.blank-layout {
    width: 100%;
    height: 100vh;
    overflow: hidden;
}
