/* ==========================================================================
   /dev/ai/* — Etlworks AI Agent API developer documentation
   --------------------------------------------------------------------------
   Self-contained dev-docs stylesheet. Loads alongside /css/tokens.css.

   The dev docs are deliberately scoped under their own URL prefix and
   load only this stylesheet (not base.css / components.css / sections.css)
   — the marketing site CSS would over-style developer content (typography,
   button shapes, container widths) in ways that hurt readability of long
   technical pages.

   Class naming mirrors the v3 dev-docs structure (.hero, .features,
   .feature, .steps, .tabs, .tab-btn, .tab-panel, .endpoint, .callout,
   .code-block, .copy-btn, .cards, .card, .download-card) — they're
   semantic and well-organized; the visual treatment here is the v4 refresh.
   ========================================================================== */

/* ---- Reset + base ------------------------------------------------------- */

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

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font-sans);
  color: var(--color-text-primary);
  background: var(--color-bg);
  line-height: 1.7;
}

a {
  color: var(--color-teal-900);
  text-decoration: none;
}
a:hover {
  color: var(--color-teal-1000);
  text-decoration: underline;
  text-underline-offset: 2px;
}

ul, ol { margin: 0 0 16px; padding-left: 24px; }
li { margin-bottom: 6px; }
strong { font-weight: 500; color: var(--color-navy-800); }
hr {
  border: none;
  border-top: var(--border-thin);
  margin: 48px 0;
}

/* ---- Layout: header + sidebar + main ------------------------------------ */

:root {
  --dai-header-h: 60px;
  --dai-sidebar-w: 264px;
  --dai-content-max: 820px;
}

.dai-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--dai-header-h);
  background: var(--color-navy-800);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 100;
  font-size: 14px;
}
.dai-header__logo {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  text-decoration: none;
  color: white;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.dai-header__logo:hover { color: white; text-decoration: none; }
.dai-header__logo-accent { color: var(--color-teal-500); }
.dai-header__sub {
  margin-left: 14px;
  padding-left: 14px;
  border-left: 1px solid rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.75);
  font-size: 13px;
  font-weight: 400;
  text-decoration: none;
  letter-spacing: 0.01em;
}
.dai-header__sub:hover { color: white; text-decoration: none; }

.dai-header__nav {
  margin-left: auto;
  display: flex;
  gap: 4px;
  align-items: center;
}
.dai-header__nav a {
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 400;
  transition: background 150ms ease, color 150ms ease;
}
.dai-header__nav a:hover {
  background: rgba(255, 255, 255, 0.06);
  color: white;
  text-decoration: none;
}
.dai-header__nav a.active {
  background: rgba(93, 202, 165, 0.14);
  color: var(--color-teal-500);
}
.dai-header__back {
  margin-left: 14px;
  padding-left: 14px;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.55);
  font-size: 12.5px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.dai-header__back:hover { color: white; text-decoration: none; }

.dai-hamburger {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  margin-left: auto;
}

