/* ============================================================
   CRM Developer Docs — Design System
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* ---- Custom Properties ------------------------------------ */
:root {
  --bg:            #0d0f12;
  --sidebar-bg:    #111318;
  --surface:       #161b22;
  --surface-hover: #1c2230;
  --accent-blue:   #2563ff;
  --accent-teal:   #0ea5e9;
  --text:          #e2e8f0;
  --muted:         #8b95a3;
  --border:        #1e2530;

  --method-get:    #16a34a;
  --method-post:   #2563ff;
  --method-patch:  #d97706;
  --method-delete: #dc2626;
  --method-put:    #7c3aed;

  --sidebar-width: 260px;
  --toc-width:     210px;
  --header-height: 0px;

  --radius-sm: 4px;
  --radius:    8px;
  --radius-lg: 12px;

  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* ---- Reset ------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.65;
  display: flex;
  min-height: 100vh;
}

a { color: var(--accent-teal); text-decoration: none; }
a:hover { text-decoration: underline; color: #38bdf8; }

h1, h2, h3, h4, h5 {
  font-weight: 600;
  line-height: 1.3;
  color: #f1f5f9;
}

h1 { font-size: 2rem; margin-bottom: 0.75rem; }
h2 { font-size: 1.4rem; margin: 2.5rem 0 0.75rem; padding-top: 0.5rem; }
h3 { font-size: 1.1rem; margin: 1.75rem 0 0.5rem; }
h4 { font-size: 0.95rem; margin: 1.25rem 0 0.4rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

p { margin-bottom: 1rem; color: var(--text); }
ul, ol { margin: 0 0 1rem 1.4rem; }
li { margin-bottom: 0.25rem; }

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

/* ---- Layout ----------------------------------------------- */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 100;
  flex-shrink: 0;
}

.page-wrapper {
  flex: 1;
  display: flex;
  min-width: 0;
  overflow: hidden;
}

.main-content {
  flex: 1;
  min-width: 0;
  padding: 3rem 3rem 4rem;
  max-width: 900px;
  overflow-y: auto;
  margin: 0 auto;
}

.toc-sidebar {
  width: var(--toc-width);
  min-width: var(--toc-width);
  padding: 2.5rem 1rem 2rem 0.5rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
}

/* ---- Sidebar Nav ------------------------------------------ */
.sidebar-logo {
  padding: 1.4rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #f1f5f9;
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.sidebar-logo a:hover { color: #fff; }

.sidebar-logo .logo-icon {
  width: 28px; height: 28px;
  background: var(--accent-blue);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}

.sidebar-search {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.82rem;
  padding: 0.45rem 0.75rem 0.45rem 2rem;
  outline: none;
  transition: border-color 0.15s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%238b95a3' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.099zm-5.44 1.406a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 0.55rem center;
}

.search-input:focus { border-color: var(--accent-blue); }
.search-input::placeholder { color: var(--muted); }

.sidebar-nav {
  padding: 0.75rem 0 1.5rem;
  flex: 1;
  overflow-y: auto;
}

.nav-section-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 1rem 1.25rem 0.35rem;
  display: block;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.42rem 1.25rem;
  font-size: 0.85rem;
  color: #9ca3af;
  border-radius: 0;
  text-decoration: none;
  transition: color 0.12s, background 0.12s;
  position: relative;
}

.nav-item:hover {
  color: var(--text);
  background: rgba(255,255,255,0.04);
  text-decoration: none;
}

.nav-item.active {
  color: #fff;
  background: rgba(37,99,255,0.15);
  border-right: 2px solid var(--accent-blue);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--accent-blue);
  border-radius: 0 2px 2px 0;
}

.nav-item .nav-icon {
  font-size: 0.9rem;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}

.nav-sub-item {
  padding-left: 2.5rem;
  font-size: 0.8rem;
  color: #6b7280;
}

.nav-sub-item:hover { color: var(--text); }
.nav-sub-item.active { color: var(--accent-teal); }

/* ---- Hamburger -------------------------------------------- */
.hamburger {
  display: none;
  position: fixed;
  top: 0.75rem; left: 0.75rem;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.55rem;
  cursor: pointer;
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1;
}

/* ---- TOC Sidebar ------------------------------------------ */
.toc-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.6rem;
  display: block;
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc-list li { margin: 0; }

.toc-list a {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  padding: 0.3rem 0.5rem;
  border-left: 2px solid var(--border);
  transition: color 0.12s, border-color 0.12s;
  text-decoration: none;
  line-height: 1.4;
}

.toc-list a:hover {
  color: var(--text);
  border-left-color: var(--accent-teal);
}

.toc-list a.toc-active {
  color: var(--accent-teal);
  border-left-color: var(--accent-teal);
}

/* ---- Method Badges ---------------------------------------- */
.method-badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 0.5rem;
  flex-shrink: 0;
}

