/*-----------------------------------*\
  #notes.css — Notes 页面样式
  三栏布局：Sidebar + 笔记内容 + TOC
\*-----------------------------------*/

/* ==================== 整体布局 ==================== */

.notes-layout {
  display: flex;
  height: calc(100vh - 60px);
  margin-top: 60px;
  overflow: hidden;
}

/* ==================== SIDEBAR ==================== */

.notes-sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--eerie-black-2);
  border-right: 1px solid var(--jet);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.notes-sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--jet);
  flex-shrink: 0;
}

.notes-search {
  width: 100%;
  padding: 8px 12px;
  background: var(--onyx);
  border: 1px solid var(--jet);
  border-radius: 8px;
  color: var(--white-2);
  font-size: 13px;
  font-family: var(--ff-poppins);
  outline: none;
  transition: border-color var(--transition-1);
}

.notes-search:focus {
  border-color: var(--orange-yellow-crayola);
}

.notes-search::placeholder {
  color: var(--light-gray-70);
}

/* 目录容器 */
.notes-catalog {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

/* 一级目录 */
.note-category {
  border-bottom: 1px solid var(--jet);
}

.category-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.category-name {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  padding: 12px 16px;
  color: var(--white-2);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition-1), color var(--transition-1);
}

.category-name:hover {
  background: hsla(0, 0%, 100%, 0.05);
  color: var(--orange-yellow-crayola);
}

.category-name ion-icon:first-child {
  color: var(--orange-yellow-crayola);
  font-size: 18px;
}

/* 展开/折叠按钮 */
.expand-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  color: var(--light-gray-70);
  cursor: pointer;
  border-radius: 6px;
  margin-right: 8px;
  transition: background var(--transition-1), color var(--transition-1);
}

.expand-toggle:hover {
  background: var(--onyx);
  color: var(--white-2);
}

.expand-toggle ion-icon {
  font-size: 16px;
  transition: transform 0.2s ease;
}

.note-category.expanded > .category-row .expand-toggle ion-icon,
.note-subcategory.expanded > .subcategory-row .expand-toggle ion-icon {
  transform: rotate(90deg);
}

/* 子目录容器 */
.category-children {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.note-category.expanded > .category-children {
  max-height: 2000px;
}

/* 二级目录 */
.note-subcategory {
  border-top: 1px solid hsla(0, 0%, 22%, 0.5);
}

.subcategory-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.subcategory-name {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  padding: 10px 16px 10px 32px;
  color: var(--light-gray-70);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition-1), color var(--transition-1);
}

.subcategory-name:hover {
  background: hsla(0, 0%, 100%, 0.05);
  color: var(--white-2);
}

.subcategory-name ion-icon {
  font-size: 14px;
  color: var(--light-gray-70);
}

.subcategory-children {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.note-subcategory.expanded > .subcategory-children {
  max-height: 1000px;
}

/* 三级笔记项 */
.note-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 8px 48px;
  color: var(--light-gray-70);
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition-1), color var(--transition-1);
  border-left: 3px solid transparent;
}

.note-item:hover {
  background: hsla(0, 0%, 100%, 0.05);
  color: var(--white-2);
}

.note-item.active {
  background: var(--onyx);
  color: var(--orange-yellow-crayola);
  border-left-color: var(--orange-yellow-crayola);
}

.note-item ion-icon {
  font-size: 14px;
  color: var(--light-gray-70);
}

.note-item.active ion-icon {
  color: var(--orange-yellow-crayola);
}

/* 目录加载/空状态 */
.catalog-loading,
.catalog-empty,
.catalog-error {
  padding: 24px 16px;
  text-align: center;
  color: var(--light-gray-70);
  font-size: 13px;
}

/* ==================== 主内容区 ==================== */

.notes-main {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-width: 0;
}

/* ==================== 笔记内容区 ==================== */

