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

:root {
  --bg: #ffffff;
  --bg-subtle: #f8f9fb;
  --bg-muted: #f1f3f5;
  --border: #e2e5e9;
  --border-focus: #0052ff;
  --text: #1a1d21;
  --text-secondary: #5e6368;
  --text-muted: #8b9099;
  --accent: #00b341;
  --accent-hover: #009936;
  --danger: #dc2626;
  --blue: #0052ff;
  --mono: 'JetBrains Mono', 'SF Mono', monospace;
  --sans: 'Inter', -apple-system, system-ui, sans-serif;
  --radius: 6px;
  --radius-lg: 8px;
}

html { font-size: 14px; }
body {
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* === Top Bar === */
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-left { flex-shrink: 0; }

.endpoint-select {
  font-family: var(--sans);
  font-size: 13px;
  padding: 6px 28px 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  max-width: 340px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%235e6368'%3E%3Cpath d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
.endpoint-select:focus { outline: none; border-color: var(--border-focus); }

.topbar-url {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  padding: 5px 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 13px;
  overflow: hidden;
}

.method-pill {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: #e8f0fe;
  color: var(--blue);
  flex-shrink: 0;
  text-transform: uppercase;
}

.url-path {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-secondary);
}

.send-btn {
  flex-shrink: 0;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 14px;
  padding: 7px 24px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
}
.send-btn:hover:not(:disabled) { background: var(--accent-hover); }
.send-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* === Main Layout === */
.main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.left-pane {
  width: 380px;
  min-width: 300px;
  flex-shrink: 0;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding: 12px 0;
}

.right-pane {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* === Endpoint description === */
.endpoint-desc {
  padding: 0 16px 8px;
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

.server-summary {
  padding: 10px 16px 12px;
  background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
  border-bottom: 1px solid var(--border);
}

.server-summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  margin-bottom: 4px;
}

.server-summary-row:last-child {
  margin-bottom: 0;
}

.server-summary-label {
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.server-summary-value {
  color: var(--text);
  font-weight: 500;
  text-align: right;
}

/* === Param Sections === */
.param-section {
  border-bottom: 1px solid var(--border);
}
.param-section[hidden] { display: none; }

.section-title {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.section-title::-webkit-details-marker { display: none; }
.section-title::before {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 4px solid var(--text-muted);
  border-top: 3px solid transparent;
  border-bottom: 3px solid transparent;
  margin-right: 8px;
  transition: transform 0.15s;
}
details[open] > .section-title::before {
  transform: rotate(90deg);
}

.section-body {
  padding: 0 16px 12px;
}

/* === Field Rows === */
.field-row {
  margin-bottom: 12px;
}
.field-row:last-child { margin-bottom: 0; }

.field-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.field-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.field-type {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--mono);
  margin-left: 6px;
}

.field-required {
  font-size: 11px;
  font-weight: 600;
  color: var(--danger);
}

.field-optional {
  font-size: 11px;
  color: var(--text-muted);
}

.field-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
  line-height: 1.4;
  white-space: pre-wrap;
}

.field-input {
  width: 100%;
  font-family: var(--mono);
  font-size: 13px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s;
}
.field-input:focus {
  outline: none;
  border-color: var(--border-focus);
}
.field-input::placeholder { color: var(--text-muted); }

.field-select {
  width: 100%;
  font-family: var(--sans);
  font-size: 13px;
  padding: 6px 32px 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%235e6368'%3E%3Cpath d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.field-select:focus {
  outline: none;
  border-color: var(--border-focus);
}

/* === Wallet === */
.connect-btn {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  padding: 3px 12px;
  border: 1px solid var(--blue);
  border-radius: var(--radius);
  background: transparent;
  color: var(--blue);
  cursor: pointer;
  transition: all 0.15s;
}
.connect-btn:hover { background: #e8f0fe; }

.wallet-status {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}
.wallet-addr {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-secondary);
  word-break: break-all;
}
.wallet-chain {
  font-size: 11px;
  color: var(--text-muted);
}

/* === Right Pane: Results === */
.result-section {
  border-bottom: 1px solid var(--border);
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
}
.result-header.clickable { cursor: pointer; list-style: none; }
.result-header.clickable::-webkit-details-marker { display: none; }

.result-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.copy-btn {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.copy-btn:hover { border-color: var(--text-muted); color: var(--text); }

.status-tabs {
  display: flex;
  gap: 4px;
}

.status-tab {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  padding: 2px 10px;
  border-radius: 4px;
  color: var(--text-muted);
  background: transparent;
}
.status-tab.active { background: var(--bg-muted); color: var(--text); }
.status-tab.success { background: #dcfce7; color: #166534; }
.status-tab.error { background: #fee2e2; color: #991b1b; }

.code-block {
  margin: 0;
  padding: 12px 16px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
}
.code-block.small { max-height: 200px; font-size: 11px; }

.response-body {
  flex: 1;
  min-height: 120px;
}

.result-response { flex: 1; display: flex; flex-direction: column; }
.result-response .code-block { flex: 1; }

.action-notice {
  padding: 6px 16px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-subtle);
  display: none;
}
.action-notice.visible { display: block; }
.action-notice.error { color: var(--danger); background: #fff5f5; }

/* === Payment Details === */
.payment-details { padding: 0; }
.detail-block { border-bottom: 1px solid var(--border); }
.detail-block:last-child { border-bottom: none; }
.detail-label {
  display: block;
  padding: 6px 16px 0;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

/* === Meta Info === */
.meta-info { display: flex; flex-direction: column; gap: 6px; }
.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.meta-key { font-size: 12px; color: var(--text-muted); }
.meta-val { font-size: 12px; font-weight: 500; font-family: var(--mono); color: var(--text); }

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.tag-pill {
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 99px;
  background: var(--bg-muted);
  color: var(--text-secondary);
}

/* === Empty state for sections with no params === */
.no-params {
  padding: 8px 0;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* === Scrollbar === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* === Responsive === */
@media (max-width: 768px) {
  .main { flex-direction: column; }
  .left-pane { width: 100%; border-right: none; border-bottom: 1px solid var(--border); max-height: 50vh; }
  .topbar-url { display: none; }
  .endpoint-select { max-width: none; flex: 1; }
}