/* Sidebar TOC (sub-pages only) */
.dai-sidebar {
  position: fixed;
  top: var(--dai-header-h);
  left: 0;
  bottom: 0;
  width: var(--dai-sidebar-w);
  background: var(--color-bg-tint);
  border-right: var(--border-thin);
  overflow-y: auto;
  padding: 28px 0;
  z-index: 90;
}
.dai-sidebar__section {
  padding: 0 18px;
  margin-bottom: 24px;
}
.dai-sidebar__section h3 {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-tertiary);
}
.dai-sidebar a {
  display: block;
  color: var(--color-text-secondary);
  text-decoration: none;
  padding: 5px 12px;
  margin: 1px 0;
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.5;
  border-left: 2px solid transparent;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.dai-sidebar a:hover {
  background: rgba(29, 158, 117, 0.06);
  color: var(--color-navy-800);
  text-decoration: none;
}
.dai-sidebar a.active {
  background: var(--color-teal-50);
  color: var(--color-teal-1000);
  font-weight: 500;
  border-left-color: var(--color-teal-600);
}

.dai-sidebar a .method {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  padding: 1px 5px;
  border-radius: 3px;
  margin-right: 8px;
  min-width: 38px;
  text-align: center;
  letter-spacing: 0.04em;
}
.dai-sidebar a .method.get    { background: var(--color-teal-50); color: var(--color-teal-1000); }
.dai-sidebar a .method.post   { background: #E8EDFA; color: #1E3A8A; }
.dai-sidebar a .method.delete { background: #FCE8E8; color: #991B1B; }

/* Main content area */
.dai-main {
  margin-left: var(--dai-sidebar-w);
  margin-top: var(--dai-header-h);
  padding: 56px 56px 80px;
  min-height: calc(100vh - var(--dai-header-h));
}
.dai-main--no-sidebar { margin-left: 0; }
.dai-content {
  max-width: var(--dai-content-max);
  margin: 0 auto;
}
.dai-content--wide { max-width: 960px; }

/* ---- Typography --------------------------------------------------------- */

.dai-content h1 {
  font-size: 36px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--color-navy-800);
  margin: 0 0 16px;
}
.dai-content h2 {
  margin: 56px 0 16px;
  padding-bottom: 10px;
  border-bottom: var(--border-thin);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--color-navy-800);
}
.dai-content h3 {
  margin: 36px 0 12px;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--color-navy-800);
}
.dai-content h4 {
  margin: 28px 0 8px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-tertiary);
}
.dai-content p {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--color-text-secondary);
}
.dai-content .subtitle {
  margin: 0 0 32px;
  font-size: 16px;
  line-height: 1.65;
  color: var(--color-text-secondary);
}
.dai-content ul, .dai-content ol {
  font-size: 14px;
  line-height: 1.7;
  color: var(--color-text-secondary);
}

/* ---- Inline + block code ------------------------------------------------ */

code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--color-bg-tint);
  padding: 1.5px 5px;
  border-radius: 4px;
  border: var(--border-thin);
  color: var(--color-navy-800);
}

pre {
  background: #0E1830;
  color: #E2E8F0;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  padding: 18px 22px;
  overflow-x: auto;
  margin: 0 0 24px;
  line-height: 1.6;
  font-size: 13px;
}
pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  color: inherit;
}

.code-block {
  position: relative;
  margin-bottom: 24px;
  border-radius: var(--radius-lg);
  border: 1px solid #1A2541;
  overflow: hidden;
}
.code-block .code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #15192E;
  border-bottom: 1px solid #1A2541;
  padding: 8px 14px;
  font-size: 11px;
  color: #94A3B8;
}
.code-block .code-header .lang {
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.code-block pre { border-radius: 0; margin: 0; }

.copy-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94A3B8;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 11px;
  font-family: var(--font-sans);
  font-weight: 500;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}
.copy-btn:hover {
  background: rgba(255, 255, 255, 0.10);
  color: white;
  border-color: rgba(255, 255, 255, 0.20);
}
.copy-btn.copied {
  background: rgba(93, 202, 165, 0.15);
  color: var(--color-teal-500);
  border-color: rgba(93, 202, 165, 0.30);
}

