/* Gateway switcher (frontend/connection/gateway-switcher.js): a server button at the bottom of the project
   rail (styled like Automations and Settings) opens a menu of the account's gateways. */
.project-rail-gateway { margin-top: auto; flex-shrink: 0; }
.project-rail-gateway[hidden] { display: none; }
/* the bottom group keeps its place at the rail's foot whether or not the switcher shows */
.project-rail-gateway:not([hidden]) ~ .project-rail-automations-btn { margin-top: 2px; }
.project-rail-gateway > .project-rail-cog-btn:focus-visible { outline: 2px solid var(--text-primary); outline-offset: 2px; }

/* the rail clips its children, so the menu sits fixed beside it (phone bottom sheet: end of file) */

.project-rail-gateway > .gw-chip__menu {
  position: fixed;
  left: 62px;
  top: auto;
  right: auto;
  width: 260px;
  min-width: 260px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  z-index: 1100;
}
.gw-chip__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  outline: none;
}
.gw-chip__item:hover, .gw-chip__item:focus-visible { background: var(--bg-tertiary); }
.gw-chip__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gw-chip__item.is-current .gw-chip__label { font-weight: 600; }
.gw-chip__item.is-offline .gw-chip__label { color: var(--text-muted); }
.gw-chip__dot { width: 8px; height: 8px; border-radius: 50%; flex: none; box-sizing: border-box; }
.gw-chip__dot.is-online { background: var(--accent-color); }
.gw-chip__dot.is-idle { border: 1.5px solid var(--text-muted); }
.gw-chip__manage { margin-top: 4px; border-top: 1px solid var(--border-color); border-radius: 0 0 6px 6px; padding-top: 10px; color: var(--text-muted); text-decoration: none; }
.gw-chip__manage:hover, .gw-chip__manage:focus-visible { color: var(--text-primary); }
.gw-chip__manage .gw-chip__check { color: inherit; }
.gw-chip__check { width: 14px; height: 14px; flex: none; color: var(--text-primary); }

/* Phone: the rail is a drawer whose slide transform would make it the menu's containing block (clipped to
   52px). The open drawer drops the transform and the menu becomes a bottom sheet across the screen. */
@media (max-width: 480px) {
  .project-rail.open { transform: none; }
  .project-rail-gateway > .gw-chip__menu {
    left: 8px;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px)) !important; /* beats the JS desktop anchor */
    width: auto;
    min-width: 0;
    max-width: none;
    translate: none !important; /* dropdown.js fitMenu shift */
    padding: 6px;
    border-radius: 14px;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.45);
  }
  .project-rail-gateway > .gw-chip__menu .gw-chip__item { min-height: 48px; padding: 12px; font-size: 15px; }
}
