/*
 * Application shell: sidebar and main area.
 * The sidebar is a white card floating on the page ground; under 960px it
 * stacks above the content and the menu wraps.
 */

/* Hidden until the session is loaded, so no empty shell flashes. */
body.loading .app { visibility: hidden; }

.app {
  display: flex;
  align-items: flex-start;
  gap: var(--gap);
  min-height: 100vh;
  padding: var(--gap);
}

.main { flex: 1 1 0; min-width: 0; padding: 8px 8px 32px; }
.page { display: none; max-width: 1280px; }
.page.active { display: block; }

/* Sidebar */
.sidebar {
  flex: 0 0 256px;
  position: sticky;
  top: var(--gap);
  min-height: calc(100vh - 2 * var(--gap));
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 16px 16px;
  background: var(--surface);
  border-radius: var(--radius-lg);
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; text-decoration: none; }
.brand-mark { width: 36px; height: 36px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 20px; }
.brand-sub { font-size: 12px; color: var(--text-muted); }

/* Signed-in address and sign-out, top left */
.account-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  padding: 12px; border: 1px solid var(--line); border-radius: var(--radius);
}
.account-text { width: 100%; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.account-label { font-size: 12px; color: var(--text-muted); }
.account-email { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  min-height: var(--control-h); padding: 0 12px;
  border-radius: 12px;
  color: #4A4A52; text-decoration: none; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item:hover { background: var(--ground); color: var(--text); }
.nav-item.active { background: var(--violet); color: #FFFFFF; }
.nav-item.active svg { color: var(--lime); }
.nav-label { flex: 1; }
.nav-count {
  min-width: 22px; height: 22px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 11px; background: var(--violet-soft); color: var(--violet-ink);
  font-size: 12px; font-weight: 600;
}

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.help-card { display: flex; flex-direction: column; gap: 4px; padding: 16px; border-radius: 16px; background: var(--ground); }
.help-title { font-weight: 600; }
.help-card a { color: var(--violet-ink); }
.legal-links { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 0 8px; font-size: 12px; }
.legal-links a { color: var(--text-muted); text-decoration: none; }
.legal-links a:hover { color: var(--violet-ink); text-decoration: underline; }

/* Admin "Voir en tant que" bar (admins only) */
.admin-bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  margin: 0 0 16px; padding: 12px 18px; border-radius: var(--radius);
  background: var(--violet); color: #FFFFFF;
  box-shadow: 0 6px 18px rgba(121, 60, 251, .25);
}
.admin-bar-title { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
.admin-bar-title svg { width: 18px; height: 18px; }
.admin-bar-label { margin: 0; color: #FFFFFF; font-size: 14px; font-weight: 400; }
.admin-bar-select { width: auto; min-width: 240px; min-height: 40px; border: 0; border-radius: var(--pill); color: var(--text); font-weight: 700; }
.admin-bar-badge { margin-left: auto; padding: 4px 10px; border-radius: 12px; background: var(--lime); color: var(--ink); font-size: 12px; font-weight: 700; }

/* Demo only: identity switch */
.demo-switch {
  align-self: flex-start; margin: 0 8px; padding: 0; border: 0; background: none;
  color: var(--violet-ink); font-size: 12px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}

.signout {
  padding: 0; border: 0; background: none;
  color: var(--text-muted); font-size: 13px; font-weight: 700; cursor: pointer;
}
.signout:hover { color: var(--violet-ink); text-decoration: underline; }

/* Page header */
.page-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 16px; padding: 8px 4px 24px;
}
.page-head h1 { font-size: 40px; }
.eyebrow { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.page-sub { max-width: 620px; margin-top: 8px; color: var(--text-muted); }
.head-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

/* Tablet and phone: compact top bar, the menu scrolls sideways. */
@media (max-width: 960px) {
  .app { flex-direction: column; align-items: stretch; }
  .sidebar { position: static; flex: none; min-height: 0; gap: 14px; padding: 16px; }
  .help-card { display: none; }
  .account-card { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; }
  .account-text { width: auto; flex: 1; }
  .signout { flex: none; }
  .nav { flex-direction: row; overflow-x: auto; gap: 4px; margin: 0 -16px; padding: 0 16px; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav-item { flex: none; white-space: nowrap; background: var(--ground); }
  .sidebar-foot { margin-top: 0; }
  .main { padding: 0 0 24px; }
  .page-head h1 { font-size: 32px; }
}
