/* Signed-in app frame (#appShell): the sidebar shared by Home and every
   page, the account menu, page headers and the room switcher. Home's own
   layout lives in home.css; the pages' contents in app.css.

   Layout by width:
     >= 1500px   full sidebar
     768-1499    icon rail
     < 768       bottom tab bar

   Shape rule: panels 16px, tiles and cards 14px, nav items and inputs
   10px, small controls (avatar, room switcher, chips) are pills. */

#appShell {
  --h-bg: #071817;
  --h-bg-deep: #051312;
  --h-panel: rgba(10, 31, 29, 0.9);
  --h-tile: rgba(17, 46, 43, 0.62);
  --h-tile-hover: rgba(21, 56, 52, 0.8);
  --h-line: rgba(92, 176, 169, 0.14);
  --h-line-strong: rgba(92, 176, 169, 0.32);
  --h-teal: #4fc0b8;
  --h-teal-bright: #6fd6cc;
  --h-teal-wash: rgba(79, 192, 184, 0.13);
  --h-text: #eef6f5;
  --h-text-soft: #b3cbc8;
  --h-text-muted: #8ea9a6;
  --h-amber: #e8b968;
  --h-amber-wash: rgba(232, 185, 104, 0.1);
  --h-amber-line: rgba(232, 185, 104, 0.34);
  --h-coral: #f2938b;
  --h-coral-wash: rgba(242, 147, 139, 0.1);
  --h-coral-line: rgba(242, 147, 139, 0.34);
  --h-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --h-font-display: 'Outfit', 'IBM Plex Sans', system-ui, sans-serif;

  display: grid; grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh; min-height: 100dvh;
  background: var(--h-bg);
  color: var(--h-text);
}
body { padding-bottom: 0; }
/* Scrollbars to match the palette (color-scheme: dark lives in base.css). */
:root { scrollbar-color: #24504c var(--bg); }
#appShell ::selection { background: rgba(79, 192, 184, 0.32); color: #fff; }
#appShell :focus-visible { outline: 2px solid var(--h-teal); outline-offset: 3px; }
/* Zero-specificity defaults, so component classes always win. */
/* Line-icon defaults for the sprite icons only. Charts and other inline
   SVG in the pages draw their own strokes and fills. */
:where(.shell-nav, .shell-topbar, #welcomeScreen) svg { fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
:where(#appShell) button { font-family: inherit; color: inherit; }

/* Full-page admin screens (manage plan, platform admin, flagged products)
   are a centred column; give them a solid backdrop so the sidebar behind
   doesn't show, or take clicks, at the sides. */
#managePlanScreen, #platformAdminScreen, #flaggedProductsScreen {
  position: fixed; inset: 0; z-index: 150; background: var(--bg);
}

/* ---------- Sidebar ---------- */
.shell-nav {
  position: sticky; top: 0; z-index: 20;
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  padding: 26px 16px 20px;
  background: var(--h-bg-deep);
  border-right: 1px solid var(--h-line);
  overflow-y: auto;
}
.shell-brand { padding: 0 6px 30px; }
.shell-brand-full { display: block; width: 184px; height: auto; }
.shell-brand-mark { display: none; width: 34px; height: 34px; color: var(--h-teal); margin: 0 auto; }
.shell-nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.shell-nav-item {
  display: flex; align-items: center; gap: 14px;
  width: 100%; height: 46px; padding: 0 14px;
  border: 0; border-radius: 10px; background: transparent;
  color: var(--h-text-soft); font-size: 15px; font-weight: 500; text-align: left;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, transform 160ms var(--h-ease-out);
}
.shell-nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.shell-nav-item[aria-current="page"] { background: var(--h-teal-wash); color: var(--h-text); }
.shell-nav-item[aria-current="page"] svg { color: var(--h-teal-bright); }
.shell-nav-item:active { transform: scale(0.98); }
.shell-help {
  display: flex; align-items: center; gap: 12px;
  margin-top: auto; padding: 12px 14px; border-radius: 10px;
  color: var(--h-text-soft); text-decoration: none;
  transition: background-color 150ms ease;
}
.shell-help svg { width: 20px; height: 20px; flex-shrink: 0; }
.shell-help-title { display: block; font-size: 14px; }
.shell-help-link { display: block; font-size: 13px; color: var(--h-teal); margin-top: 2px; }
@media (hover: hover) and (pointer: fine) {
  .shell-nav-item:not([aria-current="page"]):hover { background: rgba(79, 192, 184, 0.07); color: var(--h-text); }
  .shell-help:hover { background: rgba(79, 192, 184, 0.07); }
  .shell-help:hover .shell-help-link { color: var(--h-teal-bright); }
}

/* ---------- Main column + account menu ---------- */
.shell-main { position: relative; min-width: 0; }
.shell-topbar {
  position: absolute; top: 22px; right: 32px; z-index: 30;
  display: flex; align-items: center; justify-content: flex-end;
}
.shell-topbar-logo { display: none; width: 136px; height: auto; }

#appShell .profile-menu { position: relative; top: auto; right: auto; }
#appShell .profile-icon {
  width: 44px; height: 44px; padding: 0; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--h-teal-wash); border: 1px solid var(--h-line-strong);
  color: var(--h-teal-bright); cursor: pointer;
  transition: background-color 150ms ease, transform 160ms var(--h-ease-out);
}
#appShell .profile-icon svg { width: 20px; height: 20px; }
#appShell .profile-icon.has-initials svg,
#appShell .profile-icon:not(.has-initials) .profile-initials { display: none; }
.profile-initials { font-size: 14px; font-weight: 600; letter-spacing: 0.02em; }
#appShell .profile-icon:active { transform: scale(0.96); }
#appShell .profile-dropdown {
  top: 52px; right: 0; min-width: 200px; padding: 6px;
  background: #0f2b29; border: 0; border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
  transform-origin: top right;
}
#appShell .profile-dropdown.open { animation: shellPop 160ms var(--h-ease-out); }
#appShell .profile-dropdown-item { color: var(--h-text); border-radius: 8px; }
@media (hover: hover) and (pointer: fine) {
  #appShell .profile-icon:hover { background: rgba(79, 192, 184, 0.22); }
  #appShell .profile-dropdown-item:hover { background: var(--h-teal-wash); }
}

