/* ============================================
   教程页面样式 (tutorial.css)
   ============================================ */

/* 教程容器 */
.tutorial-container {
  display: flex;
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  gap: 30px;
}

/* ============================================
   左侧边栏
   ============================================ */
.tutorial-sidebar {
  width: 260px;
  flex-shrink: 0;
  position: sticky;
  top: 100px;
  max-height: calc(100vh - 120px); /* 减去 header 高度和间距 */
  overflow-y: auto; /* 允许垂直滚动 */
  overflow-x: hidden; /* 隐藏水平滚动条 */
  padding-right: 10px; /* 为滚动条留出空间 */
}

/* 自定义滚动条样式 */
.tutorial-sidebar::-webkit-scrollbar {
  width: 6px;
}

.tutorial-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.tutorial-sidebar::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

.tutorial-sidebar::-webkit-scrollbar-thumb:hover {
  background-color: rgba(0, 0, 0, 0.3);
}

/* 搜索框 */
.sidebar-search {
  position: relative;
  margin-bottom: 20px;
}

.search-input {
  width: 100%;
  padding: 10px 40px 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.9rem;
  background-color: var(--card-bg);
  color: var(--text-color);
  transition: border-color 0.2s, background-color 0.2s;
  box-sizing: border-box;
  font-family: inherit;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary-color);
  background-color: white;
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* 侧边栏导航 */
.sidebar-nav {
  background-color: transparent;
  padding: 10px 0;
}

.sidebar-item {
  margin-bottom: 0;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-item:last-child {
  border-bottom: none;
}

.sidebar-link {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 14px 12px;
  border: none;
  background: none;
  color: var(--text-color);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s;
  text-align: left;
  font-family: inherit;
}

.sidebar-link.expandable {
  justify-content: space-between;
}

.sidebar-link:hover {
  color: var(--primary-color);
}

.sidebar-link.active {
  color: var(--primary-color);
  font-weight: 600;
}

.sidebar-link.expandable {
  font-weight: 500;
}

.expand-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
  opacity: 0.5;
}

.sidebar-link.expanded .expand-icon {
  transform: rotate(180deg);
}

.sidebar-link:hover .expand-icon {
  opacity: 1;
}

/* 子菜单 */
.sidebar-submenu {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.3s ease-in-out, padding 0.3s ease-in-out;
  background-color: var(--card-bg);
  padding: 0;
}

.sidebar-submenu.expanded {
  grid-template-rows: 1fr;
  padding: 8px 0;
}

.sidebar-submenu > div {
  overflow: hidden;
}

.sidebar-sublink {
  display: block;
  padding: 9px 12px 9px 28px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 400;
  transition: color 0.2s, background-color 0.2s;
  margin: 0;
}

.sidebar-sublink:hover {
  color: var(--text-color);
  background-color: rgba(0, 122, 204, 0.05);
}

.sidebar-sublink.active {
  color: var(--primary-color);
  font-weight: 500;
}

/* ============================================
   右侧内容区
   ============================================ */
.tutorial-content {
  flex: 1;
  min-width: 0;
}

.tutorial-content h1 {
  font-size: 2.5rem;
  margin-bottom: 10px;
}

.tutorial-description {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-bottom: 40px;
}

/* ============================================
   视频网格
   ============================================ */
.video-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 25px;
}

/* 视频卡片 */
.video-card {
  background-color: white;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.3s, box-shadow 0.3s;
}

.video-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.video-thumbnail {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 比例 */
  overflow: hidden;
  background-color: var(--card-bg);
}

.video-thumbnail img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  background-color: rgba(0, 122, 204, 0.9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 24px;
  transition: background-color 0.3s, transform 0.3s;
}

.video-card:hover .play-icon {
  background-color: var(--primary-color);
  transform: translate(-50%, -50%) scale(1.1);
}

.video-info {
  padding: 15px;
}

.video-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 8px 0;
  color: var(--text-color);
}

.video-duration {
  font-size: 0.85rem;
  color: var(--primary-color);
  margin: 0 0 8px 0;
  font-weight: 500;
}

.video-description {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============================================
   视频模态框
   ============================================ */
.video-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.85);
  z-index: 2000;
  justify-content: center;
  align-items: center;
}

.video-modal.active {
  display: flex;
}

.video-modal-content {
  position: relative;
  width: 90%;
  max-width: 1200px;
  background-color: #000;
  border-radius: 12px;
  overflow: hidden;
}

.video-modal-close {
  position: absolute;
  top: -40px;
  right: 0;
  background: none;
  border: none;
  color: white;
  font-size: 36px;
  cursor: pointer;
  z-index: 2001;
  padding: 0;
  width: 40px;
  height: 40px;
  line-height: 40px;
  text-align: center;
  transition: transform 0.2s;
}

.video-modal-close:hover {
  transform: scale(1.2);
}

.video-player-wrapper {
  position: relative;
  padding-top: 56.25%;
  width: 100%;
}

.video-player-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* ============================================
   文档内容样式 (resources.html)
   ============================================ */

/* 文档章节 */
.doc-section {
  margin-bottom: 50px;
  padding-bottom: 30px;
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.3s ease;
  scroll-margin-top: 100px; /* 为 header 留出空间，避免被遮挡 */
}

.doc-section:last-child {
  border-bottom: none;
}

/* 文档标题 */
.doc-section h2 {
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--text-color);
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--primary-color);
}

.doc-section h3 {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-color);
  margin-top: 25px;
  margin-bottom: 12px;
}

.doc-section h4 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-color);
  margin-top: 20px;
  margin-bottom: 10px;
}

/* 文档段落 */
.doc-section p {
  line-height: 1.8;
  margin-bottom: 15px;
  color: var(--text-color);
}

.doc-section p strong {
  font-weight: 600;
  color: var(--primary-color);
}

/* 文档列表 */
.doc-section ul,
.doc-section ol {
  margin-bottom: 15px;
  padding-left: 25px;
}

.doc-section li {
  line-height: 1.8;
  margin-bottom: 8px;
  color: var(--text-color);
}

.doc-section ul li {
  list-style-type: disc;
}

.doc-section ol li {
  list-style-type: decimal;
}

/* 代码样式 */
.doc-section code {
  background-color: var(--card-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.9em;
  color: #e91e63;
  border: 1px solid var(--border-color);
}

/* 搜索高亮 */
mark.search-highlight {
  background-color: #ffeb3b;
  color: #000;
  padding: 2px 4px;
  border-radius: 3px;
  font-weight: 500;
}

/* 表格样式 */
.doc-section table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  background-color: white;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}

.doc-section table thead {
  background-color: var(--card-bg);
}

.doc-section table th {
  padding: 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-color);
  border-bottom: 2px solid var(--border-color);
}

.doc-section table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-color);
}

.doc-section table tr:last-child td {
  border-bottom: none;
}

.doc-section table tr:hover {
  background-color: rgba(0, 122, 204, 0.03);
}

/* ============================================
   响应式设计
   ============================================ */
@media (max-width: 1200px) {
  .video-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 900px) {
  .tutorial-container {
    flex-direction: column;
  }

  .tutorial-sidebar {
    width: 100%;
    position: static;
  }

  .video-grid {
    grid-template-columns: 1fr;
  }

  /* 文档内容响应式 */
  .doc-section h2 {
    font-size: 1.5rem;
  }

  .doc-section h3 {
    font-size: 1.2rem;
  }

  .doc-section table {
    font-size: 0.9rem;
  }

  .doc-section table th,
  .doc-section table td {
    padding: 8px;
  }
}
