/*
  App shell: persistent left sidebar + content topbar. Replaces the earlier
  topbar-only layout. Maps to SidebarComponent (nav items,
  active state) + AppShellComponent (wraps sidebar + main slot).
*/

.icon { display: inline-flex; width: 1.25em; height: 1.25em; flex-shrink: 0; }
.icon svg { width: 100%; height: 100%; }

body.has-shell { display: flex; min-height: 100vh; }

.shell-sidebar {
  width: 17rem;
  flex-shrink: 0;
  background: var(--color-bg-surface);
  border-right: var(--border-width) solid var(--color-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.shell-sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-6);
}
.shell-sidebar__brand-mark {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-md);
  background: var(--color-primary-vivid);
  color: var(--color-text-on-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-primary);
}
.shell-sidebar__brand-name {
  font-family: var(--font-family-bold); font-weight: var(--font-weight-bold);
  font-size: var(--font-size-caption);
  letter-spacing: var(--letter-spacing-wide);
  color: var(--color-primary-vivid);
  margin: 0;
}
.shell-sidebar__brand-sub { font-size: var(--font-size-caption); color: var(--color-text-secondary); margin: 0; }

/* Search filter above the nav groups (-> SidebarSearchComponent). Same input
   chrome as .search-bar__input-wrap, scaled down for the sidebar's narrower
   column. Filters items across all groups via sidebar.js; matched groups
   auto-expand, groups with zero matches hide entirely. */
.shell-nav-search { position: relative; margin: 0 var(--space-4) var(--space-4); }
.shell-nav-search .icon { position: absolute; left: var(--space-3); top: 50%; transform: translateY(-50%); color: var(--color-text-secondary); width: 1rem; height: 1rem; }
.shell-nav-search input {
  width: 100%;
  font-family: var(--font-family-base);
  font-size: var(--font-size-body-sm);
  padding: var(--space-3) var(--space-3) var(--space-3) 2rem;
  border: var(--border-width) solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-bg-surface);
  color: var(--color-text-primary);
  box-sizing: border-box;
}
.shell-nav-search input:focus {
  border-color: var(--color-primary-vivid);
  box-shadow: 0 0 0 3px var(--color-primary-surface);
  outline: none;
}

.shell-nav {
  padding: 0 var(--space-4) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

/* Collapsible group (-> SidebarGroupComponent): a plain <button> header +
   an item list, no <details> here since sidebar.js's search filter needs to
   force-expand a group on match regardless of its own collapsed state --
   <details>'s native open/closed state doesn't compose with that as cleanly
   as a class/attribute toggle does. */
.shell-nav-group + .shell-nav-group { margin-top: var(--space-2); }
.shell-nav-group__header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: none;
  background: none;
  cursor: pointer;
  color: var(--color-text-secondary);
  font-family: var(--font-family-bold); font-weight: var(--font-weight-bold);
  font-size: var(--font-size-caption);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
  border-radius: var(--radius-sm);
}
.shell-nav-group__header:hover { background: var(--color-bg-surface-sunken); color: var(--color-text-primary); }
.shell-nav-group__header .icon:first-child { width: 1rem; height: 1rem; flex-shrink: 0; }
.shell-nav-group__label { flex: 1; text-align: left; }
.shell-nav-group__chevron { width: 0.9rem; height: 0.9rem; flex-shrink: 0; transition: transform var(--duration-fast) var(--ease-standard); }
.shell-nav-group__header[aria-expanded="false"] .shell-nav-group__chevron { transform: rotate(-90deg); }

.shell-nav-group__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-1); }

.shell-nav__item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4) var(--space-3) var(--space-9);
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: var(--font-size-body-sm);
  font-family: var(--font-family-medium); font-weight: var(--font-weight-medium);
  transition: background-color var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard);
}
.shell-nav__item:hover { background: var(--color-primary-surface); color: var(--color-primary-vivid); }
.shell-nav__item.is-active { background: var(--color-primary-surface); color: var(--color-primary-vivid); }

