/* ================================
   STAGE TOOLBAR
   Brand and model at the top left, camera pills and environment pills.
   The header covers the stage (layout.css) and its groups follow the width
   the 3D view actually has: one top row on wide stages, camera pills at the
   bottom on narrow ones, a second top row on phones.
   ================================ */
.global-header {
  position: absolute;
  inset: 0;
  z-index: var(--z-header);
  pointer-events: none;
}

.header-left,
.header-center,
.environment-quick-controls {
  position: absolute;
  top: calc(18px + env(safe-area-inset-top, 0px));
  pointer-events: auto;
}

.header-left {
  left: 22px;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  max-width: calc(100% - 44px);
}

/* The logo sits on a navy plate: client logos are made for a dark ground
   (light wordmarks), so it stays legible over any sky next to the light pills. */
.client-logo {
  box-sizing: border-box;
  height: 34px;
  width: auto;
  max-width: 150px;
  padding: 6px 14px;
  border-radius: var(--radius-round);
  background: var(--ui-frame);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), var(--ui-shadow-float);
  object-fit: contain;
}

.client-logo.hidden {
  display: none;
}

/* Model pill: the current model and the switch to the client's other models. */
.boat-name-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  max-width: 260px;
  padding: 3px 3px 3px 13px;
  border-radius: var(--radius-round);
  background: var(--ui-glass);
  box-shadow: inset 0 0 0 1px rgba(15, 29, 48, 0.06), var(--ui-shadow-float);
}

.boat-name-wrapper .boat-name {
  min-width: 0;
  overflow: hidden;
  color: var(--ui-ink);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.005em;
  line-height: 1;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.dropdown-toggle {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ui-mute);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.dropdown-toggle:hover,
.dropdown-toggle[aria-expanded="true"] {
  background: var(--secondary-hover);
  color: var(--ui-ink);
}

.dropdown-toggle:focus-visible {
  outline: 2px solid var(--ui-ring);
  outline-offset: -2px;
}

.dropdown-toggle svg {
  transition: transform 0.18s ease;
  transform-origin: 50% 55%;
}

.dropdown-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 1;
  min-width: 100%;
  max-height: min(50vh, 420px);
  display: flex;
  flex-direction: column;
  padding: 6px;
  overflow: auto;
  border: 1px solid var(--ui-line);
  border-radius: 14px;
  background: var(--ui-card);
  box-shadow: var(--ui-shadow-lg);
}

.dropdown-menu.hidden {
  display: none;
}

.dropdown-menu button {
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--ui-ink-2);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.dropdown-menu button:hover {
  background: var(--ui-hover);
  color: var(--ui-ink);
}

.dropdown-menu button.active {
  background: var(--ui-accent-soft);
  color: var(--ui-accent-text);
  font-weight: 700;
}

/* Pill groups */
.header-center {
  left: 50%;
  transform: translateX(-50%);
}

.controls-inner,
.environment-quick-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-round);
  background: var(--ui-glass-group);
  box-shadow: inset 0 0 0 1px rgba(15, 29, 48, 0.06), var(--ui-shadow-float);
}

.environment-quick-controls {
  right: 18px;
}

.environment-quick-controls.hidden {
  display: none;
}

.controls-group {
  display: contents;
}

.controls-group.hidden {
  display: none;
}

.view-split-control {
  display: flex;
  gap: 2px;
}

.header-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 13px;
  border: 0;
  border-radius: var(--radius-round);
  background: transparent;
  color: var(--ui-ink-2);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.3;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.header-pill:hover {
  background: var(--ui-press);
  color: var(--ui-ink);
}

.header-pill:focus-visible {
  outline: 2px solid var(--ui-ring);
  outline-offset: 1px;
}

.header-pill.active,
.header-pill[aria-pressed="true"] {
  background: var(--ui-accent);
  color: var(--ui-on-accent);
}

.header-pill.disabled,
.header-pill:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  filter: grayscale(1);
}

.view-menu-toggle svg {
  width: 14px;
  height: 14px;
  transition: transform var(--t-fast) var(--ease-standard);
}

.view-menu-toggle[aria-expanded="true"]:not(.active) {
  background: var(--ui-press);
  color: var(--ui-ink);
}

.view-menu-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

/* Camera views menu (moved to <body> by toolbar.js, placed next to Views). */
.view-preset-menu {
  position: fixed;
  z-index: calc(var(--z-header) + 10);
  min-width: 160px;
  padding: 6px;
  border: 1px solid var(--ui-line);
  border-radius: 14px;
  background: var(--ui-card);
  box-shadow: var(--ui-shadow-lg);
}

