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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  background-color: #f8f9fa;
  height: 100vh;
  overflow: hidden;
}

.container {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* 侧边栏样式 */
.sidebar {
  min-width: 200px;
  max-width: min(450px, 40vw);
  width: auto;
  background: #fff;
  border-right: 1px solid #e1e4e8;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
  resize: horizontal;
  overflow: hidden;
  flex-shrink: 0;
  transition: all 0.3s ease;
  transform: translateX(0);
}

.sidebar.collapsed {
  min-width: 0;
  max-width: 0;
  width: 0;
  border-right: none;
  box-shadow: none;
  transform: translateX(-100%);
}

.sidebar.collapsed * {
  opacity: 0;
  pointer-events: none;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid #e1e4e8;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.sidebar-header h1 {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.sidebar-header p {
  opacity: 0.9;
  font-size: 0.9rem;
}

.search-box {
  padding: 15px;
  border-bottom: 1px solid #e1e4e8;
}

.search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5da;
  border-radius: 6px;
  font-size: 14px;
}

.search-input:focus {
  outline: none;
  border-color: #0366d6;
  box-shadow: 0 0 0 3px rgba(3, 102, 214, 0.1);
}

.category-controls {
  padding: 10px 15px;
  border-bottom: 1px solid #e1e4e8;
  display: flex;
  gap: 8px;
}

.category-control-btn {
  flex: 1;
  padding: 6px 8px;
  font-size: 11px;
  border: 1px solid #d1d5da;
  border-radius: 4px;
  background: #fff;
  color: #586069;
  cursor: pointer;
  transition: all 0.2s;
}

.category-control-btn:hover {
  background: #f6f8fa;
  border-color: #0366d6;
  color: #0366d6;
}

.category-control-btn:active {
  background: #e1e4e8;
}

.file-tree {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0;
}

.category {
  margin-bottom: 10px;
}

.category-header {
  padding: 8px 20px;
  background: #f6f8fa;
  border-left: 3px solid #0366d6;
  font-weight: 600;
  color: #24292e;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.2s ease;
  user-select: none;
}

.category-header:hover {
  background: #e1e4e8;
  border-left-color: #0366d6;
}

.category-header:active {
  background: #d1d5da;
}

.category-icon {
  margin-right: 8px;
  width: 16px;
  text-align: center;
}

.category-title {
  flex: 1;
  display: flex;
  align-items: center;
}

.category-toggle {
  transition: transform 0.3s ease;
  color: #586069;
  font-size: 12px;
}

.category.collapsed .category-toggle {
  transform: rotate(-90deg);
}

.category-count {
  background: #e1e4e8;
  color: #586069;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 8px;
  font-weight: normal;
}

.file-list {
  display: block;
  transition: all 0.3s ease;
  overflow: hidden;
  max-height: 1000px;
}

.category.collapsed .file-list {
  max-height: 0;
  opacity: 0;
  transform: translateY(-10px);
}

.category:not(.collapsed) .file-list {
  opacity: 1;
  transform: translateY(0);
}

.file-item {
  padding: 8px 20px 8px 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: background-color 0.2s;
  border-left: 3px solid transparent;
  white-space: nowrap;
  overflow: hidden;
}

.file-item:hover {
  background: #f6f8fa;
  border-left-color: #0366d6;
}

.file-item.active {
  background: #e3f2fd;
  border-left-color: #0366d6;
  color: #0366d6;
}

.file-icon {
  margin-right: 8px;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}

.file-name {
  flex: 1;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 主内容区域 */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #fff;
  min-width: 0;
  overflow: hidden;
}

/* 内容区域布局 */
.content-container {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-width: 0;
}

/* 目录侧边栏 */
.toc-sidebar {
  min-width: 150px;
  max-width: min(400px, 30vw);
  width: auto;
  background: #f8f9fa;
  border-right: 1px solid #e1e4e8;
  display: none;
  flex-direction: column;
  overflow: hidden;
  resize: horizontal;
  flex-shrink: 0;
}

.toc-sidebar.show {
  display: flex;
}

.toc-header {
  padding: 15px;
  background: #fff;
  border-bottom: 1px solid #e1e4e8;
  font-weight: 600;
  color: #24292e;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toc-content {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0;
}

