/*
 * Simplified Navbar Styles
 * Reduced complexity, improved reusability
 */

/* ------------- COMMON STYLES (ALL SCREEN SIZES) ------------- */
.header {
  background-color: rgba(251, 247, 238, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 1px 0 rgba(212, 200, 173, 0.75);
  padding: 0.75rem 0;
  width: 100%;
  overflow: visible; /* Changed from overflow-x: hidden */
}

/* Subtle gradient background for header */
.header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--color-copper) 45%, transparent);
  z-index: 1001;
}

.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  position: relative;
}

.logo {
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--color-ink);
  text-decoration: none;
  letter-spacing: 0;
  padding: 0.25rem 0;
  transition: transform 0.2s ease;
  display: block;
  white-space: nowrap;
  z-index: 10; /* Keep high but not super high z-index */
}

.logo:hover {
  transform: scale(1.02);
  color: var(--color-copper);
}

/* Badge styling */
.badge-pilot {
  background-color: #0055b3;
  color: white;
  margin-left: 0.35em;
  font-size: 0.7rem;
  padding: 0.25em 0.5em;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.badge-danger {
  background-color: var(--danger);
  color: white;
  margin-left: 0.35em;
  font-size: 0.7rem;
  padding: 0.25em 0.5em;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

/* ------------- DESKTOP NAVIGATION (992px and up) ------------- */
@media (min-width: 992px) {
  .nav-links {
    display: flex;
    align-items: center;
    flex: 1;
  }
  
  .nav-center {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin: 0 auto;
  }
  
  .nav-link {
    color: var(--color-ink);
    font-weight: 500;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    transition: all 0.3s ease;
    text-align: center;
    position: relative;
  }
  
  .nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--color-copper);
    transition: all 0.3s ease;
    transform: translateX(-50%);
    border-radius: 1px;
    opacity: 0;
  }
  
  .nav-link:hover {
    background-color: rgba(184, 85, 30, 0.08);
    color: var(--color-copper);
  }
  
  /* Special styling for Get Started button */
  .nav-link.btn.btn-primary {
    background: var(--color-ink) !important;
    color: var(--color-paper) !important;
    border: 1px solid var(--color-ink) !important;
    box-shadow: var(--shadow-sm);
  }

  .nav-link.btn.btn-primary:hover {
    background: var(--color-copper) !important;
    border-color: var(--color-copper) !important;
    transform: translateY(-1px);
    box-shadow: 0 12px 26px -12px rgba(184, 85, 30, 0.65);
    color: var(--color-paper) !important;
  }
  
  .nav-link:hover::after {
    width: 60%;
    opacity: 1;
  }
  
  /* Desktop User Menu */
  .user-menu {
    position: relative;
  }
  
  /* Nav dropdown link styles */
  .nav-dropdown a {
    display: block;
    padding: 10px 16px;
    color: var(--color-ink);
    text-decoration: none;
    border-bottom: 1px solid var(--border-light);
    margin: 0;
    font-weight: 500;
    transition: background 0.2s ease;
  }
  
  .nav-dropdown a:hover {
    background: rgba(184, 85, 30, 0.08);
    color: var(--color-copper);
  }
  
  .nav-dropdown a.logout {
    color: #dc3545;
    border-bottom: none;
  }
  
  .nav-dropdown a.admin-link {
    color: var(--color-ink);
  }
  
  .nav-dropdown .divider {
    height: 1px;
    background-color: var(--border-light);
    margin: 4px 0;
  }
  
  .nav-user-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.45);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    transition: all 0.3s ease;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--text-primary);
  }
  
  .nav-user-button:hover {
    background: rgba(184, 85, 30, 0.08);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
  }
  
  .nav-user-button i {
    font-size: 0.8rem;
    transition: transform 0.2s ease;
  }
  
  .user-email {
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    font-weight: 500;
    color: var(--color-ink);
  }
  
  /* Nav item dropdown container */
  .nav-item-dropdown {
    position: relative;
    display: inline-block;
  }
  
  .nav-dropdown-toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    padding: 0.5rem 1rem;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition: all 0.2s ease;
  }
  
  .nav-dropdown-toggle:hover {
    color: var(--color-copper);
  }
  
  .nav-dropdown-toggle i {
    font-size: 0.8rem;
    transition: transform 0.2s ease;
  }
  
  /* Dropdown menu */
  .nav-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: auto;
    background: var(--color-canvas-elevated);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    min-width: 220px;
    z-index: 9999;
    display: none;
    overflow: hidden;
    border: 1px solid var(--border-light);
    padding: 0;
    margin-top: 8px;
    width: 100%;
    animation: dropdownFadeIn 0.3s ease;
  }
  
  /* Use display: block instead of any transform or height animation - simpler */
  .nav-dropdown.show {
    display: block;
  }
  
  @keyframes dropdownFadeIn {
    from {
      opacity: 0;
      transform: translateY(10px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  .nav-dropdown a {
    display: block;
    padding: 0.75rem 1.5rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.2s ease;
    position: relative;
  }
  
  .nav-dropdown a:hover {
    background-color: rgba(0, 0, 0, 0.025);
    padding-left: 1.75rem;
  }
  
  .dropdown-divider {
    height: 1px;
    background: linear-gradient(90deg, 
      rgba(0,0,0,0.03) 0%, 
      rgba(0,0,0,0.07) 50%,
      rgba(0,0,0,0.03) 100%);
    margin: 0.25rem 0;
  }
  
  /* Auth buttons for non-logged in users */
  .auth-buttons {
    display: flex;
    gap: 0.75rem;
    align-items: center;
  }
  
  .auth-buttons .btn {
    padding: 0.5rem 1.25rem;
    transition: all 0.3s ease;
    font-weight: 500;
  }
  
  .auth-buttons .btn-light {
    background: rgba(255, 255, 255, 0.5);
    color: var(--color-ink);
    border: 1px solid var(--border-light);
  }
  
  .auth-buttons .btn-light:hover {
    background: rgba(184, 85, 30, 0.08);
    color: var(--color-copper);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
  }
  
  .auth-buttons .btn:not(.btn-light) {
    background: var(--color-ink);
    color: var(--color-paper);
    border: none;
  }
  
  .auth-buttons .btn:not(.btn-light):hover {
    background: var(--color-copper);
    transform: translateY(-1px);
    box-shadow: 0 12px 26px -12px rgba(184, 85, 30, 0.65);
  }
  
  /* Hide mobile menu button on desktop */
  .mobile-menu-btn {
    display: none;
  }
}

/* ------------- MOBILE NAVIGATION (991px and below or low height screens) ------------- */
@media (max-width: 991px), (max-height: 600px) {
  /* Always show hamburger menu */
  .mobile-menu-btn {
    display: flex;
    background-color: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    font-size: 1.8rem;
    color: var(--color-ink);
    cursor: pointer;
    padding: 10px 15px;
    transition: all 0.2s ease;
    margin-right: 0.5rem;
    z-index: 10;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    min-width: 44px;
    min-height: 44px;
  }
  
  .mobile-menu-btn i {
    font-size: 1.4rem;
  }
  
  .mobile-menu-btn:hover, 
  .mobile-menu-btn:active {
    background-color: rgba(0,0,0,0.08);
  }
  
  .mobile-menu-btn.active i {
    transform: rotate(90deg);
  }
  
  /* Nav links container */
  .nav-links {
    position: fixed;
    top: 61px; /* Account for header height */
    left: 0;
    right: 0;
    background: var(--color-canvas);
    flex-direction: column;
    padding: 1.25rem;
    box-shadow: var(--shadow-lg);
    z-index: 999;
    display: none;
    border-top: 1px solid var(--border-light);
    max-height: calc(100vh - 70px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scroll on iOS */
  }
  
  .nav-links.active {
    display: flex;
    animation: mobileMenuSlideDown 0.3s ease;
  }
  
  @keyframes mobileMenuSlideDown {
    from {
      opacity: 0;
      transform: translateY(-20px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  /* Centered navigation links */
  .nav-center {
    flex-direction: column;
    width: 100%;
    margin-bottom: 1rem;
    gap: 0.5rem;
  }
  
  /* Fix nav-item-dropdown in mobile */
  .nav-item-dropdown {
    width: 100%;
    display: block;
  }
  
  .nav-dropdown-toggle {
    width: 100%;
    text-align: left;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    outline: none;
    box-shadow: none;
    border-radius: var(--radius);
    justify-content: space-between;
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-ink);
    border-left: 3px solid transparent;
  }
  
  .nav-dropdown-toggle:hover {
    background-color: rgba(0, 0, 0, 0.02);
    border-left-color: var(--color-copper);
  }
  
  .nav-dropdown-toggle:focus {
    outline: none;
    box-shadow: none;
  }
  
  /* Individual links */
  .nav-link {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    display: block;
    width: 100%;
    text-align: left;
    font-weight: 500;
    border-left: 3px solid transparent;
    color: var(--color-ink);
    text-decoration: none;
    transition: all 0.2s ease;
    position: relative;
  }
  
  /* Fix for non-logged in users nav links in mobile - force vertical layout */
  .nav-center > div {
    flex-direction: column !important;
    width: 100% !important;
    gap: 0 !important;
  }
  
  .nav-center > div > div {
    flex-direction: column !important;
    width: 100% !important;
    gap: 0 !important;
    justify-content: flex-start !important;
  }
  
  .nav-center > div .nav-link {
    width: 100% !important;
    margin-bottom: 0.5rem;
  }
  
  /* Mobile notification badge - position it inline next to the text */
  .nav-link .message-notification-badge {
    position: static;
    margin-left: 8px;
    margin-right: 0;
    vertical-align: middle;
  }
  
  /* Ensure correct display type when the badge is visible */
  .nav-link .message-notification-badge:not([style*="display: none"]) {
    display: inline-flex !important;
  }
  
  .nav-link:hover,
  .nav-link:active {
    border-left-color: var(--color-copper);
    background-color: rgba(184, 85, 30, 0.08);
    color: var(--color-copper);
  }
  
  /* No hover underline on mobile */
  .nav-link::after {
    display: none;
  }
  
  /* User menu in mobile */
  .user-menu {
    width: 100%;
  }
  
  .nav-user-button {
    background-color: rgba(255, 255, 255, 0.75);
    border: 1px solid var(--border-light);
    width: 100%;
    justify-content: flex-start;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--color-ink);
  }
  
  .user-email {
    color: var(--color-copper);
    font-weight: 600;
    max-width: 220px;
  }
  
  /* Dropdown Menu for Mobile */
  .nav-dropdown {
    position: static;
    box-shadow: none;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    border-radius: var(--radius);
    background-color: rgba(255, 255, 255, 0.45);
    width: 100%;
    display: none;
    padding: 0;
    border: none;
    border-left: 3px solid var(--color-copper);
  }
  
  .nav-dropdown.show {
    display: block;
  }
  
  .nav-dropdown a {
    padding: 0.75rem 1rem;
    display: block;
    color: var(--color-ink);
    text-decoration: none;
    transition: all 0.2s ease;
    border-radius: 4px;
    border-bottom: none;
  }
  
  .nav-dropdown .divider {
    margin: 0;
    height: 1px;
    background-color: rgba(0, 0, 0, 0.05);
  }
  
  .nav-dropdown a:hover {
    background-color: rgba(184, 85, 30, 0.08);
    color: var(--color-copper);
  }
  
  /* Mobile Admin and Logout links */
  .nav-dropdown a.admin-link,
  .nav-dropdown a.logout {
    font-weight: 600;
    padding: 0.75rem 1rem;
  }
  
  .nav-dropdown a.admin-link {
    color: var(--color-copper);
  }
  
  .nav-dropdown a.logout {
    color: var(--danger);
  }
  
  /* Login/register buttons */
  .auth-buttons {
    flex-direction: column;
    width: 100%;
    gap: 0.75rem;
    display: flex;
  }
  
  .auth-buttons .btn {
    width: 100%;
    padding: 0.75rem;
    display: block;
    text-align: center;
  }
}

/* ------------- SPECIFIC LANDSCAPE MODE FIXES (any width, just orientation) ------------- */
@media (orientation: landscape) and (max-width: 991px) {
  body {
    overflow-x: hidden;
  }
  
  /* Ensure mobile menu button is displayed in landscape */
  .mobile-menu-btn {
    display: flex !important; /* Override any other display settings */
    align-items: center;
    justify-content: center;
  }
  
  /* Ensure nav links container is scrollable in landscape */
  .nav-links {
    height: calc(100vh - 61px); /* Full height minus navbar */
    max-height: none; /* Override the max-height from above */
    display: none; /* Hidden by default */
  }
  
  /* Show nav links when active class is applied */
  .nav-links.active {
    display: flex;
  }
  
  /* Ensure logo is not too wide */
  .logo {
    max-width: 180px;
  }
  
  /* Make buttons slightly more compact in landscape */
  .nav-link, 
  .nav-user-button,
  .nav-dropdown a {
    padding: 0.6rem 1rem;
  }
  
  /* Set smaller menu padding in landscape */
  .nav-links {
    padding: 1rem;
  }
}
