/* ===== 基础页面布局 ===== */
.book-page {
  max-width: 100%;
  overflow-x: hidden;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  padding: 2rem;
  background-color: white;
  margin: 1rem;
  position: relative;
  transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.book-page:hover {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* ===== 标题样式 ===== */
.markdown h1, 
.markdown h2, 
.markdown h3, 
.markdown h4, 
.markdown h5, 
.markdown h6 {
  color: #1e3a8a;
  font-weight: 600;
  margin-bottom: 1rem;
}

.markdown h1 {
  font-size: 2rem;
  padding: 0.75rem 1rem;
  margin-bottom: 2rem;
  background-color: #dbeafe; /* 浅蓝色背景 */
  color: #1e40af; /* 深蓝色文字 */
  text-align: center; /* 居中显示 */
  border-radius: 8px; /* 圆角边框 */
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05); /* 轻微阴影 */
  border: none; /* 移除底部边框 */
}

.markdown h2 {
  font-size: 1.5rem;
  margin-top: 2rem;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 0.3rem;
}

/* ===== 段落和文本样式 ===== */
.markdown p {
  line-height: 1.7;
  margin-bottom: 1.25rem;
}

/* ===== 链接样式 ===== */
.markdown a {
  color: #2563eb;
  text-decoration: none;
  transition: all 0.2s ease;
  position: relative;
}

.markdown a:hover {
  color: #1d4ed8;
}

.markdown a:hover::after {
  transform: scaleX(1);
  transform-origin: bottom left;
}

.markdown a::after {
  content: '';
  position: absolute;
  width: 100%;
  transform: scaleX(0);
  height: 1px;
  bottom: 0;
  left: 0;
  background-color: currentColor;
  transform-origin: bottom right;
  transition: transform 0.3s ease-out;
}

/* ===== 表格样式 ===== */
.markdown table,
table {
  width: 100%;
  margin: 2rem 0;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  table-layout: fixed;
  overflow-wrap: break-word;
}

.markdown table,
table {
  display: table;
  width: 100%;
  overflow-x: auto;
}

.markdown th,
th {
  background-color: #f3f4f6;
  color: #1e3a8a;
  font-weight: 600;
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid #e5e7eb;
}

.markdown td,
td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e5e7eb;
  color: #374151;
  border: 1px solid #ddd;
  word-wrap: break-word;
  white-space: normal;
  overflow-wrap: break-word;
  hyphens: auto;
}

.markdown tr:last-child td,
tr:last-child td {
  border-bottom: none;
}

.markdown tr:nth-child(even),
tr:nth-child(even) {
  background-color: #f9fafb;
}

.markdown tr,
tr {
  transition: background-color 0.2s ease;
}

.markdown tr:hover,
tr:hover {
  background-color: #f3f4f6;
}

/* ===== 引用块样式 ===== */
.markdown blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.5rem;
  border-left: 4px solid #3b82f6;
  background-color: #f0f9ff;
  border-radius: 0 8px 8px 0;
  color: #1e40af;
  font-style: italic;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.markdown blockquote:hover {
  transform: translateX(2px);
  box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.1);
}

.markdown blockquote p:last-child {
  margin-bottom: 0;
}

/* ===== 代码块样式 ===== */
.markdown pre {
  background-color: #1e293b;
  color: #e2e8f0;
  padding: 1.25rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 1.5rem 0;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  transition: box-shadow 0.2s ease;
}

.markdown pre:hover {
  box-shadow: 0 6px 8px -1px rgba(0, 0, 0, 0.15);
}

.markdown pre code {
  background: none;
  color: inherit;
  padding: 0;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.9rem;
}

/* ===== 行内代码样式 ===== */
.markdown code {
  background-color: #f1f5f9;
  color: #2563eb;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.9em;
  transition: background-color 0.2s ease;
}

.markdown code:hover {
  background-color: #e0e7ff;
}

/* ===== 列表样式 ===== */
.markdown ul, 
.markdown ol {
  padding-left: 1.5rem;
  margin: 1.25rem 0;
}

.markdown li {
  margin-bottom: 0.5rem;
  line-height: 1.7;
  transition: transform 0.2s ease;
}

.markdown li:hover {
  transform: translateX(2px);
}

.markdown li::marker {
  color: #3b82f6;
}

.markdown ul ul, 
.markdown ul ol, 
.markdown ol ul, 
.markdown ol ol {
  margin: 0.5rem 0;
}

/* ===== 水平分割线样式 ===== */
.markdown hr {
  height: 1px;
  background: linear-gradient(to right, #3b82f6, transparent);
  border: none;
  margin: 2rem 0;
}

/* ===== 页脚样式 ===== */
.book-footer {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e5e7eb;
  color: #6b7280;
  font-size: 0.875rem;
}

.book-footer a {
  color: #3b82f6;
  text-decoration: none;
  transition: color 0.2s ease;
}

.book-footer a:hover {
  color: #1d4ed8;
  text-decoration: underline;
}

/* ===== 响应式调整 ===== */
@media screen and (max-width: 768px) {
  .book-page {
    padding: 1.5rem;
    margin: 0.5rem;
  }
  
  /* 移动端表格滚动设置 */
  .markdown table,
  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    width: 100%;
    -webkit-overflow-scrolling: touch; /* 提供iOS设备上更流畅的滚动 */
  }
  
  .markdown td,
  .markdown th,
  td, th {
    max-width: 200px;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
  }
  
  /* 添加滚动提示 */
  .markdown table::before,
  table::before {
    content: '← 滑动查看更多 →';
    display: block;
    text-align: center;
    padding: 0.5rem;
    color: #6b7280;
    font-size: 0.75rem;
    font-style: italic;
  }
}
