/* Top Navigation Bar Styles */
.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  z-index: 1000;
  padding: var(--space-3) 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  /* TEMPORARY FIX - Ensure top-nav is always visible */
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  transform: none !important;
}

.top-nav-container {
  max-width: 100%;
  margin: 0;
  padding: 0 10px; /* 10px from left/right edges */
  display: -webkit-flex; /* Safari flexbox prefix */
  display: flex;
  -webkit-align-items: center; /* Safari align-items prefix */
  align-items: center;
  -webkit-justify-content: space-between; /* Safari justify-content prefix */
  justify-content: space-between;
}

/* Three-dots button hidden by default (desktop/tablet) */
.nav-menu-button { display: none; }

.top-nav-logo {
  display: -webkit-flex; /* Safari flexbox prefix */
  display: flex;
  -webkit-align-items: center; /* Safari align-items prefix */
  align-items: center;
}

.top-nav-logo .logo-text {
  display: inline-block;
  width: 40px;
  height: 40px;
  background: var(--primary-color);
  color: white;
  border-radius: var(--radius-base);
  display: -webkit-flex; /* Safari flexbox prefix */
  display: flex;
  -webkit-align-items: center; /* Safari align-items prefix */
  align-items: center;
  -webkit-justify-content: center; /* Safari justify-content prefix */
  justify-content: center;
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
}

.top-nav-menu {
  display: -webkit-flex; /* Safari flexbox prefix */
  display: flex;
  -webkit-align-items: center; /* Safari align-items prefix */
  align-items: center;
  gap: var(--space-6);
  flex: 1; /* occupy remaining width between logo and right edge */
  min-width: 0; /* prevent overflow calc issues in Safari */
}

.top-nav-item {
  padding: var(--space-2) var(--space-4);
  color: var(--text-secondary) !important;
  text-decoration: none;
  font-weight: var(--font-medium);
  font-size: var(--text-sm);
  border-radius: var(--radius-base);
  transition: all var(--transition-fast);
  position: relative;
  display: inline-block;
}

.top-nav-item:hover {
  color: var(--text-primary);
  background-color: var(--bg-secondary);
}

.top-nav-item.active {
  color: white;
  background-color: transparent;
  font-weight: var(--font-semibold);
}

/* Mobile Top Navigation (≤ 767px) */
@media (max-width: 767px) {
  .top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex !important;
    visibility: visible !important;
    padding: 0;
    overflow-x: hidden; /* prevent slight horizontal shift */
  }

  .top-nav-container {
    display: flex !important;
    align-items: center;
    justify-content: space-between; /* MT logo on left, hamburger on right */
    width: 100%;
    height: 100%;
    padding: 0 var(--space-3); /* 12px from edges on mobile */
    gap: var(--space-3);
  }

  /* Show MT logo on mobile (left) */
  .top-nav-logo { display: flex !important; align-items: center !important; }
  .top-nav-logo .logo-text { display: inline-flex !important; }

  /* Hide the full nav menu on mobile; replaced by quick menu */
  .top-nav-menu { display: none !important; }

  .top-nav-menu::-webkit-scrollbar {
    display: none;
  }

  .top-nav-item {
    display: block !important;
    visibility: visible !important;
    white-space: nowrap;
    font-size: var(--text-sm);
    padding: var(--space-2) var(--space-3);
    color: var(--text-secondary) !important;
    text-decoration: none;
    border-radius: var(--radius-base);
    transition: all var(--transition-fast);
    flex-shrink: 0;
    pointer-events: auto;
    touch-action: manipulation;
    cursor: pointer;
  }

  .top-nav-item:hover,
  .top-nav-item.active {
    color: var(--primary-color) !important;
    background: var(--bg-secondary);
  }

  /* Hamburger Menu (3 dots) - positioned on FAR RIGHT edge */
  .hamburger {
    display: flex !important;
    visibility: visible !important;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    width: 21px;
    height: 21px;
    background: transparent;
    border: none;
    padding: 0;
    flex-shrink: 0;
    cursor: pointer;
    margin-left: auto; /* Push to far right */
    margin-right: 0; /* Aligned to right edge with container padding */
    z-index: 10005; /* Above sidebar and overlay */
    position: relative;
  }

  .hamburger span {
    width: 4px;
    height: 4px;
    background-color: var(--text-primary);
    border-radius: 50%;
    display: block;
  }
}

/* Mobile quick nav (three horizontal lines) - HIDDEN - Sidebar navigation handles mobile navigation */
@media (max-width: 767px) {
  /* Hide mobile quick nav completely - it blocks interactive elements and is redundant with sidebar */
  #mobileQuickNav,
  .mobile-quick-nav {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }
  
  /* Hide nav-lines button that triggers mobile quick nav */
  .nav-lines,
  #navLinesBtn {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }
}

/* Very small screens optimization */
@media (max-width: 480px) {
  .top-nav-container {
    padding: 0 var(--space-2);
    gap: var(--space-2);
  }

  .top-nav-menu {
    gap: var(--space-1);
    padding: 0 var(--space-1);
  }

  .top-nav-item {
    font-size: var(--text-xs);
    padding: var(--space-2) var(--space-2);
  }

  .top-nav-logo .logo-text {
    width: 28px;
    height: 28px;
    font-size: var(--text-xs);
  }
}

@media (min-width: 769px) {
  /* Mobile header removed - top-nav handles all navigation */
  
  /* Desktop: Hide hamburger (3 dots) - not needed on desktop */
  .hamburger {
    display: none !important;
    visibility: hidden !important;
  }
  
  /* Desktop: Properly spaced navigation menu - evenly distributed */
  .top-nav-menu {
    gap: calc(var(--space-6) * 2.5) !important; /* gap setting */
    -webkit-justify-content: space-between !important; /* Even spacing between About and Contact */
    justify-content: space-between !important;
    flex-wrap: nowrap;
    margin-left: 259px; /* moved further ~10% left from 288px */
  }
  
  .top-nav-item {
    padding: var(--space-2) var(--space-4) !important; /* Tighter padding so last item (Contact) fits */
    margin: 0 !important;
  }
  
  /* Adjust main content to account for top nav */
  .main-content {
    margin-top: 60px; /* Add top margin to account for fixed nav */
  }
  
  /* Adjust sidebar to account for top nav */
  .sidebar {
    top: 60px; /* Position sidebar below top nav */
    height: calc(100vh - 60px);
  }
}

/* Ensure mobile-only controls are hidden on desktop */
@media (min-width: 769px) {
  .nav-lines, .mobile-quick-nav { display: none !important; }
}

/* Desktop wide (≥1334px): sidebar is 400px, add 10px */
@media (min-width: 1334px) {
  .top-nav-menu { margin-left: 332px; }
}

/* Desktop medium (1024–1333px): sidebar ~30% but ≥280px; use 320px safe offset */
@media (min-width: 1024px) and (max-width: 1333px) {
  .top-nav-menu { margin-left: 259px; }
}

/* Tablet (768–1023px): sidebar = 280px; add 10px */
@media (min-width: 768px) and (max-width: 1023px) {
  .top-nav-menu { margin-left: 235px; }
}

/* Push Contact (last item) to right edge using auto margin; honors 10px container padding */
.top-nav-menu .top-nav-item:last-child { margin-left: auto; }
