/* ========================================================
   云御大模型 API 文档 — Infima / Docusaurus Inspired
   ======================================================== */

/* ---- CSS Custom Properties ---- */
:root {
  /* Primary */
  --ifm-color-primary: #007aff;
  --ifm-color-primary-dark: #006ee6;
  --ifm-color-primary-darker: #0068d9;
  --ifm-color-primary-darkest: #0055b3;
  --ifm-color-primary-light: #1a87ff;
  --ifm-color-primary-lighter: #268eff;
  --ifm-color-primary-lightest: #4da2ff;
  --ifm-color-primary-contrast-background: #ebf2fc;
  --ifm-color-primary-contrast-foreground: #102445;

  /* Links */
  --ifm-link-color: #007aff;
  --ifm-link-hover-color: #007aff;

  /* Navbar */
  --ifm-navbar-background-color: #fff;
  --ifm-navbar-link-color: #1c1e21;
  --ifm-navbar-link-hover-color: #007aff;
  --ifm-navbar-height: 60px;
  --ifm-navbar-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.1);

  /* Menu (Sidebar) */
  --ifm-menu-color: #606770;
  --ifm-menu-color-active: #007aff;
  --ifm-menu-color-background-active: rgba(0, 0, 0, 0.05);

  /* Typography */
  --ifm-font-family-base: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --ifm-font-size-base: 16px;
  --ifm-line-height-base: 1.65;
  --ifm-heading-font-family: var(--ifm-font-family-base);
  --ifm-heading-font-weight: 700;
  --ifm-heading-color: #1c1e21;
  --ifm-h1-font-size: 2rem;
  --ifm-h2-font-size: 1.5rem;
  --ifm-h3-font-size: 1.25rem;

  /* Code */
  --ifm-code-font-size: 95%;
  --ifm-pre-background: #f6f7f8;
  --ifm-pre-border-radius: 6.4px;
  --ifm-pre-line-height: 1.45;

  /* Table */
  --ifm-table-border-color: #dadde1;
  --ifm-table-stripe-background: rgba(0, 0, 0, 0.03);

  /* Colors */
  --ifm-color-emphasis-0: #fff;
  --ifm-color-emphasis-100: #f5f6f7;
  --ifm-color-emphasis-200: #ebedf0;
  --ifm-color-emphasis-600: #8d949e;
  --ifm-color-emphasis-700: #606770;
  --ifm-color-emphasis-800: #444950;
  --ifm-color-emphasis-900: #1c1e21;

  /* TOC */
  --ifm-toc-border-color: #ccd0d5;
  --ifm-toc-link-color: #525860;

  /* Misc */
  --ifm-global-radius: 6.4px;
  --ifm-global-shadow-lw: 0 1px 2px 0 rgba(0, 0, 0, 0.1);
  --ifm-container-width: 1140px;
  --ifm-spacing-horizontal: 1rem;
  --ifm-tabs-color-active: #007aff;

  /* Sidebar width */
  --doc-sidebar-width: 300px;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: var(--ifm-font-size-base); -webkit-font-smoothing: antialiased; text-size-adjust: 100%; }
body {
  font-family: var(--ifm-font-family-base);
  line-height: var(--ifm-line-height-base);
  color: var(--ifm-color-emphasis-900);
  background: var(--ifm-color-emphasis-0);
  overflow-x: hidden;
}
a { color: var(--ifm-link-color); text-decoration: none; }
a:hover { color: var(--ifm-link-hover-color); text-decoration: underline; }
img { display: block; max-width: 100%; }
ul, ol { list-style: none; }
table { border-collapse: collapse; width: 100%; }
code { font-size: var(--ifm-code-font-size); }
button { font-family: inherit; font-size: inherit; cursor: pointer; border: none; background: none; }

/* ---- Skip Link ---- */
.skip-link {
  position: fixed; top: 0; left: 50%; transform: translateX(-50%) translateY(-100%);
  background: var(--ifm-color-emphasis-900); color: var(--ifm-color-emphasis-0);
  padding: 8px 16px; border-radius: 0 0 8px 8px; z-index: 300; font-size: 14px;
  transition: transform 0.2s;
}
.skip-link:focus { transform: translateX(-50%) translateY(0); }

