/* ==========================================================================
   Keith APIs — shared design system
   A dark "console" aesthetic built around the idea that this is a live
   request bench: every endpoint is a row you can run, like a terminal
   command, not a table of links.
   ========================================================================== */

:root {
  /* --- palette --- */
  --bg: #0a0c10;
  --bg-raised: #10131a;
  --surface: #141821;
  --surface-2: #191e28;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);

  --text: #eef0f3;
  --text-muted: #8b93a3;
  --text-faint: #5c6472;

  --accent: #00e5a0;        /* signal green — success / primary action */
  --accent-dim: rgba(0, 229, 160, 0.12);
  --violet: #7c5cff;        /* secondary accent */
  --violet-dim: rgba(124, 92, 255, 0.14);
  --danger: #ff5c73;
  --danger-dim: rgba(255, 92, 115, 0.12);
  --warn: #ffb454;
  --warn-dim: rgba(255, 180, 84, 0.12);

  /* --- type --- */
  --font-display: 'Space Grotesk', 'Inter', sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;

  /* --- layout --- */
  --sidebar-w: 264px;
  --topbar-h: 64px;
  --radius: 10px;
  --radius-lg: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(circle at 15% 0%, rgba(124, 92, 255, 0.08), transparent 40%),
    radial-gradient(circle at 85% 10%, rgba(0, 229, 160, 0.06), transparent 35%);
  background-attachment: fixed;
  min-height: 100vh;
}

a { color: inherit; }

::selection { background: var(--accent-dim); color: var(--accent); }

/* focus visibility, kept even though we style buttons custom */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ==========================================================================
   Topbar
   ========================================================================== */

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0 1rem;
  background: rgba(10, 12, 16, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 200;
}

.topbar-toggle {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.topbar-toggle:hover { border-color: var(--border-strong); color: var(--accent); }

.topbar-brand {
  display: flex; align-items: center; gap: 0.55rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  text-decoration: none;
  white-space: nowrap;
}
.topbar-brand .dot { color: var(--accent); }

.topbar-spacer { flex: 1; }

.topbar-status {
  display: flex; align-items: center; gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}
.topbar-status .pulse {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(0,229,160,.7);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(0,229,160,.55); }
  70%  { box-shadow: 0 0 0 6px rgba(0,229,160,0); }
  100% { box-shadow: 0 0 0 0 rgba(0,229,160,0); }
}

.topbar-profile img {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  display: block;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */

.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  padding: 1rem 0.9rem 1.5rem;
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  z-index: 220;
}
.sidebar.open { transform: translateX(0); }

.sidebar-head {
  display: flex; align-items: center; gap: 0.6rem;
  height: var(--topbar-h);
  padding: 0 0.35rem;
  margin-bottom: 0.5rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1rem;
}
.sidebar-head .dot { color: var(--accent); }
.sidebar-close {
  margin-left: auto;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.sidebar-close:hover { border-color: var(--border); color: var(--text); }

.nav-heading {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 1.1rem 0.6rem 0.4rem;
}

.nav-link {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.55rem 0.6rem;
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  margin-bottom: 2px;
  border: 1px solid transparent;
}
.nav-link i { font-size: 1rem; width: 1.1rem; text-align: center; color: var(--text-faint); }
.nav-link:hover { background: var(--surface); color: var(--text); }
.nav-link:hover i { color: var(--accent); }
.nav-link.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: rgba(0, 229, 160, 0.25);
}
.nav-link.active i { color: var(--accent); }

.sidebar-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 210;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.sidebar-overlay.show { opacity: 1; pointer-events: auto; }

@media (min-width: 960px) {
  .sidebar { transform: translateX(0); }
  .sidebar-overlay { display: none; }
  .sidebar-close { display: none; }
  .content, footer.site-footer { margin-left: var(--sidebar-w); }
  .topbar-toggle { display: none; }
}

/* ==========================================================================
   Content shell
   ========================================================================== */

.content {
  padding: calc(var(--topbar-h) + 1.25rem) 1.1rem 2.5rem;
  max-width: 1080px;
}

@media (min-width: 640px) {
  .content { padding: calc(var(--topbar-h) + 1.75rem) 2rem 3rem; }
}

.page-head {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 1.4rem;
  flex-wrap: wrap;
}
.page-head-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--violet-dim);
  color: var(--violet);
  font-size: 1.3rem;
  flex-shrink: 0;
}
.page-head h1 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  margin: 0 0 0.15rem;
}
.page-sub { color: var(--text-muted); font-size: 0.85rem; margin: 0; }
.page-head-stats {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
}
.page-head-stats b { color: var(--accent); font-weight: 700; }

