/* Synced with templates/dcs_tools_ui.html */

:root {
  --primary-green: #2EC5B1;
  --primary-green-light: #EAF9F7;
  --primary-green-dark: #259E8E;
  --bg-color-page: #F8F9FA;
  --bg-color-container: #EEF0F3;
  --bg-color-white: #FFFFFF;
  --text-primary: #080613;
  --text-primary-light: #4C586A;
  --text-secondary: #636A74;
  --text-secondary-light: #8E949F;
  --text-placeholder: #C8CDD5;
  --border-color: #EEF0F3;
  --success-green: #2EC5B1;
  --danger-red: #FF5757;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* Anchor offset: avoid sticky top-bar covering headings */
html {
  scroll-padding-top: 84px; /* top-bar height + breathing room */
}

/* Applies to anchor jumps (e.g. #xxx) */
h1, h2, h3, h4, h5, h6 {
  scroll-margin-top: 84px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--bg-color-page);
  color: var(--text-primary-light);
  line-height: 1.5;
  scroll-behavior: smooth;
}

/* Typography (match dcs_tools_ui.html scale) */
h1 { font-size: 24px; line-height: 32px; font-weight: 600; color: var(--text-primary); }
h2 { font-size: 20px; line-height: 28px; font-weight: 600; color: var(--text-primary); }
h3 { font-size: 16px; line-height: 24px; font-weight: 500; color: var(--text-primary); }
h4 { font-size: 15px; line-height: 22px; font-weight: 600; margin: 16px 0 8px; color: var(--text-primary); }
body, p, span, div, li, label, input, select, textarea { font-size: 14px; line-height: 22px; font-weight: 400; }
.text-small { font-size: 12px; line-height: 20px; font-weight: 400; }

a { color: inherit; text-decoration: none; }

/* min-width:0 让 flex 子项可被内容区压缩，避免整页横向滚动 */
.app-container {
  display: flex;
  min-height: 100vh;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

/* Side nav */
.side-nav {
  width: 300px;
  background: var(--bg-color-white);
  border-right: 1px solid var(--border-color);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
}

.side-nav-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 16px;
}

.logo { display: flex; align-items: center; gap: 10px; }
.logo-image {
  height: 32px;
  width: auto;
  display: block;
}
.logo-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--primary-green), var(--primary-green-dark));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700;
}
.logo-text { font-size: 18px; font-weight: 600; color: var(--text-primary); }
.logo-badge { font-size: 10px; background: var(--bg-color-container); padding: 2px 6px; border-radius: 4px; color: var(--text-secondary); margin-left: 8px; }

.nav-menu { list-style: none; padding: 0 12px 20px; }
.nav-item { margin-bottom: 2px; }

.nav-link {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-radius: 8px;
  color: var(--text-primary); font-size: 14px; font-weight: 500;
  transition: all 0.2s; cursor: pointer;
}

.nav-link-left { display: flex; align-items: center; gap: 12px; }
.nav-link-left i { width: 20px; font-size: 16px; color: var(--text-secondary); }

.nav-link:hover { background-color: var(--primary-green-light); }
.nav-link.active { background-color: var(--primary-green-light); color: var(--primary-green); }
.nav-link.active .nav-link-left i { color: var(--primary-green); }

.chevron { font-size: 12px; color: var(--text-secondary-light); transition: transform 0.2s; }
.nav-link.expanded .chevron { transform: rotate(90deg); }

.sub-menu { list-style: none; padding-left: 44px; margin: 4px 0; display: none; }
.sub-menu.show { display: block; }
.sub-link {
  display: block;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 13px;
  transition: all 0.2s;
}
.sub-link:hover { background-color: var(--primary-green-light); color: var(--primary-green); }
.sub-link.active { background-color: var(--primary-green-light); color: var(--primary-green); font-weight: 500; }

