/* === 管理页样式 === */
:root {
  --sidebar-width: 260px;
  --toolbar-height: 48px;
  --primary: #1a73e8;
  --primary-hover: #1557b0;
  --primary-light: #e8f0fe;
  --danger: #d93025;
  --danger-light: #fce8e6;
  --bg: #fff;
  --bg-secondary: #f8f9fa;
  --border: #e0e0e0;
  --text: #202124;
  --text-secondary: #5f6368;
  --text-muted: #9aa0a6;
  --radius: 6px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  color: var(--text);
  background: var(--bg);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* === 登录 === */
.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  backdrop-filter: blur(2px);
}

.login-box {
  background: #fff;
  border-radius: 12px;
  padding: 40px 36px;
  width: 380px;
  max-width: 90vw;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
  text-align: center;
}

.login-icon {
  margin-bottom: 16px;
}

.login-box h2 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 6px;
}

.login-box .subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 28px;
}

.login-box input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  outline: none;
  margin-bottom: 8px;
  transition: border 0.2s, box-shadow 0.2s;
  text-align: left;
}
.login-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}

.login-box .error-msg {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 16px;
  min-height: 18px;
  text-align: left;
}

.login-box button {
  width: 100%;
  padding: 10px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}
.login-box button:hover { background: var(--primary-hover); }
.login-box button:disabled { opacity: 0.6; cursor: not-allowed; }

/* === 顶部工具栏 === */
.toolbar {
  height: var(--toolbar-height);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 0;
  background: #fff;
  flex-shrink: 0;
}

.toolbar .site-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  margin-right: 16px;
  white-space: nowrap;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 8px;
}

.toolbar button,
.toolbar .btn {
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
}

.toolbar button:hover { background: var(--bg-secondary); color: var(--text); }

.toolbar .btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.toolbar .btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.toolbar .btn-outline {
  border-color: var(--border);
  background: #fff;
}
.toolbar .btn-outline:hover {
  background: var(--bg-secondary);
}

.toolbar .btn-text {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 6px 8px;
}
.toolbar .btn-text:hover {
  color: var(--danger);
  background: var(--danger-light);
}

.toolbar button svg {
  flex-shrink: 0;
}

/* 删除按钮特殊样式 */
#btnDelete:hover {
  color: var(--danger);
  background: var(--danger-light);
  border-color: transparent;
}

/* === 主体布局 === */
.admin-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* === 左侧文档列表 === */
.doc-panel {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  border-right: 1px solid var(--border);
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.doc-panel-header {
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.doc-panel-header .add-btn {
  width: 26px;
  height: 26px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.doc-panel-header .add-btn:hover {
  background: #e0e0e0;
  color: var(--text);
}

.doc-tree {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.doc-tree-item {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  gap: 6px;
  transition: all 0.12s;
  border-left: 3px solid transparent;
  user-select: none;
  position: relative;
}

.doc-tree-item:hover { background: #e8eaed; }

.doc-tree-item.selected {
  background: var(--primary-light);
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 500;
}

.doc-tree-item.folder {
  font-weight: 600;
  color: var(--text);
}

.doc-tree-item .icon {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.doc-tree-item .icon svg { opacity: 0.5; }
.doc-tree-item.selected .icon svg { opacity: 1; }

.doc-tree-item .title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-tree-item .actions {
  display: none;
  gap: 2px;
  flex-shrink: 0;
}
.doc-tree-item:hover .actions { display: flex; }
.doc-tree-item .actions button {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  padding: 2px 5px;
  border-radius: 3px;
  color: var(--text-muted);
  transition: all 0.1s;
  line-height: 1;
}
.doc-tree-item .actions button:hover {
  background: #d0d0d0;
  color: var(--text);
}
.doc-tree-item .actions button.del:hover {
  background: var(--danger-light);
  color: var(--danger);
}

.doc-tree-children { padding-left: 16px; }

/* 拖拽排序 */
.doc-tree-item[draggable="true"] { cursor: grab; }
.doc-tree-item[draggable="true"]:active { cursor: grabbing; }

.doc-tree-item.drag-over {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  background: var(--primary-light) !important;
}

.doc-tree-item.drag-before {
  border-top: 2px solid var(--primary);
}

.doc-tree-item.drag-after {
  border-bottom: 2px solid var(--primary);
}

/* === 右侧编辑区 === */
.editor-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
}

.editor-panel .doc-title-input {
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  font-size: 22px;
  font-weight: 600;
  outline: none;
  width: 100%;
  flex-shrink: 0;
  font-family: inherit;
}
.editor-panel .doc-title-input:focus {
  border-bottom-color: var(--primary);
}

.editor-meta {
  display: flex;
  gap: 16px;
  padding: 8px 24px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-secondary);
  align-items: center;
  flex-shrink: 0;
  background: #fafafa;
}

.editor-meta label {
  font-weight: 500;
  font-size: 12px;
  color: var(--text-muted);
}

.editor-meta select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  outline: none;
  background: #fff;
  cursor: pointer;
}
.editor-meta select:focus {
  border-color: var(--primary);
}

.ql-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* === 空状态 === */
.no-selection {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 15px;
  user-select: none;
}

/* === 密码弹窗 === */
#passwordDialog {
  border: none;
  border-radius: 12px;
  padding: 28px 24px;
  width: 360px;
  max-width: 90vw;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.22);
}

#passwordDialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

#passwordDialog h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
}

#passwordDialog input {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  margin-bottom: 8px;
  transition: border 0.2s;
}
#passwordDialog input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.08);
}

#pwError {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 16px;
  min-height: 18px;
}

.dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.dialog-actions button {
  padding: 8px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid var(--border);
}

.dialog-actions .btn-cancel {
  background: #fff;
  color: var(--text-secondary);
}
.dialog-actions .btn-cancel:hover { background: var(--bg-secondary); }

.dialog-actions .btn-confirm {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.dialog-actions .btn-confirm:hover { background: var(--primary-hover); }

/* === Quill 编辑器微调 === */
.ql-toolbar.ql-snow {
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 6px 16px;
  background: #fff;
}

.ql-container.ql-snow {
  border: none;
  font-size: 15px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

.ql-editor {
  padding: 20px 24px;
  line-height: 1.8;
}

.ql-editor.ql-blank::before {
  left: 24px;
  color: var(--text-muted);
  font-style: normal;
}

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