/* =========================================================
   Documentation components.
   The three-column shell (.docs-layout, .docs-sidebar,
   .docs-content) lives in styles.css; this file adds the
   reference-doc furniture built on the same tokens.
   ========================================================= */

/* ---- Layout -------------------------------------------
   One nav, not two: the sidebar lists sections and expands
   the current section's subheadings, so the right-hand rail
   is redundant on a single-page document. */
.docs-layout { grid-template-columns: 248px minmax(0, 1fr); gap: 56px; }

/* styles.css sets overflow-x:hidden on both html and body. The one on <body>
   makes it a scroll container, which pins position:sticky descendants — that
   is what stopped the sidebar from holding its place. <html> still clips
   horizontally, so dropping it here costs nothing. */
body { overflow-x: visible; }

/* ---- Sidebar ------------------------------------------ */
.docs-nav-group + .docs-nav-group { margin-top: 22px; }

.docs-nav-label {
  margin: 0 0 8px;
  padding-left: 10px;
  color: #8a9590;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}

strong {font-weight: 500;}

.docs-sidebar a { border-radius: 0 6px 6px 0; }
/* display:block above would otherwise beat the UA's [hidden] rule */
.docs-sidebar a[hidden] { display: none; }

.docs-filter-wrap { position: relative; margin-bottom: 20px; }

.docs-filter {
  width: 100%;
  min-height: 38px;
  padding: 0 12px 0 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  outline: none;
  transition: border-color .22s ease, box-shadow .22s ease;
}

.docs-filter::placeholder { color: #9aa5a0; }
.docs-filter:focus { border-color: var(--accent-soft); box-shadow: 0 0 0 3px rgba(90, 163, 138, .14); }

.docs-filter-wrap svg {
  position: absolute;
  left: 11px;
  top: 50%;
  width: 15px;
  height: 15px;
  transform: translateY(-50%);
  fill: none;
  stroke: #9aa5a0;
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}

.docs-filter-empty { padding: 8px 10px; color: var(--muted); font-size: 12px; }

.docs-nav-toggle {
  display: none;
  width: 100%;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.docs-nav-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .3s var(--ease-out); }
.docs-nav-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }

/* ---- Sub-navigation (current section's headings) ------- */
.docs-subnav {
  margin: 2px 0 6px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.docs-subnav[hidden] { display: none; }

.docs-subnav a {
  display: block;
  padding: 5px 10px;
  border-left: 2px solid transparent;
  margin-left: -13px;
  padding-left: 21px;
  border-radius: 0;
  color: #7a8580;
  font-size: 12px;
  line-height: 1.4;
  transition: color .22s ease, border-color .22s ease;
}

.docs-subnav a:hover { color: var(--accent-deep); }
.docs-subnav a.active { border-left-color: var(--accent); color: var(--ink); font-weight: 600; background: none; }

/* ---- Section headers ----------------------------------- */
.docs-content section > .kicker {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.docs-content h2,
.docs-content h3 { scroll-margin-top: 96px; position: relative; }

.doc-anchor {
  position: absolute;
  left: -22px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  color: var(--accent);
  font-size: 14px;
  text-decoration: none !important;
  opacity: 0;
  transition: opacity .2s ease, background-color .2s ease;
}

.docs-content h2:hover .doc-anchor,
.docs-content h3:hover .doc-anchor,
.doc-anchor:focus-visible { opacity: 1; }
.doc-anchor:hover { background: #eff8f4; }

.docs-content .lede {
  margin: 0 0 18px;
  color: #46514b;
  font-size: 15.5px;
  line-height: 1.7;
}

/* ---- Code blocks --------------------------------------- */
.doc-code { overflow: visible; }

.doc-code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 10px 0 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.doc-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.doc-tabs::-webkit-scrollbar { display: none; }

.doc-tab {
  appearance: none;
  padding: 10px 10px 8px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: rgba(220, 238, 229, .58);
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: color .22s ease, border-color .22s ease;
}

.doc-tab:hover { color: #eef7f3; }
.doc-tab.active { border-color: var(--accent); color: #fff; }

.doc-copy {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 6px;
  background: transparent;
  color: rgba(220, 238, 229, .72);
  font-size: 11px;
  cursor: pointer;
  transition: color .22s ease, border-color .22s ease, background-color .22s ease;
}

.doc-copy:hover { color: #fff; border-color: rgba(255, 255, 255, .34); background: rgba(255, 255, 255, .06); }
.doc-copy svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.doc-copy.copied { color: #9fe0c4; border-color: rgba(159, 224, 196, .5); }

.doc-code pre { overflow-x: auto; scrollbar-width: thin; scrollbar-color: rgba(90, 163, 138, .6) transparent; }
.doc-code pre::-webkit-scrollbar { height: 5px; }
.doc-code pre::-webkit-scrollbar-thumb { background: rgba(90, 163, 138, .6); border-radius: 999px; }
.doc-code pre[hidden] { display: none; }

/* ---- Callouts ------------------------------------------ */
.doc-note,
.doc-warn,
.doc-danger {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 20px 0;
  padding: 15px 17px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 13.5px;
  line-height: 1.65;
}

.doc-note { background: #f2faf6; color: #2c4c40; }
.doc-warn { background: #fdf8ee; color: #5c4620; }
/* Only the highest-severity callout keeps an accent bar. */
.doc-danger {background: #fdf3f1; color: #6b2f28; }

.doc-note > svg,
.doc-warn > svg,
.doc-danger > svg {
  flex: 0 0 17px;
  width: 17px;
  height: 17px;
  margin-top: 2px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.doc-note p, .doc-warn p, .doc-danger p { margin: 0; color: inherit; font-size: inherit; line-height: inherit; }
.doc-note p + p, .doc-warn p + p, .doc-danger p + p { margin-top: 8px; }
.doc-note b, .doc-warn b, .doc-danger b { color: inherit; }

/* ---- Definition list ----------------------------------- */
.doc-defs { margin: 18px 0; border-top: 1px solid var(--line); }

.doc-defs > div {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 18px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--line);
  transition: background-color .22s ease;
}

.doc-defs > div:hover { background: #f9fcfb; }
.doc-defs dt { color: var(--ink); font-size: 13.5px; font-weight: 600; }
.doc-defs dd { margin: 0; color: #46514b; font-size: 13.5px; line-height: 1.65; }

/* ---- HTTP method badges -------------------------------- */
.method {
  display: inline-block;
  min-width: 46px;
  padding: 2px 7px;
  border-radius: 5px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .04em;
  text-align: center;
}

.method.get { background: #e4f0fb; color: #2a5d87; }
.method.post { background: #dceee8; color: #1f5f4b; }

.docs-content table td .method { margin-right: 8px; }

/* ---- Tables -------------------------------------------- */
/* Scroll wide tables inside the content column rather than letting them
   break identifiers like `whatsapp:read` across lines. */
.docs-content table {
  width: 100%;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: #c6d8d0 transparent;
}

.docs-content table code { white-space: nowrap; }
.api-table td:first-child { white-space: nowrap; }
.api-table td:first-child code { display: inline-block; vertical-align: middle; }

/* ---- Role / capability matrix -------------------------- */
.docs-content table .yes { color: var(--accent-deep); font-weight: 800; }
.docs-content table .no { color: #b3bdb8; }
.docs-content table .center { text-align: center; }

/* ---- Inline chips -------------------------------------- */
.req-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  background: #eef7f3;
  color: #287a5e;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  vertical-align: middle;
}

.req-badge.admin { background: #f3f0fb; color: #58479c; }
.req-badge.early { background: #fdf3f1; color: #a2483e; }

/* ---- Step list ----------------------------------------- */
.doc-steps { margin: 18px 0; padding: 0; list-style: none; counter-reset: docstep; }

.doc-steps > li {
  position: relative;
  margin: 0;
  padding: 0 0 20px 38px;
  color: #46514b;
  font-size: 14px;
  line-height: 1.72;
}

.doc-steps > li::before {
  counter-increment: docstep;
  content: counter(docstep);
  position: absolute;
  left: 0;
  top: 0;
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, #7dbba8 0%, #2f8066 100%);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 6px 12px rgba(47, 128, 102, .18);
}

.doc-steps > li::after {
  content: "";
  position: absolute;
  left: 12px;
  top: 30px;
  bottom: 4px;
  width: 1px;
  background: var(--line);
}

.doc-steps > li:last-child { padding-bottom: 0; }
.doc-steps > li:last-child::after { display: none; }
.doc-steps > li + li { margin-top: 0; }
.doc-steps .doc-code { margin-left: 0; }

/* ---- Next steps cards ---------------------------------- */
.doc-next { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 22px 0 0; }

.doc-next a {
  display: block;
  padding: 17px 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  text-decoration: none !important;
  transition: transform .3s var(--ease-out), box-shadow .3s var(--ease-out), border-color .3s ease;
}

.doc-next a:hover { transform: translateY(-3px); border-color: var(--accent-soft); box-shadow: 0 16px 34px rgba(20, 45, 36, .1); }
.doc-next b { display: block; margin-bottom: 5px; color: var(--ink); font-size: 14px; font-weight: 600; }
.doc-next span { color: var(--muted); font-size: 12.5px; line-height: 1.55; }

/* ---- Responsive ---------------------------------------- */
@media (max-width: 1080px) {
  .docs-layout { grid-template-columns: 224px minmax(0, 1fr); gap: 40px; }
}

@media (max-width: 980px) {
  .docs-layout { grid-template-columns: minmax(0, 1fr); }
  .docs-nav-toggle { display: flex; }
  .docs-sidebar {
    position: static;
    max-height: none;
    display: block;
    padding: 16px 0 0;
    border-bottom: 1px solid var(--line);
  }
  .docs-sidebar[data-collapsed="true"] { display: none; }
  .docs-nav-group + .docs-nav-group { margin-top: 16px; }
  .doc-defs > div { grid-template-columns: 1fr; gap: 4px; }
  .doc-next { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .doc-anchor { display: none; }
  .doc-steps > li { padding-left: 32px; }
}
