/* ========== Reset & Base ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; font-family: -apple-system, "Microsoft YaHei", "PingFang SC", sans-serif; font-size: 14px; color: #333; background: #f0f2f5; }
button { cursor: pointer; border: none; outline: none; font-family: inherit; font-size: 13px; }
input { font-family: inherit; font-size: 13px; }

/* ========== Topbar ========== */
.topbar {
  height: 48px; background: #1a1a2e; color: #fff; display: flex; align-items: center;
  padding: 0 16px; gap: 24px; position: sticky; top: 0; z-index: 100;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; }
.btn-settings {
  background: none; color: #aaa; font-size: 18px; width: 32px; height: 32px;
  border-radius: 6px; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.btn-settings:hover { background: rgba(255,255,255,0.1); color: #fff; }
.logo { font-size: 15px; letter-spacing: 0.5px; }
.topbar-nav { display: flex; gap: 8px; align-items: center; }
.nav-label { color: #aaa; font-size: 13px; }
.nav-sep { color: #555; font-size: 13px; }

/* ========== Main Layout ========== */
.main-layout {
  display: flex; height: calc(100vh - 48px);
}
.panel { display: flex; flex-direction: column; overflow: hidden; }
.panel-files { width: 420px; min-width: 360px; background: #fff; border-right: 1px solid #e5e7eb; }
.panel-xbb { flex: 1; background: #f5f5f5; }

/* ========== Breadcrumb ========== */
.breadcrumb {
  padding: 10px 12px; font-size: 12px; color: #666; border-bottom: 1px solid #f0f0f0;
  white-space: nowrap; overflow-x: auto;
}
.breadcrumb a { color: #2563eb; cursor: pointer; text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb span { margin: 0 4px; color: #ccc; }

/* ========== Toolbar ========== */
.toolbar {
  display: flex; gap: 8px; padding: 10px 12px; border-bottom: 1px solid #f0f0f0;
  flex-wrap: wrap;
}
.btn {
  padding: 7px 16px; border-radius: 6px; background: #f3f4f6; color: #333;
  font-size: 13px; transition: background 0.15s; white-space: nowrap;
}
.btn:hover { background: #e5e7eb; }
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }

/* ========== File List ========== */
.file-list {
  flex: 1; overflow-y: auto; padding: 4px 0;
}
.file-item {
  display: flex; align-items: center; padding: 8px 12px; gap: 10px;
  cursor: pointer; border-bottom: 1px solid #f9fafb; transition: background 0.1s;
  user-select: none;
}
.file-item:hover { background: #f3f4f6; }
.file-item.selected { background: #eff6ff; }
.file-item .icon { width: 28px; text-align: center; font-size: 18px; flex-shrink: 0; }
.file-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.file-item .size { font-size: 11px; color: #999; flex-shrink: 0; width: 60px; text-align: right; }
.file-item .actions { display: flex; gap: 4px; flex-shrink: 0; }
.file-item .actions button {
  padding: 3px 8px; border-radius: 4px; font-size: 11px; background: #f3f4f6;
}
.file-item .actions button:hover { background: #e5e7eb; }
.file-item .actions .btn-del:hover { background: #fee2e2; color: #ef4444; }
.file-item.dragging { opacity: 0.4; }
.file-item.drag-over { background: #dbeafe; outline: 2px dashed #2563eb; outline-offset: -2px; }
.loading { padding: 24px; text-align: center; color: #999; }

/* ========== 销帮帮面板 ========== */
.xbb-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; background: #fff; border-bottom: 1px solid #e5e7eb;
  font-size: 12px; color: #666;
}
.xbb-hint { flex: 1; }
#xbbIframe { flex: 1; width: 100%; border: none; }

/* ========== Modal ========== */
.modal {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.6); z-index: 200; display: flex;
  align-items: center; justify-content: center;
}
.modal.hidden { display: none; }
.modal-content {
  background: #fff; border-radius: 12px; width: 90%; max-width: 640px;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid #eee; font-weight: 600;
}
.btn-close { font-size: 22px; background: none; color: #999; padding: 0 4px; }
.btn-close:hover { color: #333; }
.camera-body { position: relative; background: #000; min-height: 300px; display: flex; align-items: center; justify-content: center; }
#cameraVideo, #cameraCanvas { width: 100%; max-height: 420px; object-fit: contain; }
.camera-actions { display: flex; gap: 8px; padding: 12px 16px; justify-content: center; }
.photo-preview { padding: 0 16px 12px; text-align: center; }
.photo-preview.hidden { display: none; }
#previewImg { max-width: 100%; max-height: 300px; border-radius: 6px; }

/* ========== Toast ========== */
.toast {
  position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%);
  padding: 10px 24px; background: #333; color: #fff; border-radius: 8px;
  font-size: 13px; z-index: 300; transition: opacity 0.3s; box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.toast.hidden { opacity: 0; pointer-events: none; }
.toast.error { background: #ef4444; }
.toast.success { background: #16a34a; }

/* ========== 拖拽遮罩 ========== */
.drag-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(37,99,235,0.08); z-index: 150; pointer-events: none;
  display: flex; align-items: center; justify-content: center; font-size: 18px; color: #2563eb;
}
.drag-overlay.hidden { display: none; }

/* ========== 设置面板 ========== */
.settings-content { max-width: 400px; }
.settings-tabs {
  display: flex; border-bottom: 1px solid #e5e7eb; padding: 0 16px;
}
.settings-tab {
  padding: 10px 16px; font-size: 13px; color: #666; background: none;
  border-bottom: 2px solid transparent; transition: color 0.15s, border-color 0.15s;
}
.settings-tab:hover { color: #2563eb; }
.settings-tab.active { color: #2563eb; border-bottom-color: #2563eb; font-weight: 600; }
.settings-body { padding: 16px; }
.settings-tab-content { display: none; }
.settings-tab-content.active { display: block; }
.settings-section { margin-bottom: 16px; }
.settings-section label { font-weight: 600; font-size: 14px; display: block; margin-bottom: 6px; }
.settings-desc { font-size: 12px; color: #888; line-height: 1.6; }

/* ========== 响应式 ========== */
@media (max-width: 768px) {
  .main-layout { flex-direction: column; }
  .panel-files { width: 100%; min-width: 0; height: 50%; }
  .panel-xbb { flex: 1; }
}
/* 横屏拍摄适配 */
@media (orientation: landscape) {
  .modal-content { max-width: 560px; max-height: 90vh; }
  .camera-body { min-height: 180px; }
  #cameraVideo, #cameraCanvas { max-height: 65vh; }
}
/* ===== 图片查看器 ===== */
.image-viewer-content { max-width: 90vw; max-height: 90vh; }
.image-viewer-body { display: flex; align-items: center; justify-content: center; overflow: auto; }
.image-viewer-body img { max-width: 100%; max-height: 72vh; object-fit: contain; border-radius: 4px; }

/* ===== 登录页 ===== */
.login-overlay { position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; }
.login-overlay.hidden { display: none; }
.login-card { background: #fff; border-radius: 8px; padding: 40px 32px; width: 360px; max-width: 90vw; box-shadow: 0 4px 24px rgba(0,0,0,.15); text-align: center; }
.login-card h2 { margin: 0 0 24px; font-size: 20px; color: #333; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-form input[type="text"],
.login-form input[type="password"] { padding: 10px 12px; border: 1px solid #d9d9d9; border-radius: 4px; font-size: 14px; outline: none; }
.login-form input:focus { border-color: #1890ff; }
.login-actions { margin-top: 4px; }
.btn-block { width: 100%; padding: 10px; }
.login-switch { font-size: 13px; color: #999; }
.login-switch a { color: #1890ff; text-decoration: none; }
.login-error { color: #ff4d4f; font-size: 13px; margin: 0; }
.login-error.hidden, .login-form.hidden { display: none; }

/* ===== 设置 - 安全设置 ===== */
.change-pwd-form { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.change-pwd-form input { padding: 8px 10px; border: 1px solid #d9d9d9; border-radius: 4px; font-size: 13px; outline: none; }
.change-pwd-form input:focus { border-color: #1890ff; }

/* ===== 设置 - 高级管理 ===== */
.settings-toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; margin-top: 8px; }
.settings-toggle input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }
.admin-user-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
.admin-user-table th, .admin-user-table td { border-bottom: 1px solid #f0f0f0; padding: 8px 6px; text-align: left; }
.admin-user-table th { background: #fafafa; font-weight: 500; }
.admin-add-user { display: flex; gap: 6px; margin-top: 10px; align-items: center; }
.admin-add-user input, .admin-add-user select { padding: 6px 8px; border: 1px solid #d9d9d9; border-radius: 4px; font-size: 13px; }
.admin-add-user input { width: 100px; }
.btn-danger { background: #ff4d4f; color: #fff; }
.btn-danger:hover { background: #ff7875; }
.btn-sm { font-size: 12px; padding: 4px 10px; }
