/* ── App shell grid ────────────────────────────────────────────────────────── */
.nexus-shell {
  display: grid;
  grid-template-rows: var(--topbar-h, 40px) 1fr var(--statusbar-h, 28px);
  grid-template-columns: var(--sidebar-left-w, 220px) 1fr var(--sidebar-right-w, 0px);
  grid-template-areas:
    "topbar    topbar  topbar"
    "sidebar-l main    sidebar-r"
    "statusbar statusbar statusbar";
  height: 100dvh;
  overflow: hidden;
}

/* ── Topbar ─────────────────────────────────────────────────────────────────── */
.nexus-topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  z-index: 100;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.topbar-center {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* ── Left sidebar ──────────────────────────────────────────────────────────── */
.nexus-sidebar-left {
  grid-area: sidebar-l;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  overflow: hidden;
  z-index: 90;
  transition: width 200ms ease, transform 200ms ease;
}

.nexus-sidebar-left.collapsed {
  width: 0 !important;
  border-right-width: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo-mark {
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-primary);
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 16px;
  color: var(--sidebar-text);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 0;
  transition: background 100ms ease, color 100ms ease;
  position: relative;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

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

.sidebar-nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.sidebar-nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke-width: 1.75;
}

.sidebar-nav-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 16px;
}

.sidebar-footer {
  padding: 8px 0;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-badge {
  margin-left: auto;
  background: var(--accent);
  color: var(--text-inverse);
  font-size: 0.625rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ── Main content ──────────────────────────────────────────────────────────── */
.nexus-main {
  grid-area: main;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-base);
  position: relative;
}

/* ── Right sidebar ─────────────────────────────────────────────────────────── */
.nexus-sidebar-right {
  grid-area: sidebar-r;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  overflow: hidden;
  z-index: 90;
  transition: width 200ms ease;
}

.nexus-sidebar-right.hidden {
  width: 0 !important;
  border-left-width: 0;
}

/* ── Statusbar ─────────────────────────────────────────────────────────────── */
.nexus-statusbar {
  grid-area: statusbar;
  display: flex;
  align-items: center;
  background: var(--statusbar-bg);
  border-top: 1px solid var(--border);
  color: var(--statusbar-text);
  font-size: 0.75rem;
  z-index: 100;
  overflow: hidden;
}

.statusbar-zone {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
}

.statusbar-zone-left { flex: 1; }
.statusbar-zone-center { flex: 1; justify-content: center; }
.statusbar-zone-right { flex: 1; justify-content: flex-end; }

/* ── Breadcrumb ────────────────────────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  min-width: 0;
}

.breadcrumb-item {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.breadcrumb-sep {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.breadcrumb-item:last-child {
  color: var(--text-primary);
  font-weight: 500;
}

/* ── WS status dot ─────────────────────────────────────────────────────────── */
.ws-status {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--success);
  flex-shrink: 0;
}
.ws-status.connecting { background: var(--warning); }
.ws-status.disconnected { background: var(--danger); }

/* ── Topbar icon button ────────────────────────────────────────────────────── */
.topbar-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  transition: background 100ms ease, color 100ms ease;
  position: relative;
  flex-shrink: 0;
}
.topbar-btn:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}
.topbar-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ── Save status ───────────────────────────────────────────────────────────── */
.save-status {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  white-space: nowrap;
}
.save-status.saving { color: var(--warning); }
.save-status.saved { color: var(--success); }
.save-status.unsaved { color: var(--danger); }

/* ── Module content area ───────────────────────────────────────────────────── */
.module-container {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Overlay for drawers ───────────────────────────────────────────────────── */
.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
}
.drawer-overlay.visible { display: block; }
