/* cspell:ignore scrollbars, clickability */
/* ============================================
   HEADER NO-SCROLL FIX - COMPLETE SOLUTION
   Applied: October 8, 2025
   Eliminates ALL scrollbars in header while maintaining functionality
   ============================================ */

/* ============================================
   1. CORE HEADER STRUCTURE - NO SCROLLING
   ============================================ */

.main-nav {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10001 !important; /* Ensure header stays above mobile menu */
  background-color: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  width: 100%;
  min-height: 64px;
  max-height: 64px; /* Fixed height prevents vertical scroll */
  box-sizing: border-box;
  overflow: hidden !important; /* No overflow in any direction */
  padding: 0;
  margin: 0;
}

.nav-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px; /* Fixed height */
  max-height: 64px;
  width: 100%;
  box-sizing: border-box;
  flex-wrap: nowrap; /* Never wrap */
  position: relative;
  padding: 8px clamp(8px, 2vw, 24px);
  overflow: hidden !important; /* No overflow */
  gap: clamp(4px, 1vw, 16px);
}

/* ============================================
   2. LOGO - FIXED SIZE, NO SHRINK
   ============================================ */

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
  text-decoration: none;
  flex-shrink: 0; /* Never shrink */
  white-space: nowrap;
  font-size: clamp(14px, 2vw, 18px);
  max-width: fit-content;
  overflow: hidden;
  height: 48px;
  min-height: 48px;
  max-height: 48px;
}

.logo svg {
  width: clamp(28px, 4vw, 36px);
  height: clamp(28px, 4vw, 36px);
  flex-shrink: 0;
}

.logo-text {
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================
   3. NAVIGATION LINKS - ADAPTIVE, NO SCROLL
   ============================================ */

.nav-links {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-width: 0;
  height: 48px;
  max-height: 48px;
  overflow: visible; /* Allow normal visibility on desktop */
  flex-wrap: nowrap;
  gap: clamp(2px, 1vw, 12px);
  padding: 0;
  margin: 0 clamp(4px, 1vw, 16px);
  position: relative;
}

/* Desktop-specific navigation (769px and above - tablets and larger) */
@media (min-width: 769px) {
  .nav-links {
    overflow: visible !important; /* Allow proper display on desktop */
    display: flex !important; /* Always show on desktop */
    position: static !important; /* Normal positioning on desktop */
    flex-direction: row !important; /* Horizontal layout */
    background: transparent !important; /* No background on desktop */
    padding: 0 !important; /* No extra padding on desktop */
    box-shadow: none !important; /* No shadow on desktop */
    border: none !important; /* No border on desktop */
    opacity: 1 !important; /* Always visible on desktop */
    visibility: visible !important; /* Always visible on desktop */
    transform: none !important; /* No transform on desktop */
    z-index: auto !important; /* Normal z-index on desktop */
  }

  .nav-link {
    height: 36px;
    min-height: 36px;
    max-height: 36px;
    background-color: transparent !important;
    border: none !important;
    margin: 0 !important;
  }

  .mobile-menu-toggle {
    display: none !important; /* Hide hamburger on desktop */
  }
}

/* Hide any scrollbars completely */
.nav-links::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

.nav-links {
  /* Browser compatibility: scrollbar hiding */
  -ms-overflow-style: none !important; /* IE and Edge */
  scrollbar-width: none !important; /* Firefox */
}

.nav-links::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

.nav-link {
  position: relative;
  padding: clamp(4px, 0.8vw, 8px) clamp(6px, 1.2vw, 12px);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  transition: color var(--transition-fast),
    background-color var(--transition-fast);
  white-space: nowrap;
  flex-shrink: 1; /* Allow shrinking to fit */
  text-decoration: none;
  font-size: clamp(11px, 1.5vw, 14px);
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box;
  height: 36px;
  min-height: 36px;
  max-height: 36px;
}

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

.nav-link.active::after {
  content: "";
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  height: 2px;
  background-color: var(--color-text);
}

/* ============================================
   4. NAVIGATION ACTIONS - COMPACT, NO SCROLL
   ============================================ */

.nav-actions {
  display: flex;
  align-items: center;
  gap: clamp(4px, 0.8vw, 8px);
  flex-shrink: 0; /* Never shrink */
  height: 48px;
  max-height: 48px;
  overflow: hidden;
  padding: 0;
  margin: 0;
}

/* Auth buttons */
.auth-buttons {
  display: flex;
  align-items: center;
  gap: clamp(2px, 0.5vw, 6px);
  flex-wrap: nowrap;
  overflow: hidden;
}

.auth-buttons .btn-sm {
  padding: clamp(3px, 0.6vw, 6px) clamp(6px, 1vw, 12px);
  font-size: clamp(10px, 1.2vw, 12px);
  white-space: nowrap;
  min-width: -webkit-fill-available;
  min-width: fit-content;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  height: 32px;
  min-height: 32px;
  max-height: 32px;
  box-sizing: border-box;
}

/* Theme toggle button */
.theme-toggle {
  position: relative;
  width: clamp(28px, 4vw, 36px);
  height: clamp(28px, 4vw, 36px);
  min-width: clamp(28px, 4vw, 36px);
  min-height: clamp(28px, 4vw, 36px);
  max-width: clamp(28px, 4vw, 36px);
  max-height: clamp(28px, 4vw, 36px);
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--transition-fast),
    background-color var(--transition-fast);
  flex-shrink: 0;
  overflow: hidden;
  padding: 0;
  margin: 0;
}

