/* ===== 全局設定 ===== */
body {
  margin: 0;
  font-family: Arial, sans-serif;
  height: 100vh;
  display: flex;
}

.container {
  display: flex;
  width: 100%;
}  

/* ===== 側邊欄 ===== */
.sidebar {
  position: relative;
  width: 240px;
  background: #1e1e1e;
  color: #fff;
  display: flex;
  flex-direction: column; /* 讓底部語系選單自動貼底 */
  height: 100vh; /* 滿高 */
}

/* 章節列表佔滿中間，讓語系切換在最底 */
.chapter-list {
  flex: 1; /* 中間自動撐開 */
  overflow-y: auto; /* 章節太多可以捲動 */
  padding: 10px;
}

/* 語系切換區固定在底部 */
.lang-switch {
  padding: 10px;
  border-top: 1px solid #333;
  background: #151515;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.lang-switch select {
  flex: 1;
  background: #222;
  color: #fff;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 6px;
}

/* 收合/展開按鈕 */
.collapse-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #2a2a2a;
  color: #fff;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 6px 8px;
  cursor: pointer;
}

.sidebar button {
  display: block;
  width: 100%;
  padding: 8px;
  margin-bottom: 5px;
  background: none;
  border: none;
  text-align: left;
  color: inherit;
  cursor: pointer;
  border-radius: 4px;
}

.sidebar button:hover {
  background-color: #333;
}

.sidebar button.active {
  background-color: #007acc;
}

/* ===== 內容區 ===== */

.content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  
  /* --- 新增 --- */
  /* 將內容區設為 flex 容器，好讓頁尾能固定在底部 */
  display: flex;
  flex-direction: column;
}

/* 標題層級樣式 */
.content h1 { font-size: 2em; border-bottom: 2px solid #ccc; padding-bottom: 5px; }
.content h2 { font-size: 1.75em; border-bottom: 1px solid #ccc; padding-bottom: 4px; }
.content h3 { font-size: 1.5em; }
.content h4 { font-size: 1.25em; }
.content h5 { font-size: 1.1em; color: #666; }

/* ===== 程式碼區塊 ===== */
/* 你的原本樣式 */
/* 你的原本樣式 */
pre {
  background-color: #1e1e1e;
  color: #dcdcdc;
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  position: relative; /* 讓複製按鈕定位 */
  flex-shrink: 0;
}

/* 新增這段：修正清單內的程式碼框間距 */
li pre {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}


code {
  font-family: Consolas, Monaco, 'Courier New', monospace;
}

/* ===== 複製按鈕 ===== */
.copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background-color: #007acc;
  color: white;
  border: none;
  padding: 4px 8px;
  font-size: 0.85em;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.8;
}

.copy-btn:hover {
  opacity: 1;
}

/* === 章節/小節（階層樣式與小箭頭） === */
.chapter-item { margin-bottom: 6px; }

.chapter-btn {
  display: block;
  width: 100%;
  padding: 8px;
  margin-bottom: 5px;
  background: none;
  border: none;
  text-align: left;
  color: inherit;
  cursor: pointer;
  border-radius: 4px;
}
.chapter-btn:hover { background-color: #333; }
.chapter-btn.active { background-color: #007acc; }

/* 小箭頭樣式與動畫 */
.chapter-btn .arrow {
  display: inline-block;
  width: 1em;
  transform: rotate(0deg);
  /* 動畫效果：旋轉動畫，耗時 0.3 秒 */
  transition: transform 0.3s ease;
}

/* 當箭頭有 .expanded class 時，旋轉 90 度 */
.chapter-btn .arrow.expanded {
  transform: rotate(90deg);
}

/* --- NEW: 修改後的小節清單，實現滑動動畫 --- */
.section-list {
  padding-left: 14px;
  border-left: 1px dashed #333;
  margin-left: 6px;
  
  /* 隱藏狀態 */
  overflow: hidden; /* 必須設置，否則內容會溢出 */
  max-height: 0;
  opacity: 0;

  /* 動畫效果：最大高度和透明度變化，耗時 0.3 秒，ease-out 效果 */
  transition: max-height 0.3s ease-out, opacity 0.2s ease;
}

/* 當列表有 .expanded class 時，展開它 */
.section-list.expanded {
  /* 展開狀態：給定一個足夠大的最大高度 */
  max-height: 500px; /* 這個值只要比你任何一個列表的實際高度大即可 */
  opacity: 1;
  /* 動畫效果：可以為展開設定不同的動畫曲線 */
  transition: max-height 0.35s ease-in, opacity 0.4s ease;
}

/* 小節按鈕樣式 (無變更) */
.section-btn {
  font-size: 0.92em;
  padding-left: 18px; /* 視覺縮排 */
  display: block;
  width: 100%;
  padding-top: 8px;
  padding-bottom: 8px;
  margin-bottom: 5px;
  background: none;
  border: none;
  text-align: left;
  color: inherit;
  cursor: pointer;
  border-radius: 4px;
}
.section-btn:hover { background-color: #333; }
.section-btn.active { background-color: #007acc; }

/* === 側邊欄可收合 === */
.sidebar {
  transition: width 0.2s ease;
}

.sidebar.collapsed {
  width: 44px;            /* 保留收合按鈕的寬度，讓使用者可再打開 */
  overflow: hidden;
}

.sidebar.collapsed .chapter-list,
.sidebar.collapsed .lang-switch {
  display: none;
}

.sidebar.collapsed .collapse-btn {
  right: 6px; /* 靠邊一點 */
}

/* === 側邊欄標頭（首頁 + 收合鈕） === */
.sidebar-header {
  padding: 10px;
  border-bottom: 1px solid #333;
}

.home-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.home-btn {
  flex: 1;
  padding: 8px;
  background: none;
  border: none;
  color: inherit;
  text-align: left;
  border-radius: 4px;
}

.home-btn.active { background-color: #007acc; }

.inline-toggle {
  min-width: 36px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid #333;
  background: #2a2a2a;
  color: #fff;
  cursor: pointer;
}

/* 收合時保留標頭，隱藏列表與語系，只顯示☰按鈕 */
.sidebar.collapsed {
  width: 44px;
}

.sidebar.collapsed .home-btn {
  display: none; /* 只留下 ☰/X */
}

.sidebar.collapsed .inline-toggle {
  width: 100%;
}

.sidebar.collapsed .chapter-list,
.sidebar.collapsed .lang-switch {
  display: none;
}

/* 章節列（首頁作為章節，右側有切換鈕） */
.chapter-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-toggle {
  margin-left: auto;
  background: #2a2a2a;
  color: #fff;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
}
/* ===== 頁尾 (修改後) ===== */
.site-footer {
  /* 關鍵！自動外推邊距，會將頁尾推到 flex 容器的底部 */
  margin-top: auto; 
  
  /* 為了防止內容過長時頁尾被擠壓變形 */
  flex-shrink: 0; 
  
  /* 其他樣式維持不變 */
  padding: 20px;
  background-color: #1f2937;
  color: #f3f4f6;
  text-align: center;
  font-size: 0.95rem;
  line-height: 1.7;
}

.site-footer a {
  color: #93c5fd;            /* 淺藍色連結 */
  text-decoration: underline;
}

.site-footer a:hover {
  color: #60a5fa;            /* 滑過變亮藍 */
}