/* ---------- Page header (every page except Home) ---------- */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap;
  gap: 18px 28px;
  max-width: 1440px; margin-inline: auto;
  /* Right padding keeps the tools clear of the account button, which sits
     in the top-right corner of the main column. */
  padding: 44px 104px 0 48px;
}
/* Wide enough that the centred column's margin already clears it. */
@media (min-width: 1800px) {
  .page-head { padding-right: 48px; }
}
.page-head h1 {
  margin: 0;
  font-family: var(--h-font-display); font-weight: 600;
  font-size: 2.25rem; line-height: 1.1; letter-spacing: -0.02em;
}
.page-sub { margin: 8px 0 0; max-width: 60ch; font-size: 15px; line-height: 1.55; color: var(--h-text-soft); }
.page-sub:empty { display: none; }
.page-head-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 16px; }
.page-head .location-bar { padding: 0; margin: 0; border: 0; }
.page-head .sync-pill { font-size: 12.5px; color: var(--h-text-muted); }

/* ---------- Room switcher (Home and page headers) ---------- */
:is(.home-switcher, .location-bar) .loc-dropdown-trigger {
  min-width: 0; gap: 8px; padding: 5px 12px 5px 6px;
  background: rgba(10, 31, 29, 0.78); border: 1px solid var(--h-line-strong); border-radius: 999px;
  box-shadow: none;
  transition: border-color 150ms ease, background-color 150ms ease, transform 160ms var(--h-ease-out);
}
:is(.home-switcher, .location-bar) .loc-dropdown-trigger:hover { transform: none; box-shadow: none; }
:is(.home-switcher, .location-bar) .loc-dropdown-trigger:active { transform: scale(0.98); }
:is(.home-switcher, .location-bar) .loc-dropdown-trigger.open,
:is(.home-switcher, .location-bar) .loc-dropdown-trigger:hover { border-color: var(--h-teal); }
:is(.home-switcher, .location-bar) .loc-dropdown-icon-badge { width: 26px; height: 26px; border-radius: 999px; background: var(--h-teal-wash); }
:is(.home-switcher, .location-bar) .loc-dropdown-icon { width: 15px; height: 15px; color: var(--h-teal-bright); }
:is(.home-switcher, .location-bar) .loc-dropdown-name { font-size: 14px; font-weight: 500; color: var(--h-text); }
:is(.home-switcher, .location-bar) .loc-dropdown-meta { display: none; }
:is(.home-switcher, .location-bar) .loc-dropdown-chevron { width: 16px; height: 16px; color: var(--h-text-soft); }
:is(.home-switcher, .location-bar) .loc-dropdown-menu {
  min-width: 220px; padding: 6px;
  background: #0f2b29; border: 0; border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
  transform-origin: top left;
}
:is(.home-switcher, .location-bar) .loc-dropdown-item { color: var(--h-text); border-radius: 8px; }
:is(.home-switcher, .location-bar) .loc-dropdown-item:hover { background: var(--h-teal-wash); }
:is(.home-switcher, .location-bar) .loc-dropdown-item.active { background: var(--h-teal-wash); color: var(--h-teal-bright); }
:is(.home-switcher, .location-bar) .loc-dropdown-check { color: var(--h-teal-bright); }
:is(.home-switcher, .location-bar) .loc-dropdown-divider { background: var(--h-line); }

