/* ===== 全局重置 ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f14;
  --surface: #1a1a24;
  --surface2: #22222e;
  --border: #2a2a3a;
  --text: #e0e0e8;
  --text2: #8888a0;
  --primary: #6c5ce7;
  --primary-hover: #7c6cf7;
  --primary-dim: rgba(108,92,231,0.12);
  --success: #00d68f;
  --danger: #ff6b6b;
  --warning: #ffa940;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-card: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.2);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
}

html, body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ===== 页面容器 ===== */
.page {
  display: none;
  min-height: 100vh;
}
.page.active { display: block; }

/* ===== 登录界面 ===== */
#loginPage {
  display: none;
  align-items: center;
  justify-content: center;
}
#loginPage.active { display: flex; }
.login-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 32px;
  width: 360px;
  max-width: 92vw;
  text-align: center;
  box-shadow: var(--shadow);
}
.login-icon { font-size: 48px; margin-bottom: 8px; }
.login-container h1 { font-size: 24px; margin-bottom: 4px; }
.login-subtitle { color: var(--text2); font-size: 14px; margin-bottom: 28px; }
.password-wrapper input {
  width: 100%;
  padding: 14px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}
.password-wrapper input:focus {
  border-color: var(--primary);
}
.pwd-toggle {
  display: block;
  margin: 8px auto 0;
  background: none;
  border: none;
  font-size: 13px;
  cursor: pointer;
  color: var(--text2);
  transition: color 0.2s;
  padding: 4px 8px;
}
.pwd-toggle:hover {
  color: var(--primary);
}
.login-form button {
  width: 100%;
  margin-top: 12px;
  padding: 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.login-form button:hover { background: var(--primary-hover); }
.login-form button:active { transform: scale(0.98); }
.error-msg { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 20px; }

/* ===== 顶部栏 ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-title { font-size: 18px; font-weight: 700; }
.topbar-status {
  display: flex;
  align-items: center;
  gap: 10px;
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.status-dot.online { background: var(--success); box-shadow: 0 0 8px var(--success); }
.status-dot.offline { background: #555; }
.status-dot.connecting { background: var(--warning); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }
.online-badge {
  font-size: 12px;
  color: var(--text2);
  background: var(--surface2);
  padding: 4px 10px;
  border-radius: 20px;
}
.btn-logout {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}
.btn-logout:hover { background: var(--surface2); }

/* ===== Tab ===== */
.tabs {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 52px;
  z-index: 99;
}
.tab {
  flex: 1;
  padding: 14px;
  background: none;
  border: none;
  color: var(--text2);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}
.tab.active {
  color: var(--text);
  font-weight: 600;
}
.tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20%;
  width: 60%;
  height: 3px;
  background: var(--primary);
  border-radius: 3px 3px 0 0;
}
.tab:active { background: var(--surface2); }

.tab-content { display: none; padding: 16px; max-width: 1000px; margin: 0 auto; }
.tab-content.active { display: block; }

/* ===== 上传区域 ===== */
.upload-area {
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  margin-bottom: 16px;
}
.upload-area:hover, .upload-area.dragover {
  border-color: var(--primary);
  background: rgba(108,92,231,0.05);
}
.upload-icon { font-size: 48px; margin-bottom: 8px; }
.upload-area p { margin-bottom: 4px; }
.upload-hint { font-size: 12px; color: var(--text2); }
.file-input-hidden { display: none; }

/* ===== 进度条 ===== */
.progress-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.progress-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 14px;
  word-break: break-all;
}
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--success));
  border-radius: 3px;
  transition: width 0.3s;
}
.progress-detail {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text2);
}
.status-text { font-weight: 500; }
.status-text.done { color: var(--success); }
.status-text.error { color: var(--danger); }

/* ===== 左右布局：保存盒 + 文件卡片 ===== */
.files-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

/* ===== 保存到服务器盒 ===== */
.save-box {
  flex: 0 0 220px;
  min-height: 280px;
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  transition: all 0.3s;
  position: sticky;
  top: 116px;
}
.save-box.dragover {
  border-color: var(--success);
  background: rgba(0,214,143,0.06);
  box-shadow: 0 0 20px rgba(0,214,143,0.1);
}
.save-box-header {
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.save-box-hint {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text2);
  font-size: 13px;
  line-height: 1.6;
}
.save-box-hint .save-icon {
  font-size: 40px;
  margin-bottom: 8px;
  opacity: 0.5;
}
.save-box-footer {
  font-size: 11px;
  color: var(--text2);
  text-align: center;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  opacity: 0.6;
}