/* ---- Navbar ---- */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  height: var(--ifm-navbar-height);
  background: var(--ifm-navbar-background-color);
  box-shadow: var(--ifm-navbar-shadow);
  display: flex; align-items: center;
}
.navbar__inner {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; max-width: var(--ifm-container-width);
  padding: 0 var(--ifm-spacing-horizontal); margin: 0 auto;
}
.navbar__brand {
  display: flex; align-items: center; gap: 8px;
  color: var(--ifm-color-emphasis-900); font-weight: 600; font-size: 18px;
  text-decoration: none;
}
.navbar__brand:hover { text-decoration: none; }
.navbar__logo { width: 32px; height: 32px; }
.navbar__title { color: inherit; }
.navbar__items { display: flex; align-items: center; gap: 4px; }

.navbar__item { padding: 8px 12px; border-radius: var(--ifm-global-radius); }
.navbar__link {
  color: var(--ifm-navbar-link-color); font-size: 14px; font-weight: 500;
  display: flex; align-items: center; gap: 4px;
}
.navbar__link:hover { color: var(--ifm-navbar-link-hover-color); text-decoration: none; }

.platform-link {
  background: var(--ifm-color-emphasis-100);
  padding: 6px 12px; border-radius: var(--ifm-global-radius);
  transition: background 0.2s;
}
.platform-link:hover { background: var(--ifm-color-emphasis-200); }

/* Dropdown */
.dropdown { position: relative; }
.dropdown__toggle { display: flex; align-items: center; gap: 4px; color: var(--ifm-navbar-link-color); }
.dropdown__menu {
  position: absolute; top: 100%; left: 0; min-width: 160px;
  background: var(--ifm-color-emphasis-0); border-radius: var(--ifm-global-radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12); padding: 4px; z-index: 210;
}
.dropdown__menu[hidden] { display: none; }
.dropdown__link {
  display: block; padding: 6px 12px; border-radius: 4px; font-size: 14px;
  color: var(--ifm-color-emphasis-700); text-decoration: none;
}
.dropdown__link:hover { background: var(--ifm-color-emphasis-100); text-decoration: none; }
.dropdown__link--active { color: var(--ifm-color-primary); }

/* Theme Toggle */
.theme-toggle {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; color: var(--ifm-color-emphasis-700); transition: background 0.2s;
}
.theme-toggle:hover { background: var(--ifm-color-emphasis-100); }

/* Sidebar Toggle (mobile) */
.sidebar-toggle { display: none; width: 32px; height: 32px; border-radius: 50%; }

/* ---- Layout ---- */
.docs-wrapper {
  display: flex; padding-top: var(--ifm-navbar-height); min-height: calc(100vh - 310px);
}

/* ---- Sidebar ---- */
.sidebar {
  position: fixed; top: var(--ifm-navbar-height); left: 0; bottom: 0;
  width: var(--doc-sidebar-width); overflow-y: auto; overflow-x: hidden;
  padding: 8px 0; border-right: 1px solid var(--ifm-toc-border-color);
  background: var(--ifm-color-emphasis-0); z-index: 100;
  -webkit-overflow-scrolling: touch;
}
.menu { padding: 8px; }
.menu__list { padding-left: 0; }
.menu__list .menu__list { padding-left: 12px; }
.menu__list-item { margin: 2px 0; }
.menu__list-item-collapsed .menu__list { display: none; }

