/**
 * 文章導航增強樣式
 */

/* 浮動按鈕 */
.article-nav-float-btn {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #5e81ac;
  color: #fff;
  border: none;
  font-size: 0.875rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  transition: background 0.2s, transform 0.2s;
}

.article-nav-float-btn:hover {
  background: #81a1c1;
  transform: scale(1.05);
}

/* 導航面板 */
.article-nav-panel {
  position: fixed;
  bottom: 5.5rem;
  right: 2rem;
  width: 300px;
  max-height: 60vh;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  z-index: 999;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.article-nav-panel.show {
  display: flex;
}

/* 導航面板標頭 */
.article-nav-header {
  padding: 0.75rem;
  border-bottom: 1px solid #e5e9f0;
  background: #f8f9fb;
}

.article-nav-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #d8dee9;
  border-radius: 4px;
  font-size: 0.875rem;
  outline: none;
  box-sizing: border-box;
}

.article-nav-input:focus {
  border-color: #5e81ac;
  box-shadow: 0 0 0 2px rgba(94, 129, 172, 0.2);
}

.article-nav-input::placeholder {
  color: #9ca3af;
}

/* 導航列表 */
.article-nav-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.article-nav-item {
  display: block;
  padding: 0.5rem 1rem;
  color: #4c566a;
  text-decoration: none;
  font-size: 0.875rem;
  transition: background 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.article-nav-item:hover {
  background: #e5e9f0;
}

/* 標題層級縮排 */
.article-nav-item.level-1 {
  padding-left: 1rem;
  font-weight: 600;
}

.article-nav-item.level-2 {
  padding-left: 1.5rem;
  font-weight: 500;
}

.article-nav-item.level-3 {
  padding-left: 2rem;
}

.article-nav-item.level-4 {
  padding-left: 2.5rem;
  font-size: 0.8125rem;
}

.article-nav-item.level-5 {
  padding-left: 3rem;
  font-size: 0.8125rem;
}

/* 提示文字 */
.article-nav-hint {
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  color: #9ca3af;
  border-top: 1px solid #e5e9f0;
  margin-top: 0.5rem;
}

/* 程式碼區塊樣式 */
pre.article-nav-code {
  position: relative;
}

.code-number-label {
  position: absolute;
  top: 0;
  left: 0;
  background: #5e81ac;
  color: #fff;
  font-size: 0.75rem;
  padding: 0.125rem 0.5rem;
  border-radius: 6px 0 4px 0; /* 左上配合 pre 圓角 */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  z-index: 2;
  pointer-events: none; /* 避免影響滑鼠操作 */
}

/* 程式碼區塊包裹容器 */
.code-block-wrapper {
  position: relative;
  margin: 1rem 0;
}

.code-block-wrapper > pre {
  margin: 0; /* 移除 pre 原本的 margin，改由 wrapper 控制 */
}

.code-lang-label {
  position: absolute;
  top: 0;
  right: 0;
  background: #4c566a;
  color: #d8dee9;
  font-size: 0.75rem;
  padding: 0.125rem 0.5rem;
  border-radius: 0 6px 0 4px; /* 右上配合 pre 圓角 */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  text-transform: lowercase;
  z-index: 2;
  pointer-events: none; /* 避免影響滑鼠操作 */
}

/* 圖片樣式 */
.article-nav-img-wrapper {
  position: relative;
  display: inline-block;
}

.img-number-label {
  position: absolute;
  bottom: 4px;
  left: 4px;
  background: rgba(94, 129, 172, 0.9);
  color: #fff;
  font-size: 0.375rem;
  padding: 0.0625rem 0.25rem;
  border-radius: 2px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  z-index: 1;
}

/* 深色主題適配 */
body.theme-dark .article-nav-panel {
  background: #3b4252;
}

body.theme-dark .article-nav-header {
  background: #434c5e;
  border-bottom-color: #4c566a;
}

body.theme-dark .article-nav-input {
  background: #2e3440;
  border-color: #4c566a;
  color: #eceff4;
}

body.theme-dark .article-nav-input:focus {
  border-color: #88c0d0;
  box-shadow: 0 0 0 2px rgba(136, 192, 208, 0.2);
}

body.theme-dark .article-nav-item {
  color: #d8dee9;
}

body.theme-dark .article-nav-item:hover {
  background: #434c5e;
}

body.theme-dark .article-nav-hint {
  border-top-color: #4c566a;
  color: #7b88a1;
}

/* 響應式 - 手機版（小於 iPad 橫向） */
@media (max-width: 480px) {
  .article-nav-float-btn {
    bottom: 1rem;
    right: 1rem;
    width: 48px;
    height: 48px;
    font-size: 1.25rem;
  }

  .article-nav-panel {
    bottom: 4.5rem;
    right: 1rem;
    left: 1rem;
    width: auto;
    max-height: 50vh;
  }
}