@keyframes shellPop {
  from { opacity: 0; transform: translateY(-4px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  #appShell *, #appShell *::before, #appShell *::after {
    animation: none !important; transition-duration: 0.01ms !important;
  }
}

/* ---------- Responsive ---------- */

/* Icon rail */
@media (max-width: 1499px) {
  #appShell { grid-template-columns: 76px minmax(0, 1fr); }
  .shell-nav { padding: 22px 12px 18px; align-items: center; }
  .shell-brand { padding: 0 0 26px; }
  .shell-brand-full { display: none; }
  .shell-brand-mark { display: block; }
  .shell-nav-list { width: 100%; }
  .shell-nav-item { justify-content: center; padding: 0; height: 48px; }
  .shell-nav-item span,
  .shell-help-text {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
  }
  .shell-help { justify-content: center; padding: 12px 0; width: 100%; }
  .page-head { padding-left: 40px; }
}

/* Phone: bottom tab bar, account menu in a top bar */
@media (max-width: 767px) {
  #appShell { grid-template-columns: minmax(0, 1fr); }
  .shell-nav {
    position: fixed; top: auto; left: 0; right: 0; bottom: 0; z-index: 40;
    height: auto;
    flex-direction: row; align-items: stretch;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: rgba(5, 19, 18, 0.97);
    border-right: 0; border-top: 1px solid var(--h-line);
    overflow: visible;
  }
  .shell-brand, .shell-help, .shell-nav-secondary { display: none; }
  .shell-nav-list { flex-direction: row; gap: 2px; }
  .shell-nav-list li { flex: 1; min-width: 0; }
  .shell-nav-item {
    flex-direction: column; justify-content: center; gap: 4px;
    height: 54px; padding: 0 2px; font-size: 11px;
  }
  .shell-nav-item span {
    position: static; width: auto; height: auto; overflow: hidden;
    clip: auto; clip-path: none; text-overflow: ellipsis; max-width: 100%;
  }
  .shell-nav-item[aria-current="page"] { background: transparent; color: var(--h-teal-bright); }
  .shell-main { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
  .shell-topbar { position: relative; top: auto; right: auto; justify-content: space-between; padding: 14px 16px 0; }
  .shell-topbar-logo { display: block; }
  #appShell .profile-icon { width: 40px; height: 40px; }
  .page-head { padding: 20px 16px 0; gap: 14px; }
  .page-head h1 { font-size: 1.75rem; }
  .page-sub { font-size: 14px; }
}
