/**
 * 布局样式 - 清晰分层无重叠
 * LAN Transfer - Layout Styles
 */

/* ========== 基础页面结构 ========== */
html, body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background: var(--bg-primary);
    overflow-x: hidden; /* 防止横向溢出 */
}

body {
    padding-top: 72px; /* 为固定顶栏留出空间 */
}

/* ========== 顶栏（全宽固定） ========== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 72px;
    background: linear-gradient(180deg, var(--bg-secondary) 0%, rgba(22, 27, 34, 0.98) 100%);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 28px;
    z-index: 1000;
    gap: 20px;
    /* Windows drag region */
    -webkit-app-region: drag;
    app-region: drag;
}

.header > * {
    -webkit-app-region: no-drag;
    app-region: no-drag;
}

/* 移动端顶栏内容（默认隐藏） */
.mobile-header-content {
    display: none;
}

/* 桌面端专用元素 */
.desktop-only {
    display: flex;
}

/* 顶栏Logo */
.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-logo-icon {
    font-size: 26px;
}

.header-logo-text {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(90deg, var(--text-primary), var(--accent-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-logo-tag {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-purple);
    background: rgba(163, 113, 247, 0.15);
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid rgba(163, 113, 247, 0.3);
}

/* 顶栏左侧区域 */
.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1;
}

/* 顶栏右侧区域 */
.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* 存储进度条容器 */
.storage-bar-container {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 280px;
    max-width: 400px;
}

.storage-bar-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

.storage-bar-track {
    flex: 1;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    min-width: 120px;
}

.storage-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-success), var(--accent-primary));
    border-radius: 4px;
    transition: width 0.3s ease;
}

.storage-bar-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.storage-bar-info span:first-child {
    font-weight: 600;
    color: var(--accent-primary);
}

/* 网络状态 - 精简样式 */
.network-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

.network-dot {
    font-size: 10px;
}

.network-dot.online {
    color: var(--accent-success);
}

.network-ip {
    font-family: var(--font-mono);
    color: var(--text-secondary);
}

/* 控制区 */
.header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 100%;
}

.admin-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: linear-gradient(135deg, rgba(248, 81, 73, 0.15), rgba(163, 113, 247, 0.15));
    border: 1px solid rgba(248, 81, 73, 0.4);
    border-radius: 18px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-danger);
    height: 32px;
    box-sizing: border-box;
}

.admin-dot {
    width: 6px;
    height: 6px;
    background: var(--accent-danger);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 4px;
    height: 44px;
    box-sizing: border-box;
}

.ctrl-btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.ctrl-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.ctrl-btn.primary {
    background: var(--accent-primary);
    color: #000;
}

/* 主题切换按钮 */
.theme-btn {
    position: relative;
    overflow: hidden;
}

.theme-icon {
    width: 20px;
    height: 20px;
    position: absolute;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-icon.sun {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

.theme-icon.moon {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

/* 暗色模式下显示月亮 */
[data-theme="dark"] .theme-icon.sun {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

[data-theme="dark"] .theme-icon.moon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* 刷新按钮 */
.refresh-symbol {
    font-size: 20px;
    line-height: 1;
    transition: transform 0.6s ease;
}

.refresh-btn.refreshing .refresh-symbol {
    animation: spin 0.8s linear infinite;
}

/* ========== 左侧在线用户面板（独立浮动） ========== */
.sidebar {
    position: fixed;
    left: 12px;
    top: 84px; /* 顶栏下方 12px 间距 */
    width: 180px; /* 侧边栏宽度 */
    z-index: 999;
}

/* 面板头部（可点击展开/收起） */
.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.sidebar-header:hover {
    border-color: var(--accent-success);
}

.sidebar-icon {
    font-size: 18px;
}

.sidebar-title {
    font-size: 14px;
    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 10px;
    border-radius: 12px;
}

.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 {
    margin-top: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 0 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    
    /* 动画 */
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transform: translateY(-10px);
    transition: max-height 0.35s ease-out, opacity 0.25s ease-out, transform 0.3s ease-out, padding 0.3s ease;
    pointer-events: none;
}

/* 展开状态 */
.sidebar.expanded .sidebar-content {
    max-height: 500px;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    padding: 16px;
}

/* 在线用户列表 */
.online-users-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.online-user-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.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);
}

.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;
    flex: 1;
    min-width: 0;
}

.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);
}

/* ========== 主内容区 ========== */
.main-content {
    padding: 24px 24px 24px 32px;
    margin-left: 210px; /* 为左侧边栏留出空间 (180px + 30px间距) */
    width: calc(100% - 234px); /* 总宽度减去侧边栏(180px) + 左间距(12px) + 右间距(24px) */
    max-width: none;
    box-sizing: border-box;
    overflow-x: hidden; /* 防止内容溢出 */
    min-width: 0; /* 允许内容区域收缩 */
}

@media (max-width: 1400px) {
    .main-content {
        margin-left: 205px;
        width: calc(100% - 229px);
        padding: 20px 20px 20px 28px;
        box-sizing: border-box;
        min-width: 0;
    }
}

@media (max-width: 1200px) {
    .main-content {
        margin-left: 200px;
        width: calc(100% - 224px);
        padding: 20px 16px 20px 24px;
        box-sizing: border-box;
        min-width: 0;
    }
}

@media (max-width: 768px) {
    .main-content {
        margin-left: 0;
        max-width: 100%;
        padding: 16px;
    }
}

/* ========== Tab 翻页动画 ========== */
.tab-content-wrapper {
    position: relative;
    overflow: hidden;
    min-height: 400px;
}

.tab-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    opacity: 0;
    transform: translateX(50px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
    visibility: hidden;
    pointer-events: none;
}

.tab-content.active {
    position: relative;
    opacity: 1;
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
}

.tab-content.slide-out-left {
    opacity: 0;
    transform: translateX(-50px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.tab-content.slide-in-right {
    opacity: 1;
    transform: translateX(0);
    transition: opacity 0.3s ease 0.05s, transform 0.3s ease 0.05s;
}

/* 移动端减少动画距离 */
@media (max-width: 768px) {
    .tab-content {
        transform: translateX(30px);
    }
    
    .tab-content.slide-out-left {
        transform: translateX(-30px);
    }
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
    .tab-content,
    .tab-content.active,
    .tab-content.slide-out-left,
    .tab-content.slide-in-right {
        transition: none;
        transform: none;
    }
}

/* ========== 响应式适配 ========== */
@media (max-width: 768px) {
    body {
        padding-top: 72px;
    }
    
    .header {
        display: flex;
        flex-wrap: wrap;
        height: auto;
        min-height: 72px;
        padding: 12px 16px;
    }
    
    .header-logo {
        order: 1;
    }
    
    .header-controls {
        order: 2;
        margin-left: auto;
    }
    
    .header-status-panel {
        order: 3;
        width: 100%;
        margin-top: 10px;
    }
    
    .main-content {
        margin-left: 0;
        padding: 16px;
        max-width: 100%;
    }
    
    .sidebar {
        left: 12px;
        top: 84px;
        width: calc(100% - 24px);
        max-width: 300px;
    }
}
