/* API Reference - Scalar-like styling */

.api-reference {
  display: flex;
  max-width: 1440px;
  margin: 0 auto;
  min-height: calc(100vh - 80px - 4rem);
}

/* Sidebar */
.api-sidebar {
  width: 280px;
  min-width: 280px;
  padding: 20px 16px;
  border-right: 1px solid var(--border);
  position: sticky;
  top: 81px;
  height: calc(100vh - 81px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar) transparent;
}

.api-sidebar::-webkit-scrollbar {
  width: 4px;
}

.api-sidebar::-webkit-scrollbar-thumb {
  background: var(--scrollbar);
  border-radius: 2px;
}

.api-search {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font-size: 13px;
  margin-bottom: 16px;
  outline: none;
}

.api-search:focus {
  border-color: var(--border-hover);
}

.api-search::placeholder {
  color: var(--muted-fg);
}

.api-sidebar__group {
  margin-bottom: 4px;
}

.api-sidebar__group-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  border-radius: 4px;
  cursor: pointer;
}

.api-sidebar__group-toggle:hover {
  background: var(--surface-hover);
}

.api-sidebar__group-toggle svg {
  transition: transform 0.15s ease;
}

.api-sidebar__group--collapsed .api-sidebar__group-toggle svg {
  transform: rotate(-90deg);
}

.api-sidebar__group--collapsed .api-sidebar__group-items {
  display: none;
}

.api-sidebar__group-items {
  padding: 2px 0 8px 0;
}

.api-sidebar__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  font-size: 13px;
  border-radius: 4px;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.api-sidebar__item:hover {
  background: var(--surface-hover);
}

.api-sidebar__item--active {
  background: var(--surface);
}

.api-sidebar__item-path {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Method Badges */
.method-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  padding: 2px 6px;
  border-radius: 4px;
  min-width: 42px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.method-badge--get {
  background: rgba(34, 197, 94, 0.15);
  color: #16a34a;
}

.method-badge--post {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}

.method-badge--put {
  background: rgba(249, 115, 22, 0.15);
  color: #ea580c;
}

.method-badge--delete {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.method-badge--patch {
  background: rgba(168, 85, 247, 0.15);
  color: #a855f7;
}

.method-badge--head,
.method-badge--options {
  background: rgba(107, 114, 128, 0.15);
  color: #9ca3af;
}

[data-theme="light"] .method-badge--get {
  background: rgba(34, 197, 94, 0.12);
  color: #15803d;
}

[data-theme="light"] .method-badge--post {
  background: rgba(59, 130, 246, 0.12);
  color: #2563eb;
}

[data-theme="light"] .method-badge--put {
  background: rgba(249, 115, 22, 0.12);
  color: #c2410c;
}

[data-theme="light"] .method-badge--delete {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
}

[data-theme="light"] .method-badge--patch {
  background: rgba(168, 85, 247, 0.12);
  color: #7c3aed;
}

/* Main Content */
.api-content {
  flex: 1;
  min-width: 0;
  padding: 32px;
}

/* API Info Section */
.api-info {
  padding-bottom: 32px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border);
}

.api-info__title {
  font-size: 1.8em;
  font-weight: 700;
  margin-bottom: 8px;
}

.api-info__version {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  margin-bottom: 16px;
}

.api-info__description {
  font-size: 15px;
  line-height: 1.6;
  color: var(--muted);
}

/* Markdown content inside descriptions */
.api-info__description a,
.api-group__description a,
.api-operation__description a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(99, 102, 241, 0.4);
  text-underline-offset: 2px;
}

.api-info__description a:hover,
.api-group__description a:hover,
.api-operation__description a:hover {
  text-decoration-color: var(--accent);
}

.api-info__description code,
.api-group__description code,
.api-operation__description code {
  font-family: monospace;
  font-size: 0.9em;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface);
}

.api-info__description h1,
.api-info__description h2,
.api-info__description h3 {
  color: var(--text);
  margin-top: 1.2em;
  margin-bottom: 0.4em;
}

.api-info__description ul,
.api-info__description ol {
  padding-left: 1.5em;
  margin: 0.5em 0;
}

.api-info__description li {
  margin: 0.25em 0;
}

.api-info__description p {
  margin: 0.5em 0;
}

.api-info__description p:first-child {
  margin-top: 0;
}

