/* ============================================
   LEVERAGE - NAVIGATION SYSTEM
   Shared header & nav styles for all pages
   ============================================ */



* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-ui);
  background-color: var(--bg-color);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ===================== HEADER ===================== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #0b0f19;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding: 0;
  backdrop-filter: none;
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.header-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.header-bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 0.75rem;
}

/* ===================== SUBNAV BAR (BELOW HEADER) ===================== */
.page-subnav-bar {
  background: #0A0A0B;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  width: 100%;
}

.page-subnav-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 8px 1.5rem;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

/* ===================== BACK BUTTON ===================== */
.back-btn,
.nav-back-btn {
  color: #a1a1aa;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.2s ease;
  cursor: pointer;
  flex-shrink: 0;
  user-select: none;
  line-height: 1;
}

.back-btn:hover,
.nav-back-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.back-btn:active,
.nav-back-btn:active {
  transform: translateY(0);
  background: rgba(255, 255, 255, 0.08);
}

.back-btn svg,
.nav-back-btn svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  stroke-width: 2;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.back-btn:hover svg,
.nav-back-btn:hover svg {
  transform: translateX(-2px);
}

/* ===================== LOGO ===================== */
.logo-container {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  flex-shrink: 0;
}

.brand-logo-full {
  height: 40px;
  width: auto;
  max-width: 260px;
  display: block;
  object-fit: contain;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.brand-logo-icon-only {
  display: none;
  height: 38px;
  width: 38px;
  object-fit: contain;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.logo-container:hover .brand-logo-full,
.logo-container:hover .brand-logo-icon-only {
  transform: scale(1.03);
  opacity: 0.95;
}

.logo-icon {
  height: 48px;
  width: auto;
  display: block;
  border-radius: 8px;
}

.brand-image-wrapper {
  height: 48px;
  width: auto;
  overflow: hidden;
  margin-left: 0px;
  display: flex;
  align-items: center;
}

.brand-text {
  font-family: var(--font-brand);
  font-size: 1.4rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.5px;
}

.brand-image {
  height: 100%;
  width: 100%;
  object-fit: contain;
  display: block;
  transition: transform 0.3s ease;
}

/* ===================== SEARCH ===================== */
.search-panel {
  flex: 1;
  margin: 0 24px;
  max-width: 500px;
}

.search-container {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #ffffff;
  padding: 8px 36px 8px 36px;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 400;
  outline: none;
  transition: all 0.2s ease;
}

.search-input:focus {
  border-color: var(--accent-blue);
  background: rgba(255, 255, 255, 0.1);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-shortcut {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 4px;
  pointer-events: none;
}

/* REMOVED scrolling overlay classes */

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: #0a0a0a;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  max-height: 400px;
  overflow-y: auto;
  z-index: 200;
  display: none;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
}

.search-results.visible {
  display: block;
}

.result-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  transition: background 0.15s;
}

.result-item:last-child {
  border-bottom: none;
}

.result-item:hover {
  background: rgba(255,255,255,0.05);
}

.result-info {
  flex: 1;
  min-width: 0;
}

.result-name {
  font-size: 0.85rem;
  color: var(--text-primary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-ticker {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.result-price {
  text-align: right;
  white-space: nowrap;
}

.search-launch-btn {
  background: var(--accent-blue);
  color: white;
  border: none;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  opacity: 0;
  transform: translateX(10px);
  transition: all 0.2s;
  pointer-events: none;
  white-space: nowrap;
}

.result-item:hover .search-launch-btn {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

/* ===================== NAV LINKS ===================== */
.nav-links {
  display: flex;
  align-items: center;
  gap: 28px;
  min-width: 0; /* flex items default to min-width:auto, which blocks shrinking below content's
                   natural width and forces the page to overflow horizontally instead of this
                   list scrolling internally */
  /* Unconditional (not just the mobile media query below) — on any viewport where the 7 links
     plus the market-status pill don't both fit (e.g. a ~900-1000px laptop window, well above
     the 768px mobile breakpoint), the links need to scroll internally instead of visually
     overflowing into the status pill next to them. */
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-links::-webkit-scrollbar {
  display: none;
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s;
  padding: 4px 0;
  position: relative;
}

.nav-link:hover,
.nav-link.active {
  color: var(--text-primary);
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent-blue);
  border-radius: 1px;
}

/* ===================== NAV DROPDOWN (MORE) ===================== */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-arrow {
  font-size: 0.7rem;
  margin-left: 4px;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
  display: block;
}

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 8px;
  min-width: 200px;
  background: rgba(17, 17, 17, 0.97);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  z-index: 1000;
  padding: 6px;
}

.nav-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 4px;
  font-size: 0.85rem;
  transition: all 0.15s;
}

.nav-dropdown-item:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
}

.nav-dropdown-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
}

/* ===================== NAV ACTIONS ===================== */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.nav-icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.nav-icon-btn:hover {
  color: var(--text-primary);
}

.notification-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--danger);
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