.menu__link {
  display: flex; align-items: center; padding: 6px 12px;
  border-radius: var(--ifm-global-radius); font-size: 14px;
  color: var(--ifm-menu-color); text-decoration: none; transition: all 0.1s;
  line-height: 1.4; min-height: 32px;
}
.menu__link:hover { background: var(--ifm-menu-color-background-active); text-decoration: none; }
.menu__link--active {
  color: var(--ifm-menu-color-active) !important;
  background: var(--ifm-menu-color-background-active);
  font-weight: 500;
}
.menu__link--sublist::after {
  content: ''; margin-left: auto; width: 16px; height: 16px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'%3E%3Cpath d='M8 10l4 4 4-4' stroke='currentColor' stroke-width='1.5' fill='none'/%3E%3C/svg%3E") center no-repeat;
  transition: transform 0.2s; opacity: 0.6;
}
.menu__link--sublist.menu__link--active::after { transform: rotate(180deg); }

/* ---- Main Content ---- */
.main-content {
  margin-left: var(--doc-sidebar-width); flex: 1; min-width: 0; padding-bottom: 4rem;
}
.container { max-width: var(--ifm-container-width); margin: 0 auto; padding: 0 var(--ifm-spacing-horizontal); }
.row { display: flex; gap: 0; }
.col--main { flex: 1; min-width: 0; max-width: 740px; padding: 24px 16px; }
.col--toc { width: 200px; flex-shrink: 0; padding: 24px 0 24px 16px; position: sticky; top: calc(var(--ifm-navbar-height) + 24px); align-self: flex-start; max-height: calc(100vh - var(--ifm-navbar-height) - 48px); overflow-y: auto; }

/* ---- Breadcrumbs ---- */
.breadcrumbs { margin-bottom: 12px; }
.breadcrumbs__list { display: flex; align-items: center; gap: 4px; }
.breadcrumbs__item { display: flex; align-items: center; }
.breadcrumbs__item + .breadcrumbs__item::before {
  content: '›'; margin: 0 6px; color: var(--ifm-color-emphasis-600); font-size: 18px;
}
.breadcrumbs__link {
  display: inline-flex; align-items: center; padding: 4px 8px;
  border-radius: var(--ifm-global-radius); font-size: 14px;
  color: var(--ifm-color-emphasis-700); text-decoration: none;
}
.breadcrumbs__link:hover { background: var(--ifm-menu-color-background-active); text-decoration: none; }
.breadcrumbs__link--active { color: var(--ifm-color-primary); font-weight: 500; }

/* ---- Headings ---- */
h1 { font-size: var(--ifm-h1-font-size); font-weight: var(--ifm-heading-font-weight); color: var(--ifm-heading-color); margin-bottom: 1rem; }
h2 {
  font-size: var(--ifm-h2-font-size); font-weight: var(--ifm-heading-font-weight);
  color: var(--ifm-heading-color); margin: 2rem 0 0.75rem;
  display: flex; align-items: center; gap: 6px;
}
h3 { font-size: var(--ifm-h3-font-size); font-weight: var(--ifm-heading-font-weight); color: var(--ifm-heading-color); margin: 1.5rem 0 0.5rem; }

.hash-link { opacity: 0; font-size: 20px; color: var(--ifm-color-primary); text-decoration: none; transition: opacity 0.2s; }
h2:hover .hash-link, h3:hover .hash-link { opacity: 1; }
.hash-link:hover { text-decoration: none; }

/* ---- Paragraphs ---- */
p { margin-bottom: 1rem; }
p code {
  background: var(--ifm-color-emphasis-200); padding: 1px 6px;
  border-radius: 4px; font-size: var(--ifm-code-font-size); border: 1px solid var(--ifm-color-emphasis-200);
}
.note { font-size: 14px; color: var(--ifm-color-emphasis-700); }
.note code { font-size: 13px; }

