/* ─── BranchBar (sticky top bar — pushes all content including abs-positioned items) ─── */

.bar {
  position: sticky;
  top: 0;
  z-index: 10000;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 11px;
  line-height: 1;
}

.barInner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 32px;
  background: var(--sb-branch-bar-bg, hsl(212, 92%, 45%));
  color: #fff;
  padding: 4px 12px;
  position: relative;
  font-size: 11px;
  line-height: 1;
}

.barProd {
  background: #1c2128;
}

.barTrigger {
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  color: var(--color-foreground-on-emphasis, #ddd);
  font-size: 11px;
  font-weight: 400;
  font-family: inherit;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
  transition: background 0.1s;
}

.barTrigger:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.barActions {
  position: absolute;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.barLabel {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--color-foreground-on-emphasis, #ddd);
  font-size: 11px;
  font-weight: 400;
}

.barBranchName {
  font-weight: 500;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.barDomainName {
  font-weight: 400;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.barSeparator {
  opacity: 0.6;
  margin: 0 2px;
}

.barAction {
  background: none;
  border: none;
  color: var(--color-foreground-on-emphasis, #777);
  font-size: 11px;
  font-weight: 400;
  font-family: inherit;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 3px;
  transition: all 0.1s;
}

.barAction:hover {
  color: var(--color-foreground-on-emphasis, #fff);
  background: rgba(255, 255, 255, 0.1);
}

/* Expose bar height as CSS variable for consumers */
:global(html:has([data-branch-bar]):not(.storyboard-chrome-hidden)) {
  --sb-branch-bar-height: 32px;
}

:global(html.storyboard-chrome-hidden [data-branch-bar]) {
  display: none;
}

/* ─── Shared dropdown (used by both BranchBar and ViewfinderNew) ─── */

.branchBtn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: #fff;
  color: #555;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.branchBtn:hover {
  background: #f5f5f5;
  border-color: #ccc;
}

.branchBtnText {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.branchPositioner {
  z-index: 10001;
}

.branchPopup {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  min-width: 240px;
  max-width: 320px;
  padding: 6px 0;
  font-family: 'Mona Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

.branchSectionLabel {
  padding: 8px 14px 4px;
  font-size: 14px;
  font-weight: 600;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.branchItem {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  font-size: 16px;
  color: #555;
  cursor: pointer;
  transition: background 0.1s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.branchItem:hover,
.branchItem[data-highlighted] {
  background: #f5f5f5;
}

.branchItemActive {
  composes: branchItem;
  color: #1a1a1a;
  font-weight: 600;
}

.branchSeparator {
  height: 1px;
  background: #e5e5e5;
  margin: 4px 10px;
}

.branchViewport {
  max-height: 280px;
  overflow-y: auto;
}

.branchShowAll {
  display: block;
  width: 100%;
  padding: 8px 14px;
  font-size: 16px;
  color: #2563eb;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}

.branchShowAll:hover {
  background: #f5f5f5;
}

.branchError {
  padding: 6px 14px;
  font-size: 12px;
  color: #ef4444;
  background: #fef2f2;
  border-bottom: 1px solid #fecaca;
}
