/* ===== 统一页面样式规范 - 与主页保持一致 ===== */

/* 页面容器 */
.page-wrapper {
  min-height: 100vh;
  background: #fafafa;
}

/* 顶部导航 - 统一样式 */
.top-bar {
  background: #ffffff;
  border-bottom: 1px solid #f0f0f0;
  padding: 12px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 24px;
}

.logo {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo svg {
  color: var(--primary-color);
}

.nav-links {
  display: flex;
  gap: 20px;
}

.nav-link {
  color: #666666;
  text-decoration: none;
  font-size: 14px;
  transition: color 0.2s;
}

.nav-link:hover {
  color: var(--primary-color);
}

.nav-link.active {
  color: var(--primary-color);
  font-weight: 500;
}

.top-bar-right {
  display: flex;
  gap: 12px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666666;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: #f5f5f5;
  color: var(--primary-color);
}

/* 页面内容区 */
.page-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px;
}

/* 页面标题 */
.page-title {
  font-size: 24px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 24px;
}

/* 卡片样式 - 统一规范 */
.card {
  background: #ffffff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  margin-bottom: 24px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #f0f0f0;
}

.card-title {
  font-size: 18px;
  font-weight: 600;
  color: #1a1a1a;
  margin: 0;
}

/* 表单元素 - 统一规范 */
.form-section {
  margin-bottom: 24px;
}

.form-label {
  display: block;
  font-size: 13px;
  color: #666666;
  margin-bottom: 8px;
  font-weight: 500;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #f0f0f0;
  border-radius: 8px;
  font-size: 14px;
  color: #1a1a1a;
  background: #fff;
  transition: all 0.2s;
  font-family: inherit;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(255, 107, 53, 0.08);
}

.form-textarea {
  min-height: 100px;
  resize: vertical;
  line-height: 1.6;
}

/* 按钮 - 统一规范 */
.btn-primary {
  padding: 10px 20px;
  background: var(--primary-color);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255, 107, 53, 0.2);
}

.btn-secondary {
  padding: 10px 20px;
  background: #fff;
  color: #666666;
  border: 1px solid #f0f0f0;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-secondary:hover {
  background: #f5f5f5;
  border-color: #d9d9d9;
  color: #1a1a1a;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 1px solid #f0f0f0;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666666;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: #f5f5f5;
  border-color: #d9d9d9;
  color: var(--primary-color);
}

/* 标签 - 统一规范 */
.tag-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.tag-item {
  padding: 6px 12px;
  background: #f5f5f5;
  border: 1px solid #f0f0f0;
  border-radius: 6px;
  font-size: 13px;
  color: #666666;
  cursor: pointer;
  transition: all 0.2s;
}

.tag-item:hover {
  background: #fff0e8;
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.tag-item.active {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: #fff;
}

/* 列表项 - 统一规范 */
.list-item {
  background: #fff;
  border: 1px solid #f0f0f0;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
  transition: all 0.2s;
}

.list-item:hover {
  border-color: #d9d9d9;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* 网格布局 */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}

/* ===== 数据库页面专属样式 ===== */

/* 页面整体 */
.db-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 32px;
  min-height: 100vh;
}

/* 页面头部 */
.db-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 2px solid #f0f0f0;
}

.db-header h1 {
  font-size: 26px;
  font-weight: 700;
  color: #1a1a1a;
  display: flex;
  align-items: center;
  gap: 10px;
}

.db-header h1 svg { color: var(--primary-color); }

.db-header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* 导航按钮 */
.db-nav-btn {
  padding: 8px 16px;
  background: #fff;
  color: #555;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.db-nav-btn:hover {
  background: #f5f7fa;
  border-color: var(--primary-color);
  color: var(--primary-color);
}

/* 统计面板 */
.db-stats-panel {
  max-width: 1200px;
  margin: 0 auto 0.5rem;
}

.db-stats-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.db-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.db-stat-card {
  background: var(--bg-secondary);
  border-radius: 10px;
  padding: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border: 1px solid var(--border-color);
  transition: all 0.25s ease;
  cursor: default;
}

.db-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.06);
  border-color: #e0e0e0;
}

.db-stat-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
}