/* Syntax highlighting */
.token-keyword  { color: #C792EA; }
.token-string   { color: #95D8A0; }
.token-comment  { color: #5C6883; font-style: italic; }
.token-number   { color: #F2B780; }
.token-function { color: #82AAFF; }
.token-variable { color: #E78A8A; }
.token-operator { color: #5DCAA5; }
.token-property { color: #E5C07B; }
.token-url      { color: #82AAFF; text-decoration: underline; }

/* ---- Tables ------------------------------------------------------------- */

.dai-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 24px;
  font-size: 13px;
}
.dai-content th {
  text-align: left;
  padding: 10px 14px;
  background: var(--color-bg-tint);
  border-bottom: var(--border-thin);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-tertiary);
}
.dai-content td {
  padding: 10px 14px;
  border-bottom: var(--border-thin);
  vertical-align: top;
  color: var(--color-text-secondary);
}
.dai-content tr:last-child td { border-bottom: none; }

/* ---- Endpoint cards (api-reference) ------------------------------------- */

.endpoint {
  border: var(--border-thin);
  border-radius: var(--radius-lg);
  margin-bottom: 28px;
  overflow: hidden;
}
.endpoint-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--color-bg-tint);
  border-bottom: var(--border-thin);
}
.endpoint-method {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  min-width: 56px;
  text-align: center;
  letter-spacing: 0.04em;
}
.endpoint-method.get    { background: var(--color-teal-50); color: var(--color-teal-1000); }
.endpoint-method.post   { background: #E8EDFA; color: #1E3A8A; }
.endpoint-method.delete { background: #FCE8E8; color: #991B1B; }

.endpoint-path {
  font-family: var(--font-mono);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--color-navy-800);
}
.endpoint-body { padding: 20px; }
.endpoint-body p:last-child { margin-bottom: 0; }

/* ---- Callout boxes ------------------------------------------------------ */

.callout {
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  margin: 0 0 24px;
  font-size: 13px;
  line-height: 1.65;
  border: var(--border-thin);
  border-left: 3px solid transparent;
}
.callout-title {
  font-weight: 500;
  margin: 0 0 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.callout p { margin: 0; font-size: 13px; line-height: 1.65; }
.callout p + p { margin-top: 8px; }

.callout.info    { background: #F1F5FE; border-left-color: #2A4A7B; }
.callout.info    .callout-title { color: #1E3A8A; }
.callout.success { background: var(--color-teal-50); border-left-color: var(--color-teal-600); }
.callout.success .callout-title { color: var(--color-teal-1000); }
.callout.warning { background: var(--color-amber-50); border-left-color: var(--color-amber-700); }
.callout.warning .callout-title { color: var(--color-amber-700); }
.callout.error   { background: #FCE8E8; border-left-color: #991B1B; }
.callout.error   .callout-title { color: #991B1B; }

/* ---- Hero (landing) ----------------------------------------------------- */

.hero {
  text-align: center;
  padding: 56px 0 40px;
}
.hero h1 {
  margin: 0 0 18px;
  font-size: clamp(36px, 4.5vw, 48px);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.025em;
  color: var(--color-navy-800);
}
.hero .subtitle {
  max-width: 660px;
  margin: 0 auto 32px;
  font-size: 16px;
  line-height: 1.65;
  color: var(--color-text-secondary);
}
.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ---- Buttons ------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 14px;
  text-decoration: none;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
  cursor: pointer;
}
.btn:hover { text-decoration: none; }
.btn-primary {
  background: var(--color-navy-800);
  color: white;
  border: 0.5px solid var(--color-navy-800);
}
.btn-primary:hover {
  background: var(--color-navy-700);
  border-color: var(--color-navy-700);
  color: white;
}
.btn-secondary {
  background: var(--color-bg);
  color: var(--color-navy-800);
  border: 0.5px solid var(--color-border);
}
.btn-secondary:hover {
  border-color: var(--color-navy-800);
  color: var(--color-navy-800);
}

/* ---- Feature grid (landing) -------------------------------------------- */

.features {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 48px 0;
}
.feature {
  border: var(--border-thin);
  border-radius: var(--radius-lg);
  padding: 24px;
  background: var(--color-bg);
}
.feature-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--color-teal-50);
  color: var(--color-teal-900);
  margin-bottom: 14px;
}
.feature-icon svg { width: 18px; height: 18px; }
.feature h3 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 500;
  color: var(--color-navy-800);
}
.feature p {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--color-text-secondary);
}

/* ---- Cards (next-step grid on landing) --------------------------------- */

.cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 32px 0;
}
.card {
  border: var(--border-thin);
  border-radius: var(--radius-lg);
  background: var(--color-bg);
  transition: border-color 150ms ease;
}
.card:hover { border-color: var(--color-teal-600); }
.card a {
  display: block;
  padding: 22px;
  color: inherit;
  text-decoration: none;
}
.card a:hover { text-decoration: none; }
.card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--color-teal-50);
  color: var(--color-teal-900);
  margin-bottom: 12px;
}
.card-icon svg { width: 16px; height: 16px; }
.card h3 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 500;
  color: var(--color-navy-800);
}
.card p {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--color-text-secondary);
}

/* ---- Steps (numbered walkthrough) -------------------------------------- */

.steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
}
.steps > li {
  counter-increment: step;
  position: relative;
  padding-left: 44px;
  margin-bottom: 28px;
}
.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 28px;
  height: 28px;
  background: var(--color-teal-50);
  color: var(--color-teal-1000);
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 12.5px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.steps > li h3 {
  margin-top: 0;
  font-size: 15px;
}
.steps > li p {
  font-size: 13px;
  line-height: 1.65;
}

