/* Modern Navbar Styles */
:root {
  --navbar-height: 64px;
  /* Total navbar height including safe area for iPhone notch */
  --navbar-total-height: calc(64px + env(safe-area-inset-top, 0px));
}

/* Hide navbar for PIN-authenticated users - applied immediately via early script */
html.pin-auth-mode .navbar,
body.pin-auth-mode .navbar {
  display: none !important;
}

.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10020;
  height: var(--navbar-height);
  padding-top: env(safe-area-inset-top);
  background: rgba(255, 255, 255, 0.98);
  /* Reduced blur for better scroll performance - using lighter blur or solid background */
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  /* Removed expensive transitions that trigger on scroll */
  /* Removed transform to prevent stacking context issues with fixed children */
  /* transform: translateZ(0); */
  /* will-change: auto; */
  /* Removed contain: paint as it clips dropdowns */
  /* contain: layout style; */
}

.dark .navbar {
  background: rgba(0, 0, 0, 0.98);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.navbar-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  min-height: var(--navbar-height);
  position: relative;
  z-index: 10020;
  overflow: visible;
}

@media (max-width: 1023px) {
  .navbar-container {
    padding: 0 0.75rem;
  }
}

@media (min-width: 768px) {
  .navbar-container {
    padding: 0 2rem;
  }
}

/* Brand Section */
.navbar-brand {
  display: flex;
  align-items: center;
  z-index: 1;
  flex-shrink: 0;
}

@media (max-width: 1023px) {
  .navbar-brand {
    flex: 0 0 auto;
    max-width: calc(100% - 60px);
  }
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
  padding: 0.5rem;
  border-radius: 0.5rem;
  transition: background 0.2s ease;
}

.brand-link:hover {
  background: rgba(0, 0, 0, 0.05);
}

.dark .brand-link:hover {
  background: rgba(255, 255, 255, 0.1);
}

.brand-logo {
  height: 40px;
  width: auto;
  max-width: 200px;
  min-height: 32px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
  transition: transform 0.2s ease, filter 0.2s ease;
  flex-shrink: 0;
}

/* Ensure logo is visible on light backgrounds */
.navbar .brand-logo {
  opacity: 1;
  visibility: visible;
}