.badge-get    { background: rgba(22,163,74,0.18);  color: #4ade80; border: 1px solid rgba(22,163,74,0.35); }
.badge-post   { background: rgba(37,99,255,0.18);  color: #60a5fa; border: 1px solid rgba(37,99,255,0.35); }
.badge-patch  { background: rgba(217,119,6,0.18);  color: #fbbf24; border: 1px solid rgba(217,119,6,0.35); }
.badge-delete { background: rgba(220,38,38,0.18);  color: #f87171; border: 1px solid rgba(220,38,38,0.35); }
.badge-put    { background: rgba(124,58,237,0.18); color: #a78bfa; border: 1px solid rgba(124,58,237,0.35); }

/* ---- Endpoint Cards --------------------------------------- */
.endpoint-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  overflow: hidden;
  border-left-width: 3px;
}

.endpoint-card.method-get    { border-left-color: var(--method-get); }
.endpoint-card.method-post   { border-left-color: var(--method-post); }
.endpoint-card.method-patch  { border-left-color: var(--method-patch); }
.endpoint-card.method-delete { border-left-color: var(--method-delete); }
.endpoint-card.method-put    { border-left-color: var(--method-put); }

.endpoint-header {
  padding: 0.9rem 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}

.endpoint-path {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  color: #f1f5f9;
  font-weight: 500;
  flex: 1;
  min-width: 0;
  word-break: break-all;
}

.endpoint-description-short {
  font-size: 0.8rem;
  color: var(--muted);
  margin-left: auto;
}

.endpoint-body {
  padding: 1.2rem 1.4rem;
}

.endpoint-desc {
  font-size: 0.88rem;
  color: #cbd5e1;
  margin-bottom: 1rem;
}

/* ---- Tables ----------------------------------------------- */
.params-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin-bottom: 1.25rem;
}

.params-table th {
  background: #1a2030;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0.5rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.params-table td {
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid rgba(30,37,48,0.8);
  vertical-align: top;
  color: var(--text);
}

.params-table tr:last-child td { border-bottom: none; }

.params-table tr:hover td { background: rgba(255,255,255,0.02); }

.param-name {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #a5f3fc;
}

.param-type {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #86efac;
}

.required-badge {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 600;
  background: rgba(220,38,38,0.18);
  color: #f87171;
  border: 1px solid rgba(220,38,38,0.3);
  border-radius: 3px;
  padding: 0.1rem 0.35rem;
  margin-left: 0.3rem;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.optional-badge {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 600;
  background: rgba(30,37,48,0.8);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.1rem 0.35rem;
  margin-left: 0.3rem;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---- Section Labels --------------------------------------- */
.table-section-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin: 1rem 0 0.4rem;
}

/* ---- Code Blocks ------------------------------------------ */
.code-block {
  background: #0a0c10;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 0.75rem 0 1.25rem;
  font-family: var(--font-mono);
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.9rem;
  background: #111520;
  border-bottom: 1px solid var(--border);
}

.code-lang-label {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.copy-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.72rem;
  padding: 0.2rem 0.55rem;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}

.copy-btn:hover {
  color: var(--text);
  border-color: #3d4a5c;
  background: rgba(255,255,255,0.04);
}

.copy-btn.copied {
  color: #4ade80;
  border-color: rgba(74,222,128,0.4);
}

.code-block pre {
  padding: 1rem 1.1rem;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.7;
  color: #e2e8f0;
  margin: 0;
}

code {
  font-family: var(--font-mono);
  font-size: 0.83em;
  background: rgba(37,99,255,0.12);
  border: 1px solid rgba(37,99,255,0.2);
  border-radius: 3px;
  padding: 0.1em 0.4em;
  color: #a5f3fc;
}

.code-block pre code {
  background: transparent;
  border: none;
  padding: 0;
  font-size: inherit;
  color: inherit;
}

/* Syntax highlighting */
.token-keyword  { color: #c084fc; }
.token-string   { color: #86efac; }
.token-comment  { color: #4b5563; font-style: italic; }
.token-number   { color: #fbbf24; }
.token-function { color: #60a5fa; }
.token-variable { color: #f9a8d4; }
.token-operator { color: #94a3b8; }
.token-url      { color: #38bdf8; }
.token-method   { color: #a78bfa; }

/* ---- Notes / Alerts --------------------------------------- */
.note-block {
  background: rgba(14,165,233,0.08);
  border: 1px solid rgba(14,165,233,0.25);
  border-left: 3px solid var(--accent-teal);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin: 0.75rem 0 1rem;
  font-size: 0.85rem;
  color: #bae6fd;
}

.note-block strong { color: var(--accent-teal); }

.warning-block {
  background: rgba(217,119,6,0.08);
  border: 1px solid rgba(217,119,6,0.25);
  border-left: 3px solid #d97706;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin: 0.75rem 0 1rem;
  font-size: 0.85rem;
  color: #fde68a;
}

/* ---- Hero / Landing --------------------------------------- */
.hero-section {
  padding: 3rem 0 2rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2.5rem;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--accent-teal);
  background: rgba(14,165,233,0.1);
  border: 1px solid rgba(14,165,233,0.25);
  border-radius: 100px;
  padding: 0.25rem 0.75rem;
  margin-bottom: 1.2rem;
}

.hero-section h1 {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1.15;
  background: linear-gradient(135deg, #f1f5f9 0%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1rem;
}

.hero-section p {
  font-size: 1.05rem;
  color: #94a3b8;
  max-width: 560px;
  margin-bottom: 1.5rem;
}

.hero-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 2rem;
}

.hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.3rem;
  transition: border-color 0.15s, transform 0.15s;
  text-decoration: none;
  display: block;
}

.hero-card:hover {
  border-color: rgba(37,99,255,0.5);
  transform: translateY(-2px);
  text-decoration: none;
}

.hero-card-icon {
  font-size: 1.6rem;
  margin-bottom: 0.75rem;
  display: block;
}

.hero-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: #f1f5f9;
  margin: 0 0 0.4rem;
}

.hero-card p {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 0.9rem;
  line-height: 1.5;
}

.hero-card-cta {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent-teal);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* ---- API Section Headers ---------------------------------- */
.api-section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  margin: 2rem 0 1rem;
  border-bottom: 1px solid var(--border);
}

.api-section-header h2 {
  margin: 0;
  padding: 0;
  font-size: 1.15rem;
}

.api-section-icon {
  font-size: 1.1rem;
}

/* ---- Base URL Banner -------------------------------------- */
.base-url-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.base-url-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  flex-shrink: 0;
}

.base-url-value {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: #38bdf8;
  flex: 1;
}

/* ---- Auth Banner ------------------------------------------ */
.auth-banner {
  background: rgba(37,99,255,0.07);
  border: 1px solid rgba(37,99,255,0.25);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: 2rem;
  font-size: 0.85rem;
}

.auth-banner p { margin: 0; color: #bfdbfe; }
.auth-banner strong { color: #93c5fd; }
.auth-banner code { background: rgba(37,99,255,0.2); border-color: rgba(37,99,255,0.3); }

/* ---- Step Cards (Quickstart) ------------------------------ */
.step-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.6rem;
  margin-bottom: 1.5rem;
  position: relative;
}

.step-number {
  position: absolute;
  top: -1px; left: -1px;
  background: var(--accent-blue);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius) 0 var(--radius-sm) 0;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

.step-card h3 {
  margin-top: 0.25rem;
  margin-bottom: 0.75rem;
}

/* ---- SDK Section ------------------------------------------ */
.sdk-section {
  padding-top: 1rem;
}

.sdk-section + .sdk-section {
  border-top: 1px solid var(--border);
  margin-top: 2rem;
  padding-top: 2rem;
}

.function-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin: 0.75rem 0 1.25rem;
}

.function-table th {
  background: #1a2030;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0.5rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.function-table td {
  padding: 0.5rem 0.9rem;
  border-bottom: 1px solid rgba(30,37,48,0.8);
  vertical-align: top;
}

.function-table tr:last-child td { border-bottom: none; }
.function-table tr:hover td { background: rgba(255,255,255,0.02); }

.function-name {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #a5f3fc;
  white-space: nowrap;
}

/* ---- Footer ----------------------------------------------- */
footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0 0;
  margin-top: 3rem;
  color: var(--muted);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

footer a { color: var(--muted); }
footer a:hover { color: var(--text); }

/* ---- Overlay ---------------------------------------------- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 90;
}

/* ---- Responsive ------------------------------------------- */
@media (max-width: 1100px) {
  .toc-sidebar { display: none; }
  .main-content { max-width: 100%; }
}

@media (max-width: 768px) {
  .hamburger { display: flex; align-items: center; }

  .sidebar {
    position: fixed;
    left: 0; top: 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 150;
    height: 100vh;
  }

  .sidebar.sidebar-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
  }

  .sidebar-overlay.overlay-open { display: block; }

  .main-content {
    padding: 1.5rem 1.25rem 3rem;
    padding-top: 3.5rem;
  }

  .hero-cards { grid-template-columns: 1fr; }

  .hero-section h1 { font-size: 1.75rem; }

  .endpoint-description-short { display: none; }
}

@media (max-width: 480px) {
  .main-content { padding: 1.25rem 1rem 2.5rem; padding-top: 3.5rem; }
  .base-url-banner { flex-direction: column; align-items: flex-start; gap: 0.25rem; }
}

/* ---- Scrollbar -------------------------------------------- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a3240; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #3d4a5c; }

/* ---- Swagger wrapper -------------------------------------- */
.swagger-wrapper {
  background: var(--bg);
  min-height: 100vh;
  padding: 1rem;
}

.swagger-inner {
  background: #fff;
  border-radius: var(--radius-lg);
  overflow: hidden;
}
