/* API Explorer — Terminal-style interactive API explorer */

.explorer-layout {
  display: grid;
  grid-template-columns: 22ch 1fr;
  gap: 0;
  min-height: calc(100vh - 6rem);
}

/* ── Sidebar ── */
.explorer-sidebar {
  border-right: 1px solid var(--border);
  padding: 1rem 0;
  overflow-y: auto;
}

.explorer-sidebar h2 {
  padding: 0 1rem;
  margin-bottom: 1rem;
  font-size: 0.8rem;
}

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

.endpoint-item {
  display: block;
  width: 100%;
  background: none;
  border: none;
  border-left: 2px solid transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.4rem 1rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.endpoint-item:hover {
  color: var(--text);
  background: var(--bg-lighter);
}

.endpoint-item.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--bg-lighter);
}

.endpoint-method {
  font-size: 0.7rem;
  font-weight: bold;
  margin-right: 0.5ch;
  color: var(--accent);
}

/* ── Main Panel ── */
.explorer-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Request Section ── */
.explorer-request {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.explorer-endpoint-bar {
  display: flex;
  align-items: center;
  gap: 1ch;
  margin-bottom: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  overflow-x: auto;
}

.explorer-method-badge {
  color: var(--accent);
  font-weight: bold;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.explorer-url {
  color: var(--text-muted);
  white-space: nowrap;
}

.explorer-desc {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

/* Parameter inputs */
.param-group {
  margin-bottom: 0.75rem;
}

.param-label {
  display: flex;
  align-items: center;
  gap: 1ch;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
}

.param-name {
  color: var(--accent);
}

.param-required {
  color: var(--taken);
  font-size: 0.7rem;
}

.param-optional {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.param-type {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.param-desc {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-bottom: 0.25rem;
}

.param-input {
  width: 100%;
  max-width: 40ch;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.75rem;
  font-family: inherit;
  font-size: 0.85rem;
}

.param-input:focus {
  outline: none;
  border-color: var(--accent);
}

.param-input::placeholder {
  color: #555;
}

.param-input.invalid {
  border-color: var(--taken);
}

/* Action buttons row */
.explorer-actions {
  display: flex;
  gap: 1ch;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.btn-send {
  background: var(--bg);
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 0.5rem 1.5rem;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-send:hover {
  background: var(--accent);
  color: var(--bg);
}

.btn-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-send:disabled:hover {
  background: var(--bg);
  color: var(--accent);
}

.btn-secondary {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

/* ── Response Section ── */
.explorer-response {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 1.5rem;
}

.response-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.response-meta {
  display: flex;
  gap: 2ch;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.response-status {
  font-weight: bold;
}

.response-status.ok { color: var(--accent); }
.response-status.err { color: var(--taken); }

.response-actions {
  display: flex;
  gap: 1ch;
}

.response-actions button {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.25rem 0.75rem;
  font-family: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.1s;
}

.response-actions button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.response-viewer {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  overflow: auto;
  position: relative;
}

.response-viewer pre {
  margin: 0;
  padding: 1rem;
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.response-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 10rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* JSON syntax highlighting (terminal style) */
.json-key { color: var(--accent); }
.json-str { color: #ffd700; }
.json-num { color: #ff79c6; }
.json-bool { color: #8be9fd; }
.json-null { color: var(--text-muted); }
.json-brace { color: var(--text-muted); }

/* ── History Panel ── */
.explorer-history {
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
  max-height: 12rem;
  overflow-y: auto;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.history-header h3 {
  font-size: 0.8rem;
  font-weight: normal;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.history-clear {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0;
}

.history-clear:hover {
  color: var(--taken);
}

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

.history-entry {
  display: flex;
  align-items: center;
  gap: 1ch;
  padding: 0.25rem 0;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--text-muted);
  border: none;
  background: none;
  font-family: inherit;
  width: 100%;
  text-align: left;
}

.history-entry:hover {
  color: var(--text);
}

.history-status {
  font-size: 0.7rem;
  font-weight: bold;
}

.history-status.ok { color: var(--accent); }
.history-status.err { color: var(--taken); }

.history-time {
  color: #555;
  margin-left: auto;
  flex-shrink: 0;
}

/* ── Mobile Toggle ── */
.explorer-sidebar-toggle {
  display: none;
  background: var(--bg-lighter);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 1rem;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  width: 100%;
  text-align: left;
}

.explorer-sidebar-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Copied feedback ── */
.copied-flash {
  color: var(--accent) !important;
  border-color: var(--accent) !important;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .explorer-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .explorer-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 0;
  }

  .explorer-sidebar h2 {
    display: none;
  }

  .explorer-sidebar-toggle {
    display: block;
  }

  .endpoint-list {
    display: none;
    padding-bottom: 0.5rem;
  }

  .endpoint-list.open {
    display: block;
  }

  .explorer-request,
  .explorer-response {
    padding: 1rem;
  }

  .explorer-history {
    padding: 1rem;
  }

  .param-input {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .explorer-endpoint-bar {
    font-size: 0.8rem;
    padding: 0.4rem 0.75rem;
  }

  .explorer-actions {
    flex-direction: column;
  }

  .explorer-actions button {
    width: 100%;
    text-align: center;
  }

  .response-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
