/* ========== 通用基础重置 ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  background-color: #f5f5f5;
  color: #333;
  padding-top: 60px; /* 为固定导航栏预留空间 */
}

/* ========== Markdown 表格增强样式 ========== */
/* assets/css/style.css */
.markdown-table {
  /* 基础样式 */
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-size: 0.95em;
  
  /* 容错处理 */
  white-space: pre-wrap;    /* 保留原始空格 */
  font-family: monospace;   /* 等宽字体对齐 */
  table-layout: fixed;      /* 防止内容溢出 */
}

/* 表头/单元格样式 */
.markdown-table th,
.markdown-table td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid #e1e1e1;
  min-width: 100px;         /* 防止内容挤压 */
  word-break: break-word;   /* 长内容自动换行 */
}

/* 表头特殊样式 */
.markdown-table th {
  background-color: #f8f9fa;
  font-weight: 600;
  position: sticky;
  top: 0;                   /* 固定表头（可选） */
}

/* 交互效果 */
.markdown-table tr:hover td {
  background-color: #f5f5f5;
}

/* 针对复制粘贴的容错处理 */
.markdown-table :is(td, th) {
  overflow: visible;        /* 显示溢出内容 */
}

/* 修复 Markdown 转换可能缺失的边框 */
.markdown-table :is(td, th):not(:last-child) {
  border-right: 1px solid #f0f0f0;
}

/* 强制修复错位表格的视觉对齐 */
.markdown-table tr > *:first-child {
  padding-left: 1.5em;      /* 首列缩进 */
}
.markdown-table tr > *:last-child {
  padding-right: 1.5em;     /* 末列缩进 */
}

/* ========== 布局容器 ========== */
.container {
  display: flex;
  flex-direction: row;
  gap: 2rem;
  padding: 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

/* ========== 主内容区域 ========== */
main {
  flex-grow: 1;
  max-width: 800px;
  margin-left: 0; /* No sidebar margin needed */
  padding: 2rem;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.03);
  transition: margin 0.3s ease;
}

/* ========== 顶部导航栏 ========== */
.navbar {
  background: #ffffff;
  border-bottom: 1px solid #eaeaea;
  padding: 1rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.navbar-fixed {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1000;
  background: white;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* 主行：logo + 菜单按钮 */
.navbar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.navbar .logo {
  font-size: 1.3rem;
  font-weight: bold;
  color: #333;
  text-decoration: none;
}

.navbar .mobile-menu {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #333;
}

/* 横排导航链接 */
.navbar .nav-links {
  display: flex;
  gap: 1.5rem;
  margin-top: 1rem;
}

.navbar .nav-links a {
  color: #333;
  text-decoration: none;
  font-weight: 500;
  font-size: 1rem;
}

.navbar .nav-links a:hover {
  color: #007acc;
}



/* ========== 分类侧边栏 ========== */
.category-sidebar {
  width: 200px;
  background: #fff;
  padding: 1rem;
  border-radius: 8px;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.05);
}

.sidebar-fixed {
  display: none; /* Hide sidebar on desktop */
  position: fixed;
  top: 60px;
  left: 0;
  width: 250px;
  height: calc(100vh - 60px);
  overflow-y: auto;
  z-index: 500;
  background: white;
  box-shadow: 2px 0 5px rgba(0,0,0,0.1);
}

.category-sidebar h3 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  color: #333;
  border-bottom: 1px solid #eee;
  padding-bottom: 0.5rem;
}

.category-sidebar ul {
  list-style: none;
  padding-left: 0;
}

.category-sidebar li {
  margin-bottom: 0.75rem;
}

.category-sidebar a {
  text-decoration: none;
  color: #333;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.category-sidebar a:hover {
  color: #007acc;
}

/* ========== 文章样式 ========== */
article.post {
  line-height: 1.75;
  font-size: 1rem;
}

article.post h1,
article.post h2,
article.post h3 {
  margin-top: 1.5em;
  margin-bottom: 0.5em;
}

/* ========== 代码块与复制按钮 ========== */
pre, code {
  font-family: Consolas, Monaco, monospace;
  font-size: 14px;
}

pre {
  position: relative;
  background: #f8f8f8;
  padding: 1rem;
  overflow: auto;
  border-radius: 6px;
}

.copy-button {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.4rem;
  font-size: 0.9rem;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  color: #333;
}

.copy-button:hover {
  background: #e6f7ff;
  border-color: #91d5ff;
}

.copy-button.copied {
  color: green;
  border-color: green;
}

/* ========== 响应式样式 ========== */
@media (max-width: 768px) {
  .navbar {
    align-items: stretch;
    padding: 1rem;
  }

  .navbar-inner {
    flex-direction: row;
  }

  .navbar .nav-links {
    display: none;
    position: fixed;
    top: 60px;
    left: 0;
    width: 100%;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
    background: white;
    z-index: 999;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
  }

  .navbar .nav-links.active {
    display: flex;
  }

  .navbar .mobile-menu {
    display: block;
  }

  body.menu-open {
    overflow: hidden;
    height: 100vh;
  }

  /* 隐藏侧边栏 */
  .category-sidebar,
  .sidebar-fixed {
    display: none !important;
  }

  main {
    margin-left: 0;
    width: 100%;
  }

  .markdown-table {
    display: block;
    overflow-x: auto;       /* 横向滚动 */
    white-space: nowrap;    /* 防止换行 */
  }
  
  .markdown-table td {
    min-width: 150px;       /* 移动端最小宽度增大 */
  }
}