/* 三级：文档页 H1 锚点 */
/* 三级锚点：更紧凑，且视觉完全继承 sub-link */
.sub-sub-menu { padding-left: 16px; margin: 2px 0 10px 44px; border-left: 2px solid var(--border-color); }
.sub-sub-link { padding: 6px 10px; font-size: 12px; line-height: 20px; }
.sub-sub-link.active { font-weight: 500; }

/* Main content */
.main-content {
  flex: 1;
  margin-left: 300px;
  min-height: 100vh;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.top-bar {
  background: var(--bg-color-white);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 32px;
  display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; z-index: 99;
  background: rgba(255,255,255,0.98); backdrop-filter: blur(8px);
}

.top-left { display: flex; align-items: center; gap: 14px; }
.page-title { font-size: 20px; font-weight: 600; color: var(--text-primary); }

/* 顶栏 Logo：仅移动端显示在标题左侧（PC 隐藏） */
.top-bar-mobile-logo {
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-decoration: none;
  color: inherit;
}

.top-bar-mobile-logo-img {
  display: block;
  width: 28px;
  height: auto;
  max-height: 30px;
  object-fit: contain;
}

.top-actions {
  display: flex;
  gap: 16px;
  align-items: center;
  min-width: 0;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  white-space: nowrap;
}

.lang-btn {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 22px;
  padding: 4px 2px;
}

.lang-btn.active {
  color: var(--primary-green-dark);
  font-weight: 600;
}

.lang-divider {
  color: var(--text-placeholder);
}

.top-search {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 280px;
}

.top-search-input {
  width: 240px;
  padding: 9px 12px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: white;
  font-size: 14px;
}
.top-search-input::placeholder { color: var(--text-placeholder); }
.top-search-input:focus {
  outline: none;
  border-color: var(--primary-green);
  box-shadow: 0 0 0 2px rgba(46,197,177,0.2);
}

.btn-primary {
  background: var(--primary-green); color: white; border: none;
  padding: 8px 20px; border-radius: 4px; font-weight: 500; font-size: 14px;
  cursor: pointer; transition: all 0.2s;
}
.btn-primary:hover { background: var(--primary-green-dark); }

.btn-secondary {
  background: transparent;
  border: 1px solid var(--primary-green);
  color: var(--primary-green);
  padding: 8px 16px;
  border-radius: 4px;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:hover { background: var(--primary-green-light); }

/* 占满主栏可用宽度，宽屏不再留大块右侧空白 */
.content-container {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 32px clamp(16px, 2.5vw, 48px);
  overflow-x: hidden;
  overflow-wrap: anywhere;
}

.content-container img,
.content-container video,
.content-container svg {
  max-width: 100%;
  height: auto;
}

.footer { background: var(--bg-color-white); padding: 24px 32px; text-align: center; font-size: 12px; color: var(--text-secondary); border-top: 1px solid var(--border-color); margin-top: 32px; }
.footer a { color: var(--primary-green-dark); text-decoration: underline; }

/* ===== Code blocks container ===== */
.code-container {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  margin: 16px 0;
  box-sizing: border-box;
}

/* ===== Code blocks only (Word 规范：浅色、无白线) ===== */
pre,
pre code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'SF Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

pre {
  background: #F8F9FA;
  color: var(--text-primary);
  border: none; /* 移除上下白线 */
  outline: none;
  box-shadow: none;
  border-radius: 6px;
  padding: 12px 16px;
  width: 100%;
  max-width: 100%;
  min-width: 100%;
  margin: 16px 0;
  box-sizing: border-box;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  font-size: 13px;
  line-height: 22px;
  font-weight: 400;
}

pre code {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: max-content;
  box-sizing: border-box;
}

code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'SF Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Inline code */
:not(pre) > code {
  background: var(--bg-color-container);
  color: var(--text-primary);
  border: none;
  outline: none;
  box-shadow: none;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 22px;
  font-weight: 400;
}

/* Any code-ish containers */
[class*="code-block"],
[class*="language-"],
[class*="codehilite"],
[class*="highlight"] {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'SF Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Remove borders/shadows that may create horizontal "white lines" */
pre *, code * {
  box-shadow: none !important;
  outline: none !important;
}

/* Scroll constraints for tall code blocks */
.code-scroll-y {
  max-height: 300px;
  overflow-y: auto;
}

/* ===== Cards (Word 规范) ===== */
.card,
.content-card {
  background: var(--bg-color-white);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  box-shadow: none;
  transition: box-shadow 0.2s;
}
.card:hover,
.content-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* ===== Tables: consistent width + horizontal scroll per-table =====
   Applies to:
   - Markdown-rendered tables wrapped by app.py in .table-container
   - Homepage tables wrapped in .table-responsive-wrapper
*/
.table-container,
.table-responsive-wrapper {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-color-white);
}

.table-nowrap {
  overflow-x: auto;
}

.table-container table,
.table-responsive-wrapper table,
table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  background: var(--bg-color-white);
}

/* Prevent long content from forcing page overflow; allow wrap by default */
th, td {
  word-break: break-word;
  overflow-wrap: anywhere;
}

.table-nowrap table {
  width: max-content;
  max-width: none;
}

.table-nowrap th,
.table-nowrap td {
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
}

/* Release notes: keep the 3-column changelog readable in English and Chinese. */
.release-notes-page .table-container,
.release-notes-page .table-responsive-wrapper {
  overflow-x: auto;
}

.release-notes-page .table-container table,
.release-notes-page .table-responsive-wrapper table {
  width: 100%;
  max-width: 100%;
  table-layout: auto;
}

.release-notes-page table th,
.release-notes-page table td {
  text-align: left;
}

.release-notes-page table th:nth-child(1),
.release-notes-page table td:nth-child(1),
.release-notes-page table th:nth-child(2),
.release-notes-page table td:nth-child(2) {
  width: 1%;
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
}

.release-notes-page table th:nth-child(3),
.release-notes-page table td:nth-child(3) {
  width: auto;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

table th,
table td {
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  vertical-align: top;
}

table th {
  background: var(--bg-color-container);
  color: var(--text-primary);
  font-weight: 500;
}

table td {
  color: var(--text-primary-light);
}

table tbody tr:hover td {
  background: var(--bg-color-page);
}

/* Vertical scroll for long tables (>~10 rows), with sticky header */
.table-scroll-y {
  max-height: 400px;
  overflow-y: auto;
}

.table-scroll-y thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-color-container);
}