/* Disabled item: no href, no pointer, no hover feedback -- a named
   placeholder for a flow this redesign hasn't reached yet, not a real
   destination. Kept in the menu (not omitted) so the app's full scope stays
   visible; see sidebar.js's NAV_GROUPS for the source mapping. */
.shell-nav__item.is-disabled {
  color: var(--color-text-disabled);
  cursor: not-allowed;
  user-select: none;
}

.shell-nav-empty {
  padding: var(--space-4);
  margin: 0;
  font-size: var(--font-size-body-sm);
  color: var(--color-text-secondary);
  text-align: center;
}

/* Design System is a review artifact for this workstream, not a real
   end-user destination -- kept out of the main nav, surfaced as a quiet
   link above the account footer instead. */
.shell-sidebar__meta {
  margin-top: auto;
  padding: var(--space-4) var(--space-6);
}
.shell-sidebar__meta-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-caption);
  color: var(--color-text-secondary);
  text-decoration: none;
}
.shell-sidebar__meta-link:hover,
.shell-sidebar__meta-link.is-active { color: var(--color-primary-vivid); }
.shell-sidebar__meta-link .icon { width: 1rem; height: 1rem; }

.shell-sidebar__footer {
  padding: var(--space-5) var(--space-6);
  border-top: var(--border-width) solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--space-4);
}
.shell-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--color-gray-200);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-family-bold); font-weight: var(--font-weight-bold);
  font-size: var(--font-size-caption);
  color: var(--color-text-secondary);
}
.shell-sidebar__footer-name { font-size: var(--font-size-body-sm); font-family: var(--font-family-medium); font-weight: var(--font-weight-medium); margin: 0; }
.shell-sidebar__footer-role { font-size: var(--font-size-caption); color: var(--color-text-secondary); margin: 0; }

.shell-main { flex: 1; min-width: 0; min-height: 100vh; }

/* ---------- Mobile topbar + drawer nav ----------
   Below the tablet breakpoint, the persistent sidebar becomes an off-canvas
   drawer, toggled by a checkbox (no JS -- same no-JS-where-possible approach
   as .filter-popover's <details>). A slim topbar (menu button + brand mark)
   replaces the sidebar's visual space so wide screens and narrow screens both
   always show which app section you're in. */
.shell-topbar {
  display: none;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  background: var(--color-bg-surface);
  border-bottom: var(--border-width) solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.shell-topbar__brand { display: flex; align-items: center; gap: var(--space-3); }
.shell-topbar__brand-mark {
  width: 2rem; height: 2rem; border-radius: var(--radius-md);
  background: var(--color-primary-vivid); color: var(--color-text-on-brand);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.shell-topbar__brand-name { font-family: var(--font-family-bold); font-weight: var(--font-weight-bold); font-size: var(--font-size-body-sm); color: var(--color-primary-vivid); }
.shell-menu-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 2.5rem; height: 2.5rem; border-radius: var(--radius-md);
  border: var(--border-width) solid var(--color-border-strong);
  background: var(--color-bg-surface); color: var(--color-text-primary);
  cursor: pointer; flex-shrink: 0;
}
.shell-menu-toggle .icon { width: 1.25rem; height: 1.25rem; }

/* Checkbox-hack drawer state -- hidden checkbox toggled by the topbar button's
   <label>; sibling combinator drives sidebar visibility and backdrop opacity. */
#shell-nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.shell-drawer-backdrop {
  display: none;
  position: fixed; inset: 0; background: rgba(26, 26, 26, 0.4); z-index: 25;
}

@media (max-width: 900px) {
  body.has-shell { flex-direction: column; }
  .shell-topbar { display: flex; }
  .shell-sidebar {
    position: fixed;
    top: 0; left: 0; height: 100vh;
    transform: translateX(-100%);
    transition: transform var(--duration-base) var(--ease-standard);
    z-index: 30;
    box-shadow: var(--shadow-lg);
  }
  #shell-nav-toggle:checked ~ .shell-sidebar { transform: translateX(0); }
  #shell-nav-toggle:checked ~ .shell-drawer-backdrop { display: block; }
}
