/* API guide: two-column layout with a sticky section menu. Colors come from theme.css. */
.api-guide {
  --guide-code-bg: #1d232c;
  --guide-code-head: #262e39;
  --guide-get: #15803d;
  --guide-post: #2457d6;
  --guide-put: #b45309;
  --guide-delete: #c62828;
  align-items: start;
  display: grid;
  gap: 1.75rem;
  grid-template-columns: 250px minmax(0, 1fr);
}

/* ---------- Section menu ---------- */
.guide-nav {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  padding: 0.6rem;
  position: sticky;
  scrollbar-width: thin;
  top: 80px;
}
.guide-nav-toggle { display: none; }
.guide-nav-search {
  align-items: center;
  background: var(--surface-muted);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  display: flex;
  gap: 0.45rem;
  margin: 0.1rem 0 0.4rem;
  padding: 0 0.6rem;
}
.guide-nav-search i { color: var(--text-secondary); font-size: 0.8rem; }
.guide-nav-search input {
  background: transparent;
  border: 0;
  box-shadow: none;
  color: var(--text-primary);
  font-size: 0.86rem;
  margin: 0;
  min-width: 0;
  outline: none;
  padding: 0.45rem 0;
  width: 100%;
}
.guide-nav-group {
  color: var(--text-secondary);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 0.75rem 0.6rem 0.25rem;
  text-transform: uppercase;
}
.guide-nav a {
  align-items: center;
  border-left: 2px solid transparent;
  border-radius: 7px;
  color: var(--text-primary);
  display: flex;
  font-size: 0.88rem;
  gap: 0.55rem;
  line-height: 1.3;
  padding: 0.4rem 0.6rem;
  text-decoration: none;
}
.guide-nav a i { color: var(--text-secondary); font-size: 0.8rem; text-align: center; width: 1rem; }
.guide-nav a:hover { background: var(--surface-muted); }
.guide-nav a.is-active { background: var(--accent-soft); color: var(--primary-color); font-weight: 600; }
.guide-nav a.is-active i { color: var(--primary-color); }
.guide-nav-empty { color: var(--text-secondary); font-size: 0.85rem; margin: 0.5rem 0.6rem; }
.guide-nav [hidden] { display: none !important; }

/* ---------- Content ---------- */
.guide-content { min-width: 0; }
.guide-section {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  padding: 1.5rem 1.75rem;
  scroll-margin-top: 84px;
}
.guide-section h2 {
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0 0 1rem;
  padding-bottom: 0.65rem;
}
.guide-section h3 {
  color: var(--text-primary);
  font-size: 1.02rem;
  font-weight: 600;
  margin: 1.4rem 0 0.6rem;
  scroll-margin-top: 84px;
}
.guide-section p, .guide-section li { color: var(--text-primary); line-height: 1.65; }
.guide-section p { margin: 0 0 0.85rem; }
.guide-section a { color: var(--primary-color); }
.guide-muted, .guide-section p.guide-muted { color: var(--text-secondary); font-size: 0.9rem; }
.guide-list { margin: 0.4rem 0 0.9rem; padding-left: 1.2rem; }
.guide-list li { margin-bottom: 0.4rem; }

.guide-section :not(pre) > code {
  background: var(--surface-muted);
  border: 1px solid var(--border-color);
  border-radius: 5px;
  color: #b4235a;
  font-family: 'Fira Code', Consolas, Monaco, monospace;
  font-size: 0.84em;
  padding: 0.05rem 0.32rem;
  white-space: nowrap;
}
.guide-table :not(pre) > code { white-space: normal; word-break: break-word; }

/* ---------- Hero ---------- */
.guide-hero { padding: 1.9rem 1.75rem; }
.guide-eyebrow {
  align-items: center;
  background: var(--accent-soft);
  border-radius: 999px;
  color: var(--primary-color);
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 600;
  gap: 0.4rem;
  padding: 0.25rem 0.7rem;
}
.guide-hero h1 { color: var(--text-primary); font-size: 1.9rem; font-weight: 700; margin: 0.7rem 0 0.4rem; }
.guide-lead { color: var(--text-secondary); font-size: 1.05rem; max-width: 46rem; }
.guide-facts {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 1.1rem 0;
  overflow: hidden;
}
.guide-facts > div {
  border-right: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.9rem;
  padding: 0.7rem 0.9rem;
}
.guide-facts > div:last-child { border-right: 0; }
.guide-facts span {
  color: var(--text-secondary);
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  margin-bottom: 0.2rem;
  text-transform: uppercase;
}