.brand-link:hover .brand-logo {
  transform: scale(1.05);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

/* Fallback if logo fails to load */
.brand-logo[src=""],
.brand-logo:not([src]) {
  display: none;
}

.brand-text {
  display: none !important;
}

/* Navigation */
.navbar-nav {
  display: flex;
  align-items: center;
  gap: 2rem;
  position: relative;
  z-index: 10020;
  overflow: visible;
}

@media (max-width: 1023px) {
  .navbar-nav {
    display: none;
  }
}

/* Navigation Links */
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  color: hsl(var(--foreground, #1f2937));
  text-decoration: none;
  font-weight: 500;
  font-size: 0.875rem;
  border-radius: 0.5rem;
  transition: background 0.2s ease, color 0.2s ease, opacity 0.2s ease;
  position: relative;
  white-space: nowrap;
}

.nav-link:hover {
  background: rgba(0, 0, 0, 0.05);
  color: hsl(var(--foreground, #1f2937));
}

.dark .nav-link:hover {
  background: rgba(255, 255, 255, 0.1);
}

.nav-link.active {
  background: hsl(var(--primary, #3b82f6));
  color: hsl(var(--primary-foreground, #ffffff));
}

.nav-link.active:hover {
  background: hsl(var(--primary, #3b82f6));
  opacity: 0.9;
}

/* Dropdown */
.dropdown {
  position: relative;
  z-index: 10030;
}

.dropdown-toggle {
  cursor: pointer;
  background: none;
  border: none;
  font: inherit;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dropdown-arrow {
  transition: transform 0.2s ease;
}

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

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 0.75rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  opacity: 0;
  visibility: hidden;
  transform: translateX(-50%) translateY(-10px);
  transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10030;
  /* Wider min-width to accommodate 2 columns */
  min-width: 520px;
  max-width: 90vw;
  pointer-events: none;
  /* Desktop dropdown max-height with scrolling */
  max-height: calc(100vh - var(--navbar-height) - 2rem);
  overflow-y: auto;
  overflow-x: hidden;
}

.dark .dropdown-menu {
  background: hsl(var(--background, #1f2937));
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

/* Custom scrollbar for dropdown menu */
.dropdown-menu::-webkit-scrollbar {
  width: 6px;
}

.dropdown-menu::-webkit-scrollbar-track {
  background: transparent;
  margin: 0.5rem 0;
}

.dropdown-menu::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 3px;
}

.dropdown-menu::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.25);
}

.dark .dropdown-menu::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
}

.dark .dropdown-menu::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Firefox scrollbar styling */
.dropdown-menu {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}

.dark .dropdown-menu {
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.dropdown.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* Dropdown Grid */
.dropdown-grid {
  display: grid;
  /* Force 2 columns on desktop to reduce dropdown height */
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 0.5rem;
  padding: 0.75rem;
  overflow: visible;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  text-decoration: none;
  color: inherit;
  border-radius: 0.5rem;
  transition: background 0.2s ease;
}

.dropdown-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

.dark .dropdown-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.dropdown-item button {
  width: 100%;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  padding: 0;
}

.dropdown-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.dropdown-content {
  flex: 1;
  min-width: 0;
  overflow: visible;
}

.dropdown-title {
  font-weight: 600;
  font-size: 0.875rem;
  color: hsl(var(--foreground, #1f2937));
  margin-bottom: 0.125rem;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
  text-align: left;
}

.dropdown-desc {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground, #6b7280));
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
  line-height: 1.4;
}

/* Dropdown Footer */
.dropdown-footer {
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  padding: 0.75rem;
}

.dark .dropdown-footer {
  border-color: rgba(255, 255, 255, 0.1);
}

.dropdown-footer .dropdown-link {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  margin: 0.125rem;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground, #6b7280));
  text-decoration: none;
  border-radius: 0.25rem;
  transition: background 0.2s ease, color 0.2s ease;
}

.dropdown-footer .dropdown-link:hover {
  background: rgba(0, 0, 0, 0.05);
  color: hsl(var(--foreground, #1f2937));
}

.dark .dropdown-footer .dropdown-link:hover {
  background: rgba(255, 255, 255, 0.1);
}

.dropdown-divider {
  height: 1px;
  background: rgba(0, 0, 0, 0.1);
  margin: 0.5rem 0;
}

.dark .dropdown-divider {
  background: rgba(255, 255, 255, 0.1);
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  padding: 0.75rem;
  min-width: 44px;
  min-height: 44px;
  background: none;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background 0.2s ease;
  z-index: 1001;
  position: relative;
  -webkit-appearance: none;
  appearance: none;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  margin: 0;
  text-decoration: none;
  outline: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.dark .mobile-menu-toggle {
  border-color: rgba(255, 255, 255, 0.2);
}

.mobile-menu-toggle:hover {
  background: rgba(0, 0, 0, 0.05);
}

.dark .mobile-menu-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
}

@media (min-width: 1024px) {
  .mobile-menu-toggle {
    display: none !important;
  }
}

/* Ensure toggle is visible on mobile (but we hide it in the media query below for bottom nav) */
@media (max-width: 1023px) {
  .mobile-menu-toggle {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
}

.hamburger-line {
  width: 20px;
  height: 2px;
  background: hsl(var(--foreground, #1f2937));
  transition: transform 0.3s ease, opacity 0.3s ease;
  transform-origin: center;
  will-change: transform, opacity;
}

.mobile-menu-toggle.mobile-menu-open .hamburger-line:nth-child(1),
body.mobile-menu-open .mobile-menu-toggle .hamburger-line:nth-child(1) {
  transform: rotate(45deg) translate(6px, 6px);
}

.mobile-menu-toggle.mobile-menu-open .hamburger-line:nth-child(2),
body.mobile-menu-open .mobile-menu-toggle .hamburger-line:nth-child(2) {
  opacity: 0;
}

.mobile-menu-toggle.mobile-menu-open .hamburger-line:nth-child(3),
body.mobile-menu-open .mobile-menu-toggle .hamburger-line:nth-child(3) {
  transform: rotate(-45deg) translate(6px, -6px);
}

/* Mobile Menu & Bottom Nav Adjustments */
@media (max-width: 1023px) {
  /* Body padding for bottom nav - increased to prevent content from being hidden behind bottom nav */
  body {
    padding-bottom: calc(80px + env(safe-area-inset-bottom)) !important;
  }

  /* Hide Top Hamburger - Commented out to allow top menu usage */
  /* .mobile-menu-toggle {
    display: none !important;
  } */


  .navbar-nav {
    position: fixed;
    top: var(--navbar-total-height, calc(64px + env(safe-area-inset-top)));
    bottom: calc(64px + env(safe-area-inset-bottom));
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    padding: 1rem;
    flex-direction: column;
    gap: 1rem;
    transform: translateY(100%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    display: flex !important;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: none;
    height: calc(100vh - var(--navbar-total-height, calc(64px + env(safe-area-inset-top))) - 64px - env(safe-area-inset-bottom));
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 10019;
    border-radius: 1.5rem 1.5rem 0 0;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.1);
    will-change: transform, opacity;
    box-sizing: border-box;
  }

  .dark .navbar-nav {
    background: hsl(var(--background, #1f2937));
    border-color: rgba(255, 255, 255, 0.1);
  }

  body.mobile-menu-open .navbar-nav,
  .mobile-menu-open .navbar-nav {
    transform: translateY(0) !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  .nav-section {
    width: 100%;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding-bottom: 1rem;
    overflow: hidden;
    box-sizing: border-box;
  }

  .nav-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
  }

  .dark .nav-section {
    border-color: rgba(255, 255, 255, 0.1);
  }

  .dropdown-menu {
    position: static;
    transform: none;
    opacity: 1;
    visibility: visible;
    box-shadow: none;
    border: none;
    background: transparent;
    padding: 0;
    margin-top: 0.5rem;
    /* Critical: Enable pointer events on mobile - default is none */
    pointer-events: auto;
    /* Prevent horizontal overflow */
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    min-width: 0;
  }

  .dropdown-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.375rem;
    padding: 0;
    /* Ensure grid stays within bounds */
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-width: 0;
  }

  .dropdown-item {
    /* Vertical stack layout for icon grid */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0.5rem 0.25rem;
    border-radius: 0.5rem;
    background: rgba(0, 0, 0, 0.03);
    gap: 0.25rem;
    min-height: 56px;
    min-width: 0;
    overflow: hidden;
    /* Ensure dropdown items are clickable on mobile */
    pointer-events: auto;
    touch-action: manipulation;
  }

  .dropdown-item:hover,
  .dropdown-item:active {
    background: rgba(0, 0, 0, 0.08);
  }

  .dark .dropdown-item {
    background: rgba(255, 255, 255, 0.05);
  }

  .dark .dropdown-item:hover,
  .dark .dropdown-item:active {
    background: rgba(255, 255, 255, 0.1);
  }

  .dropdown-icon {
    font-size: 1.1rem;
    margin: 0;
  }

  .dropdown-content {
    width: 100%;
    min-width: 0;
    overflow: hidden;
  }

  .dropdown-title {
    font-size: 0.6rem;
    font-weight: 500;
    line-height: 1.2;
    text-align: center;
    /* Allow 2-line wrap for longer titles */
    white-space: normal;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .dropdown-desc {
    display: none;
  }

  /* Footer links as compact grid */
  .dropdown-footer {
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    padding: 0.5rem 0 0 0;
    margin-top: 0.375rem;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.375rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-width: 0;
  }

  .dark .dropdown-footer {
    border-color: rgba(255, 255, 255, 0.1);
  }

  .dropdown-footer .dropdown-link {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.375rem 0.125rem;
    margin: 0;
    font-size: 0.55rem;
    text-align: center;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 0.375rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* Ensure footer links are clickable on mobile */
    pointer-events: auto;
    touch-action: manipulation;
  }

  .dropdown-footer .dropdown-link:hover,
  .dropdown-footer .dropdown-link:active {
    background: rgba(0, 0, 0, 0.08);
  }

  .dark .dropdown-footer .dropdown-link {
    background: rgba(255, 255, 255, 0.05);
  }

  .dark .dropdown-footer .dropdown-link:hover,
  .dark .dropdown-footer .dropdown-link:active {
    background: rgba(255, 255, 255, 0.1);
  }

  /* Account menu - match Tools grid style */
  #account-menu {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.375rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-width: 0;
  }

  #account-menu .dropdown-item {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0.5rem 0.25rem;
    border-radius: 0.5rem;
    background: rgba(0, 0, 0, 0.03);
    gap: 0.25rem;
    min-height: 56px;
    min-width: 0;
    overflow: hidden;
  }

  #account-menu .dropdown-divider {
    display: none;
  }

  /* Logout button - full width prominent button */
  #account-menu #logoutNavButton {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    min-height: 44px;
    padding: 0.75rem 1rem;
    margin-top: 0.5rem;
    background: #dc2626;
    color: white;
    border-radius: 0.5rem;
    font-weight: 600;
    gap: 0.5rem;
  }

  #account-menu #logoutNavButton:hover,
  #account-menu #logoutNavButton:active {
    background: #b91c1c;
  }

  #account-menu #logoutNavButton .dropdown-icon {
    color: white;
  }

  #account-menu #logoutNavButton .dropdown-title {
    color: white;
    font-size: 0.875rem;
  }

  #account-menu #logoutNavButton .dropdown-desc {
    display: none;
  }

  /* Hide login button icon on mobile, show full width */
  #account-menu #loginNavButton {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    min-height: 44px;
    padding: 0.75rem 1rem;
    margin-top: 0.5rem;
    background: hsl(var(--primary, #3b82f6));
    color: white;
    border-radius: 0.5rem;
    font-weight: 600;
    gap: 0.5rem;
  }

  #account-menu #loginNavButton:hover,
  #account-menu #loginNavButton:active {
    background: hsl(var(--primary, #2563eb));
  }

  #account-menu #loginNavButton .dropdown-icon {
    color: white;
  }

  #account-menu #loginNavButton .dropdown-title {
    color: white;
    font-size: 0.875rem;
  }

  #account-menu #loginNavButton .dropdown-desc {
    display: none;
  }
}

/* Mobile Menu Overlay */
.mobile-menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  z-index: 1000;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

body.mobile-menu-open .mobile-menu-overlay,
.mobile-menu-open .mobile-menu-overlay {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Focus and Accessibility */
.dropdown-toggle:focus-visible,
.mobile-menu-toggle:focus-visible,
.nav-link:focus-visible {
  outline: 2px solid hsl(var(--primary, #3b82f6));
  outline-offset: 2px;
}

/* Animations */
@keyframes slideIn {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.navbar {
  animation: slideIn 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .navbar {
    background: white;
    border-bottom: 2px solid black;
  }

  .dark .navbar {
    background: black;
    border-bottom: 2px solid white;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .navbar,
  .dropdown-menu,
  .navbar-nav,
  .mobile-menu-overlay,
  .hamburger-line,
  .brand-link,
  .nav-link,
  .dropdown-item {
    transition: none;
    animation: none;
  }
}

/* Bottom Navigation */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.98);
  /* Reduced blur for better scroll performance */
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  /* Fixed height that includes safe area */
  min-height: calc(64px + env(safe-area-inset-bottom, 0px));
  height: calc(64px + env(safe-area-inset-bottom, 0px));
  z-index: 1002;
  justify-content: space-around;
  align-items: center;
  padding-top: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -4px 10px rgba(0,0,0,0.03);
  /* Performance optimizations - removed contain: paint as it breaks touch events on mobile */
  transform: translateZ(0);
  will-change: auto;
}

.dark .bottom-nav {
  background: rgba(31, 41, 55, 0.95);
  border-color: rgba(255, 255, 255, 0.1);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 56px;
  height: 100%;
  color: hsl(var(--muted-foreground, #6b7280));
  text-decoration: none;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 500;
  gap: 4px;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s ease;
  /* Ensure touch events work properly */
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

.bottom-nav-item:hover {
  color: hsl(var(--foreground, #1f2937));
  background: rgba(0,0,0,0.02);
}

.dark .bottom-nav-item:hover {
  background: rgba(255,255,255,0.05);
}

.bottom-nav-item.active,
.bottom-nav-item:active,
.bottom-nav-item.mobile-menu-open {
  color: hsl(var(--primary, #3b82f6));
}

.bottom-nav-icon {
  font-size: 1.5rem;
  line-height: 1;
  margin-bottom: 2px;
  transition: transform 0.2s ease;
}

.bottom-nav-item:active .bottom-nav-icon {
  transform: scale(0.9);
}

/* Keyboard focus styles for accessibility */
.bottom-nav-item:focus-visible {
  outline: 2px solid hsl(var(--primary, #3b82f6));
  outline-offset: 2px;
  border-radius: 0.25rem;
}

  /* Ensure bottom nav is visible on mobile */
@media (max-width: 1023px) {
  .bottom-nav {
    display: flex;
  }

  /* Add bottom padding to body to prevent content being hidden behind bottom nav */
  body {
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Additional padding for iOS PWA standalone mode */
  body.standalone {
    padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

/* =============================================================================
   PERMISSION-BASED MENU FILTERING
   Hide menu items until permissions are checked to prevent flash of all items
   ============================================================================= */

/* Hide permission-filterable dropdown items by default (only in Tools dropdown) */
.navbar:not(.permissions-ready) #tools-menu .dropdown-item[href],
.navbar:not(.permissions-ready) #tools-menu .dropdown-link[href] {
  opacity: 0;
  visibility: hidden;
}

/* Account menu items and auth buttons should always be visible */
.navbar #account-menu .dropdown-item,
.navbar #loginNavButton,
.navbar #logoutNavButton {
  opacity: 1;
  visibility: visible;
}

/* Show items once permissions have been checked */
.navbar.permissions-ready #tools-menu .dropdown-item[href],
.navbar.permissions-ready #tools-menu .dropdown-link[href] {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.15s ease-in-out;
}

/* Items explicitly hidden by permission filtering */
.permission-hidden {
  display: none !important;
}
