/* ===== 公共样式 - VG接口文档 ===== */

/* 主题变量 */
:root {
  --bg-primary: #1e212e;
  --bg-secondary: #2a2d3e;
  --bg-card: #2a2d3e;
  --bg-hover: #353850;
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0b0;
  --text-muted: #6c6c80;
  --border-color: #3a3d4e;
  --accent-color: #4a9eff;
  --accent-hover: #3a8eef;
  --success-color: #4caf50;
  --warning-color: #ff9800;
  --danger-color: #f44336;
  --code-bg: #1a1d2e;
  --table-header-bg: #353850;
  --table-border: #3a3d4e;
  --table-stripe: #2a2d3e;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --radius: 6px;
  --radius-lg: 10px;
  --transition: all 0.3s ease;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

/* 亮色主题 */
body.theme-light {
  --bg-primary: #f5f5f5;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #e8e8e8;
  --text-primary: #333333;
  --text-secondary: #666666;
  --text-muted: #999999;
  --border-color: #dddddd;
  --accent-color: #2196f3;
  --accent-hover: #1976d2;
  --code-bg: #f8f8f8;
  --table-header-bg: #f0f0f0;
  --table-border: #dddddd;
  --table-stripe: #fafafa;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* 全局重置 */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: var(--transition);
}

a {
  color: var(--accent-color);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* ===== 主题切换按钮 ===== */
.switch-theme {
  position: fixed;
  top: 15px;
  right: 15px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 6px 14px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.switch-theme:hover {
  background: var(--bg-hover);
}

.switch-theme i {
  font-size: 16px;
  color: var(--text-secondary);
  transition: var(--transition);
}

.switch-theme .fa-sun { color: #ff9800; }
.switch-theme .fa-moon { color: #4a9eff; }

/* ===== 登录弹窗 ===== */
.popup-login {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2000;
  width: 360px;
  max-width: 90vw;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  overflow: hidden;
}

.popup-login.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

.popup-login-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.popup-login-title-text {
  font-size: 18px;
  font-weight: 600;
}

.popup-login-title-close {
  cursor: pointer;
  font-size: 18px;
  color: var(--text-muted);
  transition: var(--transition);
}

.popup-login-title-close:hover {
  color: var(--danger-color);
}

.popup-login-content {
  padding: 20px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  color: var(--text-secondary);
}

.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.2);
}

.btn {
  display: inline-block;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary {
  background: var(--accent-color);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-warning {
  background: var(--warning-color);
  color: #fff;
}

.btn-warning:hover {
  background: #e68900;
}

.btn-block {
  display: block;
  width: 100%;
}

/* ===== 遮罩层 ===== */
.popup-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1999;
  background: rgba(0,0,0,0.5);
}

.popup-overlay.active {
  display: block;
}

/* ===== 主容器 ===== */
.main-container {
  display: flex;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0;
  min-height: 100vh;
}

/* ===== 导航栏 ===== */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  height: 56px;
  padding: 0 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow);
}

.navbar .menu {
  display: none;
  cursor: pointer;
  font-size: 20px;
  margin-right: 16px;
  color: var(--text-primary);
}

.navbar .logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-color);
  white-space: nowrap;
}

.navbar .page-breadcrumb {
  flex: 1;
  margin-left: 24px;
  font-size: 14px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.navbar .page-breadcrumb a {
  color: var(--text-secondary);
}

.navbar .page-breadcrumb a:hover {
  color: var(--accent-color);
}

.navbar .login {
  margin-left: auto;
}

.navbar .login a {
  color: var(--text-primary);
  font-size: 14px;
}

.navbar .login a:hover {
  color: var(--accent-color);
  text-decoration: none;
}

/* ===== 侧边栏目录 ===== */
.categories {
  position: fixed;
  top: 56px;
  left: 0;
  bottom: 0;
  width: 260px;
  overflow-y: auto;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  padding: 12px 0;
  z-index: 90;
}

.categories::-webkit-scrollbar {
  width: 6px;
}

.categories::-webkit-scrollbar-track {
  background: transparent;
}

.categories::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.categories ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.categories > ul > li {
  margin-bottom: 2px;
}

.category-title {
  padding: 10px 20px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.categories > ul > li > a {
  display: block;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
}

.categories > ul > li > a:hover {
  background: var(--bg-hover);
  text-decoration: none;
}

.categories > ul > li > a.active {
  color: var(--accent-color);
}

.categories ul ul {
  padding-left: 0;
}

.categories ul ul li a {
  display: block;
  padding: 8px 20px 8px 36px;
  font-size: 13px;
  color: var(--text-secondary);
  transition: var(--transition);
}

.categories ul ul li a:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  text-decoration: none;
}

.categories ul ul li a.active {
  color: var(--accent-color);
  background: rgba(74, 158, 255, 0.1);
  border-right: 3px solid var(--accent-color);
}

.login-info-mobile {
  display: none;
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
  margin-top: 16px;
}

/* ===== 主内容区 ===== */
.main-articles {
  flex: 1;
  margin-left: 260px;
  margin-top: 56px;
  padding: 32px 40px;
  max-width: 900px;
}

.article-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--accent-color);
}

/* ===== 文章编辑器 ===== */
.article-editor {
  display: none;
  margin-bottom: 20px;
}

