*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --border: #2a2d3e;
  --accent: #6c63ff;
  --accent2: #00d4aa;
  --warn: #ff6b6b;
  --text: #e2e8f0;
  --muted: #7c8496;
  --code-bg: #0d1117;
  --green: #22c55e;
  --yellow: #facc15;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ── */
nav {
  width: 220px;
  min-width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0;
}

nav .logo {
  padding: 0 1.25rem 1.5rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1.25rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}

nav a:hover { color: var(--text); background: rgba(255,255,255,0.04); }
nav a.active { color: var(--text); border-left-color: var(--accent); background: rgba(108,99,255,0.1); }

nav .ws-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--warn);
  margin-left: auto;
  flex-shrink: 0;
}
nav .ws-dot.on { background: var(--green); box-shadow: 0 0 6px var(--green); }

nav .section-label {
  padding: 1.25rem 1.25rem 0.4rem;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

nav .api-base {
  padding: 0.5rem 1.25rem 0;
  font-size: 0.72rem;
  color: var(--muted);
  word-break: break-all;
}
nav .api-base input {
  width: 100%;
  background: var(--code-bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.35rem 0.5rem;
  font-size: 0.72rem;
  border-radius: 4px;
  margin-top: 0.25rem;
}

/* ── Mobile toggle ── */
.nav-toggle {
  display: none;
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 6px;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0;
}

.nav-close {
  display: none;
  align-self: flex-end;
  margin: -0.5rem 0.75rem 0.5rem auto;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  line-height: 1;
}

.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 149;
}

/* ── Main ── */
main {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  padding-bottom: 3rem;
}

.panel { display: none; }
.panel.active { display: block; }

h2 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

h3 {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 1.5rem 0 0.75rem;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
}

.card h3 { margin-top: 0; }

/* ── Inputs / Buttons ── */
.field { margin-bottom: 0.85rem; }
.field label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.3rem; }

input[type=text], input[type=file], select, textarea {
  width: 100%;
  background: var(--code-bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.55rem 0.75rem;
  font-size: 0.85rem;
  border-radius: 6px;
  font-family: inherit;
}

input[type=file] { padding: 0.4rem; cursor: pointer; }

button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  font: inherit;
  font-size: 0.85rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s;
}
button:hover { opacity: 0.85; }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-success { background: var(--accent2); color: #0f1117; font-weight: 600; }
.btn-danger  { background: var(--warn); color: #fff; }
.btn-ghost   { background: transparent; border: 1px solid var(--border); color: var(--text); }

.btn-row { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.75rem; }

/* ── Output / log ── */
.output {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  font-family: 'Cascadia Code', 'Fira Code', monospace;
  font-size: 0.78rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  min-height: 120px;
  max-height: 340px;
  overflow-y: auto;
  color: #a8d8a8;
}

.log-scroll {
  min-height: 180px;
  max-height: 400px;
}

.output .err { color: var(--warn); }
.output .muted { color: var(--muted); }
.output .hi { color: var(--accent2); }
.output .warn { color: var(--yellow); }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge-green { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-red   { background: rgba(255,107,107,0.15); color: var(--warn); }
.badge-blue  { background: rgba(108,99,255,0.15); color: var(--accent); }
.badge-yellow{ background: rgba(250,204,21,0.15); color: var(--yellow); }

/* ── Tables ── */
table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
th { text-align: left; padding: 0.5rem 0.75rem; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border); }
td { padding: 0.5rem 0.75rem; border-bottom: 1px solid rgba(255,255,255,0.04); vertical-align: top; }
tr:hover td { background: rgba(255,255,255,0.02); }

/* ── Tag pills ── */
.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tag {
  background: rgba(108,99,255,0.15);
  color: var(--accent);
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
}

/* ── Status bar ── */
.statusbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 26px;
  background: var(--accent);
  display: flex;
  align-items: center;
  padding: 0 1rem;
  font-size: 0.72rem;
  gap: 1.5rem;
  z-index: 99;
}
.statusbar span { opacity: 0.85; }
.statusbar .sep { opacity: 0.35; }

/* ── Health dot ── */
.health-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--warn);
  display: inline-block;
}
.health-dot.ok { background: var(--green); box-shadow: 0 0 6px var(--green); }

.doc-id-display {
  font-family: monospace;
  font-size: 0.78rem;
  color: var(--accent2);
  background: var(--code-bg);
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  word-break: break-all;
}

/* ── Swagger link ── */
nav .swagger-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1.25rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}
nav .swagger-link:hover { color: var(--text); background: rgba(255,255,255,0.04); }

/* ── Alert table scroll wrapper ── */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-scroll table { min-width: 520px; }

/* ── Responsive ── */
@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }

  .nav-toggle { display: inline-flex; }
  .nav-close  { display: block; }

  nav {
    position: fixed;
    top: 0; left: 0;
    height: 100%;
    z-index: 150;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: 240px;
    min-width: 240px;
  }

  nav.open { transform: translateX(0); }
  .nav-overlay.open { display: block; }

  main { padding-top: 3.5rem; }

  /* statusbar: allow wrap, auto height */
  .statusbar {
    height: auto;
    min-height: 26px;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.68rem;
  }

  /* hide separators on mobile so wrapping looks clean */
  .statusbar .sep { display: none; }
}
