/* ============================================
   EarningsAPI — Custom API Docs (polished)
   ============================================ */

/* Layout */
.docs-layout {
  display: flex;
  min-height: calc(100vh - 64px);
  padding-top: 64px;
  max-width: 1200px;
  margin: 0 auto;
  padding-left: 24px;
  padding-right: 24px;
}

.docs-sidebar {
  width: 360px;
  min-width: 360px;
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  overflow-y: auto;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-inner {
  padding: 28px 20px;
}

.sidebar-section {
  margin-bottom: 28px;
}

.sidebar-section h4 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  padding: 0 12px;
  margin-bottom: 10px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 450;
  transition: var(--transition);
  line-height: 1.4;
}

.sidebar-link:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

.sidebar-link.active {
  color: var(--text-primary);
  background: rgba(148, 163, 184, 0.08);
  border-left: 2px solid var(--text-secondary);
}

.sidebar-link.sub {
  padding-left: 28px;
  font-size: 12.5px;
  font-family: var(--mono);
  color: var(--text-muted);
}

.sidebar-link.sub:hover {
  color: var(--text-secondary);
}

.method-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.method-dot.method-get { background: #94a3b8; }
.method-dot.method-post { background: #8b8ff5; }
.method-dot.method-put { background: #d9a963; }
.method-dot.method-delete { background: #c87070; }

/* Main Content */
.docs-main {
  flex: 1;
  min-width: 0;
  padding: 0 0 80px 48px;
}

/* Auth Bar — full-width header bar */
.docs-auth-bar {
  position: sticky;
  top: 64px;
  z-index: 5;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  border-top: 1px solid var(--border);
  margin: 0 0 16px -48px;
  padding: 24px 24px 24px 48px;
  width: calc(100% + 48px);
}

.auth-bar-inner {
  display: flex;
  align-items: center;
  gap: 14px;
}

.auth-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

#api-key-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
}

#api-key-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.auth-status {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 60px;
}

.auth-status.auth-ok {
  color: #8baa8b;
  font-weight: 600;
}

/* ---- Sections ---- */
.docs-section {
  padding-top: 36px;
  margin-bottom: 20px;
}

.docs-section h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text-primary);
}

.docs-section p {
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 18px;
  font-size: 15px;
}

.docs-section code {
  background: var(--bg-card);
  padding: 3px 8px;
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 13px;
  color: #b0bec5;
  border: 1px solid var(--border);
}

.docs-divider {
  height: 1px;
  background: var(--border);
  margin: 48px 0 16px;
}

/* ---- Code Blocks ---- */
.code-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
}

.code-header {
  padding: 10px 18px;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.code-block pre {
  padding: 18px;
  margin: 0;
  overflow-x: auto;
}

.code-block code {
  font-family: var(--mono);
  font-size: 13.5px;
  color: var(--text-primary);
  background: none;
  padding: 0;
  line-height: 1.6;
}

/* ---- Tier Table (Rate Limits) ---- */
.tier-table {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
}

.tier-row {
  display: grid;
  grid-template-columns: 160px 1fr 1fr 1fr;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary);
  align-items: center;
  gap: 16px;
}

.tier-row:last-child { border-bottom: none; }

.tier-row.tier-header {
  background: rgba(255,255,255,0.03);
  font-weight: 700;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding: 12px 20px;
}

.tier-row:not(.tier-header) span {
  font-size: 14px;
}

.tier-yes {
  color: var(--text-secondary);
  font-weight: 600;
}

.tier-no {
  color: var(--text-muted);
}

.tier-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.tier-badge.free { background: rgba(148, 163, 184, 0.08); color: var(--text-secondary); border: 1px solid var(--border); }
.tier-badge.pro { background: rgba(148, 163, 184, 0.08); color: var(--text-primary); border: 1px solid var(--border-light); }
.tier-badge.enterprise { background: rgba(148, 163, 184, 0.08); color: var(--text-primary); border: 1px solid var(--border-light); }

/* ---- Error Codes ---- */
.error-codes {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 8px;
}

.error-row {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.error-row:last-child { border-bottom: none; }

.error-row code {
  background: var(--bg-card);
  padding: 3px 10px;
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  min-width: 44px;
  text-align: center;
}

.error-row span {
  color: var(--text-secondary);
}

/* ---- Endpoint Groups ---- */
.endpoint-group {
  padding-top: 44px;
}

.endpoint-group h2 {
  margin-bottom: 6px;
}

p.tag-desc {
  color: var(--text-muted);
  margin-bottom: 20px;
  font-size: 14.5px;
  line-height: 1.6;
}

/* ---- Endpoint Cards ---- */
.endpoint-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
  transition: var(--transition);
}

.endpoint-card:hover {
  border-color: var(--border-light);
}

.endpoint-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  cursor: pointer;
  user-select: none;
}

.endpoint-method-path {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.method-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 12px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  min-width: 54px;
  text-align: center;
}

