:root {
  --bg-base: #090d16;
  --bg-surface: #101726;
  --bg-input: #1b263b;
  --border-color: #24334c;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.25);
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.2);
  --danger: #ef4444;
  --accent: #8b5cf6;
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}

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

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-base);
  color: var(--text-main);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-base);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

header {
  background-color: rgba(16, 23, 38, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-glow {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-gradient);
  box-shadow: 0 0 12px var(--primary);
  animation: pulse 2s infinite;
}

.logo-text {
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.5px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--success);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: blink 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.25); opacity: 1; }
}

@keyframes blink {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.main-layout {
  display: flex;
  flex: 1;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

aside {
  width: 280px;
  border-right: 1px solid var(--border-color);
  padding: 2rem;
  position: sticky;
  top: 70px;
  height: calc(100vh - 70px);
  overflow-y: auto;
}

.nav-group {
  margin-bottom: 2rem;
}

.nav-group-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
  transition: all 0.2s ease;
}

.nav-link:hover, .nav-link.active {
  color: var(--text-main);
  background-color: rgba(99, 102, 241, 0.1);
}

.nav-link.active {
  font-weight: 500;
  border-left: 2px solid var(--primary);
  border-radius: 0 6px 6px 0;
}

main {
  flex: 1;
  padding: 2rem 3rem;
  overflow-y: auto;
}

.section-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 2rem;
  margin-bottom: 2.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  letter-spacing: -0.5px;
}

h2 {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}

h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}

p {
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.endpoint-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  font-weight: 700;
  margin-right: 0.5rem;
}

.badge-get {
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-post {
  background-color: rgba(99, 102, 241, 0.15);
  color: var(--primary);
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.endpoint-container {
  background-color: var(--bg-base);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.endpoint-url {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  color: var(--text-main);
}

/* Grid layout */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 900px) {
  .main-layout { flex-direction: column; }
  aside { width: 100%; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--border-color); }
  .grid-2 { grid-template-columns: 1fr; }
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
}

th, td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

th {
  font-weight: 600;
  color: var(--text-main);
  background-color: rgba(27, 38, 59, 0.4);
}

td {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Code Snippets */
.code-block {
  background-color: #070b13;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.25rem;
  position: relative;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  overflow-x: auto;
  margin-bottom: 1.5rem;
}

.code-block pre {
  white-space: pre;
}

.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-muted);
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.2s;
}

.copy-btn:hover {
  background-color: var(--primary);
  color: var(--text-main);
}

/* Interactive playground panels */
.playground-panel {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.playground-header {
  background-color: rgba(27, 38, 59, 0.5);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.playground-title {
  font-weight: 600;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.playground-body {
  padding: 1.5rem;
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.5rem;
  min-height: 500px;
}

@media (max-width: 1024px) {
  .playground-body { grid-template-columns: 1fr; }
}

.control-column {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.input-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

.input-field {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.2s;
}

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

.btn {
  background-color: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.65rem 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  display: inline-block;
}

.btn:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 0 10px var(--primary-glow);
}

.btn-secondary {
  background-color: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.05);
  box-shadow: none;
}

.btn-danger {
  background-color: var(--danger);
}
.btn-danger:hover {
  background-color: #dc2626;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.25);
}

.btn:disabled {
  background-color: var(--border-color);
  color: var(--text-muted);
  cursor: not-allowed;
  box-shadow: none;
}

/* Terminal logs */
.terminal-column {
  display: flex;
  flex-direction: column;
  background-color: #050811;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  height: 100%;
}

.terminal-header {
  background-color: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.terminal-logs {
  padding: 1rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  height: 400px;
}

.log-entry {
  border-left: 2px solid var(--border-color);
  padding-left: 0.75rem;
  margin-bottom: 0.25rem;
}

.log-time {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-right: 0.5rem;
}

.log-info { border-color: var(--primary); }
.log-success { border-color: var(--success); }
.log-error { border-color: var(--danger); }
.log-warning { border-color: var(--accent); }

.log-event-tag {
  font-weight: 600;
  font-size: 0.75rem;
  padding: 0.05rem 0.25rem;
  border-radius: 3px;
  margin-right: 0.5rem;
}
.tag-joined { background-color: rgba(16, 185, 129, 0.2); color: var(--success); }
.tag-roster { background-color: rgba(99, 102, 241, 0.2); color: var(--primary); }
.tag-signal { background-color: rgba(139, 92, 246, 0.2); color: var(--accent); }

.json-key { color: #818cf8; }
.json-string { color: #34d399; }
.json-number { color: #f59e0b; }
.json-boolean { color: #f472b6; }
.json-null { color: #9ca3af; }

/* Roster UI list */
.roster-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 150px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.5rem;
  background-color: rgba(0, 0, 0, 0.2);
}

.roster-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  background-color: var(--bg-surface);
  border: 1px solid transparent;
}

.roster-item.self {
  border-color: var(--success);
  background-color: rgba(16, 185, 129, 0.05);
}

.roster-item-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--primary);
}
.roster-item.self .roster-item-dot {
  background-color: var(--success);
}

/* Tabs */
.tabs-nav {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
}

.tab-btn:hover, .tab-btn.active {
  color: var(--text-main);
  background-color: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
  background-color: var(--primary);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Links on doc */
.doc-link-btn {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  color: var(--text-main);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transition: all 0.2s;
}
.doc-link-btn:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
}
.doc-link-title {
  font-weight: 600;
  font-size: 1rem;
}
.doc-link-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}
