/* ==========================================
   MENU BAR V2 - Clean Architecture
   Layout only, no visibility control
   Breakpoints: 768px (mobile), 1024px (tablet), 1025px+ (desktop)
   ========================================== */

/* ==========================================
   BASE STRUCTURE
   ========================================== */

.menu-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-header);
  background: var(--bg-primary);
  height: var(--menu-bar-height);
  box-sizing: border-box;
}

.menu-bar-inner {
  max-width: var(--container-xl); /* 1280px max width for desktop */
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: 0 var(--space-md);
}

/* ==========================================
   BRAND LOGO
   ========================================== */

.brand-logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: var(--primary);
  font-weight: var(--font-bold);
  font-size: var(--text-2xl);
  padding: var(--space-sm);
  border-radius: var(--radius-lg);
  transition: var(--transition-colors);
  flex-shrink: 0;
  letter-spacing: -0.02em;
}

.brand-logo:hover {
  transform: scale(1.02);
}

.brand-name {
  white-space: nowrap;
}

/* ==========================================
   MOBILE LAYOUT (≤768px)
   ========================================== */

.mobile-layout {
  display: flex;
  align-items: center;
  position: relative;
}

/* ==========================================
   TABLET LAYOUT (769px - 1024px)
   ========================================== */

.tablet-layout {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-xl);
  padding: var(--space-sm) var(--space-md);
  box-shadow: var(--shadow-base);
}

.icon-wrapper {
  position: relative;
  /* No z-index - prevents creating stacking context that traps dropdown children */
}

/* ==========================================
   DESKTOP LAYOUT (≥1025px)
   ========================================== */

.desktop-layout {
  display: flex;
  width: 100%;
  justify-content: flex-end; /* Align items to the right */
  align-items: stretch; /* Make children same height */
  gap: var(--space-md);
}

.menu-center {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-xl);
  padding: var(--space-sm) var(--space-md);
  box-shadow: var(--shadow-base);
}

.menu-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-xl);
  padding: var(--space-sm) var(--space-md);
  box-shadow: var(--shadow-base);
  flex-shrink: 0; /* Don't shrink, maintain natural width */
}

/* ==========================================
   ICON BUTTONS (All Layouts)
   ========================================== */

.icon-button {
  background: var(--input-bg);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-full);
  width: 40px;
  height: 40px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: var(--transition-all);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-base);
  position: relative;
}

.icon-button:hover {
  background: var(--primary);
  color: var(--btn-text);
  border-color: var(--primary);
  transform: scale(1.05);
}

.icon-button i {
  transition: var(--transition-transform);
}

.icon-button:hover i {
  transform: rotate(15deg);
}

/* ==========================================
   OVERFLOW MENU (Mobile)
   ========================================== */

.overflow-toggle {
  /* Uses icon-button styles */
}

.overflow-dropdown {
  position: fixed;
  top: var(--menu-bar-height);
  right: var(--space-md);
  z-index: var(--z-dropdown);
  min-width: 220px;
  max-width: 280px;
  max-height: 80vh;
  padding: var(--space-xs) 0;
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
}

.overflow-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: none;
  background: none;
  color: var(--text-primary);
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
  transition: var(--transition-colors);
  text-decoration: none;
}

.overflow-item:hover {
  background: var(--hover-bg);
}

.overflow-item i {
  width: 20px;
  font-size: var(--text-base);
  text-align: center;
  opacity: 0.7;
}

.overflow-item.danger {
  color: var(--error);
}

.overflow-item.danger:hover {
  background: var(--error-bg);
}

.overflow-divider {
  height: 1px;
  margin: var(--space-xs) 0;
  background: var(--border-primary);
}

.overflow-section-header {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.overflow-subitem {
  font-size: var(--text-sm);
  padding-left: 2rem;
}

.overflow-badge {
  min-width: 20px;
  padding: 0.125rem var(--space-sm);
  border-radius: var(--radius-full);
  background: var(--accent);
  color: var(--btn-text);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-align: center;
  margin-left: auto;
}

.user-avatar-small {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: var(--btn-text);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
}

/* ==========================================
   DROPDOWNS (Tablet & Desktop)
   ========================================== */

.dropdown-wrapper {
  position: relative;
}

.dropdown {
  position: absolute;
  top: calc(100% + var(--space-sm));
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  min-width: 200px;
  z-index: var(--z-dropdown);
  overflow: hidden;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  cursor: pointer;
  transition: var(--transition-colors);
  text-decoration: none;
  color: var(--text-primary);
  font-size: var(--text-sm);
}

.dropdown-item:hover {
  background: var(--hover-bg);
}

.dropdown-item i {
  width: 20px;
  text-align: center;
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.dropdown-item:hover i {
  color: var(--primary);
}

.dropdown-item.danger {
  color: var(--error);
}

.dropdown-item.danger:hover {
  background: var(--error-bg);
}

.dropdown-item.danger i {
  color: var(--error);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-primary);
  margin: var(--space-sm) 0;
}

.dropdown-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-primary);
  background: var(--bg-secondary);
}

