/* ============================================================
   Portal 3 — App shell: topbar + sidebar + page canvas
   Grid layout: topbar spans full width, sidebar + page below.
   Sidebar has two states: extended (132px) and minimized (56px).
   The toggle (arrow) lives at the bottom-right of the sidebar.
   ============================================================ */

.app-shell {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  height: 100vh;
  width: 100vw;
  background: var(--bg);
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  grid-column: 1 / -1;
  grid-row: 1;
  background: var(--chrome);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px 0 0;
  z-index: 5;
}

.topbar-brand {
  display: flex; align-items: center;
  height: 100%;
  padding: 0 12px;
  width: var(--sidebar-w-extended);
  transition: width .2s ease, padding .2s ease;
}
.app-shell:has(.sidebar.is-minimized) .topbar-brand {
  width: var(--sidebar-w-minimized);
  padding: 0 8px;
  justify-content: center;
}
.topbar-brand .brand-logo {
  max-height: 26px;
  max-width: 100%;
  height: auto;
  width: auto;
  display: block;
}
.topbar-brand .brand-logomark {
  height: 28px;
  width: auto;
  display: none;
}
.app-shell:has(.sidebar.is-minimized) .topbar-brand .brand-logo { display: none; }
.app-shell:has(.sidebar.is-minimized) .topbar-brand .brand-logomark { display: block; }

/* Generic search bar */
.topbar-search {
  flex: 1;
  max-width: 420px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-2);
  color: var(--muted);
}
.topbar-search:focus-within {
  border-color: var(--ink-2);
  background: var(--paper);
}
.topbar-search svg { color: currentColor; flex-shrink: 0; }
.topbar-search input {
  flex: 1; min-width: 0;
  background: transparent; border: 0; outline: 0;
  color: var(--ink);
  font: inherit; font-size: 13px;
  line-height: 1;
  padding-top: 1px;
}
.topbar-search kbd {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
}

.topbar-spacer { flex: 1; }

/* Location selector — lives in the topbar, just left of notifications */
.topbar-loc {
  display: flex; align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  cursor: pointer;
  max-width: 240px;
}
.topbar-loc:hover { border-color: var(--ink-2); background: var(--bg-2); }
.topbar-loc .loc-mark {
  width: 24px; height: 24px;
  border-radius: var(--radius);
  background: var(--bg-2);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  color: var(--muted);
  flex-shrink: 0;
}
.topbar-loc .loc-meta {
  display: flex; flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}
.topbar-loc .loc-meta .nm {
  font-size: 13px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar-loc .loc-meta .sub {
  font-size: 12px; color: var(--muted);
  font-family: var(--font-mono);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar-loc .chev { color: var(--muted); flex-shrink: 0; }

.topbar-icon {
  position: relative;
  width: 34px; height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink-2);
  cursor: pointer;
  display: grid; place-items: center;
}
.topbar-icon:hover { border-color: var(--ink-2); background: var(--bg-2); }
.topbar-icon .badge {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--bad); color: white;
  font-family: var(--font-mono);
  font-size: 12px;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  border-radius: var(--radius);
  display: grid; place-items: center;
  border: 2px solid var(--paper);
}

.topbar-user {
  display: flex; align-items: center;
  gap: 10px;
  padding: 4px 4px 4px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
}
.topbar-user:hover { background: var(--bg-2); }
.topbar-user-meta {
  display: flex; flex-direction: column;
  line-height: 1.15;
  text-align: right;
}
.topbar-user-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.topbar-user-role { font-size: 12px; color: var(--muted); }
.topbar-user .avatar {
  width: 28px; height: 28px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  grid-column: 1;
  grid-row: 2;
  width: var(--sidebar-w-extended);
  background: var(--chrome);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width .2s ease;
}
.sidebar.is-minimized { width: var(--sidebar-w-minimized); }

/* Nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.nav-section { padding: 4px 0; }

.nav-section-title {
  padding: 8px 12px 2px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
}
.sidebar.is-minimized .nav-section-title { display: none; }
/* Minimized: drop section padding so the gap between groups
   equals the gap between items within a group. */
.sidebar.is-minimized .nav-section { padding: 0; }

/* Nav item — extended: horizontal `[icon] Label`, left-aligned, compact */
.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  margin: 1px 6px;
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--ink-2);
  cursor: pointer;
  position: relative;
  text-align: left;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-item:hover { background: color-mix(in oklab, var(--ink) 10%, var(--bg-2)); color: var(--ink); }
