/* ===== 基础重置 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f0f2f5;
  color: #333;
  font-size: 14px;
  overflow: hidden;
}
button { font-family: inherit; }

/* ===== 布局 ===== */
.app { display: flex; height: 100vh; }

/* ===== 侧边栏 ===== */
.sidebar {
  width: 320px;
  min-width: 320px;
  background: #fff;
  border-right: 1px solid #e8e8e8;
  display: flex;
  flex-direction: column;
}
.sidebar-header {
  padding: 14px 16px;
  border-bottom: 1px solid #e8e8e8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.sidebar-title { font-size: 16px; font-weight: 600; white-space: nowrap; }
.tree-container { flex: 1; overflow-y: auto; padding: 8px; }
.sidebar-footer {
  padding: 10px 16px;
  border-top: 1px solid #e8e8e8;
  font-size: 12px;
  color: #999;
  transition: all 0.2s;
  flex-shrink: 0;
}
.sidebar-footer.drag-over {
  background: #e6f7ff;
  color: #1890ff;
  border-color: #1890ff;
}
.footer-actions { margin-bottom: 8px; }
.footer-hint { text-align: center; color: #bbb; font-size: 12px; }

/* ===== 同步指示器 ===== */
.sync-indicator {
  padding: 6px 16px;
  font-size: 12px;
  border-bottom: 1px solid #e8e8e8;
  flex-shrink: 0;
  cursor: default;
}
.sync-disabled { color: #bbb; }
.sync-idle { color: #52c41a; }
.sync-syncing { color: #1890ff; }
.sync-synced { color: #52c41a; }
.sync-error { color: #ff4d4f; cursor: help; }
.sync-offline { color: #faad14; }

/* ===== 设置面板 ===== */
.settings-help {
  background: #f6f8fa; border: 1px solid #e1e4e8;
  border-radius: 4px; padding: 10px 12px;
  font-size: 12px; color: #586069; margin-bottom: 16px;
  line-height: 1.6;
}
.settings-help a { color: #1890ff; text-decoration: none; }
.settings-help a:hover { text-decoration: underline; }
.settings-help ol { margin-left: 18px; margin-top: 4px; }
.settings-status {
  background: #f6ffed; border: 1px solid #b7eb8f;
  border-radius: 4px; padding: 10px 12px;
  font-size: 13px; color: #389e0d; margin-bottom: 16px;
}
.settings-status.error {
  background: #fff1f0; border-color: #ffa39e; color: #cf1322;
}

/* ===== 按钮 ===== */
.btn {
  padding: 6px 14px;
  border: 1px solid #d9d9d9;
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn:hover { border-color: #1890ff; color: #1890ff; }
.btn-primary { background: #1890ff; color: #fff; border-color: #1890ff; }
.btn-primary:hover { background: #40a9ff; border-color: #40a9ff; color: #fff; }
.btn-danger { color: #ff4d4f; border-color: #ff4d4f; }
.btn-danger:hover { background: #ff4d4f; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; text-align: center; }

/* ===== 树节点 ===== */
.node {
  display: flex;
  align-items: center;
  padding: 5px 8px;
  border-radius: 4px;
  cursor: pointer;
  margin-bottom: 1px;
  user-select: none;
  transition: background 0.15s;
}
.node:hover { background: #f0f7ff; }
.node.selected { background: #e6f7ff; }
.node.drop-target { background: #bae7ff !important; border: 1px dashed #1890ff; }
.node.drop-denied { background: #ffccc7 !important; }
.indent { width: 20px; flex-shrink: 0; }
.expand-icon {
  width: 16px; height: 16px; margin-right: 2px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: #999; cursor: pointer; flex-shrink: 0;
}
.expand-icon:hover { color: #1890ff; }
.node-icon { margin-right: 6px; font-size: 16px; flex-shrink: 0; }
.node-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.type-tag {
  font-size: 10px; padding: 1px 6px; border-radius: 3px;
  margin-left: 6px; flex-shrink: 0;
}
.tag-folder { background: #fff7e6; color: #d46b08; }
.tag-leaf { background: #f6ffed; color: #389e0d; }
.node-actions { display: none; gap: 2px; margin-left: 4px; flex-shrink: 0; }
.node:hover .node-actions { display: flex; }
.node-actions button {
  border: none; background: transparent; cursor: pointer;
  color: #bbb; font-size: 14px; padding: 0 4px; line-height: 1;
}
.node-actions button:hover { color: #1890ff; }
.tree-empty {
  text-align: center; color: #bbb; padding: 60px 20px; font-size: 13px;
}

/* ===== 主内容区 ===== */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.main-header {
  padding: 14px 24px;
  background: #fff;
  border-bottom: 1px solid #e8e8e8;
  flex-shrink: 0;
}
.breadcrumb { font-size: 14px; color: #666; }
.breadcrumb .crumb { color: #1890ff; }
.main-body { flex: 1; padding: 24px; overflow-y: auto; }

/* ===== 面板 ===== */
.panel {
  background: #fff;
  border-radius: 8px;
  padding: 24px;
  max-width: 760px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.panel-title {
  font-size: 18px; font-weight: 600; margin-bottom: 20px;
  display: flex; align-items: center; gap: 8px;
}
.form-group { margin-bottom: 20px; }
.form-label {
  display: block; font-size: 14px; color: #333; margin-bottom: 6px;
  font-weight: 500;
}
.form-input, .form-textarea {
  width: 100%; padding: 8px 12px;
  border: 1px solid #d9d9d9; border-radius: 4px;
  font-size: 14px; font-family: inherit;
  transition: border-color 0.2s;
}
.form-input:focus, .form-textarea:focus {
  outline: none; border-color: #1890ff;
  box-shadow: 0 0 0 2px rgba(24,144,255,0.1);
}
.form-textarea { min-height: 80px; resize: vertical; }
.form-hint { font-size: 12px; color: #999; margin-top: 4px; }

/* ===== 上传区域 ===== */
.upload-area {
  border: 2px dashed #d9d9d9;
  border-radius: 8px;
  padding: 36px 20px;
  text-align: center;
  color: #999;
  cursor: pointer;
  transition: all 0.2s;
}
.upload-area:hover, .upload-area.drag-over {
  border-color: #1890ff; color: #1890ff; background: #f0f8ff;
}
.upload-icon { font-size: 32px; margin-bottom: 8px; }

/* ===== 文件卡片 ===== */
.file-card {
  display: flex; align-items: center;
  padding: 12px 16px;
  background: #f6ffed;
  border: 1px solid #b7eb8f;
  border-radius: 6px;
  gap: 12px;
}
.file-card-icon { font-size: 24px; }
.file-card-info { flex: 1; min-width: 0; }
.file-card-name {
  font-weight: 500; color: #333;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-card-meta { font-size: 12px; color: #999; margin-top: 2px; }
.file-card-link {
  color: #1890ff; text-decoration: none; font-size: 13px;
  padding: 4px 12px; border: 1px solid #1890ff; border-radius: 4px;
  white-space: nowrap; transition: all 0.2s; flex-shrink: 0;
}
.file-card-link:hover { background: #1890ff; color: #fff; }
.file-card-delete {
  color: #ff4d4f; cursor: pointer; font-size: 16px;
  padding: 4px; flex-shrink: 0;
}
.file-card-delete:hover { opacity: 0.7; }

/* ===== 空状态 ===== */
.empty-state {
  text-align: center; padding: 80px 20px; color: #bbb;
}
.empty-state-icon { font-size: 56px; margin-bottom: 16px; }
.empty-state-text { font-size: 15px; margin-bottom: 4px; color: #999; }
.empty-state-hint { font-size: 13px; color: #ccc; }

/* ===== 提示框 ===== */
.hint-box {
  background: #e6f7ff; border: 1px solid #91d5ff;
  border-radius: 4px; padding: 10px 14px;
  font-size: 13px; color: #096dd9; margin-bottom: 16px;
}

/* ===== 右键菜单 ===== */
.context-menu {
  position: fixed;
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 6px;
  box-shadow: 0 3px 12px rgba(0,0,0,0.12);
  padding: 4px 0;
  z-index: 1000;
  min-width: 170px;
  display: none;
}
.context-menu-item {
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  transition: background 0.15s;
}
.context-menu-item:hover { background: #f5f5f5; }
.context-menu-item.danger { color: #ff4d4f; }
.context-menu-item.danger:hover { background: #fff1f0; }
.context-menu-divider { height: 1px; background: #e8e8e8; margin: 4px 0; }
.context-menu-item.disabled { color: #ccc; cursor: not-allowed; }
.context-menu-item.disabled:hover { background: transparent; }

/* ===== 模态框 ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: none;
  align-items: center; justify-content: center;
  z-index: 2000;
}
.modal-overlay.active { display: flex; }
.modal {
  background: #fff;
  border-radius: 8px;
  width: 480px;
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 6px 24px rgba(0,0,0,0.15);
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e8e8e8;
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
  border: none; background: transparent; font-size: 22px;
  cursor: pointer; color: #999; line-height: 1; padding: 0;
}
.modal-close:hover { color: #333; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid #e8e8e8;
  display: flex; justify-content: flex-end; gap: 8px;
}
.modal-tree {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid #e8e8e8;
  border-radius: 4px;
  padding: 8px;
}
.modal-tree .node:hover { background: #f0f7ff; }
.modal-tree .node.selectable.selected { background: #e6f7ff; }
.modal-tree .node.disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== 单选组 ===== */
.radio-group { display: flex; gap: 20px; margin-bottom: 16px; }
.radio-item {
  display: flex; align-items: center; gap: 6px;
  cursor: pointer; padding: 8px 16px;
  border: 1px solid #d9d9d9; border-radius: 4px;
  transition: all 0.2s;
}
.radio-item:hover { border-color: #1890ff; }
.radio-item.checked { border-color: #1890ff; background: #e6f7ff; }
.radio-item input { cursor: pointer; }
.radio-item-label { font-size: 14px; }
.radio-item-hint { font-size: 12px; color: #999; }

/* ===== Toast ===== */
.toast-container {
  position: fixed; top: 20px; right: 20px;
  z-index: 3000; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 10px 16px;
  border-radius: 4px;
  font-size: 14px;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  animation: toastIn 0.3s ease;
  max-width: 360px;
}
.toast.success { background: #52c41a; }
.toast.error { background: #ff4d4f; }
.toast.info { background: #1890ff; }
.toast.warning { background: #faad14; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ===== 滚动条美化 ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }
::-webkit-scrollbar-track { background: transparent; }

/* ===== 内联编辑 ===== */
.node-edit-input {
  flex: 1; padding: 2px 6px;
  border: 1px solid #1890ff; border-radius: 3px;
  font-size: 14px; font-family: inherit;
  outline: none;
}

/* ===== 登录/注册页面 ===== */
.auth-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
}
.auth-container {
  background: #fff;
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.auth-logo {
  font-size: 48px;
  text-align: center;
  margin-bottom: 8px;
}
.auth-title {
  text-align: center;
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 24px;
  color: #333;
}
.auth-tabs {
  display: flex;
  border-bottom: 2px solid #e8e8e8;
  margin-bottom: 24px;
}
.auth-tab {
  flex: 1;
  text-align: center;
  padding: 12px 0;
  cursor: pointer;
  font-size: 15px;
  color: #999;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}
.auth-tab:hover { color: #1890ff; }
.auth-tab.active {
  color: #1890ff;
  border-bottom-color: #1890ff;
  font-weight: 500;
}
.auth-form .form-group { margin-bottom: 16px; }
.auth-form .form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  font-size: 14px;
  transition: all 0.2s;
}
.auth-form .form-input:focus {
  outline: none;
  border-color: #1890ff;
  box-shadow: 0 0 0 3px rgba(24,144,255,0.1);
}
.auth-form .btn-primary {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  margin-top: 8px;
}
.auth-hint {
  text-align: center;
  margin-top: 16px;
  font-size: 12px;
  color: #999;
}

/* ===== 用户信息区域 ===== */
.user-info {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e8e8e8;
}
.user-info-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.user-avatar {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  flex-shrink: 0;
}
.user-details { flex: 1; min-width: 0; }
.user-name {
  font-size: 14px;
  font-weight: 500;
  color: #333;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-role {
  font-size: 12px;
  color: #1890ff;
  margin-top: 2px;
}
.user-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.user-actions .btn {
  flex: 1;
  min-width: 0;
  font-size: 11px;
  padding: 4px 8px;
}
.btn-admin {
  color: #fa8c16;
  border-color: #ffa940;
}
.btn-admin:hover {
  background: #fa8c16;
  color: #fff;
  border-color: #fa8c16;
}
.btn-logout {
  color: #ff4d4f;
  border-color: #ffa39e;
}
.btn-logout:hover {
  background: #ff4d4f;
  color: #fff;
  border-color: #ff4d4f;
}

/* ===== 管理员后台 ===== */
.admin-page {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #f0f2f5;
  z-index: 100;
  overflow-y: auto;
}
.admin-header {
  background: #fff;
  padding: 16px 24px;
  border-bottom: 1px solid #e8e8e8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.admin-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: #333;
}
.admin-body {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px;
}
.admin-section {
  background: #fff;
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.admin-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: #333;
}
.user-table-container {
  overflow-x: auto;
}
.user-table {
  width: 100%;
  border-collapse: collapse;
}
.user-table th,
.user-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid #e8e8e8;
}
.user-table th {
  background: #fafafa;
  font-weight: 500;
  color: #666;
  font-size: 13px;
}
.user-table td {
  font-size: 14px;
}
.user-table tr:hover {
  background: #f5f5f5;
}
.tag-admin {
  display: inline-block;
  padding: 2px 8px;
  background: #fff7e6;
  color: #d46b08;
  border-radius: 3px;
  font-size: 12px;
}
.tag-user {
  display: inline-block;
  padding: 2px 8px;
  background: #e6f7ff;
  color: #1890ff;
  border-radius: 3px;
  font-size: 12px;
}
.text-muted {
  color: #bbb;
  font-size: 12px;
}