.notes-body {
  flex: 1;
  overflow-y: auto;
  padding: 32px 48px;
  min-width: 0;
}

/* 标题区 */
.note-title-area {
  margin-bottom: 32px;
}

.note-title-area .note-title {
  font-size: 28px;
  font-weight: 600;
  color: var(--white-2);
  margin-bottom: 12px;
  line-height: 1.3;
}

.note-title-area .note-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--light-gray-70);
  margin-bottom: 12px;
}

.note-title-area .note-meta time,
.note-title-area .note-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.note-title-area .note-meta ion-icon {
  font-size: 14px;
}

.note-title-area .note-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.note-title-area .note-tag {
  display: inline-block;
  padding: 2px 10px;
  background: var(--onyx);
  border-radius: 12px;
  font-size: 12px;
  color: var(--light-gray-70);
}

/* 笔记正文 */
.note-content {
  line-height: 1.8;
  color: var(--light-gray);
}

.note-content h2 {
  font-size: 22px;
  font-weight: 600;
  color: var(--white-2);
  margin: 32px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--jet);
}

.note-content h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--white-2);
  margin: 24px 0 12px;
}

.note-content h4 {
  font-size: 16px;
  font-weight: 600;
  color: var(--white-2);
  margin: 20px 0 8px;
}

.note-content p {
  margin-bottom: 16px;
}

.note-content a {
  color: var(--orange-yellow-crayola);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color var(--transition-1);
}

.note-content a:hover {
  border-bottom-color: var(--orange-yellow-crayola);
}

.note-content ul,
.note-content ol {
  margin: 0 0 16px 24px;
}

.note-content li {
  margin-bottom: 8px;
}

.note-content blockquote {
  border-left: 3px solid var(--orange-yellow-crayola);
  padding: 8px 16px;
  margin: 16px 0;
  background: hsla(0, 0%, 100%, 0.03);
  border-radius: 0 8px 8px 0;
}

.note-content hr {
  border: none;
  border-top: 1px solid var(--jet);
  margin: 24px 0;
}

.note-content img {
  max-width: 100%;
  border-radius: 8px;
  margin: 16px 0;
}

/* 代码块 */
.note-content pre,
.note-content pre[class*="language-"] {
  background: hsl(0, 0%, 10%) !important;
  border: 1px solid var(--jet) !important;
  border-radius: 8px !important;
  padding: 16px !important;
  margin: 16px 0 !important;
  overflow-x: auto !important;
  position: relative;
  text-align: left !important;
  white-space: pre !important;
  word-spacing: normal !important;
  word-break: normal !important;
  word-wrap: normal !important;
}

.note-content pre code,
.note-content pre code[class*="language-"],
.note-content pre code * {
  display: inline !important;
  font-family: 'Fira Code', 'Consolas', monospace !important;
  font-size: 13px !important;
  line-height: 1.6 !important;
  text-align: left !important;
  white-space: pre !important;
  word-spacing: normal !important;
  word-break: normal !important;
  word-wrap: normal !important;
  background: none !important;
  padding: 0 !important;
}

.note-content code {
  font-family: 'Fira Code', 'Consolas', monospace !important;
  font-size: 0.9em !important;
  background: var(--onyx) !important;
  padding: 2px 6px !important;
  border-radius: 4px !important;
  white-space: nowrap !important;
  text-align: left !important;
}

/* 代码复制按钮 */
.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--onyx);
  border: 1px solid var(--jet);
  border-radius: 6px;
  color: var(--light-gray-70);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition-1), background var(--transition-1);
}

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

.code-copy-btn:hover {
  background: var(--jet);
  color: var(--white-2);
}

.code-copy-btn.copied {
  color: var(--orange-yellow-crayola);
}

/* 面包屑（底部） */
.note-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--jet);
  font-size: 13px;
  color: var(--light-gray-70);
  flex-wrap: wrap;
}