.api-info__description p:last-child {
  margin-bottom: 0;
}

.api-info__servers {
  margin-top: 16px;
}

.api-info__server-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  margin-bottom: 6px;
}

.api-info__server-url {
  display: inline-block;
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 4px;
  background: var(--pre-bg);
  color: var(--fg);
}

/* Auth */
.api-auth {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.api-auth__label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg-muted, #6b7280);
  min-width: 90px;
}

.api-auth__controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.api-auth__type {
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
}

.api-auth__value {
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  min-width: 220px;
  background: var(--bg);
  color: var(--fg);
}

.api-auth__value--hidden {
  display: none;
}

/* Tag Group */
.api-group {
  margin-bottom: 40px;
}

.api-group__header {
  margin-bottom: 20px;
}

.api-group__title {
  font-size: 1.3em;
  font-weight: 700;
  margin-bottom: 4px;
}

.api-group__description {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}

/* Operation */
.api-operation {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 16px;
  overflow: hidden;
}

.api-operation__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
}

.api-operation__header:hover {
  background: var(--surface-hover);
}

.api-operation__path {
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 14px;
  font-weight: 500;
}

.api-operation__summary {
  font-size: 13px;
  color: var(--muted);
  margin-left: auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.api-operation__toggle-icon {
  flex-shrink: 0;
  transition: transform 0.15s ease;
  color: var(--muted-fg);
}

.api-operation--collapsed .api-operation__toggle-icon {
  transform: rotate(-90deg);
}

.api-operation--collapsed .api-operation__body {
  display: none;
}

.api-operation__body {
  display: flex;
  border-top: 1px solid var(--border);
  padding: 0;
}

.api-operation__docs {
  flex: 1;
  min-width: 0;
  padding: 20px;
}

.api-operation__description {
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 20px;
  color: var(--muted);
}

/* Parameters */
.api-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  margin-bottom: 10px;
}

.api-params-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
  font-size: 13px;
}

.api-params-table th {
  text-align: left;
  font-weight: 600;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-strong);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--muted);
  background: none;
}

.api-params-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.api-param-name {
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-weight: 600;
  font-size: 13px;
}

.api-param-required {
  color: #ef4444;
  font-size: 11px;
  margin-left: 4px;
}

.api-param-type {
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
  color: var(--muted);
}

.api-param-in {
  font-size: 11px;
  color: var(--muted-fg);
  padding: 1px 6px;
  background: var(--surface);
  border-radius: 3px;
}

.api-param-desc {
  color: var(--muted);
  font-size: 13px;
}

.api-param-enum {
  font-size: 11px;
  color: var(--muted-fg);
  margin-top: 4px;
}

.api-param-enum code {
  font-size: 11px;
  margin: 0 2px;
}

/* Schema Properties */
.api-schema {
  margin-bottom: 20px;
}