.theme-toggle:hover {
  border-color: var(--color-border-hover);
  background-color: var(--color-bg-secondary);
}

.theme-toggle svg {
  width: clamp(14px, 2vw, 18px);
  height: clamp(14px, 2vw, 18px);
  flex-shrink: 0;
}

/* User menu */
.user-menu {
  position: relative;
  flex-shrink: 0;
  height: 36px;
  max-height: 36px;
  overflow: visible; /* Allow dropdown to show */
}

.user-button {
  display: flex;
  align-items: center;
  gap: clamp(2px, 0.5vw, 6px);
  padding: clamp(3px, 0.6vw, 6px) clamp(6px, 1vw, 10px);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-base);
  font-size: clamp(10px, 1.2vw, 12px);
  white-space: nowrap;
  min-width: -webkit-fill-available;
  min-width: fit-content;
  max-width: 120px;
  height: 32px;
  min-height: 32px;
  max-height: 32px;
  overflow: hidden;
  box-sizing: border-box;
}

.user-avatar {
  width: clamp(20px, 3vw, 24px);
  height: clamp(20px, 3vw, 24px);
  min-width: clamp(20px, 3vw, 24px);
  min-height: clamp(20px, 3vw, 24px);
  border-radius: var(--radius-full);
  flex-shrink: 0;
  background: var(--color-bg-tertiary);
}

.user-name {
  font-size: clamp(9px, 1.1vw, 11px);
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60px;
}

/* ============================================
   5. MOBILE MENU - HIDDEN SCROLLBARS
   ============================================ */

.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--color-text);
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  max-width: 36px;
  max-height: 36px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  z-index: 999998 !important; /* Ensure hamburger button is always clickable */
  overflow: hidden;
}

.hamburger {
  display: block;
  width: 20px;
  height: 2px;
  background-color: currentColor;
  position: relative;
  transition: background-color var(--transition-fast);
}

.hamburger::before,
.hamburger::after {
  content: "";
  position: absolute;
  width: 100%;
  height: 2px;
  background-color: currentColor;
  left: 0;
  transition: transform var(--transition-base);
}

.hamburger::before {
  top: -6px;
}

.hamburger::after {
  bottom: -6px;
}

