/*
 * Blueberry Universal Bar
 * Shared ecosystem navigation
 */

:root {
  --bb-universal-height: 46px;
  --bb-universal-blue: #087BFF;
  --bb-universal-sky: #69B5FF;
  --bb-universal-midnight: #071426;
  --bb-universal-text: #EAF4FF;
  --bb-universal-muted: rgba(218, 233, 247, 0.62);
  --bb-universal-border: rgba(116, 181, 245, 0.14);
  --bb-universal-bg: rgba(5, 15, 28, 0.94);
}

#blueberry-universal-bar {
  position: relative;
  z-index: 2147483000;
  width: 100%;
  min-height: var(--bb-universal-height);
  box-sizing: border-box;
  color: var(--bb-universal-text);
  background:
    linear-gradient(
      180deg,
      rgba(9, 28, 50, 0.98),
      var(--bb-universal-bg)
    );
  border-bottom:
    1px solid var(--bb-universal-border);
  font-family:
    Inter,
    ui-sans-serif,
    -apple-system,
    BlinkMacSystemFont,
    "SF Pro Display",
    "SF Pro Text",
    "Segoe UI",
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

#blueberry-universal-bar *,
#blueberry-universal-bar *::before,
#blueberry-universal-bar *::after {
  box-sizing: border-box;
}

.bb-universal-inner {
  width: 100%;
  min-height: var(--bb-universal-height);
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.bb-universal-brand {
  min-width: 0;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #FFFFFF;
  text-decoration: none;
}

.bb-universal-logo {
  width: 18px;
  height: 18px;
  color: var(--bb-universal-blue);
  flex-shrink: 0;
}

.bb-universal-wordmark {
  font-size: 13px;
  font-weight: 720;
  letter-spacing: -0.015em;
  white-space: nowrap;
}

.bb-universal-divider {
  width: 1px;
  height: 16px;
  background: rgba(255,255,255,.14);
}

.bb-universal-product {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--bb-universal-muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.bb-universal-nav {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: stretch;
  justify-content: center;
  align-self: stretch;
  overflow-x: auto;
  scrollbar-width: none;
}

.bb-universal-nav::-webkit-scrollbar {
  display: none;
}

.bb-universal-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 0 11px;
  color: rgba(220, 234, 247, 0.66);
  font-size: 12px;
  font-weight: 590;
  text-decoration: none;
  white-space: nowrap;
  transition:
    color 150ms ease,
    background 150ms ease;
}

.bb-universal-link:hover {
  color: #FFFFFF;
  background: rgba(255,255,255,.035);
}

.bb-universal-link.is-active {
  color: #FFFFFF;
}

.bb-universal-link.is-active::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 0;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--bb-universal-blue);
}

.bb-universal-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.bb-universal-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--bb-universal-muted);
  font-size: 11px;
  font-weight: 600;
}

.bb-universal-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #41D477;
  box-shadow:
    0 0 0 3px rgba(65, 212, 119, 0.09);
}

#blueberry-universal-bar.is-offline
.bb-universal-status-dot {
  background: #FFB342;
  box-shadow:
    0 0 0 3px rgba(255, 179, 66, 0.10);
}