/* ==========================================
   SELECTOR BUTTONS
   ========================================== */

.selector-button {
  background: var(--input-bg);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  color: var(--text-primary);
  transition: var(--transition-all);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--text-sm);
  height: 40px;
  box-sizing: border-box;
  white-space: nowrap;
}

.selector-button:hover {
  background: var(--hover-bg);
  border-color: var(--primary);
}

.selector-button .button-text {
  font-weight: var(--font-medium);
}

.selector-button i.fa-chevron-down {
  font-size: 0.7rem;
  transition: var(--transition-transform);
}

/* ==========================================
   USER ELEMENTS
   ========================================== */

.user-button {
  /* Uses selector-button styles */
}

.user-avatar {
  background: var(--primary);
  color: var(--btn-text);
  border-radius: var(--radius-full);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
}

.user-dropdown .dropdown-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-primary);
}

.user-name {
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.user-email {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

/* ==========================================
   TAB BUTTONS (Desktop)
   ========================================== */

.tab-button {
  background: transparent;
  border: none;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-weight: var(--font-medium);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  transition: var(--transition-all);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  white-space: nowrap;
  flex-shrink: 0;
  text-decoration: none;
  height: 44px;
  box-sizing: border-box;
}

.tab-button:hover {
  background: var(--hover-bg);
  color: var(--text-primary);
}

.tab-button.active,
.tab-button.with-context {
  background: var(--primary);
  color: var(--btn-text);
  font-weight: var(--font-semibold);
}

.tab-button i {
  font-size: var(--text-sm);
}

/* ==========================================
   NOTIFICATION ELEMENTS
   ========================================== */

.notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--error);
  color: white;
  border-radius: var(--radius-full);
  padding: 2px 6px;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  min-width: 18px;
  text-align: center;
}

.notification-dropdown {
  position: absolute;
  top: calc(100% + var(--space-sm));
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  min-width: 320px;
  max-height: 400px;
  overflow-y: auto;
  z-index: var(--z-dropdown);
}

.notification-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-primary);
}

.notification-title {
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.mark-all-btn {
  background: transparent;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: var(--text-xs);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  transition: var(--transition-colors);
}

.mark-all-btn:hover {
  background: var(--primary-bg-subtle);
}

.notification-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  color: var(--text-secondary);
  gap: var(--space-sm);
}

.notification-empty p {
  margin: 0;
  font-size: var(--text-sm);
}

.empty-state-icon {
  font-size: var(--text-4xl);
  opacity: 0.3;
}

/* ==========================================
   CONTEXT SELECTOR ITEMS (Portfolio/Market)
   ========================================== */

.selector-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  cursor: pointer;
  transition: var(--transition-colors);
  text-decoration: none;
  color: var(--text-primary);
  font-size: var(--text-sm);
  border-left: 3px solid transparent;
}

.selector-item:hover {
  background: var(--hover-bg);
}

.selector-item.active {
  background: var(--primary-bg-subtle);
  border-left-color: var(--primary);
}

.selector-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.selector-item-name {
  font-weight: var(--font-medium);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selector-item-meta {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selector-item i.selector-icon {
  width: 20px;
  text-align: center;
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.selector-item.active i.selector-icon {
  color: var(--primary);
}

/* Context-aware tab styling */
.tab-button.with-context {
  max-width: 280px;
  padding-right: var(--space-md);
}

.tab-button .context-separator {
  opacity: 0.5;
  margin: 0 var(--space-xs);
}

.tab-button .context-name {
  font-weight: var(--font-normal);
  opacity: 0.9;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 150px;
}

/* Dropdown for context selectors */
.selector-dropdown {
  position: absolute;
  top: calc(100% + var(--space-sm));
  left: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  min-width: 280px;
  max-width: 320px;
  max-height: 400px;
  overflow-y: auto;
  z-index: var(--z-dropdown);
}

.selector-section-header {
  padding: var(--space-sm) var(--space-lg);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-tertiary);
}

/* ==========================================
   DARK MODE ADJUSTMENTS
   ========================================== */

[data-theme="dark"] .overflow-dropdown,
[data-theme="dark"] .dropdown,
[data-theme="dark"] .notification-dropdown,
[data-theme="dark"] .selector-dropdown {
  background: var(--bg-secondary);
  border-color: var(--border-primary);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