/* Active state */
.mobile-menu-toggle[aria-expanded="true"] .hamburger {
  background-color: transparent;
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger::before {
  transform: translateY(6px) rotate(45deg);
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger::after {
  transform: translateY(-6px) rotate(-45deg);
}

/* ============================================
   6. RESPONSIVE BREAKPOINTS - NO SCROLLING
   ============================================ */

/* Extra Large Desktop (1441px+) */
@media (min-width: 1441px) {
  .nav-content {
    gap: 20px;
    padding: 8px 32px;
  }

  .nav-links {
    gap: 16px;
    margin: 0 20px;
    overflow: visible !important;
    display: flex !important;
    position: static !important;
    background: transparent !important;
    opacity: 1 !important;
    visibility: visible !important;
  }

  .nav-link {
    padding: 8px 14px;
    font-size: 14px;
  }

  .nav-actions {
    gap: 12px;
  }
}

/* Large Desktop (1025px - 1440px) */
@media (max-width: 1440px) and (min-width: 1025px) {
  .nav-content {
    gap: 16px;
    padding: 8px 24px;
  }

  .nav-links {
    gap: 12px;
    margin: 0 16px;
    overflow: visible !important;
    display: flex !important;
    position: static !important;
    background: transparent !important;
    opacity: 1 !important;
    visibility: visible !important;
  }

  .nav-link {
    padding: 7px 12px;
    font-size: 13px;
  }

  .nav-actions {
    gap: 10px;
  }
}

/* Tablet (769px - 1024px) */
@media (max-width: 1024px) and (min-width: 769px) {
  .nav-content {
    gap: 12px;
    padding: 8px 20px;
  }

  .nav-links {
    gap: 8px;
    margin: 0 12px;
    overflow: visible !important;
    display: flex !important;
    position: static !important;
    background: transparent !important;
    opacity: 1 !important;
    visibility: visible !important;
  }

  .nav-link {
    padding: 6px 10px;
    font-size: 12px;
  }

  .nav-actions {
    gap: 8px;
  }

  .user-name {
    display: none;
  }

  .user-button {
    max-width: 40px;
    padding: 6px;
  }
}

/* Small Tablet/Large Mobile (641px - 768px) */
@media (max-width: 768px) and (min-width: 641px) {
  .nav-content {
    gap: 8px;
    padding: 8px 16px;
  }

  .nav-links {
    gap: 4px;
    margin: 0 8px;
  }

  .nav-link {
    padding: 5px 8px;
    font-size: 11px;
  }

  .nav-actions {
    gap: 6px;
  }

  .user-name {
    display: none;
  }

  .user-button {
    max-width: 36px;
    padding: 5px;
  }

  .auth-buttons .btn-sm {
    padding: 4px 8px;
    font-size: 10px;
  }
}

/* Mobile (481px - 640px) */
@media (max-width: 640px) and (min-width: 481px) {
  .nav-content {
    gap: 6px;
    padding: 8px 12px;
  }

  .nav-links {
    gap: 2px;
    margin: 0 6px;
  }

  .nav-link {
    padding: 4px 6px;
    font-size: 10px;
  }

  .nav-actions {
    gap: 4px;
  }

  .user-name {
    display: none;
  }

  .user-button {
    max-width: 32px;
    padding: 4px;
  }

  .auth-buttons .btn-sm {
    padding: 3px 6px;
    font-size: 9px;
  }

  .theme-toggle {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    max-width: 32px;
    max-height: 32px;
  }

  .theme-toggle svg {
    width: 14px;
    height: 14px;
  }
}

/* Mobile and Small Windows (320px - 768px) - Switch to hamburger */
@media (max-width: 768px) {
  .mobile-menu-toggle {
    display: flex;
    order: 3;
    z-index: 999999 !important; /* Same as mobile menu for accessibility */
    position: relative !important;
    /* Additional fixes for clickability */
    background: transparent !important;
    border: none !important;
    cursor: pointer !important;
    pointer-events: auto !important;
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: transparent !important;
  }

  .nav-content {
    gap: 4px;
    padding: 8px 8px;
    flex-wrap: nowrap;
    justify-content: space-between;
    align-items: center;
  }

  .nav-links {
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    flex-direction: column;
    background-color: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    padding: 16px;
    gap: 8px;
    display: none;
    z-index: 999999 !important; /* Highest z-index to appear above everything including header */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: calc(100vh - 64px);
    overflow-y: auto;
    overflow-x: hidden;
    margin: 0;
    height: auto;
    width: 100vw;
    box-sizing: border-box;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
    /* Additional fixes for dropdown blocking */
    isolation: isolate;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    backface-visibility: hidden;
    will-change: transform, opacity, visibility;
  }

  .nav-links.active {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
    /* Force above everything */
    z-index: 999999 !important;
    position: fixed !important;
    isolation: isolate;
    -webkit-transform: translateZ(0) translateY(0);
    transform: translateZ(0) translateY(0);
    backface-visibility: hidden;
    will-change: transform, opacity, visibility;
    /* Additional emergency fixes for dropdown */
    top: 64px !important;
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    height: auto !important;
    max-height: calc(100vh - 64px) !important;
    background-color: var(--color-bg, white) !important;
    border: 1px solid var(--color-border, #e5e5e5) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
  }

  /* Add backdrop overlay when menu is open */
  .nav-links.active::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.3);
    z-index: -1;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
  }

  .nav-link {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    justify-content: center;
    font-size: 14px;
    height: auto;
    min-height: 48px;
    max-height: none;
    color: var(--color-text) !important;
    background-color: transparent !important;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    text-decoration: none;
    display: flex;
    align-items: center;
    box-sizing: border-box;
  }

  .nav-link:hover {
    background-color: var(--color-bg-secondary) !important;
    color: var(--color-text) !important;
    border-color: var(--color-border);
  }

  .nav-link.active::after {
    display: none;
  }

  .nav-link.active {
    background-color: var(--color-bg-secondary) !important;
    font-weight: var(--font-weight-semibold);
    color: var(--color-text) !important;
    border-color: var(--color-border);
  }

  .nav-actions {
    gap: 4px;
    order: 2;
  }

  .logo {
    order: 1;
    font-size: 14px;
  }

  .logo-text {
    display: none;
  }

  .auth-buttons {
    flex-direction: row; /* Keep horizontal layout */
    gap: 2px;
    flex-wrap: nowrap; /* Don't wrap */
  }

  .auth-buttons .btn-sm {
    min-width: 40px;
    padding: 4px 6px;
    font-size: 10px;
    white-space: nowrap; /* Prevent text wrapping */
  }

  .user-name {
    display: none;
  }

  .user-button {
    max-width: 28px;
    min-width: 28px;
    width: 28px;
    padding: 3px;
  }

  .theme-toggle {
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    max-width: 28px;
    max-height: 28px;
  }

  .theme-toggle svg {
    width: 12px;
    height: 12px;
  }
}

/* Extra Small Mobile (320px and below) */
@media (max-width: 320px) {
  .nav-content {
    gap: 4px;
    padding: 6px 8px;
    min-height: 56px;
    height: 56px;
    max-height: 56px;
  }

  .main-nav {
    min-height: 56px;
    max-height: 56px;
  }

  .logo svg {
    width: 24px;
    height: 24px;
  }

  .theme-toggle {
    width: 26px;
    height: 26px;
    min-width: 26px;
    min-height: 26px;
    max-width: 26px;
    max-height: 26px;
  }

  .mobile-menu-toggle {
    width: 26px;
    height: 26px;
    min-width: 26px;
    min-height: 26px;
    max-width: 26px;
    max-height: 26px;
  }

  .auth-buttons .btn-sm {
    padding: 2px 4px;
    font-size: 8px;
    min-width: 40px;
  }

  .nav-links {
    top: 56px;
    max-height: calc(100vh - 56px);
  }
}

/* ============================================
   7. FOCUS STATES - NO SCROLL IMPACT
   ============================================ */

.nav-link:focus-visible,
.theme-toggle:focus-visible,
.user-button:focus-visible,
.mobile-menu-toggle:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
  z-index: 10;
}