/* Market Status */
.market-status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(255,255,255,0.05);
  border-radius: 16px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  flex-shrink: 0; /* was shrinking under space pressure with no min-width floor, letting
                      .nav-links' own links overflow past it and visually overlap the pill */
}

/* Mobile-only landing spot for .market-status-indicator, between the header and the index
   ticker strip on home.html/index.html — see initMobileMarketStatusSlot() in nav.js. Empty
   and inert on desktop, where the indicator stays inside the header. */
.mobile-market-status-slot {
  display: none;
}

.status-text {
  white-space: nowrap;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--success);
  animation: pulse 2s infinite;
}

.pulse-dot.closed {
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}

@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.5; }
  100% { opacity: 1; }
}

/* ===================== AUTH ===================== */
.auth-btn {
  padding: 8px 16px;
  background: var(--accent-blue);
  color: white;
  border: none;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
  white-space: nowrap;
}

.auth-btn:hover {
  background: var(--accent-blue-hover);
}

/* User Dropdown */
.user-info {
  display: none;
}

.user-dropdown {
  position: relative;
  display: inline-block;
}

.user-profile-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #1e1e24, #0a0a0c);
  border: 1px solid rgba(37, 99, 235, 0.3);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(37, 99, 235, 0.15), inset 0 0 5px rgba(255,255,255,0.05);
  transition: all 0.3s ease;
}

.user-profile-btn:hover,
.user-dropdown.active .user-profile-btn {
  border-color: var(--accent-blue);
  box-shadow: 0 0 15px rgba(37, 99, 235, 0.4), inset 0 0 8px rgba(255,255,255,0.1);
  transform: translateY(-1px);
}

.user-profile-btn svg {
  color: var(--accent-blue);
}

.user-balance {
  color: var(--success);
  font-weight: 600;
  padding: 3px 8px;
  background: rgba(0,200,83,0.1);
  border-radius: 4px;
  font-size: 0.85rem;
}

.user-name {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 0.85rem;
}

.dropdown-arrow {
  font-size: 0.6rem;
  color: var(--text-secondary);
  transition: transform 0.2s;
}

.user-dropdown.active .dropdown-arrow {
  transform: rotate(180deg);
}

.dropdown-content {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 8px;
  min-width: 190px;
  background: rgba(17,17,17,0.97);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  z-index: 1000;
  padding: 6px;
}

.dropdown-content.show {
  display: block;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-header {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dropdown-user-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropdown-user-balance {
  color: var(--success);
  font-weight: 600;
  font-size: 0.85rem;
}

.dropdown-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 4px 0;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 4px;
  font-size: 0.85rem;
  transition: all 0.15s;
}

.dropdown-item:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
}

.dropdown-item .icon {
  font-size: 0.95rem;
  width: 20px;
  text-align: center;
}

