/* ============================================================
   Unified app shell — the SAME left sidebar the automation
   dashboard uses, so the connect / profiles pages feel like one
   product instead of a separate mini-app. Themed with the shared
   --cr-* tokens (defined in cafe-racer.css) so light + dark work.
   Markup is injected by js/app-sidebar.js.
   ============================================================ */

.app-sidebar {
  flex: 0 0 256px;
  width: 256px;
  align-self: stretch;
  background: var(--cr-surface);
  border-right: 1px solid var(--cr-border);
  padding: 16px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

/* Brand */
.app-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 4px 8px 16px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--cr-border);
}
.app-brand-icon {
  flex: 0 0 38px; width: 38px; height: 38px; border-radius: 10px;
  background: var(--cr-tertiary); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.app-brand-text { display: flex; flex-direction: column; min-width: 0; }
.app-brand-title {
  font-size: 0.95rem; font-weight: 700; letter-spacing: -0.01em; color: var(--cr-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app-brand-sub {
  font-size: 0.72rem; color: var(--cr-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Menu */
.app-menu { display: flex; flex-direction: column; gap: 1px; }
.app-group {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--cr-muted); padding: 0 10px; margin: 14px 0 4px;
}
.app-group:first-child { margin-top: 2px; }
.app-link {
  width: 100%;
  padding: 9px 10px;
  font-size: 0.9rem; font-weight: 500;
  color: var(--cr-secondary);
  border-radius: 8px;
  display: flex; align-items: center; gap: 11px;
  text-decoration: none;
  transition: background .12s ease, color .12s ease;
}
.app-link svg { flex: 0 0 19px; width: 19px; height: 19px; color: var(--cr-muted); transition: color .12s; }
.app-link:hover { background: var(--cr-surface-2); color: var(--cr-primary); text-decoration: none; }
.app-link:hover svg { color: var(--cr-primary); }
.app-link.active { background: var(--cr-accent-bg); color: var(--cr-tertiary); font-weight: 600; }
.app-link.active svg { color: var(--cr-tertiary); }

/* Footer */
.app-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--cr-border);
}
.app-signout {
  width: 100%;
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border: none; background: transparent;
  font: inherit; font-size: 0.9rem; font-weight: 500; color: var(--cr-secondary);
  border-radius: 8px; cursor: pointer; text-align: left;
  transition: background .12s ease, color .12s ease;
}
.app-signout svg { flex: 0 0 18px; width: 18px; height: 18px; color: var(--cr-muted); }
.app-signout:hover { background: var(--cr-surface-2); color: var(--cr-primary); }
.app-signout:hover svg { color: var(--cr-primary); }

/* On narrow screens the sidebar folds into a top bar */
@media (max-width: 860px) {
  .cr-shell { flex-direction: column; }
  .app-sidebar {
    flex: none; width: auto; height: auto; position: static;
    border-right: none; border-bottom: 1px solid var(--cr-border);
    flex-direction: row; align-items: center; gap: 8px;
    padding: 8px 14px; overflow-x: auto;
  }
  .app-brand { border-bottom: none; margin-bottom: 0; padding: 0; }
  .app-brand-sub { display: none; }
  .app-menu { flex-direction: row; flex-wrap: nowrap; gap: 4px; margin-left: auto; }
  .app-group { display: none; }
  .app-link span { display: none; }   /* icons only in the collapsed bar */
  .app-link { width: auto; padding: 8px 10px; }
  .app-foot { margin-top: 0; padding-top: 0; border-top: none; }
  .app-signout span { display: none; }
}