.toc-item {
  padding: 4px 15px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.4;
  color: #586069;
  border-left: 3px solid transparent;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toc-item:hover {
  background: #f6f8fa;
  color: #0366d6;
  border-left-color: #0366d6;
}

.toc-item.active {
  background: #e3f2fd;
  color: #0366d6;
  border-left-color: #0366d6;
  font-weight: 500;
}

.toc-item.collapsed + .toc-children {
  display: none;
}

.toc-children {
  display: block;
}

.toc-toggle {
  margin-right: 6px;
  width: 12px;
  height: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  transition: transform 0.2s;
  color: #586069;
}

.toc-toggle.collapsed {
  transform: rotate(-90deg);
}

.toc-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toc-item.level-1 {
  padding-left: 15px;
  font-weight: 500;
}
.toc-item.level-2 {
  padding-left: 25px;
}
.toc-item.level-3 {
  padding-left: 35px;
}
.toc-item.level-4 {
  padding-left: 45px;
}
.toc-item.level-5 {
  padding-left: 55px;
}
.toc-item.level-6 {
  padding-left: 65px;
}

.content-header {
  padding: 15px 20px;
  border-bottom: 1px solid #e1e4e8;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.content-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: #24292e;
}

.content-actions {
  display: flex;
  gap: 10px;
}

.btn {
  padding: 6px 12px;
  border: 1px solid #d1d5da;
  border-radius: 6px;
  background: #fff;
  color: #24292e;
  text-decoration: none;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn:hover {
  background: #f6f8fa;
  border-color: #0366d6;
}

#sidebar-toggle-btn {
  margin-right: 8px;
  border-color: #28a745;
  color: #28a745;
}

#sidebar-toggle-btn:hover {
  background: #f8fff9;
  border-color: #28a745;
  color: #28a745;
}

#sidebar-toggle-btn.active {
  background: #28a745;
  color: white;
  border-color: #28a745;
}

.content-viewer {
  flex: 1;
  overflow: auto;
  padding: 20px;
  min-width: 0;
}

/* Markdown 样式 */
.markdown-content {
  max-width: none;
  padding: 0;
}

/* PDF 查看器样式 */
.pdf-viewer {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.pdf-controls {
  padding: 10px;
  background: #f6f8fa;
  border-bottom: 1px solid #e1e4e8;
  display: flex;
  align-items: center;
  gap: 10px;
}

.pdf-canvas-container {
  flex: 1;
  overflow: auto;
  text-align: center;
  padding: 20px;
}

#pdf-canvas {
  border: 1px solid #e1e4e8;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* 欢迎页面 */
.welcome {
  text-align: center;
  padding: 60px 20px;
  color: #586069;
}

.welcome i {
  font-size: 4rem;
  margin-bottom: 20px;
  color: #d1d5da;
}

.welcome h2 {
  margin-bottom: 10px;
  color: #24292e;
}

/* 加载中提示样式 */
.loading-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60vh;
  color: #586069;
  font-size: 1.1rem;
  gap: 18px;
}
.spinner {
  width: 36px;
  height: 36px;
  border: 4px solid #e1e4e8;
  border-top: 4px solid #0366d6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 8px;
}
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
.loading-text {
  font-size: 1rem;
  color: #586069;
  letter-spacing: 1px;
}

/* 响应式设计 */
@media (max-width: 1024px) {
  .sidebar {
    min-width: 180px;
    max-width: 35vw;
  }

  .toc-sidebar {
    min-width: 120px;
    max-width: 25vw;
  }
}

@media (max-width: 768px) {
  .sidebar {
    min-width: 150px;
    max-width: 40vw;
  }

  .toc-sidebar {
    min-width: 100px;
    max-width: 30vw;
  }

  .content-viewer {
    padding: 15px;
  }

  .file-item {
    padding: 6px 15px 6px 30px;
  }

  .toc-item {
    padding: 3px 10px;
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .sidebar {
    min-width: 120px;
    max-width: 45vw;
  }

  .toc-sidebar {
    min-width: 80px;
    max-width: 35vw;
  }

  .content-viewer {
    padding: 10px;
  }
}

/* 滚动条样式 */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a1a1a1;
}

.toc-search-box {
  padding: 8px 15px 4px 15px;
  background: #f8f9fa;
  border-bottom: 1px solid #e1e4e8;
}
.toc-search-input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid #d1d5da;
  border-radius: 4px;
  font-size: 13px;
}
.toc-search-input:focus {
  outline: none;
  border-color: #0366d6;
  box-shadow: 0 0 0 2px rgba(3, 102, 214, 0.08);
}
