/* ═══════════════════════════════════════
   DASHBOARD LAYOUT — Sidebar + Main
   ═══════════════════════════════════════ */

.dashboard {
  display: none;
  min-height: 100vh;
}

/* ── SIDEBAR ── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.25s ease;
}

.sidebar.collapsed {
  transform: translateX(calc(-1 * var(--sidebar-w)));
}

.sidebar-header {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
  flex-shrink: 0;
}

.sidebar-logo {
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: white;
  flex-shrink: 0;
}

.sidebar-brand {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.sidebar-brand-dim {
  color: var(--text-muted);
  font-weight: 400;
}

/* ── SIDEBAR NAV ── */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0;
}

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

.nav-group-label {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 7px 18px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  background: none;
  border: none;
  font-family: inherit;
  text-align: left;
}

.nav-group-label:hover {
  color: var(--text-secondary);
}

.nav-chevron {
  margin-left: auto;
  font-size: 10px;
  transition: transform 0.2s ease;
}

.nav-group.collapsed .nav-chevron {
  transform: rotate(-90deg);
}

.nav-group.collapsed .nav-group-items {
  display: none;
}

.nav-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 7px 18px 7px 26px;
  gap: 9px;
  font-size: 13.5px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.12s ease;
  border: none;
  border-left: 2px solid transparent;
  background: none;
  font-family: inherit;
  text-align: left;
}

.nav-item:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.nav-item.active {
  color: var(--text-primary);
  background: var(--accent-glow);
  border-left-color: var(--accent);
}

.nav-icon {
  width: 18px;
  text-align: center;
  font-size: 14px;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  padding: 1px 7px;
  border-radius: 10px;
}

.nav-item.active .nav-badge {
  background: var(--accent);
  color: white;
}

/* ── SIDEBAR FOOTER ── */
.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  flex-shrink: 0;
}

.sidebar-server-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  margin-bottom: 8px;
}

.server-dot {
  width: 7px;
  height: 7px;
  background: var(--text-muted);
  border-radius: 50%;
  flex-shrink: 0;
  transition: all 0.3s;
}

.server-dot.online {
  background: var(--green);
  box-shadow: 0 0 6px rgba(0, 214, 143, 0.4);
  animation: pulse-dot 2.5s ease infinite;
}

.server-dot.offline {
  background: var(--red);
}

@keyframes pulse-dot {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.server-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.server-value {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.server-dot.online ~ .server-value {
  color: var(--green);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius);
}

.sidebar-avatar {
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-username {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.sidebar-logout {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.15s;
  flex-shrink: 0;
}

.sidebar-logout:hover {
  color: var(--red);
  background: var(--red-dim);
}

/* ── TOPBAR ── */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 90;
  gap: 12px;
}

.topbar-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}

.topbar-menu-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.topbar-breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
}

.topbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-right {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

.topbar-btn {
  height: 32px;
  padding: 0 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.12s;
}

.topbar-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

/* ── MAIN CONTENT ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  transition: margin-left 0.25s ease;
}

.sidebar.collapsed ~ .main-content {
  margin-left: 0;
}

.container {
  max-width: 1400px;
  margin: 24px auto;
  padding: 0 24px;
}

/* When editor is open, worldsSection breaks out of the normal flow and
   fills the viewport area to the right of the sidebar, below the topbar */
#worldsSection.editor-open {
  position: fixed;
  top: var(--topbar-h);
  left: var(--sidebar-w);
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10;
  background: #12121a;
}

.sidebar.collapsed ~ .main-content #worldsSection.editor-open {
  left: 0;
}

.section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.section h2 {
  margin-bottom: 10px;
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 600;
}

/* ── RESPONSIVE ── */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-w)));
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .topbar-menu-btn {
    display: block;
  }
}