/* ============================================
   8. PREVENT CONTENT SHIFT
   ============================================ */

/* Ensure main content doesn't jump when nav changes */
main,
.dashboard-main,
.community-main,
.racing-main,
.parts-main,
.marketplace-main,
.profile-main {
  padding-top: clamp(16px, 3vw, 32px);
  min-height: calc(100vh - 64px);
  position: relative;
  z-index: 1;
}

@media (max-width: 320px) {
  main,
  .dashboard-main,
  .community-main,
  .racing-main,
  .parts-main,
  .marketplace-main,
  .profile-main {
    min-height: calc(100vh - 56px);
  }
}

/* ============================================
   9. ACCESSIBILITY - NO SCROLLING INTERFERENCE
   ============================================ */

/* Skip navigation link */
.skip-to-content {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--color-text);
  color: var(--color-bg);
  padding: 8px 12px;
  z-index: 2000;
  transition: top var(--transition-fast);
  text-decoration: none;
  font-weight: var(--font-weight-medium);
  font-size: 12px;
}

.skip-to-content:focus {
  top: 0;
}

/* ============================================
   10. REDUCED MOTION SUPPORT
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  .nav-link,
  .theme-toggle,
  .user-button,
  .hamburger,
  .hamburger::before,
  .hamburger::after {
    transition: none;
  }
}

/* ============================================
   11. HIGH CONTRAST MODE
   ============================================ */

@media (prefers-contrast: high) {
  .nav-link {
    border: 1px solid transparent;
  }

  .nav-link:hover,
  .nav-link.active {
    border-color: currentColor;
  }

  .nav-link.active::after {
    height: 3px;
  }
}

/* ============================================
   12. PRINT STYLES
   ============================================ */

