/* ============ Docs section ============ */

/* ---- Simple link-card grid used on group index pages (e.g. proxies/index, proxy-groups/index) ---- */
.docs-link-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin: 18px 0 4px; }
.docs-link-card {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
  background: rgba(20, 45, 85, 0.03); font-size: 14px; font-weight: 600; color: var(--text);
  transition: border-color .2s, background .2s, transform .2s;
}
.docs-link-card:hover { border-color: rgba(240, 118, 10, 0.4); background: #fff; transform: translateX(3px); }
.docs-link-card i { color: var(--teal); font-size: 12px; }

.docs-toplevel-tabs {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin: 0 0 24px; border-bottom: 1px solid var(--line);
}
.docs-toplevel-tabs-links {
  display: flex; gap: 4px; overflow-x: auto; overflow-y: hidden; min-width: 0;
}
.docs-toplevel-tabs a {
  display: flex; align-items: center; gap: 8px; flex: none;
  padding: 13px 22px; font-size: 14.5px; font-weight: 700; color: var(--text-dim);
  border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap;
  transition: color .2s, border-color .2s;
}
.docs-toplevel-tabs a i { font-size: 13px; }
.docs-toplevel-tabs a:hover { color: var(--text); }
.docs-toplevel-tabs a.active { color: var(--orange); border-bottom-color: var(--orange); }

/* ---- Docs search box, sits inline in the top tab row ---- */
.docs-search { position: relative; flex: none; margin: 0 2px 10px 0; }
.docs-search > i {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  font-size: 12.5px; color: var(--text-dim); pointer-events: none;
}
.docs-search input {
  width: 190px; padding: 8px 12px 8px 34px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(20, 45, 85, 0.03);
  font-size: 13.5px; color: var(--text); font-family: inherit;
  transition: width .2s, border-color .2s, background .2s;
}
.docs-search input:focus { width: 240px; border-color: rgba(240, 118, 10, 0.4); background: #fff; }
.docs-search-results {
  position: absolute; top: calc(100% + 8px); right: 0; width: 320px; max-height: 360px;
  overflow-y: auto; background: #fff; border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 16px 40px rgba(20, 45, 85, 0.14); padding: 8px; z-index: 40;
}
.docs-search-results a {
  display: block; padding: 9px 12px; border-radius: 9px; font-weight: 600;
  font-size: 13.5px; color: var(--text); white-space: normal;
}
.docs-search-results a:hover, .docs-search-results a.active { background: rgba(240, 118, 10, 0.08); color: var(--orange); }
.docs-search-results a small { display: block; font-weight: 500; font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }
.docs-search-results .no-result { padding: 14px 12px; font-size: 13px; color: var(--text-dim); text-align: center; }
.docs-search-results mark { background: rgba(240, 118, 10, 0.18); color: var(--orange); border-radius: 3px; padding: 0 1px; }

@media (max-width: 760px) {
  .docs-toplevel-tabs { flex-wrap: wrap; }
  .docs-toplevel-tabs-links { order: 1; width: 100%; }
  .docs-search { order: 2; width: 100%; margin: 0 0 12px; }
  .docs-search input { width: 100%; }
  .docs-search input:focus { width: 100%; }
  .docs-search-results { width: 100%; }
}

/* ---- Doc layout: sidebar + content ---- */
.docs-wrap { padding: 20px 0 60px; }
/* align-items left at the default "stretch" so the sidebar column's box spans the
   full row height, giving the sticky nav room to stay stuck while the (usually
   much taller) article column scrolls past it */
.docs-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 40px; }

.docs-mobile-toggle {
  display: none; width: 100%; align-items: center; gap: 10px; justify-content: center;
  font-family: inherit; font-size: 14px; font-weight: 600; color: var(--text);
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  margin-bottom: 14px; cursor: pointer;
}

.docs-tree {
  position: sticky; top: 92px; max-height: calc(100vh - 112px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 12px; box-shadow: var(--shadow-soft);
}
.docs-group + .docs-group { border-top: 1px solid var(--line); }
.docs-group-title {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  font-family: inherit; font-size: 13px; font-weight: 700; letter-spacing: .3px; color: var(--text);
  background: none; border: none; padding: 12px 10px; cursor: pointer;
}
.docs-group-title i { font-size: 11px; color: var(--text-dim); transition: transform .2s; }
.docs-group.open .docs-group-title i { transform: rotate(180deg); }
.docs-group-items { display: grid; gap: 2px; padding: 0 6px 8px; max-height: 0; overflow: hidden; }
.docs-group.open .docs-group-items { max-height: none; padding-bottom: 10px; }
.docs-group-items a {
  font-size: 13px; color: var(--text-dim); padding: 7px 12px; border-radius: 8px;
  border-left: 2px solid transparent; transition: all .2s;
}
.docs-group-items a:hover { color: var(--text); background: rgba(20, 45, 85, 0.05); }
.docs-group-items a.active {
  color: var(--orange); border-left-color: var(--orange); background: var(--orange-soft); font-weight: 700;
}

.docs-body { min-width: 0; }
.docs-body-head { margin-bottom: 22px; }
.docs-crumb { font-size: 13px; color: var(--text-dim); margin-bottom: 10px; }
.docs-crumb a { color: var(--text-dim); }
.docs-crumb a:hover { color: var(--orange); }
.docs-body-head h1 { font-size: clamp(24px, 3vw, 32px); font-weight: 900; }
.docs-body-head p { color: var(--text-dim); font-size: 14.5px; margin-top: 10px; }

/* ---- Field definition blocks ---- */
.field-def {
  border: 1px solid var(--line); border-radius: 14px; padding: 16px 20px;
  margin-bottom: 12px; background: rgba(20, 45, 85, 0.02);
}
.field-def-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.field-def-head code {
  font-family: var(--mono); font-size: 14px; font-weight: 700; color: var(--text);
  background: rgba(20, 45, 85, 0.07); padding: 2px 9px; border-radius: 6px;
}
.field-tag {
  font-size: 10.5px; font-weight: 700; letter-spacing: .4px; padding: 2px 9px; border-radius: 999px;
}
.field-tag.required { color: #b91c1c; background: rgba(185, 28, 28, 0.09); }
.field-tag.optional { color: var(--text-dim); background: rgba(20, 45, 85, 0.06); }
.field-tag.default { color: var(--teal); background: var(--teal-soft); font-weight: 600; }
.field-def p { color: var(--text-dim); font-size: 14px; margin: 0; }
.field-def p + p { margin-top: 6px; }
.field-def code:not(.field-def-head code) {
  font-family: var(--mono); font-size: 12.5px; background: rgba(20, 45, 85, 0.07);
  padding: 1px 7px; border-radius: 5px;
}

/* ---- Ordered step explanations ---- */
.docs-steps { display: grid; gap: 12px; margin: 6px 0 16px; counter-reset: docs-step; list-style: none; padding: 0; }
.docs-steps li {
  position: relative; padding-left: 40px; font-size: 14px; color: var(--text-dim); line-height: 1.7;
  counter-increment: docs-step;
}
.docs-steps li::before {
  content: counter(docs-step); position: absolute; left: 0; top: 0;
  width: 26px; height: 26px; border-radius: 8px; background: var(--orange-soft); color: var(--orange);
  font-weight: 800; font-size: 13px; display: grid; place-items: center;
}
.docs-steps li b { color: var(--text); }

/* ---- Tables ---- */
.doc-table-wrap { overflow-x: auto; margin: 6px 0 16px; border: 1px solid var(--line); border-radius: 14px; }
.doc-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.doc-table th, .doc-table td { padding: 11px 16px; text-align: left; border-bottom: 1px solid var(--line); }
.doc-table th { background: rgba(20, 45, 85, 0.04); font-weight: 700; color: var(--text); }
.doc-table td { color: var(--text-dim); }
.doc-table tr:last-child td { border-bottom: none; }
.doc-table code { font-family: var(--mono); font-size: 12px; background: rgba(20, 45, 85, 0.07); padding: 1px 6px; border-radius: 5px; }

/* ---- Prev / next page nav ---- */
.docs-pagenav {
  margin-top: 30px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.docs-pagenav a {
  display: flex; flex-direction: column; gap: 6px; padding: 16px 20px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--panel); transition: border-color .2s, transform .2s;
}
.docs-pagenav a:hover { border-color: rgba(240, 118, 10, 0.4); transform: translateY(-2px); }
.docs-pagenav .dir { font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; }
.docs-pagenav .next { text-align: right; grid-column: 2; }
.docs-pagenav .next .dir { justify-content: flex-end; }
.docs-pagenav b { font-size: 14.5px; color: var(--text); }

/* ---- API endpoint blocks (docs/apis.html) ---- */
.api-ep {
  border: 1px solid var(--line); border-radius: 16px; padding: 18px 22px;
  margin-bottom: 14px; background: rgba(20, 45, 85, 0.02);
}
.api-ep-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.api-method {
  font-family: var(--mono); font-size: 11.5px; font-weight: 800; letter-spacing: .3px;
  padding: 3px 9px; border-radius: 6px; color: #fff; flex: none;
}
.api-method.m-get { background: #0d9488; }
.api-method.m-post { background: #ea6209; }
.api-method.m-put { background: #2563eb; }
.api-method.m-patch { background: #7c3aed; }
.api-method.m-delete { background: #b91c1c; }
.api-method.m-ws { background: #475569; }
.api-ep-head code.api-path {
  font-family: var(--mono); font-size: 14.5px; font-weight: 700; color: var(--text);
}
.api-ep-desc { color: var(--text-dim); font-size: 14px; margin: 6px 0 10px; }
.api-ep-list { display: grid; gap: 5px; margin: 0 0 4px; padding: 0; list-style: none; }
.api-ep-list li { font-size: 13.5px; color: var(--text-dim); padding-left: 16px; position: relative; }
.api-ep-list li::before { content: "·"; position: absolute; left: 2px; color: var(--orange); font-weight: 900; }
.api-ep-list code { font-family: var(--mono); font-size: 12.5px; background: rgba(20, 45, 85, 0.07); padding: 1px 7px; border-radius: 5px; color: var(--text); }
.api-ep + .tut-h3, .api-ep-group + .tut-h3 { margin-top: 30px; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .docs-layout { grid-template-columns: 1fr; gap: 18px; }
  .docs-mobile-toggle { display: flex; }
  .docs-tree { position: static; max-height: none; }
  #docsTree:not(.open) { display: none; }
  .docs-pagenav { grid-template-columns: 1fr; }
  .docs-pagenav .next { grid-column: 1; text-align: left; }
  .docs-pagenav .next .dir { justify-content: flex-start; }
}
