/* ============================================================
 * API Docs v2 — layout 3-col (sidebar + spec + example)
 * Desenhado pra espelhar o padrao OpenRouter/Stripe/Mintlify,
 * respeitando a paleta do admin (tokens.css).
 * ============================================================ */

#page-api-docs .page-header { display: none; }

.apiv2 {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 480px;
  min-height: calc(100vh - 40px);
  margin: -16px;
  background: var(--bg);
}

.apiv2-empty {
  padding: 48px;
  color: var(--text3);
  text-align: center;
}

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

.apiv2-sidebar {
  background: var(--bg4);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  align-self: start;
  height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 14px 0 60px;
}

.apiv2-search {
  margin: 0 12px 14px;
  position: relative;
}
.apiv2-search input {
  width: 100%;
  padding: 8px 32px 8px 32px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 12px;
  outline: none;
  transition: border-color 0.1s;
}
.apiv2-search input:focus { border-color: var(--accent2); }
.apiv2-search::before {
  content: "\1F50E";
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  opacity: 0.6;
  pointer-events: none;
}
.apiv2-search kbd {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10px;
  color: var(--text3);
  font-family: var(--mono, ui-monospace, Menlo, monospace);
  pointer-events: none;
}

.apiv2-section-title {
  padding: 14px 16px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text3);
}

.apiv2-group {
  padding: 6px 16px;
  font-size: 12.5px;
  color: var(--text2);
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  border-radius: 0;
  transition: background 0.08s, color 0.08s;
}
.apiv2-group:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.02);
}
.apiv2-group.open { color: var(--text); }
.apiv2-group .apiv2-chev {
  margin-left: auto;
  font-size: 9px;
  color: var(--text3);
  transition: transform 0.15s ease;
}
.apiv2-group.open .apiv2-chev { transform: rotate(90deg); }

.apiv2-items {
  display: none;
  padding: 2px 0 6px 14px;
  border-left: 1px solid var(--border);
  margin-left: 21px;
}
.apiv2-group.open + .apiv2-items { display: block; }

.apiv2-item {
  padding: 5px 10px;
  font-size: 12px;
  color: var(--text2);
  border-radius: 6px;
  margin: 1px 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono, ui-monospace, Menlo, monospace);
  transition: background 0.08s, color 0.08s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.apiv2-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}
.apiv2-item.active {
  background: rgba(164, 118, 255, 0.12);
  color: var(--accent);
  font-weight: 600;
}
.apiv2-item-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 11.5px;
}

/* Method pills (sidebar + spec) */
.apiv2-m {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border-strong, rgba(144, 143, 160, 0.3));
  font-family: var(--mono, ui-monospace, Menlo, monospace);
  letter-spacing: 0.03em;
  line-height: 1.4;
  flex-shrink: 0;
}
.apiv2-m.get    { color: var(--green);  background: rgba(142, 231, 177, 0.08); border-color: rgba(142, 231, 177, 0.3); }
.apiv2-m.post   { color: var(--blue);   background: rgba(195, 192, 255, 0.08); border-color: rgba(195, 192, 255, 0.3); }
.apiv2-m.put    { color: var(--orange); background: rgba(242, 200, 125, 0.1);  border-color: rgba(242, 200, 125, 0.3); }
.apiv2-m.delete { color: var(--red);    background: rgba(255, 180, 171, 0.08); border-color: rgba(255, 180, 171, 0.3); }
.apiv2-m.patch  { color: var(--accent); background: rgba(210, 187, 255, 0.08); border-color: rgba(210, 187, 255, 0.3); }

/* ============== SPEC PANE ============== */

.apiv2-spec {
  overflow-x: hidden;
  padding: 28px 40px 80px;
  min-width: 0;
}