.bb-universal-menu-button {
  display: none;
  width: 32px;
  height: 32px;
  padding: 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

.bb-universal-menu-button:hover {
  background: rgba(255,255,255,.06);
}

.bb-universal-menu-button span {
  display: block;
  width: 16px;
  height: 1.5px;
  margin: 3px 0;
  border-radius: 4px;
  background: rgba(255,255,255,.86);
}

.bb-universal-mobile-menu {
  padding: 8px;
  border-top:
    1px solid var(--bb-universal-border);
  background: rgba(4, 14, 26, 0.99);
}

.bb-universal-mobile-menu[hidden] {
  display: none !important;
}

.bb-universal-mobile-menu
.bb-universal-link {
  min-height: 42px;
  padding: 0 12px;
  border-radius: 8px;
}

.bb-universal-mobile-menu
.bb-universal-link.is-active::after {
  display: none;
}

.bb-universal-mobile-menu
.bb-universal-link.is-active {
  background: rgba(8, 123, 255, 0.12);
  color: var(--bb-universal-sky);
}

@media (max-width: 900px) {
  .bb-universal-nav {
    display: none;
  }

  .bb-universal-inner {
    gap: 12px;
  }

  .bb-universal-actions {
    margin-left: auto;
  }

  .bb-universal-menu-button {
    display: block;
  }
}

@media (max-width: 520px) {
  .bb-universal-inner {
    padding-left: 12px;
    padding-right: 10px;
  }

  .bb-universal-status-text {
    display: none;
  }

  .bb-universal-divider,
  .bb-universal-product {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  #blueberry-universal-bar * {
    transition: none !important;
  }
}

/* BLUEBERRY VIEWPORT GUARD START */

/*
 * The universal navigation occupies 46px above full-screen apps.
 *
 * Many Blueberry products use 100vh internally. Without this guard,
 * the result becomes:
 *
 *   46px navigation + 100vh application
 *
 * which pushes the bottom of the product below the browser viewport.
 */

html {
  --bb-universal-height: 46px;
  --bb-app-viewport:
    calc(100vh - var(--bb-universal-height));
}

@supports (height: 100dvh) {
  html {
    --bb-app-viewport:
      calc(100dvh - var(--bb-universal-height));
  }
}

html,
body {
  width: 100%;
  margin: 0;
}

body.bb-universal-active {
  min-height: 100vh;
  overflow-x: hidden;
}

@supports (height: 100dvh) {
  body.bb-universal-active {
    min-height: 100dvh;
  }
}

/*
 * Keep Blueberry navigation in its own fixed-height row.
 */
#blueberry-universal-bar {
  width: 100%;
  height: var(--bb-universal-height);
  min-height: var(--bb-universal-height);
  max-height: var(--bb-universal-height);
  flex: 0 0 var(--bb-universal-height);
}

/*
 * Common SPA application roots.
 *
 * The root gets exactly the viewport area remaining beneath
 * universal navigation.
 */
body.bb-universal-active > #root,
body.bb-universal-active > #app,
body.bb-universal-active > #application,
body.bb-universal-active > .app-root {
  width: 100%;
  height: var(--bb-app-viewport);
  min-height: 0;
  max-height: var(--bb-app-viewport);
}

/*
 * Full-screen apps frequently contain another 100vh wrapper.
 * Constrain the first application layer to the available root height
 * without changing product-specific components.
 */
body.bb-universal-active > #root > :first-child,
body.bb-universal-active > #app > :first-child,
body.bb-universal-active > #application > :first-child,
body.bb-universal-active > .app-root > :first-child {
  max-height: 100%;
}

/*
 * Static/non-SPA websites do not necessarily have #root.
 * They remain document-height pages and simply flow below the bar.
 */
body.bb-universal-active:not(:has(> #root)):not(:has(> #app)):not(:has(> #application)):not(:has(> .app-root)) {
  min-height: 100vh;
}

/*
 * iPhone/iPad bottom safe area.
 */
@supports (padding: env(safe-area-inset-bottom)) {
  body.bb-universal-active > #root,
  body.bb-universal-active > #app,
  body.bb-universal-active > #application,
  body.bb-universal-active > .app-root {
    padding-bottom: env(safe-area-inset-bottom);
    box-sizing: border-box;
  }
}

/*
 * Prevent fixed bottom composers / controls from disappearing behind
 * mobile browser chrome where supported.
 */
@supports (height: 100svh) {
  @media (max-width: 900px) {
    html {
      --bb-app-viewport:
        calc(100svh - var(--bb-universal-height));
    }
  }
}

/* BLUEBERRY VIEWPORT GUARD END */
