/* ── App shell ─────────────────────────────────────────── */
#app { display: flex; height: 100vh; width: 100%; overflow: hidden; }
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#page { flex: 1; overflow-y: auto; overflow-x: hidden; position: relative; }

/* ── Sidebar (escura) ──────────────────────────────────── */
#app-sidebar {
  width: var(--sidebar-w); flex: none;
  background: var(--side-bg);
  display: flex; flex-direction: column; gap: 4px;
  padding: 14px 12px; color: var(--side-fg);
  position: relative;
}

/* brand switcher */
.brand-switch {
  display: flex; align-items: center; gap: 11px; width: 100%;
  background: transparent; border: none; border-radius: 11px;
  padding: 9px; cursor: pointer; text-align: left; color: inherit;
  transition: background var(--duration) var(--ease);
}
.brand-switch:hover { background: rgba(255,255,255,.05); }
.bs-avatar {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; color: #fff;
}
.bs-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.bs-name { color: #fff; font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bs-handle { color: #7C7A72; font-size: 11.5px; }
.brand-switch svg { color: #7C7A72; }

/* brand dropdown */
.brand-menu {
  display: none; flex-direction: column; gap: 2px;
  background: var(--side-menu-bg); border: 1px solid var(--side-menu-border);
  border-radius: 12px; padding: 6px; margin: 2px 0 6px;
}
.brand-menu.open { display: flex; animation: rise .14s ease both; }
.bm-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: transparent; border: none; border-radius: 8px;
  padding: 7px 8px; cursor: pointer; text-align: left; color: inherit;
}
.bm-item:hover, .bm-item.active { background: rgba(255,255,255,.07); }
.bm-avatar { width: 24px; height: 24px; border-radius: 6px; flex: none; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; color: #fff; }
.bm-name { color: #E8E6DF; font-size: 12.5px; font-weight: 500; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bm-count { color: #6A6860; font-size: 10px; }
.bm-manage {
  display: flex; align-items: center; gap: 9px; width: 100%;
  background: transparent; border: none; border-top: 1px solid var(--side-menu-border);
  margin-top: 3px; padding: 9px 8px 4px; cursor: pointer; text-align: left;
  color: var(--side-fg); font-size: 12px; font-weight: 500;
}
.bm-manage:hover { color: #fff; }

/* AI CTA */
.ai-cta {
  display: flex; align-items: center; gap: 9px; width: 100%;
  margin: 6px 0 10px; background: var(--accent-grad); border: none; border-radius: 11px;
  padding: 11px 12px; cursor: pointer; color: #fff; font-weight: 600; font-size: 13.5px;
  box-shadow: 0 6px 18px rgba(109,84,255,.35);
  transition: transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.ai-cta:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(109,84,255,.45); }

/* nav */
.nav-section { font-size: 10.5px; font-weight: 600; letter-spacing: .08em; color: var(--side-section); text-transform: uppercase; padding: 8px 10px 4px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  background: transparent; border: none; border-radius: 9px;
  padding: 9px 10px; cursor: pointer; color: var(--side-fg);
  font-size: 13.5px; font-weight: 500; text-align: left;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
}
.nav-item:hover { background: rgba(255,255,255,.04); color: #E8E6DF; }
.nav-item.active { background: var(--side-item-active); color: #fff; font-weight: 600; }
.nav-count { margin-left: auto; font-size: 11px; color: #6A6860; }
.nav-dot { margin-left: auto; width: 7px; height: 7px; border-radius: 50%; background: var(--warning); }

/* sidebar foot */
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; padding-top: 10px; border-top: 1px solid var(--side-border); }
.side-user {
  display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 9px;
  margin-top: 2px; cursor: pointer; transition: background var(--duration) var(--ease);
}
.side-user:hover { background: rgba(255,255,255,.04); }
.su-avatar { width: 30px; height: 30px; border-radius: 50%; flex: none; background: linear-gradient(135deg,#3a3833,#1f1e1b); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; font-size: 12px; border: 1px solid #322f2b; }
.su-info { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.su-name { color: #E8E6DF; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.su-role { color: #6A6860; font-size: 11px; }
.su-streak { display: flex; align-items: center; gap: 3px; color: #E0903A; font-size: 12px; font-weight: 600; }

/* user dropdown (abre pra cima, ancorado na sidebar) */
.user-dropdown {
  position: absolute; left: 12px; right: 12px; bottom: 70px; z-index: 60;
  background: var(--side-menu-bg); border: 1px solid var(--side-menu-border);
  border-radius: 11px; padding: 6px; display: none; flex-direction: column; gap: 2px;
  box-shadow: 0 -8px 28px rgba(0,0,0,.4);
}
.user-dropdown.open { display: flex; animation: rise .14s ease both; }
.user-dd-item { background: none; border: none; text-align: left; cursor: pointer; padding: 9px 10px; border-radius: 8px; font-size: 13px; color: #E8E6DF; }
.user-dd-item:hover { background: rgba(255,255,255,.06); }
.user-dd-item.danger { color: #E88; }

/* ── Topbar ────────────────────────────────────────────── */
#topbar {
  height: var(--topbar-h); flex: none;
  display: flex; align-items: center; gap: 16px; padding: 0 26px;
  background: rgba(247,246,243,.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border); z-index: 40;
}
.topbar-title { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -.01em; color: var(--text); }
.topbar-search {
  margin-left: auto; display: flex; align-items: center; gap: 9px;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 9px;
  padding: 8px 12px; width: 300px; cursor: text; color: var(--muted); font-size: 13px;
  transition: border-color var(--duration) var(--ease);
}
.topbar-search:hover { border-color: var(--muted-3); }
.topbar-search .kbd { margin-left: auto; }
.kbd { font-family: 'JetBrains Mono', monospace; font-size: 11px; background: var(--subtle-2); border: 1px solid var(--border-2); border-radius: 5px; padding: 1px 6px; color: var(--muted-2); }
.topbar-icon {
  position: relative; width: 38px; height: 38px; flex: none; border-radius: 9px;
  border: 1px solid var(--border-2); background: var(--surface); cursor: pointer;
  display: flex; align-items: center; justify-content: center; color: var(--text-2);
  transition: border-color var(--duration) var(--ease);
}
.topbar-icon:hover { border-color: var(--muted-3); }
.tb-badge { position: absolute; top: 7px; right: 8px; width: 7px; height: 7px; background: var(--warning); border-radius: 50%; border: 1.5px solid var(--surface); }

/* ── Command palette ───────────────────────────────────── */
.cmd-overlay { position: fixed; inset: 0; background: rgba(20,18,16,.4); backdrop-filter: blur(4px); display: flex; align-items: flex-start; justify-content: center; padding-top: 14vh; z-index: 3200; animation: rise .15s ease both; }
.cmd-box { width: 540px; max-width: 92vw; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; }
.cmd-search { display: flex; align-items: center; gap: 11px; padding: 15px 18px; border-bottom: 1px solid var(--border-3); color: var(--muted); }
.cmd-search input { flex: 1; border: none; outline: none; font-family: inherit; font-size: 15px; color: var(--text); background: transparent; }
.cmd-list { padding: 8px; display: flex; flex-direction: column; gap: 2px; max-height: 340px; overflow-y: auto; }
.cmd-group { font-size: 10.5px; font-weight: 600; letter-spacing: .06em; color: var(--muted-3); text-transform: uppercase; padding: 8px 10px 4px; }
.cmd-item { display: flex; align-items: center; gap: 12px; width: 100%; background: transparent; border: none; border-radius: 9px; padding: 10px 11px; cursor: pointer; text-align: left; }
.cmd-item:hover, .cmd-item.sel { background: var(--subtle); }
.cmd-ic { display: flex; width: 30px; height: 30px; border-radius: 8px; align-items: center; justify-content: center; background: var(--subtle); color: var(--text-2); flex: none; }
.cmd-label { font-size: 14px; font-weight: 500; color: var(--text); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmd-empty { padding: 22px; text-align: center; color: var(--muted); font-size: 13px; }

/* ── Helpers ───────────────────────────────────────────── */
.spacer { flex: 1; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-sm { gap: 8px; } .gap-md { gap: 14px; } .gap-lg { gap: 20px; }
.sep-v { width: 1px; height: 22px; background: var(--border-2); flex: none; }
.sep-h { height: 1px; background: var(--border); width: 100%; }

/* ── Responsivo: sidebar colapsa ───────────────────────── */
@media (max-width: 920px) {
  #app-sidebar { width: 68px; padding: 12px 8px; }
  .bs-info, .bs-handle, .nav-item span:not(.nav-count):not(.nav-dot), .nav-section, .ai-cta span, .su-info, .su-streak, .nav-count { display: none; }
  .brand-switch svg { display: none; }
  .ai-cta { justify-content: center; padding: 11px; }
  .nav-item { justify-content: center; padding: 11px; }
  .topbar-search { width: 200px; }
}