.apiv2-breadcrumb {
  font-size: 11px;
  color: var(--text3);
  margin-bottom: 10px;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.apiv2-breadcrumb a {
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
  transition: color 0.08s;
}
.apiv2-breadcrumb a:hover {
  color: var(--accent2);
  text-decoration: underline;
}
.apiv2-breadcrumb .sep { color: var(--text3); }

.apiv2-title {
  font-size: 24px;
  font-weight: 700;
  margin: 4px 0 10px;
  letter-spacing: -0.012em;
  line-height: 1.25;
  color: var(--text);
}

.apiv2-path {
  font-family: var(--mono, ui-monospace, Menlo, monospace);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  padding: 6px 0 16px;
  word-break: break-all;
}
.apiv2-path .apiv2-method-inline {
  margin-right: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11.5px;
  vertical-align: middle;
}
.apiv2-path .apiv2-method-inline.get    { color: var(--green);  background: rgba(142, 231, 177, 0.1); }
.apiv2-path .apiv2-method-inline.post   { color: var(--blue);   background: rgba(195, 192, 255, 0.1); }
.apiv2-path .apiv2-method-inline.put    { color: var(--orange); background: rgba(242, 200, 125, 0.12); }
.apiv2-path .apiv2-method-inline.delete { color: var(--red);    background: rgba(255, 180, 171, 0.1); }
.apiv2-path .apiv2-method-inline.patch  { color: var(--accent); background: rgba(210, 187, 255, 0.1); }

.apiv2-summary {
  color: var(--text2);
  font-size: 13.5px;
  line-height: 1.65;
  margin-bottom: 14px;
  max-width: 780px;
}
.apiv2-summary code {
  font-family: var(--mono, ui-monospace, Menlo, monospace);
  font-size: 12px;
  color: var(--accent);
  background: var(--bg2);
  padding: 1px 6px;
  border-radius: 4px;
}

.apiv2-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 12px 0 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.apiv2-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--mono, ui-monospace, Menlo, monospace);
  letter-spacing: 0.01em;
}
.apiv2-pill.auth    { background: rgba(164, 118, 255, 0.12); color: var(--accent); }
.apiv2-pill.engine  { background: rgba(242, 200, 125, 0.1);  color: var(--orange); }
.apiv2-pill.session { background: rgba(142, 231, 177, 0.1);  color: var(--green); }
.apiv2-pill.webhook { background: rgba(195, 192, 255, 0.1);  color: var(--blue); }
.apiv2-pill.callback{ background: rgba(255, 180, 171, 0.1);  color: var(--red); }
.apiv2-pill.source   { background: var(--bg3); color: var(--text2); }
.apiv2-pill.consumer { background: rgba(195, 192, 255, 0.08); color: var(--blue); }

.apiv2-section-h {
  font-size: 15px;
  font-weight: 700;
  margin: 30px 0 12px;
  color: var(--text);
  letter-spacing: -0.005em;
}

.apiv2-subtle {
  font-size: 12.5px;
  color: var(--text2);
  line-height: 1.6;
  margin-bottom: 8px;
}
.apiv2-subtle code {
  font-family: var(--mono, ui-monospace, Menlo, monospace);
  font-size: 11.5px;
  color: var(--accent);
  background: var(--bg2);
  padding: 1px 6px;
  border-radius: 4px;
}

/* Param tables */
.apiv2-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 6px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.apiv2-table thead {
  background: var(--bg2);
  color: var(--text3);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}
