/* ============================================================================
   Desktop Menu Bar
   ============================================================================
   Visible on medium and large viewports.
   Renders the command tree as a horizontal bar with dropdowns.
*/

/* Hidden by default */
#desktop-menu-bar {
  display: none;
}


/* ============================================================================
   Menu Bar Layout
   ============================================================================ */

.menu-bar {
  align-items: center;
  height: 28px;
  padding: 0 4px;
  background: var(--bg-secondary, #f9fafb);
  border-bottom: 1px solid var(--border-color, #e5e7eb);
  font-size: 13px;
  user-select: none;
  flex-shrink: 0;
}

.menu-bar-item {
  position: relative;
}

.menu-bar-trigger {
  height: 28px;
  padding: 0 10px;
  border: none;
  background: transparent;
  font-size: 13px;
  cursor: pointer;
  border-radius: 4px;
  color: #1f2937;
  line-height: 28px;
}

.menu-bar-trigger:hover,
.menu-bar-trigger[aria-expanded="true"] {
  background: #e5e7eb;
}

/* ============================================================================
   Dropdowns
   ============================================================================ */

.menu-bar-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  max-height: calc(100vh - 40px);
  overflow-y: visible;
  z-index: 1001;
}


/* Right-align last 2 menus to prevent overflow */
.menu-bar-item:nth-last-child(-n+2) .menu-bar-dropdown {
  left: auto;
  right: 0;
}

/* ============================================================================
   Submenu Flyouts
   ============================================================================ */

.menu-bar-submenu-wrapper {
  position: relative;
}

.submenu-flyout {
  position: absolute;
  top: -4px;
  left: 100%;
  min-width: 200px;
  z-index: 1002;
}

/* Flip flyout to left side if near right edge */
.menu-bar-item:nth-last-child(-n+2) .submenu-flyout {
  left: auto;
  right: 100%;
}

/* ============================================================================
   Menu Search (mobile drawer)
   ============================================================================ */

.menu-search {
  padding: 8px 12px;
  border-bottom: 1px solid #e5e7eb;
}

.menu-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  background: #f9fafb;
  box-sizing: border-box;
}

.menu-search input:focus {
  border-color: #3b82f6;
  background: #fff;
}

.menu-search-results {
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  padding: 4px 0;
}

.menu-search-path {
  font-size: 13px;
  color: #374151;
}

.menu-search-empty {
  padding: 16px 12px;
  text-align: center;
  color: #9ca3af;
  font-size: 13px;
}

/* ============================================================================
   Right Section: Stream Label + Action Buttons
   ============================================================================ */

.menu-bar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 2px;
  padding-right: 4px;
}

.menu-bar-status {
  font-size: 11px;
  color: var(--text-secondary, #6b7280);
  white-space: nowrap;
  pointer-events: none;
  padding: 0 4px;
}

.menu-bar-separator {
  width: 1px;
  height: 16px;
  background: var(--border-color, #d1d5db);
  margin: 0 4px;
  flex-shrink: 0;
}

.menu-bar-action-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-secondary, #6b7280);
  font-size: 16px;
  padding: 0;
}

.menu-bar-action-btn:hover {
  background: var(--bg-hover, #e5e7eb);
  color: var(--text-primary, #1f2937);
}

.menu-bar-action-btn.active {
  color: var(--accent, #3b82f6);
}

.menu-bar-action-btn.playing {
  color: #ef4444;
}

/* ============================================================================
   Segmented View Switcher  [Edit | Staff ▾]
   ============================================================================ */

.menu-bar-view-switcher {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 26px;
  border-radius: 6px;
  background: var(--bg-hover, #e5e7eb);
  overflow: visible;
  margin: 0 2px;
}

.view-seg {
  height: 24px;
  padding: 0 10px;
  border: none;
  background: transparent;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 5px;
  color: var(--text-secondary, #6b7280);
  white-space: nowrap;
  margin: 1px;
  line-height: 24px;
  transition: background 0.12s, color 0.12s;
}

.view-seg:hover {
  color: var(--text-primary, #1f2937);
}

.view-seg.active {
  background: #fff;
  color: var(--text-primary, #1f2937);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.view-seg-arrow {
  font-size: 10px;
  opacity: 0.6;
}

.view-seg-label {
  pointer-events: none;
}

/* Dropdown for switching view tabs */
.view-seg-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 140px;
  background: var(--bg-surface, #fff);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  z-index: 1100;
  padding: 4px 0;
}

.view-seg-dropdown-item {
  display: block;
  width: 100%;
  padding: 6px 14px;
  border: none;
  background: transparent;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  color: var(--text-primary, #1f2937);
}

.view-seg-dropdown-item:hover {
  background: var(--bg-hover, #f3f4f6);
}

.view-seg-dropdown-item.active {
  color: var(--primary-color, #3b82f6);
  font-weight: 600;
}

/* ============================================================================
   Container Query Duplicates (Phase 2 migration)
   ============================================================================ */

/* Show desktop menu on medium+ container width */
@container app-layout (width >= 600px) {
  #desktop-menu-bar { display: flex; position: relative; z-index: 1000; }
  #osk-menu-btn { display: none; }
}

/* Hide toolbelt on desktop — menu bar right section replaces it */
@container app-layout (width >= 1024px) {
  #toolbelt-bar { display: none !important; }
}

/* Hide mobile detection strip when desktop menu bar is visible */
@container app-layout (width >= 600px) {
  #stream-status { display: none !important; }
}

/* ============================================================================
   Dark Mode
   ============================================================================ */

@media (prefers-color-scheme: dark) {
  .menu-bar {
    background: var(--bg-secondary, #1f2937);
    border-bottom-color: var(--border-color, #374151);
  }

  .menu-bar-trigger {
    color: #f3f4f6;
  }

  .menu-bar-trigger:hover,
  .menu-bar-trigger[aria-expanded="true"] {
    background: #374151;
  }

  .menu-search input {
    background: #1f2937;
    border-color: #374151;
    color: #f3f4f6;
  }

  .menu-search input:focus {
    border-color: #3b82f6;
    background: #111827;
  }

  .menu-search-path {
    color: #e5e7eb;
  }

  .menu-search-empty {
    color: #6b7280;
  }

  .menu-bar-separator {
    background: var(--border-color, #4b5563);
  }

  .menu-bar-action-btn {
    color: var(--text-secondary, #9ca3af);
  }

  .menu-bar-action-btn:hover {
    background: #374151;
    color: #f3f4f6;
  }

  .menu-bar-view-switcher {
    background: #374151;
  }

  .view-seg {
    color: #9ca3af;
  }

  .view-seg:hover {
    color: #f3f4f6;
  }

  .view-seg.active {
    background: #4b5563;
    color: #f3f4f6;
    box-shadow: none;
  }

  .view-seg-dropdown {
    background: #1f2937;
    border-color: #374151;
  }

  .view-seg-dropdown-item {
    color: #e5e7eb;
  }

  .view-seg-dropdown-item:hover {
    background: #374151;
  }
}