.api-schema-props {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.api-schema-prop {
  display: flex;
  gap: 12px;
  padding: 8px 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  align-items: baseline;
}

.api-schema-prop:last-child {
  border-bottom: none;
}

.api-schema-prop-name {
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-weight: 600;
  min-width: 120px;
}

.api-schema-prop-type {
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
  color: var(--muted);
  min-width: 80px;
}

.api-schema-prop-desc {
  color: var(--muted);
  flex: 1;
}

/* Code Examples */
.api-code-examples {
  margin-top: 20px;
}

.api-code-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

.api-code-tab {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.api-code-tab:hover {
  color: var(--fg);
}

.api-code-tab--active {
  color: var(--fg);
  border-bottom-color: var(--fg);
}

.api-code-panel {
  display: none;
  position: relative;
}

.api-code-panel--active {
  display: block;
}

.api-code-panel pre {
  background: var(--pre-bg);
  border-radius: 0 0 6px 6px;
  padding: 16px;
  margin: 0;
  overflow-x: auto;
}

.api-code-panel pre code {
  background: none;
  padding: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--fg);
}

.api-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 8px;
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.api-copy-btn:hover {
  border-color: var(--border-hover);
  color: var(--fg);
}

/* Response */
.api-response {
  margin-bottom: 16px;
}

.api-response__status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.api-status-code {
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
}

.api-status-code--2xx {
  background: rgba(34, 197, 94, 0.15);
  color: #16a34a;
}

.api-status-code--3xx {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}

.api-status-code--4xx {
  background: rgba(249, 115, 22, 0.15);
  color: #ea580c;
}

.api-status-code--5xx {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.api-status-code--default {
  background: var(--surface);
  color: var(--muted);
}

.api-response__desc {
  font-size: 13px;
  color: var(--muted);
}

.api-response__example pre {
  background: var(--pre-bg);
  border-radius: 6px;
  padding: 12px 16px;
  margin-top: 8px;
  overflow-x: auto;
}

.api-response__example pre code {
  background: none;
  padding: 0;
  font-size: 12px;
  line-height: 1.5;
}

/* Try It Panel */
.api-try-it {
  width: 420px;
  min-width: 360px;
  background: var(--pre-bg);
  border-left: 1px solid var(--border);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.api-try-it__title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
}

.api-try-it__url-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  overflow: hidden;
}

.api-try-it__url-display {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.api-try-it__server-select {
  background: none;
  border: none;
  color: var(--muted);
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
  padding: 2px 0;
  cursor: pointer;
  outline: none;
  max-width: 180px;
  flex-shrink: 1;
  min-width: 0;
}

.api-try-it__server-select option {
  background: var(--bg);
  color: var(--fg);
}

.api-try-it__path-display {
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.api-try-it__section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.api-try-it__section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
}

.api-try-it__param-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.api-try-it__param-info {
  display: flex;
  align-items: center;
  gap: 6px;
}

.api-try-it__param-name {
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--fg);
}

.api-try-it__param-in {
  font-size: 10px;
  color: var(--muted-fg);
  padding: 1px 5px;
  background: var(--surface);
  border-radius: 3px;
}

.api-try-it__param-input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--fg);
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
  outline: none;
  box-sizing: border-box;
}

.api-try-it__param-input:focus {
  border-color: var(--border-hover);
}

.api-try-it__param-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.api-try-it__param-input::placeholder {
  color: var(--muted-fg);
}

.api-try-it__body-editor {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  box-sizing: border-box;
}

.api-try-it__body-editor:focus {
  border-color: var(--border-hover);
}

.api-try-it__send-btn {
  width: 100%;
  padding: 8px 16px;
  background: var(--accent, #6366f1);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.api-try-it__send-btn:hover {
  opacity: 0.9;
}

.api-try-it__send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.api-try-it__response {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg);
}

.api-try-it__response--hidden {
  display: none;
}

.api-try-it__response-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.api-try-it__response-status {
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
}

.api-try-it__response-status--2xx {
  background: rgba(34, 197, 94, 0.15);
  color: #16a34a;
}

.api-try-it__response-status--3xx {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}

.api-try-it__response-status--4xx {
  background: rgba(249, 115, 22, 0.15);
  color: #ea580c;
}

.api-try-it__response-status--5xx,
.api-try-it__response-status--error {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.api-try-it__response-time {
  font-size: 12px;
  color: var(--muted);
  margin-left: auto;
}

.api-try-it__response-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.api-try-it__rtab {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  cursor: pointer;
}

.api-try-it__rtab:hover {
  color: var(--fg);
}

.api-try-it__rtab--active {
  color: var(--fg);
  border-bottom-color: var(--fg);
}

.api-try-it__rpanel {
  display: none;
}

.api-try-it__rpanel--active {
  display: block;
}

.api-try-it__rpanel pre {
  margin: 0;
  padding: 12px;
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
}

.api-try-it__rpanel pre code {
  font-size: 12px;
  line-height: 1.5;
  color: var(--fg);
  background: none;
  padding: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Mobile Sidebar for API */
.api-mobile-toggle {
  display: none;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.api-mobile-toggle button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
}

/* Responsive */
@media (max-width: 1024px) {
  .api-sidebar {
    display: none;
  }

  .api-mobile-toggle {
    display: block;
    position: sticky;
    top: 81px;
    z-index: 40;
    background: var(--bg);
  }

  .api-sidebar--mobile-open {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    z-index: 100;
    background: var(--bg);
    border-right: 1px solid var(--border);
  }

  .api-content {
    padding: 20px 16px;
  }

  .api-operation__summary {
    display: none;
  }

  .api-operation__body {
    flex-direction: column;
  }

  .api-try-it {
    width: 100%;
    min-width: 0;
    border-left: none;
    border-top: 1px solid var(--border);
  }
}