.nav-item.is-active {
  background: #dfdfdf;
  color: var(--ink);
  font-weight: 600;
}
.nav-item.is-active::before {
  content: "";
  position: absolute;
  left: -6px; top: 6px; bottom: 6px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.nav-item .nav-ico {
  width: 18px; height: 18px;
  color: currentColor;
  stroke: currentColor; fill: none; stroke-width: 1.6;
  flex-shrink: 0;
}
.nav-item .nav-dot {
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: var(--radius);
  margin-left: auto;
  flex-shrink: 0;
}

/* Nav item — minimized: icon only, label hidden */
.sidebar.is-minimized .nav-item {
  justify-content: center;
  padding: 10px 4px;
  margin: 2px 4px;
  gap: 0;
}
.sidebar.is-minimized .nav-item span:not(.nav-dot) {
  display: none;
}
.sidebar.is-minimized .nav-item .nav-ico {
  width: 20px; height: 20px;
}
.sidebar.is-minimized .nav-item.is-active::before {
  left: -4px; top: 6px; bottom: 6px;
}
.sidebar.is-minimized .nav-item .nav-dot {
  position: absolute;
  top: 6px; right: 6px;
  margin: 0;
  display: block;
}

/* Sidebar footer — Support link (left) + toggle (right) */
.sidebar-foot {
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sidebar-foot .nav-item--foot {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
}
.sidebar.is-minimized .sidebar-foot {
  flex-direction: column;
  justify-content: center;
  padding: 8px;
  gap: 4px;
}
.sidebar.is-minimized .sidebar-foot .nav-item--foot {
  flex: 0 0 auto;
  width: 100%;
}
.sidebar-toggle {
  width: 28px; height: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink-2);
  cursor: pointer;
  display: grid; place-items: center;
  transition: background .12s, border-color .12s;
}
.sidebar-toggle:hover {
  background: var(--bg-2);
  border-color: var(--ink-2);
}
.sidebar-toggle svg {
  transition: transform .2s ease;
}
.sidebar.is-minimized .sidebar-toggle svg {
  transform: rotate(180deg);
}

/* ============================================================
   PAGE CANVAS — hosts .cat
   ============================================================ */
.page {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

.cat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}

/* Page header — h1 on top, then kicker, then optional sub */
.cat-h {
  padding: 14px 32px 12px;
  background: var(--paper);
  display: flex; align-items: flex-end; gap: 24px;
  flex-shrink: 0;
}
.cat-h h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 26px; font-weight: 600; letter-spacing: -0.015em;
  line-height: 1.1;
}
.cat-h .kicker { margin-top: 2px; margin-bottom: 0; }
.cat-h .sub {
  color: var(--muted); font-size: 13px;
  margin-top: 4px; max-width: 60ch;
}
.cat-h .spacer { flex: 1; }
.cat-h .toolbar { display: flex; gap: 8px; align-items: center; }

/* Filter strip */
.cat-filter {
  padding: 12px 32px;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  flex-shrink: 0;
}

/* Footer status strip */
.cat-foot {
  border-top: 1px solid var(--line);
  background: var(--paper);
  padding: 8px 32px;
  font-family: var(--font-mono); font-size: 12px;
  color: var(--muted);
  display: flex; gap: 18px; align-items: center;
  flex-shrink: 0;
}
.cat-foot .right { margin-left: auto; }

/* Tab bar (detail page header tabs) */
.cat-tabs {
  padding: 0 32px;
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  flex-shrink: 0;
}
.cat-tab {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.cat-tab:hover { color: var(--ink); }
.cat-tab[aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ============================================================
   TOPBAR DROPDOWNS — location picker, notifications, user
   Hidden by default, shown when parent has `.open` class.
   ============================================================ */
.topbar-loc,
.topbar-notifications,
.topbar-user {
  position: relative;
}

/* Generic dropdown menu (notifications + user menus) */
.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 100;
  display: none;
}
.dropdown.open > .dropdown-menu,
.dropdown-menu.open { display: block; }

.dropdown-menu--notifications { width: 360px; padding: 0; }

.dropdown-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}
.dropdown-item:hover { background: var(--bg-2); }
.dropdown-divider {
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}