/* ---- Tabs (code-language switcher) ------------------------------------- */

.tab-group { margin-bottom: 24px; }
.tabs {
  display: flex;
  gap: 0;
  border-bottom: var(--border-thin);
  margin: 0;
}
.tab-btn {
  background: none;
  border: none;
  padding: 8px 16px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-tertiary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 150ms ease, border-color 150ms ease;
}
.tab-btn:hover { color: var(--color-text-secondary); }
.tab-btn.active {
  color: var(--color-teal-1000);
  border-bottom-color: var(--color-teal-600);
}
.tab-panel { display: none; padding-top: 16px; }
.tab-panel.active { display: block; }

/* ---- Download cards ----------------------------------------------------- */

.download-card {
  display: flex;
  align-items: center;
  gap: 18px;
  border: var(--border-thin);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  margin-bottom: 14px;
  background: var(--color-bg);
}
.download-card .dl-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--color-teal-50);
  color: var(--color-teal-900);
}
.download-card .dl-icon svg { width: 20px; height: 20px; }
.download-card .dl-info { flex: 1; min-width: 0; }
.download-card .dl-info h3 {
  margin: 0 0 2px;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-navy-800);
}
.download-card .dl-info p {
  margin: 0;
  font-size: 13px;
  color: var(--color-text-secondary);
}
.download-card .dl-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  background: var(--color-navy-800);
  color: white;
  font-weight: 500;
  font-size: 12.5px;
  text-decoration: none;
  flex-shrink: 0;
  transition: background 150ms ease;
}
.download-card .dl-btn:hover { background: var(--color-navy-700); color: white; text-decoration: none; }
.download-card .dl-btn svg { width: 13px; height: 13px; }

/* ---- Badges (free / billed pills used in api-reference) ---------------- */

.badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.badge-free   { background: var(--color-teal-50);  color: var(--color-teal-1000); }
.badge-billed { background: var(--color-amber-50); color: var(--color-amber-700); }

/* ---- Footer ------------------------------------------------------------- */

.dai-footer {
  border-top: var(--border-thin);
  padding: 28px 56px;
  margin-left: var(--dai-sidebar-w);
  font-size: 13px;
  color: var(--color-text-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}
.dai-footer--no-sidebar {
  margin-left: 0;
}
.dai-footer a {
  color: var(--color-text-secondary);
  text-decoration: none;
}
.dai-footer a:hover {
  color: var(--color-navy-800);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.dai-footer__sep { color: var(--color-border); }

/* ---- Responsive --------------------------------------------------------- */

@media (max-width: 1024px) {
  .dai-sidebar {
    transform: translateX(-100%);
    transition: transform 200ms ease;
  }
  .dai-sidebar.open { transform: translateX(0); }
  .dai-main { margin-left: 0; padding: 32px 24px 60px; }
  .dai-footer { margin-left: 0; padding: 24px; }
  .dai-hamburger { display: block; }
  .dai-header__nav { display: none; }
  .dai-header__back { display: none; }

  .features { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cards { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .hero h1 { font-size: 30px; }
  .hero { padding: 36px 0 24px; }
  .dai-content h1 { font-size: 28px; }
  .dai-content h2 { font-size: 19px; margin-top: 40px; }
  .features { grid-template-columns: 1fr; }
  .download-card { flex-direction: column; text-align: center; gap: 12px; }
  .endpoint-header { flex-direction: column; align-items: flex-start; }
  .dai-header__sub { display: none; }
}
