// ==================== 品牌色变量 ====================
$brand-color: #0055AA;
$brand-color-light: #EBF5FF;
$brand-color-hover: #004488;

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

// ==================== 2级侧边栏（子导航样式）====================
.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;
            }
            
            // 折叠状态下显示 tooltip
            &: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);
    }
    
    .el-icon {
        font-size: 14px;
        color: #64748b;
    }
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    
    .logo-icon {
        width: 32px;
        height: 32px;
        background: #3b82f6;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        
        .el-icon {
            font-size: 18px;
            color: #fff;
        }
    }
    
    .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;
    // overflow-y: auto;
    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;
}

// 1级导航项（分组标题）
.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;
    }
    
    .el-icon {
        font-size: 18px;
        flex-shrink: 0;
    }
    
    span {
        flex: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .expand-icon {
        font-size: 14px;
        color: #94a3b8;
        transition: transform 0.2s;
    }
    
    // 折叠时的 Tooltip
    .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;
        }
    }
}

// 2级导航项（子菜单）
.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;
        
        .el-icon {
            color: #fff;
        }
    }
    
    .el-icon {
        font-size: 16px;
    }
}

// 3级导航项
.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;
    }
}

// 用户信息
.user-section {
    padding: 16px;
    border-top: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background 0.2s;
    
    &:hover {
        background: #f8fafc;
    }
    
    .user-info-wrapper {
        display: flex;
        align-items: center;
        gap: 12px;
    }
    
    .user-avatar {
        flex-shrink: 0;
    }
    
    .user-name {
        font-size: 14px;
        font-weight: 500;
        color: #374151;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

// ==================== 主内容区 ====================
.main-content {
    flex: 1;
    height: 100%;
    overflow: hidden;
    background: #f8fafc;
    position: relative;
}

// iframe 容器
.iframe-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

.iframe-header {
    height: 56px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #e2e8f0;
    background: #fff;
    flex-shrink: 0;
}

.iframe-title {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
}

.content-iframe {
    flex: 1;
    width: 100%;
    height: 100%;
    border: none;
    background: #fff;
}

.iframe-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: $brand-color;
    font-size: 14px;
    z-index: 10;
    
    .el-icon {
        font-size: 32px;
    }
}

// ==================== 响应式 ====================
@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);
        }
    }
    
    .iframe-header {
        padding: 0 16px;
        
        .iframe-title {
            font-size: 14px;
        }
    }
}