.db-stat-icon.orange   { background: rgba(255,107,53,0.15); color: #ff6b35; }
.db-stat-icon.green  { background: rgba(16,185,129,0.15); color: #10b981; }
.db-stat-icon.orange { background: rgba(245,158,11,0.15); color: #f59e0b; }
.db-stat-icon.purple { background: rgba(139,92,246,0.15); color: #8b5cf6; }
.db-stat-icon.pink   { background: rgba(236,72,153,0.15); color: #ec4899; }

.db-stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.db-stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 400;
}

/* 状态分布条 */
.db-status-bar-wrap {
  background: var(--bg-secondary);
  border-radius: 10px;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
}

.db-status-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.db-status-bar-title {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.db-status-bar-count {
  font-size: 11px;
  color: var(--text-secondary);
}

.db-status-bar-track {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg-primary);
  margin-bottom: 0.4rem;
}

.db-status-bar-segment {
  height: 100%;
  transition: width 0.6s ease;
}

.db-status-legend {
  display: flex;
  gap: 0.75rem;
  font-size: 11px;
  flex-wrap: wrap;
}

.db-status-legend-item {
  display: flex;
  align-items: center;
  gap: 3px;
  color: var(--text-secondary);
}

.db-status-legend-dot {
  width: 6px;
  height: 6px;
  border-radius: 2px;
  flex-shrink: 0;
}

.db-status-legend-item b { color: var(--text-primary); font-weight: 600; }

/* TOP5 面板 */
.db-top-panel {
  background: var(--bg-secondary);
  border-radius: 10px;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
}

.db-top-title {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 0.4rem;
}

.db-top-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.db-top-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 12px;
}

.db-top-rank {
  width: 16px;
  text-align: center;
  font-weight: 700;
  color: var(--text-secondary);
  font-size: 11px;
  flex-shrink: 0;
}

.db-top-rank.gold   { color: #f59e0b; }
.db-top-rank.silver { color: #94a3b8; }
.db-top-rank.bronze { color: #d97706; }

.db-top-info {
  flex: 1;
  min-width: 0;
}

.db-top-name {
  color: var(--text-primary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
  max-width: 100%;
  margin-bottom: 1px;
}

.db-top-meta {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.db-top-bar-bg {
  flex: 1;
  height: 3px;
  background: var(--bg-primary);
  border-radius: 2px;
  overflow: hidden;
}

.db-top-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff6b35, #f59e0b);
  border-radius: 2px;
  transition: width 0.6s ease;
}

.db-top-words {
  color: var(--text-secondary);
  font-size: 10px;
  flex-shrink: 0;
  min-width: 45px;
  text-align: right;
}

/* 状态标签 */
.db-status-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  flex-shrink: 0;
  font-weight: 500;
}

.db-status-tag.writing   { background: #fff0e8; color: #ff6b35; }
.db-status-tag.completed { background: #e6f7ee; color: #10b981; }
.db-status-tag.paused    { background: #fff7e6; color: #f59e0b; }

/* 批量工具栏 */
.db-batch-toolbar {
  margin-bottom: 18px;
  padding: 12px 16px;
  background: #fff;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  border: 1px solid #f0f0f0;
}

.db-batch-toolbar label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 14px;
  user-select: none;
  color: #555;
}

.db-batch-toolbar input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary-color);
}

.db-batch-count {
  color: #999;
  font-size: 14px;
}

/* 书籍列表网格 */
.db-book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

/* 书籍卡片 */
.db-book-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  border: 1px solid #f0f0f0;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
}

.db-book-card:hover {
  border-color: #ffd4c2;
  box-shadow: 0 8px 30px rgba(255,107,53,0.08);
  transform: translateY(-2px);
}

.db-book-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, #ff6b35, #f59e0b);
  border-radius: 12px 12px 0 0;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.db-book-card:hover::before {
  opacity: 1;
}

.db-book-checkbox {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 2;
  cursor: pointer;
  width: 18px;
  height: 18px;
  accent-color: var(--primary-color);
}

.db-book-body {
  padding-left: 36px;
}

.db-book-title {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.db-book-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: #999;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.db-book-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.db-book-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.db-book-delete {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  color: #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.db-book-delete:hover {
  background: #fee2e2;
  color: #ef4444;
}

/* 删除按钮 */
.db-btn-danger {
  padding: 8px 20px;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  margin-left: auto;
}

.db-btn-danger:hover {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  box-shadow: 0 4px 15px rgba(239,68,68,0.25);
  transform: translateY(-1px);
}

.db-btn-danger:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* 章节视图 */
.db-chapter-view {
  background: #fff;
  border-radius: 16px;
  padding: 28px;
  border: 1px solid #f0f0f0;
  box-shadow: 0 2px 12px rgba(0,0,0,0.03);
}

.db-chapter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid #f0f0f0;
}

.db-chapter-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: #1a1a1a;
}

/* 大纲区块 */
.db-outline-section {
  background: #fafbfd;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 18px;
  border: 1px solid #f0f0f0;
  position: relative;
}

.db-outline-section::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 3px;
  height: 100%;
  background: linear-gradient(180deg, #ff6b35, #f59e0b);
  border-radius: 3px 0 0 3px;
}

.db-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.db-section-title {
  font-size: 15px;
  font-weight: 600;
  color: #1a1a1a;
  display: flex;
  align-items: center;
  gap: 8px;
}

.db-section-edit {
  padding: 5px 12px;
  background: #fff;
  color: var(--primary-color);
  border: 1px solid #ffd4c2;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.db-section-edit:hover {
  background: var(--primary-color);
  color: #fff;
  border-color: var(--primary-color);
}

/* 章节大纲内容 */
.db-outline-content {
  color: #555;
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
}

.db-outline-empty {
  color: #bbb;
  font-style: italic;
  padding: 8px 0;
}

/* 角色区域 */
.db-character-section {
  background: #fafbfd;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 18px;
  border: 1px solid #f0f0f0;
  position: relative;
}

.db-character-section::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 3px;
  height: 100%;
  background: linear-gradient(180deg, #10b981, #06b6d4);
  border-radius: 3px 0 0 3px;
}

.db-character-card {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 10px;
  border: 1px solid #f0f0f0;
  transition: all 0.2s;
}

.db-character-card:hover {
  border-color: #ffd4c2;
  box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}

.db-character-name {
  font-size: 15px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 8px;
}

.db-character-row {
  display: flex;
  gap: 8px;
  font-size: 13px;
  color: #666;
  line-height: 1.6;
  margin-bottom: 4px;
}

.db-character-label {
  color: #999;
  flex-shrink: 0;
  min-width: 50px;
  font-weight: 500;
}

.db-character-value {
  color: #555;
}

.db-subsection-title {
  font-size: 13px;
  font-weight: 600;
  color: #888;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.db-section-divider {
  border: none;
  border-top: 1px solid #f0f0f0;
  margin: 12px 0;
}

/* 章节卡片 */
.db-chapter-card {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 8px;
  border: 1px solid #f0f0f0;
  cursor: pointer;
  transition: all 0.2s;
}

.db-chapter-card:hover {
  border-color: #ffd4c2;
  box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}

.db-chapter-card-title {
  font-size: 15px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 6px;
}

.db-chapter-card-meta {
  font-size: 13px;
  color: #999;
}

/* 用户分组 */
.db-user-group {
  margin-bottom: 28px;
}

.db-user-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #fff8f5, #fff0e8);
  border-radius: 10px;
  border: 1px solid #ffd4c2;
}

.db-user-group-header span:first-child {
  font-weight: 600;
  color: #1a1a1a;
}

.db-user-group-header span:last-child {
  font-size: 12px;
  color: #999;
}

.db-admin-badge {
  padding: 10px 16px;
  background: linear-gradient(135deg, #fff7e6, #fff0d0);
  border-radius: 10px;
  border-left: 4px solid #f59e0b;
  margin-bottom: 20px;
  font-size: 14px;
  color: #b45309;
  font-weight: 500;
}

/* 加载/空状态 */
.db-loading {
  text-align: center;
  padding: 60px 20px;
  color: #999;
  font-size: 14px;
}

.db-empty {
  text-align: center;
  padding: 80px 20px;
  color: #bbb;
  font-size: 15px;
}

/* 章节弹窗 */
.db-chapter-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  backdrop-filter: blur(4px);
}

.db-chapter-modal {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  max-width: 800px;
  width: 90%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: dbModalIn 0.25s ease;
}

@keyframes dbModalIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.db-chapter-modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.db-chapter-modal-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: #1a1a1a;
}

.db-chapter-modal-close {
  width: 36px; height: 36px;
  background: #f5f5f5;
  border: none;
  border-radius: 8px;
  font-size: 20px;
  color: #999;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.db-chapter-modal-close:hover {
  background: #fee2e2;
  color: #ef4444;
}

.db-chapter-modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.db-chapter-content {
  white-space: pre-wrap;
  font-size: 15px;
  line-height: 1.9;
  color: #333;
  font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

/* 响应式 */
@media (max-width: 1024px) {
  .page-content {
    padding: 20px;
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .top-bar {
    padding: 12px 20px;
  }

  .nav-links {
    display: none;
  }

  .db-container {
    padding: 20px 16px;
  }

  .db-book-grid {
    grid-template-columns: 1fr;
  }

  .db-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