.logout-item:hover {
  color: #ffd700;
}

.delete-item:hover {
  background: rgba(255,82,82,0.1);
  color: var(--danger);
}

/* ===================== PAGE CONTENT ===================== */
.page-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
  min-height: 70vh;
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 768px) {
  .header-container {
    padding: 0.5rem 1rem;
  }
  .header-top-row {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .search-panel {
    order: 3;
    margin: 0;
    max-width: 100%;
    flex-basis: 100%;
  }
  .nav-links {
    gap: 16px;
    padding-bottom: 4px;
  }
  .nav-link {
    font-size: 0.8rem;
    white-space: nowrap;
  }
  .mobile-market-status-slot {
    display: flex;
    justify-content: flex-end;
    padding: 0 2px;
    margin: 0;
  }
  .brand-logo-full {
    display: none !important;
  }
  .brand-logo-icon-only {
    display: block !important;
    height: 36px;
    width: 36px;
  }
  .page-content {
    padding: 1rem;
  }
}

/* Scrolling Placeholder Styles */
.placeholder-overlay {
  position: absolute;
  left: 48px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  display: flex;
  align-items: center;
  font-size: 0.95rem;
  color: #71717a;
  white-space: nowrap;
  transition: opacity 0.2s ease, visibility 0.2s;
  z-index: 5;
}

/* Hide overlay only when input has value (placeholder is NOT shown) */
.search-input:not(:placeholder-shown)~.placeholder-overlay {
  opacity: 0;
  visibility: hidden;
}

.scrolling-wrapper {
  height: 1.4rem;
  overflow: hidden !important;
  margin-left: 5px;
  display: inline-block;
  vertical-align: middle;
}

.scrolling-content {
  display: flex;
  flex-direction: column;
  animation: scrollPlaceholder 12s cubic-bezier(0.645, 0.045, 0.355, 1) infinite;
}

.scrolling-item {
  height: 1.4rem;
  line-height: 1.4rem;
  color: var(--accent-blue);
  font-weight: 700;
}

@keyframes scrollPlaceholder {
  0%, 16% { transform: translateY(0); }
  20%, 36% { transform: translateY(-1.4rem); }
  40%, 56% { transform: translateY(-2.8rem); }
  60%, 76% { transform: translateY(-4.2rem); }
  80%, 96% { transform: translateY(-5.6rem); }
  100% { transform: translateY(-7.0rem); }
}

/* ===================== THEME TOGGLE HIDDEN ===================== */
#themeToggle {
  display: none !important;
}

/* ===================== NOTIFICATION PANEL ===================== */
.app-notification-panel {
  display: none;
  position: fixed;
  background: #151820;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.75);
  z-index: 10000;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  animation: notifFadeIn 0.2s ease-out;
}

.app-notification-panel.show {
  display: flex !important;
  flex-direction: column;
}

@keyframes notifFadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.notif-header-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.notif-header-badge {
  background: #2962ff;
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
}

.notif-close-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #a1a1aa;
  font-size: 16px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  line-height: 1;
}

.notif-close-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

.notif-body {
  max-height: 320px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 0;
}

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.15s;
}

.notif-item:last-child {
  border-bottom: none;
}

.notif-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.notif-item.unread {
  background: rgba(41, 98, 255, 0.06);
}

.notif-icon-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.notif-content {
  flex: 1;
  min-width: 0;
}

.notif-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 2px;
}

.notif-desc {
  font-size: 0.75rem;
  color: #a1a1aa;
  line-height: 1.4;
}

.notif-time {
  font-size: 0.68rem;
  color: #71717a;
  margin-top: 4px;
}

.notif-footer {
  padding: 10px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center;
  background: rgba(255, 255, 255, 0.02);
}

.notif-footer-link {
  color: #4A90E2;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.15s;
}

.notif-footer-link:hover {
  color: #70aeff;
}