.method-badge.small {
  padding: 3px 8px;
  font-size: 10.5px;
  min-width: 44px;
}

.method-badge.method-get { background: rgba(148, 163, 184, 0.12); color: #94a3b8; }
.method-badge.method-post { background: rgba(99, 102, 241, 0.1); color: #8b8ff5; }
.method-badge.method-put { background: rgba(217, 169, 99, 0.1); color: #d9a963; }
.method-badge.method-delete { background: rgba(200, 100, 100, 0.1); color: #c87070; }

code.endpoint-path {
  font-family: var(--mono);
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text-primary);
  background: none;
  padding: 0;
  border-radius: 0;
}

.endpoint-summary {
  flex: 1;
  font-size: 13px;
  color: var(--text-muted);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chevron {
  color: var(--text-muted);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.endpoint-card.open .chevron {
  transform: rotate(180deg);
}

/* ---- Endpoint Body (collapsed/expanded) ---- */
.endpoint-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease;
}

.endpoint-card.open .endpoint-body {
  max-height: 3000px;
  border-top: 1px solid var(--border);
  padding: 24px 20px;
}

p.endpoint-desc {
  color: var(--text-secondary);
  font-size: 14.5px;
  margin-bottom: 24px;
  line-height: 1.6;
}

/* ---- Parameters ---- */
.params-section {
  margin-bottom: 28px;
}

.params-section h4,
.try-it-section h4,
.response-info h4 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.params-table {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.param-row {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.param-row:last-child { border-bottom: none; }

.param-name {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 5px;
}

.param-name code {
  font-family: var(--mono);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  background: none;
  padding: 0;
}

.param-required {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #b87070;
  background: rgba(184, 112, 112, 0.08);
  padding: 2px 8px;
  border-radius: 4px;
}

.param-optional {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.param-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.param-in {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: rgba(148, 163, 184, 0.08);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.param-type {
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text-muted);
}

.param-enum, .param-default {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--mono);
}

.param-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ---- Try It ---- */
.try-it-section {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.try-it-form {
  margin-top: 14px;
}

.try-it-url {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.try-url-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
}

.try-it-params {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.try-param label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.try-param label .param-in {
  font-size: 10px;
  padding: 1px 6px;
}

.try-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
}

.try-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.try-input::placeholder {
  color: var(--text-muted);
}

/* ---- Response ---- */
.try-it-response {
  margin-top: 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.response-placeholder {
  padding: 28px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.response-loading {
  padding: 28px;
  text-align: center;
  color: var(--accent-light);
  font-size: 13px;
}

.response-error {
  padding: 18px;
  color: var(--red);
  font-size: 13px;
}

.response-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border);
}

.response-status {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
}

.response-status.status-ok { color: #8baa8b; }
.response-status.status-err { color: #c87070; }

.response-time {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
}

.response-body {
  padding: 18px;
  overflow-x: auto;
  max-height: 500px;
  overflow-y: auto;
  margin: 0;
}

.response-body code {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-secondary);
  background: none;
  padding: 0;
}

/* Test Key Box */
.test-key-box {
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 20px 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
}

.test-key-box strong {
  color: var(--accent-light);
}

.auth-test {
  color: #f59e0b !important;
  font-size: 12px;
}

/* JSON Syntax Highlighting */
.json-key { color: #a5b4c8; }
.json-string { color: #8baa8b; }
.json-number { color: #c8a87a; }
.json-bool { color: #b0a878; }

/* Response Info */
.response-info {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.response-info p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Button overrides for docs */
.btn-sm {
  padding: 8px 20px;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.5;
  border-radius: var(--radius-sm);
}

/* ---- Icons ---- */
.icon-inline {
  width: 16px;
  height: 16px;
  vertical-align: -2px;
  stroke-width: 2;
}

.logo-icon i,
.logo-icon svg {
  width: 22px;
  height: 22px;
  vertical-align: -4px;
  color: var(--accent-light);
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .docs-sidebar {
    display: none;
  }
  .docs-main {
    margin-left: 0;
    padding: 0 20px 60px;
  }
  .try-it-params {
    grid-template-columns: 1fr;
  }
  .tier-row {
    grid-template-columns: 120px 1fr 1fr 1fr;
    font-size: 12px;
    padding: 10px 14px;
    gap: 12px;
  }
  footer.footer {
    margin-left: 0 !important;
  }
}

@media (max-width: 600px) {
  .endpoint-header {
    flex-wrap: wrap;
  }
  .endpoint-summary {
    width: 100%;
    text-align: left;
    margin-top: 4px;
  }
  .auth-bar-inner {
    flex-wrap: wrap;
  }
}

/* ---- Scrollbar ---- */
.docs-sidebar::-webkit-scrollbar {
  width: 4px;
}
.docs-sidebar::-webkit-scrollbar-track {
  background: transparent;
}
.docs-sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.response-body::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.response-body::-webkit-scrollbar-track {
  background: transparent;
}
.response-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