/* 已保存的文件列表（显示在保存盒内） */
.saved-files {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 400px;
  overflow-y: auto;
}
.saved-file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--primary-dim);
  border: 1px solid rgba(108,92,231,0.2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  animation: fadeIn 0.3s;
  cursor: default;
}
.saved-file-item .saved-icon { font-size: 16px; flex-shrink: 0; }
.saved-file-item .saved-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}
.saved-file-item .saved-check {
  color: var(--success);
  font-size: 14px;
}

/* ===== 文件卡片列表（右侧） ===== */
.files-section {
  flex: 1;
  min-width: 0;
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-header h3 { font-size: 16px; }
.file-card-list .loading { color: var(--text2); text-align: center; padding: 32px; }
.file-card-list .file-list-empty {
  text-align: center;
  color: var(--text2);
  padding: 40px 20px;
}

/* 文件卡片 */
.file-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: grab;
  transition: all 0.2s;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: var(--shadow-sm);
}
.file-card:hover {
  background: var(--surface2);
  border-color: #3a3a50;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.file-card:active {
  cursor: grabbing;
}
.file-card.dragging {
  opacity: 0.4;
  transform: scale(0.95);
  border-style: dashed;
}
.file-card.saved-card {
  border-color: rgba(108,92,231,0.3);
  background: rgba(108,92,231,0.04);
}
.file-card .file-icon { font-size: 28px; flex-shrink: 0; }
.file-card .file-info { flex: 1; min-width: 0; }
.file-card .file-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-card .file-meta {
  font-size: 12px;
  color: var(--text2);
  margin-top: 2px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.file-card .file-meta .saved-badge {
  color: var(--success);
  font-weight: 500;
}
.file-card .file-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.file-card .file-actions button {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: background 0.2s;
}
.file-card .file-actions button:hover { background: var(--surface2); }
.file-card .file-actions .btn-save {
  color: var(--success);
  font-size: 16px;
}
.file-card .file-actions .btn-save:hover {
  background: rgba(0,214,143,0.1);
}

/* ===== 剪贴板 ===== */
.clipboard-send {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.clipboard-send textarea {
  width: 100%;
  padding: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  resize: vertical;
  outline: none;
  font-family: var(--font);
  transition: border-color 0.2s;
}
.clipboard-send textarea:focus { border-color: var(--primary); }
.clipboard-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
  flex-wrap: wrap;
}
.auto-sync-label {
  font-size: 13px;
  color: var(--text2);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  cursor: pointer;
}
.auto-sync-label input { accent-color: var(--primary); }

.clipboard-list .loading {
  color: var(--text2);
  text-align: center;
  padding: 32px;
}
.clipboard-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
  transition: background 0.2s;
  animation: fadeIn 0.3s;
}
.clipboard-item:hover { background: var(--surface2); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.clipboard-text {
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 120px;
  overflow-y: auto;
}
.clipboard-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text2);
  margin-top: 6px;
}
.clipboard-copy-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.clipboard-copy-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ===== 通用按钮 ===== */
.btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn:hover { background: var(--border); }
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 24px;
  font-size: 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: all 0.3s;
  z-index: 999;
  pointer-events: none;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== 滚动条美化 ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #444; }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .files-layout {
    flex-direction: column;
  }
  .save-box {
    flex: none;
    width: 100%;
    min-height: 160px;
    position: static;
  }
  .save-box-hint .save-icon { font-size: 32px; }
  .saved-files {
    max-height: 200px;
    flex-direction: row;
    flex-wrap: wrap;
  }
  .saved-file-item {
    flex: 0 0 auto;
    max-width: 160px;
  }
}

@media (max-width: 480px) {
  .login-container { padding: 28px 20px; }
  .tab { padding: 12px 8px; font-size: 14px; }
  .tab-content { padding: 12px; }
  .upload-area { padding: 24px 16px; }
  .file-card { padding: 12px; }
  .file-card .file-name { font-size: 13px; }
  .file-card .file-actions button { font-size: 16px; }
  .clipboard-item { padding: 10px 12px; }
  .topbar-title { font-size: 16px; }
  .save-box { min-height: 120px; padding: 12px; }
}

/* ===== 暗色滚动条 ===== */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
