/* ============================================================
   layout.css — App shell: sidebar, topbar, page containers
   ============================================================ */

/* ── View switcher ── */
.view { display: none; min-height: 100vh; }
.view.active { display: flex; }

/* ── App wrapper ── */
#view-app { flex-direction: column; background: var(--surface); }
.app-row   { display: flex; flex: 1; }

/* ════════════════════════════════════
   SIDEBAR
════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
}

/* Sidebar logo */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 24px 20px;
  border-bottom: 1px solid var(--sidebar-border);
}
.logo-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.logo-text {
  font-family: 'Syne', sans-serif;
  font-size: 20px;
  font-weight: 800;
  color: white;
  letter-spacing: -0.3px;
}

/* Sidebar search */
.sidebar-search { padding: 16px 16px 12px; }
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-sm);
  cursor: text;
  transition: var(--transition);
}
.search-box:hover, .search-box:focus-within {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.15);
}
.search-box input {
  background: none; border: none; outline: none;
  color: white;
  font-family: 'Manrope', sans-serif;
  font-size: 13px;
  flex: 1;
}
.search-box input::placeholder { color: rgba(255,255,255,0.25); }
.search-icon { color: rgba(255,255,255,0.3); font-size: 14px; }

/* Sidebar nav sections */
.sidebar-section { padding: 8px 12px 4px; }
.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-sidebar-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 0 8px;
  margin-bottom: 4px;
}

/* Nav items */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
  margin-bottom: 2px;
  color: var(--text-sidebar);
  font-size: 13.5px;
  font-weight: 500;
  user-select: none;
}
.nav-item:hover  { background: var(--sidebar-hover); color: white; }
.nav-item.active { background: var(--sidebar-active); color: white; }
.nav-item.active .nav-icon { color: var(--accent); }
.nav-icon  { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--accent); color: white;
  font-size: 10px; font-weight: 700;
  padding: 2px 6px; border-radius: 10px;
}
.sidebar-divider { height: 1px; background: var(--sidebar-border); margin: 8px 16px; }

/* Sidebar bottom / user card */
.sidebar-bottom {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid var(--sidebar-border);
}
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}
.user-card:hover { background: var(--sidebar-hover); }
.user-avatar-wrap { position: relative; flex-shrink: 0; }
.user-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, #8B5CF6, #EC4899);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: white;
}
/* Kingschat online indicator */
.kc-online-dot {
  position: absolute;
  bottom: -1px; right: -1px;
  width: 10px; height: 10px;
  background: var(--kc-green);
  border-radius: 50%;
  border: 2px solid var(--sidebar-bg);
}
.user-info   { flex: 1; min-width: 0; }
.user-name   { font-size: 13px; font-weight: 600; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role   { font-size: 11px; color: var(--text-sidebar-muted); }
.user-menu-btn { color: var(--text-sidebar-muted); font-size: 14px; }

/* ════════════════════════════════════
   TOPBAR
════════════════════════════════════ */
.topbar {
  height: var(--topbar-height);
  background: white;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 0 var(--border);
}
.topbar-hamburger {
  display: none;
  width: 36px; height: 36px;
  border: none;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text-primary);
  flex-shrink: 0;
}
.topbar-title {
  font-family: 'Syne', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}
.topbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 280px;
  margin-left: 8px;
}
.topbar-search input {
  background: none; border: none; outline: none;
  font-family: 'Manrope', sans-serif;
  font-size: 13px; color: var(--text-primary); flex: 1;
}
.topbar-search input::placeholder { color: var(--text-muted); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar-btn {
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  background: white;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--text-secondary);
  transition: var(--transition-fast);
  position: relative;
}
.topbar-btn:hover { background: var(--surface-2); color: var(--text-primary); }

/* ════════════════════════════════════
   MAIN CONTENT + PAGE CONTAINERS
════════════════════════════════════ */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-content { flex: 1; padding: 28px; display: none; }
.page-content.active { display: block; }

/* Special pages that need flex layout (no padding, full height) */
.page-content.flex-page {
  padding: 0 !important;
  height: calc(100vh - var(--topbar-height));
  display: none;
  flex-direction: column;
}
.page-content.flex-page.active { display: flex; }

/* ── Project / folder grids ── */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.folders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
}

/* ── Mobile sidebar overlay ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

/* ── Mobile bottom nav ── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 60px;
  background: var(--sidebar-bg);
  border-top: 1px solid rgba(255,255,255,0.06);
  z-index: 200;
}
.bottom-nav-inner { display: flex; height: 100%; }
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  transition: var(--transition-fast);
  color: rgba(255,255,255,0.4);
  font-size: 10px;
  font-weight: 600;
}
.bottom-nav-item.active { color: var(--accent); }
.bottom-nav-item .bn-icon { font-size: 20px; }
