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

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

// ==================== 1级侧边栏 ====================
.sidebar {
    width: 256px;
    height: 100%;
    background: #fff;
    display: flex;
    flex-direction: column;
    color: #333;
    flex-shrink: 0;
    transition: width 0.3s ease;
    border-right: 1px solid #f1f5f9;
    z-index: 50;
    
    &.collapsed {
        width: 80px;
        overflow: visible;
        
        .sidebar-header {
            padding: 16px 0;
            justify-content: center;
        }
        
        .nav-item {
            justify-content: center;
            padding: 12px;
            border-radius: 8px;
            margin: 0 12px;
            
            span {
                display: none;
            }
            
            // 折叠状态下显示 tooltip
            &:hover .nav-tooltip {
                opacity: 1;
                visibility: visible;
            }
        }
        
        .user-section {
            justify-content: center;
            padding: 16px;
            
            .user-info, .user-more {
                display: none;
            }
        }
    }
}

// 侧边栏头部
.sidebar-header {
    height: 64px;
    padding: 0 16px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
}

.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;
    }
    
    .el-icon {
        font-size: 18px;
    }
}

.logo-img {
    height: 32px;
    width: 100%;
    border-radius: 8px;
    object-fit: contain;
}
.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    
    .logo-text {
        font-size: 16px;
        font-weight: 600;
        color: #1e293b;
        letter-spacing: -0.02em;
    }
}

// 折叠状态下的 Logo（可点击展开）
.logo-collapsed {
    position: relative;
    display: flex;
    justify-content: center;
    cursor: pointer;
    padding: 8px;
    border-radius: 12px;
    transition: all 0.2s;
    
    &:hover {
        background: #f1f5f9;
        
        .logo-tooltip {
            opacity: 1;
            visibility: visible;
        }
    }
    
    .logo-img {
        width: 100%;
        height: 32px;
        border-radius: 8px;
        object-fit: contain;
    }
    
    .logo-tooltip {
        position: absolute;
        left: 50%;
        top: calc(100% + 8px);
        transform: translateX(-50%);
        background: #1e293b;
        color: #fff;
        padding: 8px 16px;
        border-radius: 8px;
        font-size: 13px;
        font-weight: 600;
        white-space: nowrap;
        z-index: 100;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
        opacity: 0;
        visibility: hidden;
        transition: all 0.2s;
        pointer-events: none;
        
        .tooltip-arrow {
            position: absolute;
            left: 50%;
            bottom: 100%;
            transform: translateX(-50%);
            border: 6px solid transparent;
            border-bottom-color: #1e293b;
        }
    }
}

// 导航菜单
.nav-menu {
    flex: 1;
    // overflow-y: auto;
    padding: 8px 12px;
    
    &::-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-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 2px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #64748b;
    font-size: 14px;
    font-weight: 500;
    
    &:hover {
        background: $brand-color-light;
        color: $brand-color;
    }
    
    &.active {
        background: $brand-color;
        color: #fff;
        box-shadow: 0 4px 12px rgba($brand-color, 0.25);
        
        .el-icon {
            color: #fff;
        }
    }
    
    .el-icon {
        font-size: 18px;
        flex-shrink: 0;
        transition: color 0.2s;
    }
    
    span {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    // 折叠时的 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;
        }
    }
}

// 用户信息
.user-section {
    padding: 16px;
    border-top: 1px solid #f1f5f9;
    background: #f8fafc;
    cursor: pointer;
    transition: background 0.2s;
    
    &:hover {
        background: #f1f5f9;
        
        .user-name {
            color: $brand-color;
        }
    }
    
    .user-info-wrapper {
        display: flex;
        align-items: center;
        gap: 12px;
    }
    
    .user-avatar {
        position: relative;
        flex-shrink: 0;
        
        &::after {
            content: '';
            position: absolute;
            bottom: 0;
            right: 0;
            width: 10px;
            height: 10px;
            background: #22c55e;
            border: 2px solid #fff;
            border-radius: 50%;
        }
    }
    
    .user-info {
        flex: 1;
        min-width: 0;
    }
    
    .user-name {
        font-size: 14px;
        font-weight: 500;
        color: #374151;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        transition: color 0.2s;
    }
    
    .user-more {
        color: #94a3b8;
        
        &:hover {
            color: #64748b;
        }
    }
}

// ==================== 主内容区 ====================
.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: 80px;
        
        &:not(.collapsed) {
            width: 256px;
            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;
        }
    }
}