/* 移动端底栏主导航（≤768px 时固定底部）；桌面端隐藏 */
.mobile-icon-rail {
  display: none;
}

.mobile-rail-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 0 8px;
  width: 100%;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 6px;
}

/* 仅图形标（无 DCS Tools 文字），适配窄条 */
.mobile-rail-logo-img {
  display: block;
  width: 24px;
  height: auto;
  max-height: 34px;
  object-fit: contain;
}

.mobile-rail-list {
  list-style: none;
  margin: 0;
  padding: 0 0 12px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
}

.mobile-rail-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  height: auto;
  padding: 6px 4px 8px;
  gap: 3px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  flex-shrink: 0;
  cursor: pointer;
  text-decoration: none;
  box-sizing: border-box;
  transition: background-color 0.2s, color 0.2s;
}

.mobile-rail-label {
  display: block;
  width: 100%;
  font-size: 9px;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
  color: inherit;
  opacity: 0.92;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.mobile-rail-item:hover {
  background-color: var(--primary-green-light);
  color: var(--text-primary);
}

.mobile-rail-item.active {
  background-color: var(--primary-green-light);
  color: var(--primary-green);
}

.mobile-rail-item.active .mobile-rail-label {
  color: inherit;
  opacity: 1;
}

.mobile-rail-item i {
  font-size: 16px;
  pointer-events: none;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .side-nav {
    display: none;
  }

  /* 主导航移至底部（Tab 栏），PC 仍为左侧宽栏 */
  .mobile-icon-rail {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    justify-content: flex-start;
    position: fixed;
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    width: 100%;
    height: auto;
    min-height: calc(52px + env(safe-area-inset-bottom, 0px));
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px));
    padding-left: max(6px, env(safe-area-inset-left, 0px));
    padding-right: max(6px, env(safe-area-inset-right, 0px));
    z-index: 100;
    background: var(--bg-color-white);
    border-right: none;
    border-top: 1px solid var(--border-color);
    box-sizing: border-box;
    box-shadow: 0 -2px 12px rgba(8, 6, 19, 0.06);
  }

  .mobile-rail-logo {
    display: none;
  }

  .mobile-rail-list {
    flex: 1 1 auto;
    min-width: 0; /* 允许在 flex 父级内收缩，从而出现横向滚动 */
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    gap: 4px;
    padding: 0 8px;
    scrollbar-width: thin;
  }

  .mobile-rail-list::-webkit-scrollbar {
    height: 4px;
  }

  .mobile-rail-list::-webkit-scrollbar-thumb {
    background: var(--border-color, #eef0f3);
    border-radius: 4px;
  }

  .mobile-rail-list > li {
    flex: 0 0 auto;
    min-width: 72px;
    max-width: none;
  }

  .mobile-rail-item {
    width: 100%;
    min-width: 72px;
    min-height: 48px;
    padding: 6px 8px 8px;
    box-sizing: border-box;
  }

  .main-content {
    margin-left: 0;
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }

  .content-container {
    padding: 12px 8px;
  }

  .content-container p,
  .content-container li {
    margin: 8px 0;
    line-height: 1.5;
  }

  .content-container h1,
  .content-container h2,
  .content-container h3,
  .content-container h4 {
    margin-top: 16px;
    margin-bottom: 8px;
  }

  .content-container h1 { font-size: 18px; }
  .content-container h2 { font-size: 16px; }
  .content-container h3 { font-size: 14px; }
  .content-container h4 { font-size: 13px; }

  /* 顶栏：Logo + 标题 + 搜索同一行；隐藏顶部「申请试用」 */
  .top-bar {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    padding-left: max(10px, env(safe-area-inset-left, 0px));
    padding-right: max(10px, env(safe-area-inset-right, 0px));
    padding-top: max(8px, env(safe-area-inset-top, 0px));
  }

  .top-bar-mobile-logo {
    display: flex;
  }

  .top-left {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex: 0 1 auto;
    min-width: 0;
    max-width: 50%;
    gap: 8px;
    width: auto;
  }

  .page-title {
    font-size: 15px;
    line-height: 22px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    min-width: 0;
  }

  .top-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
    gap: 8px;
    width: auto;
    justify-content: flex-end;
  }

  .lang-switch {
    gap: 4px;
  }

  .lang-btn {
    font-size: 12px;
  }

  .top-actions > .top-bar-apply-btn,
  .top-actions > .btn-primary.top-bar-apply-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    font-size: 13px;
    border-radius: 8px;
    flex-shrink: 0;
  }

  .top-search {
    flex: 1 1 auto;
    width: auto;
    max-width: 180px;
    min-width: 0;
    margin: 0;
    order: 0;
  }

  .top-search-input {
    width: 100%;
    min-width: 0;
    min-height: 36px;
    font-size: 14px;
    box-sizing: border-box;
    border-radius: 8px;
    padding: 8px 12px;
  }

  /* 代码块：移动端一行展示，允许横向滚动 */
  pre {
    padding: 8px 12px !important;
    white-space: pre !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 100% !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
  }

  pre code {
    white-space: pre !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
    display: block !important;
    min-width: max-content !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
  }

  :not(pre) > code {
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* 移动端发版日志表格：允许英文短语换行，避免窄屏下文字互相遮挡 */
  .release-notes-page table th:nth-child(1),
  .release-notes-page table td:nth-child(1),
  .release-notes-page table th:nth-child(2),
  .release-notes-page table td:nth-child(2) {
    width: auto;
    min-width: 0;
    max-width: none;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .release-notes-page table th:nth-child(3),
  .release-notes-page table td:nth-child(3) {
    width: auto;
    min-width: 0;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
  }
}