/* Notifications-specific */
.notifications-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  font-size: 13px;
}
.notifications-mark-read {
  font-size: 12px;
  color: var(--accent);
  font-weight: 500;
}
.notifications-tabs {
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.notifications-tab {
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  cursor: pointer;
  white-space: nowrap;
}
.notifications-tab:hover { background: var(--bg-2); color: var(--ink); }
.notifications-tab.active {
  background: var(--bg-2);
  color: var(--ink);
  border-color: var(--line);
}
.notifications-tab-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  margin-left: 4px;
}
.notifications-list {
  max-height: 360px;
  overflow-y: auto;
  padding: 4px;
}
.notification-item {
  align-items: flex-start;
  padding: 10px;
  border-radius: var(--radius-sm);
}
.notification-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-mono);
}
.notification-icon--warning { background: #fdebd6; color: var(--warn); }
.notification-icon--info    { background: #e0eefb; color: var(--accent); }
.notification-icon--success { background: #dcefe2; color: var(--paid); }
.notification-icon--danger  { background: #f7dad8; color: var(--bad); }
.notification-body { flex: 1; line-height: 1.35; }
.notification-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

/* Location picker menu */
.location-picker__menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  min-width: 280px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 4px;
  z-index: 100;
  display: none;
}
/* When the location picker lives inside the user cluster, anchor menu to
   the right edge of the cluster and let it grow wider than the trigger. */
.topbar-user-info .topbar-loc .location-picker__menu {
  left: auto;
  right: 0;
  min-width: 280px;
}
.topbar-loc.open .location-picker__menu,
.location-picker.open .location-picker__menu { display: block; }
.location-picker__option {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.location-picker__option:hover { background: var(--bg-2); }
.location-picker__option.active {
  background: var(--bg-2);
}
.location-picker__opt-text {
  display: flex;
  flex-direction: column;
}
.location-picker__opt-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.location-picker__opt-sub {
  font-size: 11px;
  color: var(--muted);
}

/* User dropdown — already part of .dropdown but text styling */
.topbar-user .dropdown-menu .dropdown-item { font-size: 13px; }

/* ============================================================
   STORE LINK PILL — frontstore URL with copy
   ============================================================ */
.store-link-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px 5px 10px;
  height: 30px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
}
.store-link-pill__url {
  font-size: 11px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  font-family: var(--font-mono);
  white-space: nowrap;
  line-height: 1;
  padding-top: 1px;
}
.store-link-pill__url:hover { text-decoration: none; color: var(--primary-dark, var(--accent)); }
.store-link-pill__copy {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  color: var(--ink-2);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  padding: 0;
}
.store-link-pill__copy:hover { background: var(--paper); border-color: var(--ink-2); }

/* ============================================================
   NOTIFICATION BELL — yellow with red dot
   ============================================================ */
.topbar-bell {
  position: relative;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: #f59e0b;
  cursor: pointer;
}
.topbar-bell:hover {
  background: var(--bg-2);
  border-color: var(--line);
}
.topbar-bell .notification-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: var(--bad);
  border-radius: 50%;
  border: 2px solid var(--chrome);
}

/* ============================================================
   USER CLUSTER — name on top, location pin underneath, avatar right
   Two separate dropdowns (name → profile, location → switcher),
   no border around the cluster.
   ============================================================ */
.topbar-user-cluster {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 4px 8px;
  border-radius: var(--radius);
}
.topbar-user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.15;
  gap: 2px;
}
.topbar-user-cluster .avatar {
  width: 28px; height: 28px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
}

/* Plain user name label (no longer a trigger — avatar is the trigger now) */
.topbar-user-info .topbar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

/* User dropdown wraps the avatar; menu anchors to it */
.topbar-user-cluster > .topbar-user {
  position: relative;
  display: inline-flex;
  align-items: center;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.topbar-user-cluster > .topbar-user:hover .avatar {
  outline: 2px solid color-mix(in oklab, var(--accent) 50%, transparent);
  outline-offset: 1px;
}

/* Location trigger — borderless, pin + label */
.topbar-user-info .topbar-loc {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
}
.topbar-user-info .topbar-loc:hover { background: transparent; color: var(--accent); }
.topbar-user-info .topbar-loc .loc-pin { color: var(--accent); flex-shrink: 0; }
.topbar-user-info .topbar-loc .location-picker__label {
  color: inherit;
  font-weight: 500;
  white-space: nowrap;
}

/* Section label inside any dropdown */
.dropdown-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 6px 10px 4px;
}

/* Location options (inside the standalone location-picker dropdown) */
.location-picker__option {
  display: block;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
}
.location-picker__option:hover { background: var(--bg-2); }
.location-picker__option.active { background: var(--bg-2); }
.location-picker__opt-name {
  font-weight: 600;
  color: var(--ink);
  display: block;
}
.location-picker__opt-sub {
  font-size: 11px;
  color: var(--muted);
  display: block;
}