.guide-key {
  background: var(--surface-muted);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin: 1rem 0;
  padding: 0.9rem 1rem;
}
.guide-key-head { font-weight: 600; margin-bottom: 0.5rem; }
.guide-key-head i { color: var(--text-secondary); }
.guide-key-row { display: flex; gap: 0.5rem; }
.guide-key-row .form-control {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  flex: 1;
  font-family: 'Fira Code', Consolas, Monaco, monospace;
  font-size: 0.86rem;
  margin: 0;
  min-width: 0;
  padding: 0.5rem 0.7rem;
}
.guide-key small { color: var(--text-secondary); display: block; margin-top: 0.45rem; }
.guide-key .btn.is-copied { background: #e9f7ef; border-color: #b7e2c6; color: var(--success-color); }

.guide-cards {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 1.2rem;
}
.guide-card {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.85rem 0.9rem;
  text-decoration: none;
  transition: border-color 0.15s, background-color 0.15s;
}
.guide-card:hover { background: var(--surface-muted); border-color: var(--primary-color); }
.guide-card i { color: var(--primary-color); font-size: 1rem; margin-bottom: 0.25rem; }
.guide-card strong { color: var(--text-primary); font-size: 0.92rem; }
.guide-card span { color: var(--text-secondary); font-size: 0.82rem; }

/* ---------- Endpoint line ---------- */
.endpoint {
  align-items: center;
  background: var(--surface-muted);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin: 0.4rem 0 1rem;
  padding: 0.6rem 0.75rem;
}
.endpoint > code {
  background: none !important;
  border: 0 !important;
  color: var(--text-primary) !important;
  font-family: 'Fira Code', Consolas, Monaco, monospace;
  font-size: 0.95rem !important;
  font-weight: 500;
  padding: 0 !important;
  white-space: normal !important;
  word-break: break-all;
}
.method {
  border-radius: 6px;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  min-width: 3.6rem;
  padding: 0.22rem 0.5rem;
  text-align: center;
}
.method-get { background: var(--guide-get); }
.method-post { background: var(--guide-post); }
.method-put { background: var(--guide-put); }
.method-delete { background: var(--guide-delete); }
.endpoint-type { color: var(--text-secondary); font-size: 0.82rem; margin-left: auto; }

/* ---------- Tables ---------- */
.table-scroll { margin: 0.4rem 0 1rem; overflow-x: auto; }
.guide-table {
  border: 1px solid var(--border-color);
  border-collapse: separate;
  border-radius: 8px;
  border-spacing: 0;
  font-size: 0.9rem;
  overflow: hidden;
  width: 100%;
}
.guide-table th {
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.55rem 0.8rem;
  text-align: left;
  text-transform: uppercase;
}
.guide-table td {
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  line-height: 1.55;
  padding: 0.6rem 0.8rem;
  vertical-align: top;
}
.guide-table tr:last-child td { border-bottom: 0; }
.guide-table.params td:first-child { min-width: 9rem; width: 1%; }
.guide-table.params td:first-child code { white-space: nowrap; word-break: normal; }
.guide-table.params td:nth-child(2) { color: var(--text-secondary); white-space: nowrap; width: 1%; }
.status {
  border-radius: 5px;
  display: inline-block;
  font-family: 'Fira Code', Consolas, Monaco, monospace;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
}
.status.s4 { background: #fdf3e6; color: #9a4b07; }
.status.s5 { background: #fdecec; color: var(--danger-color); }

/* ---------- Code blocks ---------- */
.codeblock {
  background: var(--guide-code-bg);
  border-radius: 8px;
  margin: 0.5rem 0 1rem;
  overflow: hidden;
}
.codeblock-head {
  align-items: center;
  background: var(--guide-code-head);
  color: #aab4c2;
  display: flex;
  font-size: 0.75rem;
  font-weight: 600;
  justify-content: space-between;
  letter-spacing: 0.04em;
  padding: 0.35rem 0.5rem 0.35rem 0.85rem;
  text-transform: uppercase;
}
.codeblock-copy {
  background: transparent;
  border: 1px solid #3a4553;
  border-radius: 6px;
  color: #c9d2dd;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  text-transform: none;
}
.codeblock-copy:hover { background: #313b48; color: #fff; }
.codeblock-copy.is-copied { border-color: #2f7d4f; color: #7ee2a8; }
.codeblock pre[class*="language-"], .codeblock pre {
  background: var(--guide-code-bg) !important;
  border: 0;
  border-radius: 0;
  margin: 0 !important;
  max-height: 520px;
  overflow: auto;
  padding: 0.9rem 1rem !important;
}
.codeblock code[class*="language-"], .codeblock code {
  background: none !important;
  border: 0 !important;
  color: #e3e8ef;
  font-family: 'Fira Code', Consolas, Monaco, monospace;
  font-size: 0.84rem;
  line-height: 1.6;
  padding: 0 !important;
  text-shadow: none;
  white-space: pre;
}

/* ---------- Callouts ---------- */
.callout {
  border: 1px solid;
  border-radius: 8px;
  display: flex;
  font-size: 0.92rem;
  gap: 0.7rem;
  line-height: 1.6;
  margin: 0.8rem 0 1rem;
  padding: 0.75rem 0.9rem;
}
.callout > i { margin-top: 0.25rem; }
.callout-info { background: #eef3fd; border-color: #cfdcf7; color: #1d3f91; }
.callout-tip { background: #edf8f1; border-color: #c6e8d3; color: #14532d; }
.callout-warn { background: #fdf6ea; border-color: #f1dcb4; color: #7a3e06; }
.callout a { color: inherit; font-weight: 600; text-decoration: underline; }

/* ---------- Steps ---------- */
.guide-steps { counter-reset: step; list-style: none; margin: 0.5rem 0 1rem; padding: 0; }
.guide-steps > li {
  border-left: 2px solid var(--border-color);
  counter-increment: step;
  margin-left: 0.85rem;
  padding: 0 0 0.6rem 1.4rem;
  position: relative;
}
.guide-steps > li:last-child { border-left-color: transparent; }
.guide-steps > li::before {
  align-items: center;
  background: var(--primary-color);
  border-radius: 50%;
  color: #fff;
  content: counter(step);
  display: flex;
  font-size: 0.78rem;
  font-weight: 700;
  height: 1.6rem;
  justify-content: center;
  left: -0.85rem;
  position: absolute;
  top: 0;
  width: 1.6rem;
}
.guide-steps > li > h3 { margin-top: 0.1rem; }

/* ---------- Formats and FAQ ---------- */
.format-grid { display: grid; gap: 0.75rem; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 0.9rem; }
.format-grid > div { border: 1px solid var(--border-color); border-radius: 8px; padding: 0.8rem 1rem; }
.format-grid h3 { margin: 0 0 0.35rem; }
.format-grid h3 i { color: var(--primary-color); margin-right: 0.3rem; }
.format-grid p { margin: 0; }
.faq { border: 1px solid var(--border-color); border-radius: 8px; margin-bottom: 0.55rem; }
.faq summary { cursor: pointer; font-weight: 600; list-style: none; padding: 0.7rem 0.9rem; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before { color: var(--text-secondary); content: '\25B8'; display: inline-block; margin-right: 0.5rem; transition: transform 0.15s; }
.faq[open] summary::before { transform: rotate(90deg); }
.faq p { margin: 0; padding: 0 0.9rem 0.8rem 1.95rem; }
.guide-support { margin-top: 1rem; }

/* ---------- Narrow screens ---------- */
@media (max-width: 1100px) {
  .guide-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .api-guide { gap: 1rem; grid-template-columns: minmax(0, 1fr); }
  .guide-nav { max-height: none; padding: 0; position: sticky; top: 64px; z-index: 20; }
  .guide-nav-toggle {
    align-items: center;
    background: var(--surface);
    border: 0;
    border-radius: var(--radius);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    font-size: 0.92rem;
    font-weight: 600;
    gap: 0.5rem;
    padding: 0.7rem 0.9rem;
    width: 100%;
  }
  .guide-nav-caret { margin-left: auto; transition: transform 0.15s; }
  .guide-nav.is-open .guide-nav-caret { transform: rotate(180deg); }
  .guide-nav-body { display: none; max-height: 65vh; overflow-y: auto; padding: 0 0.6rem 0.6rem; }
  .guide-nav.is-open .guide-nav-body { display: block; }
  .guide-section { padding: 1.2rem 1rem; scroll-margin-top: 120px; }
  .guide-section h3 { scroll-margin-top: 120px; }
  .guide-hero h1 { font-size: 1.5rem; }
  .guide-facts { grid-template-columns: minmax(0, 1fr); }
  .guide-facts > div { border-bottom: 1px solid var(--border-color); border-right: 0; }
  .guide-facts > div:last-child { border-bottom: 0; }
  .endpoint-type { margin-left: 0; width: 100%; }
}
@media (max-width: 560px) {
  .guide-cards, .format-grid { grid-template-columns: minmax(0, 1fr); }
  .guide-key-row { flex-direction: column; }
  .guide-table.params td:nth-child(2) { white-space: normal; }
  .guide-table.params td:first-child { min-width: 7rem; }
}