@media print {
  .main-nav {
    position: static;
    border-bottom: 2px solid #000;
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .mobile-menu-toggle,
  .theme-toggle,
  .auth-buttons {
    display: none !important;
  }

  .nav-links {
    display: flex !important;
    position: static;
    flex-direction: row;
    gap: 12px;
    padding: 6px 0;
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .nav-link {
    font-size: 10px;
    padding: 3px 6px;
    height: auto;
    min-height: 0;
    max-height: none;
  }

  .nav-content {
    height: auto;
    max-height: none;
    padding: 6px 12px;
  }
}

/* ============================================
   13. MOBILE MENU VISIBILITY FIX
   ============================================ */

/* Ensure mobile menu is always visible when active */
@media (max-width: 768px) {
  .nav-links.active {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
    background-color: var(--color-bg, #ffffff) !important;
    color: var(--color-text, #000000) !important;
  }

  /* Force link visibility in mobile menu */
  .nav-links.active .nav-link {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    color: var(--color-text, #000000) !important;
    background-color: transparent !important;
  }

  /* Ensure mobile menu backdrop */
  .nav-links.active::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: -1;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
  }
}

/* ============================================
   14. OVERRIDE CONFLICTING STYLES
   ============================================ */

/* Override any previous overflow settings */
.main-nav,
.nav-content,
.nav-links {
  overflow-x: hidden !important;
  overflow-y: hidden !important;
}

/* Mobile menu is exception - allows vertical scroll */
@media (max-width: 768px) {
  .nav-links {
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }
}

/* Remove any scrollbar styling */
.nav-links::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

.nav-links {
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

/* ============================================
   14. EMERGENCY FIXES
   ============================================ */

/* If content still overflows, force hide it */
.main-nav * {
  max-width: 100% !important;
  box-sizing: border-box !important;
}

/* Prevent any absolute positioning from causing overflow */
.main-nav [style*="position: absolute"] {
  max-width: calc(100vw - 32px) !important;
}

/* ============================================
   16. MOBILE MENU Z-INDEX EMERGENCY FIXES
   ============================================ */

/* Force mobile menu to be on top of everything */
@media (max-width: 768px) {
  .nav-links {
    z-index: 999999 !important;
    position: fixed !important;
    isolation: isolate; /* Create new stacking context */
  }

  .nav-links.active {
    z-index: 999999 !important;
    position: fixed !important;
    isolation: isolate; /* Create new stacking context */
    transform: translateZ(0); /* Force hardware acceleration */
    will-change: transform, opacity; /* Optimize for animations */
  }

  /* Ensure hamburger button is clickable */
  .mobile-menu-toggle {
    z-index: 999998 !important;
    position: relative !important;
    isolation: isolate; /* Create new stacking context */
  }

  /* Ensure main nav header stays below mobile menu */
  .main-nav {
    z-index: 10001 !important;
    isolation: isolate; /* Create new stacking context */
  }

  /* Force all page content below mobile menu */
  main,
  .dashboard-main,
  .community-main,
  .racing-main,
  .parts-main,
  .marketplace-main,
  .profile-main,
  [class*="-main"] {
    z-index: 1 !important;
    position: relative;
  }

  /* Force specific problematic elements to stay below */
  .tab-content,
  .card,
  .modal,
  .dropdown,
  .tooltip,
  [class*="tab-"],
  [class*="card-"],
  [class*="modal-"],
  [class*="dropdown-"] {
    z-index: auto !important;
    position: relative;
  }
}

/* ============================================
   18. BODY SCROLL LOCK AND OVERLAY FIXES
   ============================================ */

/* Lock body scroll when mobile menu is active */
@media (max-width: 768px) {
  body.mobile-menu-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
  }

  /* Ensure mobile menu covers entire viewport */
  .nav-links.active {
    position: fixed !important;
    top: 64px !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: calc(100vh - 64px) !important;
    z-index: 999999 !important;
  }

  /* Force mobile menu above everything */
  .nav-links.active::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999998;
    pointer-events: none;
  }
}

/* ============================================
   20. EMERGENCY MOBILE MENU FIXES
   ============================================ */

/* Force hamburger button to be clickable and visible */
@media (max-width: 768px) {
  .mobile-menu-toggle {
    display: flex !important;
    position: relative !important;
    z-index: 999999 !important;
    background: transparent !important;
    border: none !important;
    cursor: pointer !important;
    pointer-events: auto !important;
    touch-action: manipulation !important;
    -webkit-user-select: none !important;
    user-select: none !important;
    -webkit-tap-highlight-color: transparent !important;
  }

  /* Ensure hamburger lines are visible */
  .mobile-menu-toggle .hamburger,
  .mobile-menu-toggle .hamburger::before,
  .mobile-menu-toggle .hamburger::after {
    background-color: var(--color-text) !important;
    display: block !important;
    position: relative !important;
    z-index: inherit !important;
  }

  /* Force mobile menu above everything */
  .nav-links.active {
    position: fixed !important;
    top: 64px !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 999999 !important;
    display: flex !important;
    flex-direction: column !important;
    background: var(--color-bg, white) !important;
    padding: 16px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }

  /* Ensure nav links are visible and clickable */
  .nav-links.active .nav-link {
    display: block !important;
    padding: 12px 16px !important;
    color: var(--color-text, black) !important;
    background: transparent !important;
    border: none !important;
    text-decoration: none !important;
    width: 100% !important;
    text-align: left !important;
  }
}

/* ============================================
   21. FORCE MOBILE MENU TO WORK EVEN WITHOUT CSS VARIABLES
   ============================================ */

/* Force mobile menu to work even without CSS variables */
@media (max-width: 768px) {
  .nav-links {
    background-color: white !important;
    background-color: var(--color-bg, white) !important;
    color: black !important;
    color: var(--color-text, black) !important;
  }

  .nav-links.active {
    background-color: white !important;
    background-color: var(--color-bg, white) !important;
    color: black !important;
    color: var(--color-text, black) !important;
    border: 1px solid #e5e5e5 !important;
    border-color: var(--color-border, #e5e5e5) !important;
  }

  .nav-link {
    color: black !important;
    color: var(--color-text, black) !important;
    background-color: transparent !important;
  }

  .nav-link:hover {
    background-color: #f5f5f5 !important;
    background-color: var(--color-bg-secondary, #f5f5f5) !important;
    color: black !important;
    color: var(--color-text, black) !important;
  }

  .nav-link.active {
    background-color: #f5f5f5 !important;
    background-color: var(--color-bg-secondary, #f5f5f5) !important;
    color: black !important;
    color: var(--color-text, black) !important;
  }

  /* Dark mode support */
  [data-theme="dark"] .nav-links,
  .dark .nav-links {
    background-color: #1a1a1a !important;
    color: white !important;
  }

  [data-theme="dark"] .nav-links.active,
  .dark .nav-links.active {
    background-color: #1a1a1a !important;
    color: white !important;
    border-color: #333333 !important;
  }

  [data-theme="dark"] .nav-link,
  .dark .nav-link {
    color: white !important;
  }

  [data-theme="dark"] .nav-link:hover,
  .dark .nav-link:hover,
  [data-theme="dark"] .nav-link.active,
  .dark .nav-link.active {
    background-color: #333333 !important;
    color: white !important;
  }
}

/* ============================================
   17. MOBILE LANDSCAPE ORIENTATION
   ============================================ */

@media (max-height: 500px) and (orientation: landscape) {
  .main-nav {
    min-height: 48px;
    max-height: 48px;
  }

  .nav-content {
    min-height: 48px;
    height: 48px;
    max-height: 48px;
    padding: 4px clamp(8px, 2vw, 16px);
  }

  .logo,
  .nav-actions {
    height: 40px;
    max-height: 40px;
  }

  .nav-link {
    height: 28px;
    min-height: 28px;
    max-height: 28px;
  }

  .theme-toggle,
  .mobile-menu-toggle {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    max-width: 32px;
    max-height: 32px;
  }

  .nav-links {
    top: 48px;
    max-height: calc(100vh - 48px);
  }

  main,
  .dashboard-main,
  .community-main,
  .racing-main,
  .parts-main,
  .marketplace-main,
  .profile-main {
    min-height: calc(100vh - 48px);
  }
}

/* ============================================
   EMERGENCY HAMBURGER DROPDOWN FIX
   ============================================ */

/* Force hamburger menu to work at all costs */
@media (max-width: 768px) {
  /* Make sure hamburger button is visible and clickable */
  .mobile-menu-toggle {
    display: flex !important;
    position: relative !important;
    z-index: 999999 !important;
    width: 36px !important;
    height: 36px !important;
    background: transparent !important;
    border: none !important;
    cursor: pointer !important;
    pointer-events: auto !important;
    order: 3 !important;
  }

  /* Force hamburger lines to be visible */
  .mobile-menu-toggle .hamburger {
    display: block !important;
    width: 20px !important;
    height: 2px !important;
    background-color: var(--color-text, #333) !important;
    position: relative !important;
  }

  .mobile-menu-toggle .hamburger::before,
  .mobile-menu-toggle .hamburger::after {
    content: "" !important;
    position: absolute !important;
    width: 100% !important;
    height: 2px !important;
    background-color: var(--color-text, #333) !important;
    left: 0 !important;
    transition: transform 0.3s ease !important;
  }

  .mobile-menu-toggle .hamburger::before {
    top: -6px !important;
  }

  .mobile-menu-toggle .hamburger::after {
    bottom: -6px !important;
  }

  /* Hidden mobile menu */
  .nav-links {
    display: none !important;
    position: fixed !important;
    top: 64px !important;
    left: 0 !important;
    right: 0 !important;
    background: var(--color-bg, white) !important;
    z-index: 999999 !important;
    padding: 16px !important;
    flex-direction: column !important;
    gap: 8px !important;
    border-bottom: 1px solid var(--color-border, #e5e5e5) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    max-height: calc(100vh - 64px) !important;
    overflow-y: auto !important;
  }

  /* Show mobile menu when active */
  .nav-links.active {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
  }

  /* Style navigation links in mobile menu */
  .nav-links.active .nav-link {
    display: block !important;
    padding: 12px 16px !important;
    color: var(--color-text, #333) !important;
    text-decoration: none !important;
    border-radius: 4px !important;
    transition: background-color 0.2s ease !important;
  }

  .nav-links.active .nav-link:hover {
    background-color: var(--color-bg-secondary, #f5f5f5) !important;
  }

  /* Hamburger animation when active */
  .mobile-menu-toggle[aria-expanded="true"] .hamburger {
    background-color: transparent !important;
  }

  .mobile-menu-toggle[aria-expanded="true"] .hamburger::before {
    transform: translateY(6px) rotate(45deg) !important;
  }

  .mobile-menu-toggle[aria-expanded="true"] .hamburger::after {
    transform: translateY(-6px) rotate(-45deg) !important;
  }
}

/* ============================================
   SIMPLE HAMBURGER MENU FIX
   Applied: October 8, 2025
   Minimal fix to make hamburger menu work
   ============================================ */

/* Force hamburger menu to work properly */
@media (max-width: 768px) {
  /* Ensure hamburger button is visible and clickable */
  .mobile-menu-toggle {
    display: flex !important;
    position: relative !important;
    z-index: 99999 !important;
    background: none !important;
    border: none !important;
    cursor: pointer !important;
    width: 36px !important;
    height: 36px !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Hide desktop nav links on mobile */
  .nav-links {
    display: none !important;
    position: fixed !important;
    top: 64px !important;
    left: 0 !important;
    right: 0 !important;
    background: white !important;
    background: var(--color-bg, white) !important;
    border-bottom: 1px solid #ccc !important;
    border-bottom: 1px solid var(--color-border, #ccc) !important;
    padding: 20px !important;
    flex-direction: column !important;
    z-index: 99998 !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1) !important;
  }

  /* Show mobile menu when active */
  .nav-links.active {
    display: flex !important;
  }

  /* Style nav links in mobile menu */
  .nav-links .nav-link {
    display: block !important;
    padding: 15px 0 !important;
    margin: 0 !important;
    color: #333 !important;
    color: var(--color-text, #333) !important;
    text-decoration: none !important;
    border-bottom: 1px solid #eee !important;
    border-bottom: 1px solid var(--color-border, #eee) !important;
  }

  .nav-links .nav-link:hover {
    color: #0066cc !important;
    background: #f9f9f9 !important;
  }

  /* Ensure hamburger icon is visible */
  .mobile-menu-toggle .hamburger {
    width: 20px !important;
    height: 2px !important;
    background: #333 !important;
    background: var(--color-text, #333) !important;
    display: block !important;
    position: relative !important;
  }

  .mobile-menu-toggle .hamburger::before,
  .mobile-menu-toggle .hamburger::after {
    content: "" !important;
    width: 20px !important;
    height: 2px !important;
    background: #333 !important;
    background: var(--color-text, #333) !important;
    position: absolute !important;
    left: 0 !important;
    transition: all 0.3s ease !important;
  }

  .mobile-menu-toggle .hamburger::before {
    top: -6px !important;
  }

  .mobile-menu-toggle .hamburger::after {
    bottom: -6px !important;
  }
}

/* ============================================
   SUPER SIMPLE HAMBURGER FIX - TEST
   ============================================ */

/* Force everything to work with maximum priority */
@media (max-width: 768px) {
  .mobile-menu-toggle {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
    z-index: 999999 !important;
    background: none !important;
    border: none !important;
    cursor: pointer !important;
    width: 40px !important;
    height: 40px !important;
    padding: var(--space-xs) !important;
    color: var(--color-text) !important;
  }

  .nav-links {
    display: none !important;
    position: fixed !important;
    top: 70px !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: var(--color-bg) !important;
    padding: var(--space-xl) !important;
    z-index: 999998 !important;
    overflow-y: auto !important;
    flex-direction: column !important;
    gap: var(--space-md) !important;
  }

  .nav-links.active {
    display: flex !important;
  }

  .nav-links .nav-link {
    display: block !important;
    padding: var(--space-md) var(--space-lg) !important;
    color: var(--color-text) !important;
    background: none !important;
    margin: 0 !important;
    border: none !important;
    border-bottom: 1px solid var(--color-border) !important;
    text-decoration: none !important;
    transition: background-color var(--transition-fast) !important;
  }

  .nav-links .nav-link:hover {
    background: var(--color-bg-secondary) !important;
  }

  .nav-links .nav-link.active {
    font-weight: var(--font-weight-semibold) !important;
    color: var(--color-text) !important;
  }
}

/* CRITICAL FIX: Override global.css display:none with maximum specificity */
/* Mobile menu toggle should only show on mobile */
@media (max-width: 768px) {
  html body .mobile-menu-toggle {
    display: block !important;
  }
}

/* Desktop: Hide mobile menu toggle */
@media (min-width: 769px) {
  html body .mobile-menu-toggle {
    display: none !important;
  }
}

html body .nav-links {
  display: flex !important;
}

/* Mobile override with maximum specificity */
@media (max-width: 768px) {
  html body .mobile-menu-toggle {
    display: block !important;
  }

  html body .nav-links {
    display: none !important; /* Hidden by default on mobile */
  }

  html body .nav-links.active {
    display: flex !important; /* Shown when active */
  }
}

/* THEME TOGGLE PRODUCTION FIX - Ensure consistent visibility */
.theme-toggle {
  display: flex !important;
  position: relative !important;
  width: 40px !important;
  height: 40px !important;
  background: none !important;
  border: 1px solid var(--color-border) !important;
  border-radius: var(--radius-md) !important;
  cursor: pointer !important;
  color: var(--color-text) !important;
  align-items: center !important;
  justify-content: center !important;
  transition: border-color var(--transition-fast),
    background-color var(--transition-fast) !important;
  z-index: 10002 !important;
  margin: 0 !important;
  padding: 0 !important;
}

.theme-toggle:hover {
  border-color: var(--color-border-hover) !important;
  background-color: var(--color-bg-secondary) !important;
}

.theme-toggle svg {
  display: block !important;
  width: 20px !important;
  height: 20px !important;
  color: currentColor !important;
  fill: currentColor !important;
  position: absolute !important;
  transition: opacity var(--transition-fast), transform var(--transition-fast) !important;
}

/* Force show sun/moon icons with proper transitions */
.sun-icon {
  opacity: 1 !important;
  transform: rotate(0deg) !important;
}

.moon-icon {
  opacity: 0 !important;
  transform: rotate(90deg) !important;
}

[data-theme="dark"] .sun-icon {
  opacity: 0 !important;
  transform: rotate(-90deg) !important;
}

[data-theme="dark"] .moon-icon {
  opacity: 1 !important;
  transform: rotate(0deg) !important;
}

/* ============================================
   ULTIMATE MOBILE MENU FIX - MAXIMUM SPECIFICITY
   Added: 2025-10-17
   Ensures mobile menu appears when active
   ============================================ */
@media (max-width: 768px) {
  /* Force mobile menu toggle to be visible and clickable */
  html body header .mobile-menu-toggle,
  html body .header .mobile-menu-toggle {
    display: flex !important;
    visibility: visible !important;
    pointer-events: auto !important;
    opacity: 1 !important;
  }

  /* Force nav-links to be hidden by default on mobile */
  html body header .nav-links,
  html body .header .nav-links {
    display: none !important;
    visibility: hidden !important;
  }

  /* Force nav-links to show when active class is present */
  html body header .nav-links.active,
  html body .header .nav-links.active {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    position: fixed !important;
    top: 70px !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: var(--color-bg) !important;
    padding: var(--space-xl) !important;
    z-index: 999998 !important;
    overflow-y: auto !important;
    flex-direction: column !important;
    gap: var(--space-md) !important;
  }
}