.disclaimer-bar {
  display: flex; gap: 0.6rem; align-items: flex-start;
  background: var(--warn-dim);
  border: 1px solid rgba(255,180,84,.25);
  color: #ffd8a3;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius);
  font-size: 0.82rem;
  margin-bottom: 1.2rem;
}
.disclaimer-bar i { color: var(--warn); margin-top: 0.1rem; }

/* ==========================================================================
   Toolbar (filter + base url)
   ========================================================================== */

.toolbar {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
  margin-bottom: 1.1rem;
}

.search-box {
  flex: 1 1 240px;
  display: flex; align-items: center; gap: 0.55rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.8rem;
}
.search-box i { color: var(--text-faint); }
.search-box input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 0.88rem;
  font-family: var(--font-body);
}
.search-box input::placeholder { color: var(--text-faint); }

.base-url-chip {
  display: flex; align-items: center; gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.8rem;
  white-space: nowrap;
  overflow: hidden;
}
.base-url-chip i { color: var(--accent); }
.base-url-chip span { overflow: hidden; text-overflow: ellipsis; }

/* ==========================================================================
   Endpoint list ("request rows")
   ========================================================================== */

.endpoint-list { display: flex; flex-direction: column; gap: 0.55rem; }

.endpoint-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color .15s ease;
}
.endpoint-row:hover { border-color: var(--border-strong); }

.endpoint-row-main {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.7rem 0.85rem;
}

.method-badge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent);
  background: var(--accent-dim);
  border-radius: 6px;
  padding: 0.2rem 0.4rem;
  flex-shrink: 0;
}

.endpoint-info { min-width: 0; flex: 1; }
.endpoint-name {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0 0 0.15rem;
  color: var(--text);
}
.endpoint-path {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--violet);
  margin: 0 0 0.2rem;
  overflow-wrap: anywhere;
}
.endpoint-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0;
  overflow-wrap: anywhere;
}

.endpoint-actions {
  display: flex; align-items: center; gap: 0.4rem;
  flex-shrink: 0;
}

.icon-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 0.85rem;
  text-decoration: none;
}
.icon-btn:hover { border-color: var(--border-strong); color: var(--text); }

.run-btn {
  display: flex; align-items: center; gap: 0.4rem;
  background: var(--accent);
  color: #06110d;
  border: none;
  border-radius: 8px;
  padding: 0.45rem 0.8rem;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
}
.run-btn:hover { filter: brightness(1.08); }
.run-btn:disabled { opacity: 0.6; cursor: progress; filter: none; }
.run-btn .bi { font-size: 0.75rem; }

.spinner {
  width: 13px; height: 13px;
  border-radius: 50%;
  border: 2px solid rgba(6,17,13,.35);
  border-top-color: #06110d;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* response console */
.response-console {
  display: none;
  border-top: 1px solid var(--border);
  padding: 0.8rem 0.85rem 0.9rem;
  background: #08090c;
  border-radius: 0 0 var(--radius) var(--radius);
}
.response-console.open { display: block; }

.status-line {
  display: flex; align-items: center; gap: 0.7rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
  flex-wrap: wrap;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); flex-shrink:0; }
.status-dot.ok { background: var(--accent); }
.status-dot.err { background: var(--danger); }
.status-line .code.ok { color: var(--accent); }
.status-line .code.err { color: var(--danger); }

.response-actions { margin-left: auto; display: flex; gap: 0.35rem; }
.response-actions .icon-btn { width: 28px; height: 28px; font-size: 0.75rem; }

.response-body {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  line-height: 1.5;
  color: #d3e9df;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 340px;
  overflow: auto;
  margin: 0;
  padding: 0.7rem;
  background: #0c0e12;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.response-body .k { color: var(--violet); }
.response-body .s { color: var(--accent); }
.response-body .n { color: var(--warn); }
.response-body .b { color: #7dd3fc; }

.response-media { max-width: 100%; border-radius: 8px; border: 1px solid var(--border); display: block; }

/* skeleton loading state */
.skel-row {
  height: 62px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 37%, var(--surface) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
}
.empty-state i { font-size: 1.6rem; color: var(--text-faint); display: block; margin-bottom: 0.6rem; }

/* toast */
.toast {
  position: fixed;
  bottom: 1.1rem; left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 0.6rem 1rem;
  border-radius: 999px;
  font-size: 0.82rem;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 500;
  display: flex; align-items: center; gap: 0.5rem;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast i { color: var(--accent); }

/* footer */
footer.site-footer {
  padding: 1.3rem 1rem;
  text-align: center;
  color: var(--text-faint);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}

/* generic card, used on dashboard */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.2rem;
}
.card-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--text);
  margin: 0 0 0.7rem;
  display: flex; align-items: center; gap: 0.5rem;
}
.card-title i { color: var(--accent); }