.apiv2-table th {
  text-align: left;
  padding: 10px 14px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
}
.apiv2-table td {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.apiv2-table tbody tr:last-child td { border-bottom: none; }

.apiv2-pname {
  font-family: var(--mono, ui-monospace, Menlo, monospace);
  font-weight: 600;
  color: var(--text);
  font-size: 12.5px;
  word-break: break-word;
}
.apiv2-ptype {
  font-family: var(--mono, ui-monospace, Menlo, monospace);
  font-size: 11px;
  color: var(--text3);
  display: block;
  margin-top: 3px;
}
.apiv2-preq {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  font-family: var(--mono, ui-monospace, Menlo, monospace);
  margin-left: 6px;
  vertical-align: middle;
}
.apiv2-preq.required { background: rgba(255, 180, 171, 0.14); color: var(--red); }
.apiv2-preq.optional { background: var(--bg3); color: var(--text3); }

.apiv2-pdesc {
  color: var(--text2);
  font-size: 12.5px;
  line-height: 1.55;
}
.apiv2-pdesc code {
  font-family: var(--mono, ui-monospace, Menlo, monospace);
  font-size: 11.5px;
  color: var(--accent);
  background: var(--bg2);
  padding: 1px 6px;
  border-radius: 4px;
}
.apiv2-pconstraint {
  font-family: var(--mono, ui-monospace, Menlo, monospace);
  font-size: 11px;
  color: var(--orange);
  background: rgba(242, 200, 125, 0.08);
  padding: 2px 8px;
  border-radius: 4px;
  margin-top: 6px;
  display: inline-block;
}
.apiv2-enum {
  display: inline-flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 7px;
}
.apiv2-enum code {
  background: var(--bg3);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: var(--mono, ui-monospace, Menlo, monospace);
  font-size: 11px;
  color: var(--accent);
}

/* Callout info */
.apiv2-callout {
  background: rgba(195, 192, 255, 0.05);
  border: 1px solid rgba(195, 192, 255, 0.18);
  border-left: 3px solid var(--blue);
  border-radius: 8px;
  padding: 11px 14px;
  margin: 18px 0;
  font-size: 12.5px;
  color: var(--text2);
  line-height: 1.6;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.apiv2-callout .apiv2-callout-icon {
  color: var(--blue);
  font-size: 14px;
  flex-shrink: 0;
}
.apiv2-callout strong { color: var(--text); }
.apiv2-callout code {
  font-family: var(--mono, ui-monospace, Menlo, monospace);
  font-size: 11.5px;
  color: var(--accent);
  background: var(--bg2);
  padding: 1px 6px;
  border-radius: 4px;
}

/* Code-ref list */
.apiv2-related {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--mono, ui-monospace, Menlo, monospace);
  font-size: 12px;
}
.apiv2-related a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.08s;
}
.apiv2-related a:hover {
  color: var(--accent2);
  text-decoration: underline;
}

/* Landing view (no endpoint selected) */
.apiv2-landing {
  padding: 12px 0;
}
.apiv2-landing h1 {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 12px;
  letter-spacing: -0.015em;
}
.apiv2-landing-lead {
  color: var(--text2);
  font-size: 14px;
  margin-bottom: 28px;
  max-width: 720px;
  line-height: 1.7;
}
.apiv2-flow {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-bottom: 30px;
}
.apiv2-flow-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  transition: border-color 0.1s, transform 0.1s;
}
.apiv2-flow-card:hover {
  border-color: var(--border-strong, rgba(144, 143, 160, 0.3));
  transform: translateY(-1px);
}
.apiv2-flow-step {
  color: var(--accent2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.apiv2-flow-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.apiv2-flow-copy {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.55;
}

.apiv2-auth-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  margin-bottom: 30px;
}
.apiv2-auth-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}
.apiv2-auth-card p {
  font-size: 12.5px;
  color: var(--text2);
  margin: 8px 0 0;
  line-height: 1.6;
}

/* ============== EXAMPLE PANE ============== */

