/* ===== 现代化数据库管理页面样式 ===== */

:root {
  --primary-color: #ff6b35;
  --primary-dark: #e55a2b;
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --text-primary: #333333;
  --text-secondary: #666666;
  --text-muted: #999999;
  --border-color: #e0e0e0;
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.12);
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --transition: all 0.25s ease;
}

* { 
  margin: 0; 
  padding: 0; 
  box-sizing: border-box; 
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

.container { 
  max-width: 1400px; 
  margin: 0 auto; 
  padding: 2rem; 
}

/* ===== 页面头部 - 现代化卡片设计 ===== */
.page-header {
  background: white;
  padding: 2rem;
  border-radius: var(--radius-lg);
  margin-bottom: 2rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-left: 5px solid var(--primary-color);
}

.page-header h1 {
  font-size: 28px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-primary);
}

.back-btn {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  transition: var(--transition);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-sm);
}

.back-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* ===== 书籍列表 - 卡片网格布局 ===== */
.book-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 1.5rem;
}

.book-card {
  background: white;
  border: none;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  box-shadow: var(--shadow-md);
  border-left: 4px solid var(--primary-color);
}

.book-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
}

.book-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}

.book-meta {
  display: flex;
  gap: 1rem;
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.book-status {
  display: inline-block;
  padding: 0.35rem 0.85rem;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  margin-top: 0.5rem;
}

.status-writing { 
  background: rgba(52, 152, 219, 0.1); 
  color: #3498db; 
  border: 1px solid rgba(52, 152, 219, 0.3); 
}

.status-completed { 
  background: rgba(40, 167, 69, 0.1); 
  color: #28a745; 
  border: 1px solid rgba(40, 167, 69, 0.3); 
}

.status-paused { 
  background: rgba(243, 156, 18, 0.1); 
  color: #f39c12; 
  border: 1px solid rgba(243, 156, 18, 0.3); 
}

/* ===== 删除按钮 - 始终可见 ===== */
.delete-book-btn {
  position: static;
  background: rgba(255, 71, 87, 0.1);
  color: #ff4757;
  border: 1px solid rgba(255, 71, 87, 0.3);
  width: 100%;
  margin-top: 1rem;
  padding: 0.6rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  opacity: 1;
}

.delete-book-btn:hover {
  background: rgba(255, 71, 87, 0.2);
  border-color: rgba(255, 71, 87, 0.5);
  transform: scale(1.02);
}

/* ===== 章节视图 ===== */
.chapter-view {
  background: white;
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-lg);
}

.chapter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid var(--border-color);
}

.chapter-header h2 {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ===== 信息区块 ===== */
.info-section {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  position: relative;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.info-section::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.info-section:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-md);
}

.section-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

.edit-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-sm);
}

.edit-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* ===== 空状态提示 ===== */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-muted);
  font-size: 16px;
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* ===== 加载状态 ===== */
.loading {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
  font-size: 16px;
}

/* ===== 模态框优化 ===== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 600px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 2px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1.5rem;
  border-top: 2px solid var(--border-color);
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
}

.modal-footer button {
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  min-height: 44px;
}

/* ===== 表单元素 ===== */
input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 15px;
  transition: var(--transition);
  background: white;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-primary);
  font-size: 15px;
}

.form-group {
  margin-bottom: 1.5rem;
}

/* ===== 响应式设计 ===== */
@media (max-width: 768px) {
  body {
    font-size: 16px;
    overflow-x: hidden;
  }

  .container { 
    padding: 1rem; 
  }

  .page-header { 
    flex-direction: column; 
    gap: 1rem; 
    text-align: center;
    padding: 1.5rem;
  }

  .page-header h1 {
    font-size: 22px;
  }

  .back-btn {
    width: 100%;
    justify-content: center;
  }

  .book-list { 
    grid-template-columns: 1fr; 
    gap: 1rem;
  }

  .book-card {
    padding: 1.25rem;
  }

  .delete-book-btn {
    opacity: 1;
    position: static;
    margin-top: 0.75rem;
  }

  .chapter-header { 
    flex-direction: column; 
    gap: 1rem; 
    align-items: flex-start; 
  }

  .modal {
    padding: 1rem;
    align-items: flex-start;
    padding-top: 5vh;
  }

  .modal-content {
    width: 100%;
    max-height: 90vh;
  }

  .modal-footer {
    flex-direction: column;
  }

  .modal-footer button {
    width: 100%;
  }

  input, select, textarea {
    font-size: 16px !important;
  }

  button {
    min-height: 44px;
  }
}

/* ===== 章节查看模态框样式 ===== */
.chapter-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 2rem;
}

.chapter-modal {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 900px;
  width: 100%;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.chapter-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.chapter-modal-header h3 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--text-primary);
}

.chapter-modal-close {
  background: none;
  border: none;
  font-size: 2rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 0.5rem;
  line-height: 1;
  transition: color var(--transition);
}

.chapter-modal-close:hover {
  color: var(--text-primary);
}

.chapter-modal-body {
  padding: 2rem;
  overflow-y: auto;
  flex: 1;
}

.chapter-content {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text-primary);
  font-family: inherit;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
}

/* ===== 大纲和角色卡片 ===== */
.outline-item {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--primary-color);
}

.outline-label {
  font-weight: 600;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.outline-content {
  color: var(--text-primary);
  line-height: 1.8;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 15px;
}

.section-subtitle {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 1.5rem 0 1rem 0;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, rgba(255, 107, 53, 0.1) 0%, rgba(229, 90, 43, 0.05) 100%);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--primary-color);
  display: flex;
  align-items: center;
}

.section-divider {
  border: none;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--border-color), transparent);
  margin: 1.5rem 0;
}

.character-card {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1rem;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.character-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary-color);
  transform: translateY(-2px);
}

.character-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--primary-color);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.character-info {
  margin-bottom: 0.75rem;
  padding-left: 0.5rem;
}

.character-label {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  margin-bottom: 0.25rem;
}

.character-value {
  color: var(--text-primary);
  line-height: 1.7;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 15px;
  margin-top: 0.25rem;
}

.chapter-outline {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border-left: 3px solid #3498db;
}

.chapter-outline .character-label {
  color: #3498db;
}

/* ===== 按钮样式 ===== */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--border-color);
  transform: translateY(-2px);
}

.btn-danger {
  background: rgba(255, 71, 87, 0.1);
  color: #ff4757;
  border: 1px solid rgba(255, 71, 87, 0.3);
}

.btn-danger:hover {
  background: rgba(255, 71, 87, 0.2);
  border-color: rgba(255, 71, 87, 0.5);
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 13px;
  min-height: 36px;
}

.character-actions {
  display: flex;
  gap: 0.5rem;
}

/* ===== 表单样式补充 ===== */
.form-textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 15px;
  transition: var(--transition);
  background: white;
  font-family: inherit;
  resize: vertical;
}

.form-textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-primary);
  font-size: 15px;
}

/* ===== 用户分组样式 ===== */
.user-group {
  margin-bottom: 2rem;
}

.group-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--primary-color);
}

/* ===== 模态框关闭按钮 ===== */
.modal-close {
  background: none;
  border: none;
  font-size: 2rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color var(--transition);
}

.modal-close:hover {
  color: var(--text-primary);
}

/* ===== 动画效果 ===== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.book-card,
.character-card,
.info-section {
  animation: fadeIn 0.3s ease;
}