.view-preset-menu.hidden {
  display: none;
}

.view-preset-menu .view-menu-item {
  width: 100%;
  height: 36px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ui-ink-2);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.view-preset-menu .view-menu-item:hover,
.view-preset-menu .view-menu-item:focus-visible {
  background: var(--ui-hover);
  color: var(--ui-ink);
}

.view-preset-menu .view-menu-item.active {
  background: var(--ui-accent-soft);
  color: var(--ui-accent-text);
  font-weight: 700;
}

.view-preset-menu .view-menu-item svg {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  color: var(--ui-faint);
}

.view-preset-menu .view-menu-item.active svg {
  color: currentColor;
}

/* Narrow stages (tablets, laptops with the dock): camera pills move to the
   bottom of the stage so the top row keeps the brand and the environment. */
@container stage (max-width: 1099px) {
  .header-center {
    top: auto;
    bottom: calc(14px + var(--stage-safe-bottom));
  }
}

/* Phones: environment pills take a second top row and the camera pills wrap. */
@container stage (max-width: 599px) {
  .header-left {
    max-width: calc(100% - 44px - 68px);
  }

  .environment-quick-controls {
    top: calc(18px + env(safe-area-inset-top, 0px) + 50px);
  }

  .header-center {
    width: calc(100% - 24px);
  }

  /* Wrapped camera pills stand on their own plates, so the 3D view shows
     between them instead of behind one large panel. */
  .controls-inner {
    flex-wrap: wrap;
    justify-content: center;
    border-radius: 22px;
    background: transparent;
    box-shadow: none;
  }

  .header-pill {
    padding: 7px 11px;
  }

  /* Quieter plates than the desktop bar: no float shadow over the 3D view. */
  .controls-inner .header-pill:not(.active, [aria-pressed="true"]) {
    background: rgba(255, 254, 251, 0.82);
    box-shadow: inset 0 0 0 1px rgba(15, 29, 48, 0.08);
  }

  /* Disabled pills keep their plate and read greyed out by colour, not as
     faded grey blobs over the water. */
  .controls-inner .header-pill:is(.disabled, :disabled) {
    opacity: 1;
    filter: none;
    color: var(--ui-faint);
  }

  /* The read-only lock (panels.css) fades with !important; same look here. */
  .controls-inner .header-pill.shared-readonly-locked {
    opacity: 1 !important;
  }

  .controls-inner .header-pill:focus-visible {
    outline-offset: -2px;
  }
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: var(--overlay-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  transition: opacity 0.25s ease;
}

.modal.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Dialogs: the admin's card language. White card, hairline, soft navy
   shadow, a field with the azure focus halo, the marine primary action. */
.modal-content {
  min-width: var(--modal-min-w);
  padding: 26px;
  border: 1px solid var(--ui-line);
  border-radius: var(--radius-xl);
  background: var(--ui-card);
  color: var(--ui-ink);
  text-align: left;
  box-shadow: var(--ui-shadow-lg);
}

.modal-content h3 {
  margin: 0 0 16px;
  color: var(--ui-ink);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.modal-input-label {
  display: block;
  margin: 0 0 6px 2px;
  color: var(--ui-ink-2);
  font-size: 12px;
  font-weight: 500;
}

.modal-content input {
  width: 100%;
  height: 48px;
  margin-bottom: 20px;
  padding: 0 14px;
  border: 1px solid var(--ui-line-strong);
  border-radius: 10px;
  background: var(--ui-field);
  color: var(--ui-ink);
  box-shadow: var(--ui-shadow-xs);
  font-family: var(--font-sans);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.modal-content input::placeholder {
  color: var(--ui-subtle);
}

.modal-content input:focus {
  border-color: var(--ui-ring);
  box-shadow: 0 0 0 3px var(--ui-focus);
}

.modal-buttons {
  display: flex;
  gap: 8px;
}

/* Secondary buttons are hairline cards; the primary action is marine
   (#confirmSave). */
.modal-buttons button {
  flex: 1;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--ui-line-strong);
  border-radius: 10px;
  background: var(--ui-card);
  color: var(--ui-ink);
  box-shadow: var(--ui-shadow-xs);
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.modal-buttons button:hover {
  border-color: #9e9a91;
  background: #f9f8f5;
}

#confirmSave {
  border-color: var(--ui-accent);
  background: var(--ui-accent);
  color: var(--ui-on-accent);
  box-shadow: var(--ui-shadow-primary);
  font-weight: 700;
}

#confirmSave:hover {
  border-color: var(--ui-accent-hover);
  background: var(--ui-accent-hover);
}