.apiv2-example {
  background: var(--bg4);
  border-left: 1px solid var(--border);
  position: sticky;
  top: 0;
  align-self: start;
  height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 22px 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.apiv2-example-empty {
  padding: 40px 16px;
  color: var(--text3);
  font-size: 12.5px;
  text-align: center;
  line-height: 1.6;
}

.apiv2-card {
  background: #0a0a0d;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.apiv2-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.015);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  gap: 8px;
  flex-wrap: wrap;
}
.apiv2-card-head-path {
  font-family: var(--mono, ui-monospace, Menlo, monospace);
  color: var(--text2);
  font-size: 11.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}
.apiv2-card-head-method {
  font-weight: 700;
  flex-shrink: 0;
}
.apiv2-card-head-method.get    { color: var(--green); }
.apiv2-card-head-method.post   { color: var(--blue); }
.apiv2-card-head-method.put    { color: var(--orange); }
.apiv2-card-head-method.delete { color: var(--red); }
.apiv2-card-head-method.patch  { color: var(--accent); }

.apiv2-card-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.apiv2-card-actions button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text3);
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.1s;
}
.apiv2-card-actions button:hover {
  color: var(--text);
  border-color: var(--border-strong, rgba(144, 143, 160, 0.3));
}
.apiv2-card-actions button.apiv2-try {
  background: var(--accent2);
  border-color: var(--accent2);
  color: #1a0a3a;
  font-weight: 600;
}
.apiv2-card-actions button.apiv2-try:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.apiv2-code-tabs {
  display: flex;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border);
  padding: 0 10px;
  overflow-x: auto;
}
.apiv2-code-tab {
  padding: 8px 14px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text3);
  cursor: pointer;
  font-family: var(--mono, ui-monospace, Menlo, monospace);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color 0.08s;
}
.apiv2-code-tab:hover { color: var(--text); }
.apiv2-code-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent2);
}

.apiv2-code {
  padding: 14px 16px;
  font-family: var(--mono, ui-monospace, Menlo, monospace);
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--text2);
  white-space: pre;
  overflow-x: auto;
  max-height: 420px;
  overflow-y: auto;
}
.apiv2-code .k   { color: #d2bbff; }     /* keyword */
.apiv2-code .s   { color: #8ee7b1; }     /* string */
.apiv2-code .n   { color: #f2c87d; }     /* number */
.apiv2-code .c   { color: var(--text3); font-style: italic; } /* comment */
.apiv2-code .p   { color: var(--text3); } /* punctuation */
.apiv2-code .key { color: #c3c0ff; }     /* JSON key */
.apiv2-code .b   { color: #ff9bb3; }     /* boolean/null */

.apiv2-status-strip {
  display: flex;
  gap: 2px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.015);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-family: var(--mono, ui-monospace, Menlo, monospace);
  overflow-x: auto;
}
.apiv2-status-chip {
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text3);
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.08s, color 0.08s;
}
.apiv2-status-chip:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.apiv2-status-chip.active { background: var(--bg2); }
.apiv2-status-chip.s200.active { color: var(--green); }
.apiv2-status-chip.s400.active,
.apiv2-status-chip.s422.active { color: var(--orange); }
.apiv2-status-chip.s404.active { color: var(--blue); }
.apiv2-status-chip.s500.active,
.apiv2-status-chip.s502.active { color: var(--red); }

/* ============== SCROLLBARS ============== */

.apiv2-sidebar::-webkit-scrollbar,
.apiv2-example::-webkit-scrollbar,
.apiv2-code::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
.apiv2-sidebar::-webkit-scrollbar-track,
.apiv2-example::-webkit-scrollbar-track,
.apiv2-code::-webkit-scrollbar-track {
  background: transparent;
}
.apiv2-sidebar::-webkit-scrollbar-thumb,
.apiv2-example::-webkit-scrollbar-thumb,
.apiv2-code::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 10px;
}
.apiv2-sidebar::-webkit-scrollbar-thumb:hover,
.apiv2-example::-webkit-scrollbar-thumb:hover,
.apiv2-code::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong, rgba(144, 143, 160, 0.4));
}

/* ============== RESPONSIVE ============== */

@media (max-width: 1280px) {
  .apiv2 {
    grid-template-columns: 240px minmax(0, 1fr) 420px;
  }
  .apiv2-spec { padding: 24px 28px 60px; }
}

@media (max-width: 1100px) {
  .apiv2 {
    grid-template-columns: 1fr;
  }
  .apiv2-sidebar,
  .apiv2-example {
    position: static;
    height: auto;
    max-height: 420px;
    border-right: none;
    border-left: none;
    border-bottom: 1px solid var(--border);
  }
}

/* Small adjustment: show copy-feedback state briefly */
.apiv2-card-actions button.copied {
  color: var(--green);
  border-color: var(--green);
}