.article-editor.active {
  display: block;
}

#article-editor-inst {
  min-height: 400px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--bg-primary);
  margin-bottom: 12px;
}

.article-editor-btns {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ===== 文章内容 ===== */
.article-content {
  font-size: 15px;
  line-height: 1.8;
}

.article-content h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 32px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.article-content h1:first-child {
  margin-top: 0;
}

.article-content h1 .anchor {
  display: none;
}

.article-content blockquote {
  margin: 16px 0;
  padding: 12px 16px;
  border-left: 4px solid var(--accent-color);
  background: var(--bg-secondary);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.article-content blockquote p {
  margin: 0;
}

.article-content blockquote strong {
  color: var(--accent-color);
  font-size: 16px;
}

/* ===== 代码块 ===== */
.article-content pre {
  margin: 16px 0;
  border-radius: var(--radius);
  overflow: hidden;
}

.article-content pre code {
  display: block;
  padding: 16px 20px;
  background: var(--code-bg);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
  tab-size: 4;
}

.article-content pre code .code-line {
  display: block;
}

.article-content pre code .hljs-comment {
  color: #6a9955;
}

.article-content pre code .hljs-string {
  color: #ce9178;
}

.article-content pre code .hljs-number {
  color: #b5cea8;
}

.article-content pre code .hljs-literal {
  color: #569cd6;
}

.article-content pre code .hljs-keyword {
  color: #569cd6;
}

.article-content pre code .hljs-built_in {
  color: #4ec9b0;
}

.article-content pre code .hljs-attr {
  color: #9cdcfe;
}

.article-content pre code .hljs-params {
  color: #9cdcfe;
}

.article-content pre code .hljs-title {
  color: #dcdcaa;
}

.article-content pre code .hljs-property {
  color: #9cdcfe;
}

.article-content pre code .hljs-punctuation {
  color: #d4d4d4;
}

.article-content pre code .hljs-operator {
  color: #d4d4d4;
}

/* 亮色主题代码高亮 */
body.theme-light .article-content pre code .hljs-comment { color: #008000; }
body.theme-light .article-content pre code .hljs-string { color: #a31515; }
body.theme-light .article-content pre code .hljs-number { color: #098658; }
body.theme-light .article-content pre code .hljs-literal { color: #0000ff; }
body.theme-light .article-content pre code .hljs-keyword { color: #0000ff; }
body.theme-light .article-content pre code .hljs-built_in { color: #795e26; }
body.theme-light .article-content pre code .hljs-attr { color: #001080; }
body.theme-light .article-content pre code .hljs-params { color: #001080; }
body.theme-light .article-content pre code .hljs-title { color: #795e26; }
body.theme-light .article-content pre code .hljs-property { color: #001080; }
body.theme-light .article-content pre code .hljs-punctuation { color: #333; }
body.theme-light .article-content pre code .hljs-operator { color: #333; }

/* ===== 表格 ===== */
.cherry-table-container {
  margin: 16px 0;
  overflow-x: auto;
}

.responsive-table {
  width: 100%;
  overflow-x: auto;
}

.cherry-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.cherry-table thead th {
  background: var(--table-header-bg);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  border: 1px solid var(--table-border);
  white-space: nowrap;
}

.cherry-table tbody td {
  padding: 10px 14px;
  border: 1px solid var(--table-border);
}

.cherry-table tbody tr:nth-child(even) {
  background: var(--table-stripe);
}

.cherry-table tbody tr:hover {
  background: var(--bg-hover);
}

/* ===== 文章目录 ===== */
.article-catalog {
  position: fixed;
  top: 56px;
  right: 0;
  width: 220px;
  padding: 24px 16px;
  max-height: calc(100vh - 56px);
  overflow-y: auto;
  display: none;
}

.article-catalog h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.article-catalog ul {
  list-style: none;
  padding: 0;
}

.article-catalog ul li {
  margin-bottom: 4px;
}

.article-catalog ul li a {
  display: block;
  padding: 4px 8px;
  font-size: 13px;
  color: var(--text-secondary);
  border-left: 2px solid transparent;
  transition: var(--transition);
}

.article-catalog ul li a:hover {
  color: var(--accent-color);
  border-left-color: var(--accent-color);
  text-decoration: none;
}

/* ===== 动画 ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translate(-50%, -48%); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

/* ===== 响应式 ===== */
@media (max-width: 1024px) {
  .article-catalog {
    display: none !important;
  }
}

@media (max-width: 768px) {
  .navbar .menu {
    display: block;
  }

  .navbar .page-breadcrumb {
    display: none;
  }

  .categories {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    width: 280px;
  }

  .categories.open {
    transform: translateX(0);
  }

  .login-info-mobile {
    display: block;
  }

  .main-articles {
    margin-left: 0;
    padding: 20px 16px;
  }

  .article-title {
    font-size: 22px;
  }

  .article-content {
    font-size: 14px;
  }

  .cherry-table {
    font-size: 13px;
  }

  .cherry-table thead th,
  .cherry-table tbody td {
    padding: 8px 10px;
  }
}

@media (max-width: 480px) {
  .main-articles {
    padding: 16px 12px;
  }

  .article-title {
    font-size: 20px;
  }

  .article-content pre code {
    padding: 12px 14px;
    font-size: 12px;
  }
}