/* Layout global — shell (sidebar + topbar + main), scrollbars, modais */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  transition: background var(--transition), color var(--transition);
}

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---------- Shell ---------- */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
  transition: grid-template-columns var(--transition);
}
.app-shell.sidebar-collapsed {
  grid-template-columns: var(--sidebar-width-collapsed) 1fr;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 20;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-brand .logo-mark {
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 13px;
}
.sidebar-brand .brand-text {
  font-weight: 700;
  font-size: 14.5px;
  letter-spacing: -.01em;
}
.app-shell.sidebar-collapsed .sidebar-brand .brand-text,
.app-shell.sidebar-collapsed .nav-label,
.app-shell.sidebar-collapsed .nav-section-title,
.app-shell.sidebar-collapsed .sync-text {
  display: none;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
}
.nav-section { margin-bottom: 18px; }
.nav-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  padding: 6px 10px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  transition: background var(--transition), color var(--transition);
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); }
.nav-item.disabled { opacity: .5; cursor: not-allowed; }
.nav-item.disabled:hover { background: none; color: var(--text-muted); }
.nav-item .nav-icon {
  width: 18px; height: 18px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
}
.nav-badge {
  margin-left: auto;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  background: var(--bg-hover);
  color: var(--text-muted);
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sync-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--offline);
  flex-shrink: 0;
  box-shadow: 0 0 0 3px transparent;
  transition: background var(--transition);
}
.sync-dot.online { background: var(--online); }
.sync-text { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* ---------- Topbar ---------- */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 15;
}
.icon-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
  transition: background var(--transition), color var(--transition);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

.topbar-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.01em;
}
.topbar-spacer { flex: 1; }
.topbar-updated {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ---------- Main content ---------- */
.main-content {
  padding: 20px 24px 40px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

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

.placeholder-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 80px 20px;
  color: var(--text-muted);
  text-align: center;
}
.placeholder-view .placeholder-icon { font-size: 40px; opacity: .5; }
.placeholder-view h2 { color: var(--text); margin: 0; font-size: 18px; }

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 0 1fr; }
  .app-shell .sidebar { position: fixed; left: 0; width: var(--sidebar-width); transform: translateX(-100%); transition: transform var(--transition); }
  .app-shell.sidebar-open .sidebar { transform: translateX(0); box-shadow: var(--shadow-md); }
  .app-shell.sidebar-open::after {
    content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 15;
  }
}