.note-breadcrumb a {
  color: var(--light-gray-70);
  text-decoration: none;
  transition: color var(--transition-1);
}

.note-breadcrumb a:hover {
  color: var(--orange-yellow-crayola);
}

.note-breadcrumb .bc-sep {
  opacity: 0.5;
}

.note-breadcrumb .bc-current {
  color: var(--white-2);
}

/* ==================== 分割线 ==================== */

.notes-divider {
  width: 1px;
  background: var(--jet);
  flex-shrink: 0;
}

/* ==================== TOC 目录 ==================== */

.notes-toc {
  width: 220px;
  min-width: 220px;
  overflow-y: auto;
  padding: 24px 16px;
}

.toc-header {
  font-size: 14px;
  font-weight: 600;
  color: var(--white-2);
  margin-bottom: 16px;
}

.toc-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.toc-link {
  display: block;
  padding: 4px 8px;
  color: var(--light-gray-70);
  font-size: 12px;
  text-decoration: none;
  border-radius: 4px;
  transition: color var(--transition-1), background var(--transition-1);
  border-left: 2px solid transparent;
}

.toc-link:hover {
  color: var(--white-2);
  background: hsla(0, 0%, 100%, 0.05);
}

.toc-link.active {
  color: var(--orange-yellow-crayola);
  border-left-color: var(--orange-yellow-crayola);
}

.toc-level-3 {
  padding-left: 16px;
}

.toc-level-4 {
  padding-left: 24px;
}

/* ==================== 占位/空状态 ==================== */

.note-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  color: var(--light-gray-70);
  text-align: center;
}

.note-placeholder ion-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

/* ==================== 移动端 ==================== */

.sidebar-toggle-btn {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  background: var(--orange-yellow-crayola);
  border: none;
  border-radius: 50%;
  color: var(--smoky-black);
  font-size: 24px;
  cursor: pointer;
  box-shadow: var(--shadow-2);
  z-index: 200;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-1);
}

.sidebar-toggle-btn:hover {
  transform: scale(1.1);
}

@media (max-width: 1024px) {
  .notes-toc {
    display: none;
  }

  .notes-divider {
    display: none;
  }
}

@media (max-width: 767px) {
  .notes-sidebar {
    position: fixed;
    top: 60px;
    left: 0;
    height: calc(100vh - 60px);
    z-index: 150;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  .notes-sidebar.open {
    transform: translateX(0);
  }

  .sidebar-toggle-btn {
    display: flex;
  }

  .notes-body {
    padding: 20px 16px;
  }

  .note-title-area .note-title {
    font-size: 22px;
  }
}

/* ==================== Light 主题 ==================== */

[data-theme="light"] .notes-sidebar {
  background: var(--eerie-black-2);
  border-right-color: var(--jet);
}

[data-theme="light"] .notes-search {
  background: var(--onyx);
  border-color: var(--jet);
  color: var(--white-2);
}

[data-theme="light"] .note-content pre,
[data-theme="light"] .note-content pre[class*="language-"] {
  background: hsl(0, 0%, 95%) !important;
  border-color: var(--jet) !important;
  text-align: left !important;
  white-space: pre !important;
}

[data-theme="light"] .note-content pre code,
[data-theme="light"] .note-content pre code[class*="language-"] {
  text-align: left !important;
  white-space: pre !important;
  color: #333 !important;
}

[data-theme="light"] .token.comment { color: #6a9955 !important; }
[data-theme="light"] .token.keyword { color: #d73a49 !important; }
[data-theme="light"] .token.string { color: #032f62 !important; }
[data-theme="light"] .token.function { color: #6f42c1 !important; }
[data-theme="light"] .token.number { color: #005cc5 !important; }
[data-theme="light"] .token.operator { color: #d73a49 !important; }
[data-theme="light"] .token.punctuation { color: #24292e !important; }

[data-theme="light"] .notes-divider {
  background: var(--jet);
}
