/**
 * 侧边栏样式 - 下拉式在线用户
 * LAN Transfer - Sidebar Styles
 */

/* ========== 在线用户下拉容器 ========== */
.sidebar {
    position: fixed;
    left: 16px;
    top: 84px; /* 顶栏下方，留出足够间距 */
    width: 220px;
    z-index: 1100; /* 高于顶栏 */
}

/* ========== 下拉头部按钮 ========== */
.sidebar-dropdown-header {
    position: relative;
    z-index: 1102; /* 确保头部在最上层 */
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.sidebar-dropdown-header:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-success);
}

.sidebar-icon {
    font-size: 18px;
}

.sidebar-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.sidebar-count {
    margin-left: auto;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-success);
    background: rgba(63, 185, 80, 0.15);
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 24px;
    text-align: center;
}

.sidebar-arrow {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: transform 0.3s ease;
}

.sidebar-arrow svg {
    width: 14px;
    height: 14px;
}

/* 展开时旋转箭头 */
.sidebar.expanded .sidebar-arrow {
    transform: rotate(180deg);
}

/* ========== 下拉内容区域 ========== */
.sidebar-content {
    position: relative;
    z-index: 1101; /* 确保内容在最上层 */
    margin-top: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    
    /* 动画效果 */
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transform: translateY(-10px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

/* 展开状态 */
.sidebar.expanded .sidebar-content {
    max-height: 400px;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* ========== 在线用户列表 ========== */
.online-users-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 320px;
    overflow-y: auto;
}

.online-user-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: var(--bg-tertiary);
    border-radius: 10px;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    cursor: default;
}

.online-user-item:hover {
    background: var(--bg-primary);
    border-color: var(--border-color);
    transform: translateX(4px);
}

.online-user-item.self {
    background: rgba(63, 185, 80, 0.1);
    border-color: rgba(63, 185, 80, 0.2);
}

.online-user-item.self:hover {
    background: rgba(63, 185, 80, 0.15);
}

/* 用户头像 */
.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-purple));
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.online-user-item.self .user-avatar {
    background: linear-gradient(135deg, var(--accent-success), #3fb950);
}

/* 用户信息 */
.user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.user-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-status {
    font-size: 11px;
    color: var(--accent-success);
    display: flex;
    align-items: center;
    gap: 4px;
}

.user-status::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--accent-success);
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(63, 185, 80, 0.5);
}

/* 更多用户提示 */
.online-user-item.more {
    opacity: 0.8;
    background: transparent;
    border: 1px dashed var(--border-color);
    justify-content: center;
}

.online-user-item.more:hover {
    background: var(--bg-tertiary);
    transform: none;
}

.online-user-item.more .user-avatar {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-size: 14px;
}

/* ========== 主内容区 ========== */
.main-wrapper {
    min-height: 100vh;
    padding-left: 16px;
    padding-right: 16px;
}

/* ========== 遮罩层 ========== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1090; /* 低于侧边栏但高于主内容 */
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

/* ========== 响应式适配 ========== */
@media (max-width: 768px) {
    .sidebar {
        left: 12px;
        top: 68px;
        width: calc(100% - 24px);
        max-width: 300px;
    }
    
    .sidebar-dropdown-header {
        padding: 12px 16px;
    }
    
    .sidebar.expanded .sidebar-content {
        max-height: 60vh;
    }
    
    .online-users-list {
        max-height: 50vh;
    }
}

/* ========== 亮色主题适配 ========== */
[data-theme="light"] .sidebar-dropdown-header {
    background: #ffffff;
    border-color: #d0d7de;
}

[data-theme="light"] .sidebar-dropdown-header:hover {
    background: #f6f8fa;
    border-color: #3fb950;
}

[data-theme="light"] .sidebar-title {
    color: #24292f;
}

[data-theme="light"] .sidebar-count {
    background: rgba(26, 127, 55, 0.1);
    color: #1a7f37;
}

[data-theme="light"] .sidebar-content {
    background: #ffffff;
    border-color: #d0d7de;
}

[data-theme="light"] .online-user-item {
    background: #f6f8fa;
}

[data-theme="light"] .online-user-item:hover {
    background: #ffffff;
    border-color: #d0d7de;
}

[data-theme="light"] .online-user-item.self {
    background: rgba(26, 127, 55, 0.1);
    border-color: rgba(26, 127, 55, 0.2);
}

[data-theme="light"] .online-user-item.self:hover {
    background: rgba(26, 127, 55, 0.15);
}

[data-theme="light"] .user-name {
    color: #24292f;
}

[data-theme="light"] .user-status {
    color: #1a7f37;
}

[data-theme="light"] .user-status::before {
    background: #1a7f37;
    box-shadow: 0 0 6px rgba(26, 127, 55, 0.5);
}

[data-theme="light"] .online-user-item.more {
    border-color: #d0d7de;
}

[data-theme="light"] .online-user-item.more:hover {
    background: #f6f8fa;
}

[data-theme="light"] .online-user-item.more .user-avatar {
    background: #eaeef2;
    color: #6e7781;
}