/* ---- Table ---- */
table { margin: 1rem 0 1.5rem; border: 1px solid var(--ifm-table-border-color); border-radius: var(--ifm-global-radius); overflow: hidden; display: table; }
thead { border-bottom: 2px solid var(--ifm-table-border-color); }
th { text-align: left; padding: 12px 16px; font-weight: 600; font-size: 14px; color: var(--ifm-heading-color); background: var(--ifm-color-emphasis-0); }
td { padding: 10px 16px; font-size: 14px; border-top: 1px solid var(--ifm-table-border-color); }
td:first-child { font-weight: 500; white-space: nowrap; }
td code {
  background: none; padding: 0; border: none; color: var(--ifm-color-emphasis-800);
  font-size: 13px; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
td a { color: var(--ifm-link-color); }
td sup { color: var(--ifm-color-primary); font-size: 12px; }

/* ---- Code Tabs ---- */
.tabs-container { margin: 1.5rem 0; border: 1px solid var(--ifm-color-emphasis-200); border-radius: var(--ifm-global-radius); overflow: hidden; }
.tabs {
  display: flex; border-bottom: 1px solid var(--ifm-color-emphasis-200);
  background: var(--ifm-color-emphasis-100); padding: 0 4px;
}
.tabs__item {
  padding: 14px 20px; font-size: 14px; font-weight: 600;
  color: var(--ifm-color-emphasis-700); cursor: pointer;
  border-bottom: 3px solid transparent; border-radius: 0; transition: all 0.2s;
}
.tabs__item:hover { color: var(--ifm-color-primary); background: transparent; }
.tabs__item--active {
  color: var(--ifm-tabs-color-active) !important;
  border-bottom-color: var(--ifm-tabs-color-active);
  background: var(--ifm-color-emphasis-0);
}
.tabs__panel { display: none; }
.tabs__panel--active { display: block; }

/* ---- Code Block ---- */
.code-block { position: relative; }
.code-block__header {
  position: absolute; top: 0; right: 0; display: flex; align-items: center; gap: 4px;
  padding: 8px 12px; z-index: 1;
}
.code-block__lang {
  font-size: 12px; color: var(--ifm-color-emphasis-600);
  text-transform: uppercase; letter-spacing: 0.5px; margin-right: 8px;
}
.code-block__btn {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; color: var(--ifm-color-emphasis-600); transition: all 0.2s;
}
.code-block__btn:hover { background: var(--ifm-color-emphasis-200); color: var(--ifm-color-emphasis-900); }
pre {
  background: var(--ifm-pre-background); border-radius: var(--ifm-pre-border-radius);
  padding: 16px; margin: 0; overflow-x: auto; line-height: var(--ifm-pre-line-height);
}
pre code {
  display: block; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 14px; color: var(--ifm-color-emphasis-800); white-space: pre; tab-size: 2;
}
.code-block .code-block__header + pre { padding-top: 48px; }

/* Syntax highlighting */
.token.comment { color: #8d949e; font-style: italic; }
.token.keyword { color: #d73a49; }
.token.string { color: #032f62; }
.token.number { color: #005cc5; }
.token.function { color: #6f42c1; }
.token.operator { color: #d73a49; }
.token.punctuation { color: #24292e; }
.token.boolean { color: #005cc5; }
.token.module { color: #24292e; }
.token.class-name { color: #6f42c1; }
.token.variable { color: #24292e; }
.token.parameter { color: #24292e; }

/* ---- Pagination Nav ---- */
.pagination-nav { display: flex; justify-content: space-between; margin-top: 3rem; }
.pagination-nav__link {
  display: flex; flex-direction: column; padding: 16px 20px;
  border: 1px solid var(--ifm-color-emphasis-200); border-radius: var(--ifm-global-radius);
  max-width: 50%; transition: border-color 0.2s; text-decoration: none;
}
.pagination-nav__link:hover { border-color: var(--ifm-color-primary); text-decoration: none; }
.pagination-nav__link--next { margin-left: auto; text-align: right; }
.pagination-nav__label { font-size: 13px; color: var(--ifm-color-emphasis-600); font-weight: 500; }
.pagination-nav__title { font-size: 15px; font-weight: 600; color: var(--ifm-color-primary); margin-top: 2px; }

/* ---- TOC (Right Sidebar) ---- */
.toc { position: sticky; top: calc(var(--ifm-navbar-height) + 24px); }
.toc::before {
  content: ''; position: absolute; left: -12px; top: 0; bottom: 0;
  width: 1px; background: var(--ifm-toc-border-color);
}
.toc__list { padding-left: 0; }
.toc__link {
  display: block; padding: 4px 0; font-size: 13px; color: var(--ifm-toc-link-color);
  text-decoration: none; line-height: 1.4; transition: color 0.2s;
}
.toc__link:hover { color: var(--ifm-color-primary); text-decoration: none; }
.toc__link.toc-highlight { color: var(--ifm-color-primary); font-weight: 500; }

/* ---- Footer ---- */
.footer {
  background: #303846; color: #ebedf0; padding: 0;
}
.footer__inner { max-width: var(--ifm-container-width); margin: 0 auto; padding: 32px var(--ifm-spacing-horizontal); }
.footer__columns { display: flex; gap: 60px; padding-bottom: 32px; }
.footer__col { flex: 1; max-width: 380px; }
.footer__title { font-size: 16px; font-weight: 600; margin-bottom: 16px; color: #ebedf0; }
.footer__qrcode { background: #fff; display: inline-block; padding: 4px; border-radius: 4px; }
.footer__qrcode img { border-radius: 2px; }
.footer__links { display: flex; flex-direction: column; gap: 8px; }
.footer__link {
  display: inline-flex; align-items: center; gap: 4px; font-size: 14px;
  color: #ebedf0; text-decoration: none; opacity: 0.8; transition: opacity 0.2s;
}
.footer__link:hover { opacity: 1; text-decoration: none; }
.footer__link svg { opacity: 0.6; }
.footer__copyright {
  padding-top: 24px; border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 13px; opacity: 0.6; text-align: left;
}

/* ---- Dark Mode ---- */
body.dark {
  --ifm-color-primary: #4da2ff;
  --ifm-link-color: #4da2ff;
  --ifm-link-hover-color: #4da2ff;
  --ifm-navbar-background-color: #1b1b1d;
  --ifm-navbar-link-color: #e3e3e3;
  --ifm-heading-color: #e3e3e3;
  --ifm-menu-color: #a0a0a0;
  --ifm-color-emphasis-0: #1b1b1d;
  --ifm-color-emphasis-100: #2a2a2c;
  --ifm-color-emphasis-200: #3a3a3c;
  --ifm-color-emphasis-700: #a0a0a0;
  --ifm-color-emphasis-800: #c0c0c0;
  --ifm-color-emphasis-900: #e3e3e3;
  --ifm-pre-background: #282a2e;
  --ifm-table-border-color: #444950;
  --ifm-toc-border-color: #444950;
  --ifm-toc-link-color: #a0a0a0;
  --ifm-background-surface-color: #1b1b1d;
  color: #e3e3e3;
  background: #1b1b1d;
}

body.dark .navbar { border-bottom: 1px solid var(--ifm-color-emphasis-200); }
body.dark .sidebar { border-right-color: var(--ifm-color-emphasis-200); }
body.dark pre code { color: #e3e3e3; }
body.dark .code-block__btn:hover { background: rgba(255,255,255,0.1); }
body.dark .token.comment { color: #8b949e; }
body.dark .token.string { color: #a5d6ff; }
body.dark .token.keyword, body.dark .token.operator { color: #ff7b72; }
body.dark .token.number { color: #79c0ff; }
body.dark .token.function, body.dark .token.class-name { color: #d2a8ff; }
body.dark .token.module, body.dark .token.variable, body.dark .token.parameter, body.dark .token.punctuation { color: #e3e3e3; }
body.dark .token.boolean { color: #79c0ff; }

/* ---- Responsive ---- */
@media (max-width: 996px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.3s; z-index: 150; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: flex; align-items: center; justify-content: center; }
  .main-content { margin-left: 0; }
  .col--toc { display: none; }
  .pagination-nav__link { max-width: 100%; }
  .footer__columns { flex-direction: column; gap: 32px; }
}

@media (max-width: 576px) {
  .navbar__title { display: none; }
  .platform-link span:first-of-type { display: none; }
  .tabs { overflow-x: auto; }
}