/* ========== 内网穿透按钮栏 ========== */
.tunnel-bar {
    position: fixed;
    left: 16px;
    bottom: 20px;
    z-index: 1099;
    display: none; /* 默认隐藏，只有本机才显示 */
    align-items: center;
    gap: 8px;
}

.tunnel-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.tunnel-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.tunnel-icon {
    font-size: 18px;
}

.tunnel-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

/* 开关样式 */
.tunnel-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    cursor: pointer;
}

.tunnel-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.tunnel-switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    transition: 0.3s;
    border-radius: 24px;
}

.tunnel-switch-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-muted);
    transition: 0.3s;
    border-radius: 50%;
}

.tunnel-switch input:checked + .tunnel-switch-slider {
    background-color: var(--accent-success);
    border-color: var(--accent-success);
}

.tunnel-switch input:checked + .tunnel-switch-slider:before {
    transform: translateX(20px);
    background-color: white;
}

/* ========== 内网穿透弹窗 ========== */
.tunnel-header-icon {
    margin-right: 8px;
}

.tunnel-info {
    padding: 4px 0;
}

.tunnel-desc {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 20px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border-left: 3px solid var(--accent-primary);
}

/* 开关行 */
.tunnel-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 16px;
}

.tunnel-toggle-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

/* 开关样式 */
.tunnel-toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.tunnel-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.tunnel-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    transition: 0.3s;
    border-radius: 24px;
}

.tunnel-toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-muted);
    transition: 0.3s;
    border-radius: 50%;
}

.tunnel-toggle-switch input:checked + .tunnel-toggle-slider {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.tunnel-toggle-switch input:checked + .tunnel-toggle-slider:before {
    transform: translateX(20px);
    background-color: white;
}

/* 输入区域 */
.tunnel-input-section {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.tunnel-input-group {
    margin-bottom: 16px;
}

.tunnel-input-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.tunnel-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font-mono);
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.tunnel-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(47, 129, 247, 0.2);
}

.tunnel-input-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* 操作按钮 */
.tunnel-actions {
    margin-bottom: 16px;
}

.tunnel-test-btn {
    display: flex;
    align-items: center;
    gap: 6px;
}

.test-icon {
    display: inline-block;
    transition: transform 0.6s ease;
}

.tunnel-test-btn.testing .test-icon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* 测试结果 */
.tunnel-test-result {
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
}

.tunnel-test-result.success {
    background: rgba(63, 185, 80, 0.15);
    border: 1px solid rgba(63, 185, 80, 0.3);
    color: var(--accent-success);
}

.tunnel-test-result.error {
    background: rgba(248, 81, 73, 0.15);
    border: 1px solid rgba(248, 81, 73, 0.3);
    color: var(--accent-danger);
}

/* 工具推荐 */
.tunnel-tools {
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.tunnel-tools-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.tunnel-tools-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tunnel-tool-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-decoration: none !important;
    transition: all 0.2s ease;
}

.tunnel-tool-item:hover {
    background: var(--bg-primary);
    border-color: var(--accent-primary);
    transform: translateX(4px);
    text-decoration: none !important;
}

.tunnel-tool-item:hover .tool-name,
.tunnel-tool-item:hover .tool-desc {
    text-decoration: none !important;
}

.tool-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-primary);
    text-decoration: none !important;
}

.tool-desc {
    font-size: 11px;
    color: var(--text-muted);
}

/* 亮色主题适配 */
[data-theme="light"] .tunnel-btn {
    background: #ffffff;
    border-color: #d0d7de;
}

[data-theme="light"] .tunnel-btn:hover {
    background: #f6f8fa;
    border-color: #0969da;
}

[data-theme="light"] .tunnel-text {
    color: #24292f;
}

[data-theme="light"] .tunnel-desc {
    background: #f6f8fa;
    border-left-color: #0969da;
}

[data-theme="light"] .tunnel-input {
    background: #ffffff;
    border-color: #d0d7de;
    color: #24292f;
}

[data-theme="light"] .tunnel-input:focus {
    border-color: #0969da;
    box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.2);
}

[data-theme="light"] .tunnel-tool-item {
    background: #f6f8fa;
    border-color: #d0d7de;
}

[data-theme="light"] .tunnel-tool-item:hover {
    background: #ffffff;
    border-color: #0969da;
    text-decoration: none !important;
}

[data-theme="light"] .tunnel-tool-item:hover .tool-name,
[data-theme="light"] .tunnel-tool-item:hover .tool-desc {
    text-decoration: none !important;
}

[data-theme="light"] .tool-name {
    color: #0969da;
    text-decoration: none !important;
}

[data-theme="light"] .tunnel-test-result.success {
    background: rgba(26, 127, 55, 0.1);
    border-color: rgba(26, 127, 55, 0.3);
    color: #1a7f37;
}

[data-theme="light"] .tunnel-test-result.error {
    background: rgba(207, 34, 46, 0.1);
    border-color: rgba(207, 34, 46, 0.3);
    color: #cf222e;
}

[data-theme="light"] .tunnel-switch-slider {
    background-color: #eaeef2;
    border-color: #d0d7de;
}

[data-theme="light"] .tunnel-switch input:checked + .tunnel-switch-slider {
    background-color: #1a7f37;
    border-color: #1a7f37;
}
