/* Navbar Container */
:root {
  --navbar-height: 80px;
  --navbar-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --z-index-navbar: 1000;
  --z-index-mobile-menu: 999;
}

/* Use theme variables for colors */
.navbar-container {
  --navbar-bg: var(--header-bg);
  --navbar-text: var(--header-text);
  --navbar-hover: var(--header-hover);
  --navbar-active: var(--header-active);
  --navbar-shadow: var(--header-shadow);
}

/* Base Navbar Styles */
.navbar-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--navbar-height);
  background-color: var(--navbar-bg);
  color: var(--navbar-text);
  box-shadow: var(--navbar-shadow);
  z-index: var(--z-index-navbar);
  transition: var(--navbar-transition);
}

/* Scrolled State */
.navbar-container.scrolled {
  height: 70px;
  background-color: var(--navbar-bg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Navbar Content */
.navbar-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 2rem;
  position: relative;
  line-height: 1;
  gap: 1.5rem;
}

/* Logo Container */
.logo-container {
  display: flex;
  align-items: center;
  height: 100%;
  z-index: calc(var(--z-index-navbar) + 1);
  padding: 0;
  position: relative;
  line-height: 1;
  margin: 0;
  min-width: 200px;
  height: var(--navbar-height);
  align-self: stretch;
  justify-content: center;
}

.logo-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  height: 100%;
  padding: 0;
  position: relative;
  z-index: 1;
}

.logo-wrapper {
  display: flex;
  align-items: center;
  position: relative;
  height: 100%;
  padding: 0 16px 0 0;
  box-sizing: border-box;
  line-height: 1;
  gap: 12px;
  align-items: center;
  justify-content: flex-start;
  height: 100%;
  margin: 0;
}

/* Logo Image */
.logo-image-container {
  position: relative;
  height: 52px;
  width: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  z-index: 2;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  flex-shrink: 0;
  vertical-align: middle;
  transform: none;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15), 
              0 6px 12px rgba(0, 0, 0, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.2);
  overflow: hidden;
  align-self: center;
}

.logo-image-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 50%);
  border-radius: 50%;
  z-index: 3;
  pointer-events: none;
}

.logo-link:hover .logo-image-container {
  transform: translateY(-7px) scale(1.05);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2), 
              0 12px 24px rgba(0, 0, 0, 0.15);
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.scrolled .logo-image-container {
  height: 46px;
  width: 46px;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15), 
              0 4px 8px rgba(0, 0, 0, 0.1);
}

.scrolled .brand-name {
  font-size: 1.3rem;
}

.scrolled .logo-link:hover .logo-image-container {
  transform: translateY(-5px) scale(1.05);
}

.logo-glow {
  height: 75%;
  width: 75%;
  object-fit: contain;
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.8)) 
          brightness(1.3) 
          contrast(1.2);
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  animation: logoPulse 4s infinite alternate;
  position: relative;
  z-index: 2;
}

.logo-link:hover .logo-glow {
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 1)) 
          brightness(1.4) 
          contrast(1.3);
  transform: scale(1.05);
}

/* Brand Name */
.brand-name {
  color: #ffffff;
  font-size: 1.4rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  line-height: 1.5;
  margin: 0;
  padding: 0;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  height: 100%;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  font-family: 'Poppins', 'Segoe UI', sans-serif;
  white-space: nowrap;
  vertical-align: middle;
  margin-top: 0;
  padding-top: 2px;
}

.logo-link:hover .brand-name {
  transform: translateY(-2px);
  text-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  text-decoration: none !important;
}

/* Ensure no text decoration on the logo link */
.logo-link {
  text-decoration: none !important;
}

.logo-link:hover {
  text-decoration: none !important;
}

.scrolled .brand-name {
  font-size: 1.3rem;
  padding: 0 14px 0 0;
  letter-spacing: 1.1px;
}

.scrolled .logo-link:hover .brand-name {
  transform: translateY(-1px);
}

/* Logo Glow Effect */
.logo-glow-effect {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 110%;
  height: 110%;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.4) 0%, rgba(59, 130, 246, 0.1) 50%, rgba(255,255,255,0) 70%);
  border-radius: 50%;
  filter: blur(6px);
  opacity: 0.8;
  z-index: 1;
  pointer-events: none;
  transition: all 0.5s ease-in-out;
  animation: glowPulse 3s infinite alternate;
}

@keyframes logoPulse {
  0% {
    filter: drop-shadow(0 0 6px rgba(96, 165, 250, 0.8)) 
            brightness(1.3) 
            contrast(1.2);
  }
  100% {
    filter: drop-shadow(0 0 12px rgba(59, 130, 246, 0.9)) 
            brightness(1.4) 
            contrast(1.3);
  }
}

@keyframes glowPulse {
  0% {
    opacity: 0.6;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0.9;
    transform: translate(-50%, -50%) scale(1.1);
  }
}

/* Navigation Buttons */
.nav-buttons {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0;
  padding: 0 0 0 0.5rem;
  height: 100%;
  position: relative;
  top: 1px; /* Fine-tune vertical alignment */
}

.theme-toggle-container {
  display: flex;
  align-items: center;
}

/* User Menu */
.user-menu-container {
  position: relative;
  display: inline-block;
}

.user-dropdown {
  position: absolute;
  right: 0;
  top: 100%;
  background-color: var(--navbar-bg);
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  min-width: 180px;
  z-index: 1000;
  margin-top: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.dropdown-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  color: var(--navbar-text);
  text-decoration: none;
  transition: background-color 0.2s ease;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
}

.dropdown-item:hover {
  background-color: var(--navbar-hover);
}

.dropdown-item .icon {
  margin-right: 0.75rem;
  font-size: 1.1rem;
}

/* Navigation Actions */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 100%;
  margin-left: auto;
}

.theme-toggle-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 100%;
}

.nav-links-inner {
  display: flex;
  align-items: center;
  height: 100%;
  gap: 0.75rem;
  padding: 0 0.5rem;
  margin: 0;
}

/* Base Nav Link Styles */
.nav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 2.5rem;
  padding: 0 1.25rem;
  border-radius: 0.5rem;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.5;
  text-decoration: none !important;
  white-space: nowrap;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--header-text) !important;
  background: transparent;
  border: 2px solid transparent;
  z-index: 1;
  overflow: hidden;
  margin: 0 0.125rem;
  transform: translateY(0);
  align-self: center;
}

/* Primary Button Style */
.nav-link.primary {
  background: var(--primary);
  color: var(--text-on-primary) !important;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  border: none;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.nav-link.primary:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 15px -3px rgba(0, 0, 0, 0.15), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.nav-link.primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.1);
}

/* Outline Button Style */
.nav-link.outline {
  border: 2px solid var(--header-text);
  background: transparent;
  color: var(--header-text) !important;
  font-weight: 500;
}

.nav-link.outline:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--primary);
  color: var(--primary) !important;
}

/* Ghost Button Style */
.nav-link.ghost {
  background: transparent;
  color: var(--header-text) !important;
  border: 2px solid transparent;
}

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

/* Active State */
.nav-link.active {
  font-weight: 600;
  color: var(--text-on-primary) !important;
  background: var(--primary);
  border: 2px solid var(--primary);
  box-shadow: 0 4px 12px -1px rgba(var(--primary-rgb), 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
  position: relative;
  transform: translateY(-1px);
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 50%;
  height: 3px;
  background: var(--text-on-primary);
  border-radius: 2px;
  opacity: 0.9;
}

.nav-link.active:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px -1px rgba(var(--primary-rgb), 0.4);
}

.nav-link.active:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.1);
}

/* Focus State */
.nav-link:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.4);
  border-radius: 0.5rem;
}

/* Button with Icon */
.nav-link .btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 0.5rem;
  font-size: 1.1em;
}

/* Button Group */
.nav-btn-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: 100%;
}

/* Button with Badge */
.nav-link .badge {
  position: absolute;
  top: -0.5rem;
  right: -0.5rem;
  background: var(--error);
  color: white;
  border-radius: 9999px;
  font-size: 0.65rem;
  font-weight: 600;
  min-width: 1.25rem;
  height: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.35rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Loading State */
.nav-link.loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.nav-link.loading::after {
  content: '';
  position: absolute;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.nav-link .nav-btn-content {
  position: relative;
}

.nav-btn-content {
  position: relative;
  z-index: 1;
}

/* Theme Toggle */
.theme-toggle-container {
  display: flex;
  align-items: center;
  margin-left: 1rem;
  height: 100%;
}

/* Mobile Menu Button */
.mobile-menu-button {
  display: none;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid transparent;
  border-radius: 0.5rem;
  color: var(--header-text);
  cursor: pointer;
  padding: 0.625rem;
  z-index: calc(var(--z-index-navbar) + 1);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  width: 2.75rem;
  height: 2.75rem;
  align-items: center;
  justify-content: center;
  position: relative;
}

.mobile-menu-button:hover {
  background: rgba(255, 255, 255, 0.2);
  color: var(--primary);
}

.mobile-menu-button:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.4);
  border-color: var(--primary);
}

.mobile-menu-button .menu-icon,
.mobile-menu-button .close-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(1);
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.mobile-menu-button .close-icon {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.8);
}

.mobile-menu-button[aria-expanded="true"] .menu-icon {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.8);
}

.mobile-menu-button[aria-expanded="true"] .close-icon {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Particles */
.particles {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.particle {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(0.5px);
  transform-origin: center;
  box-shadow: 0 0 8px 2px rgba(255, 255, 255, 0.9);
  z-index: 10;
  opacity: 0;
  will-change: transform, opacity;
  backface-visibility: hidden;
  animation-timing-function: ease-in-out;
}

.particle-1 {
  width: 4px;
  height: 4px;
  top: 50%;
  left: 50%;
  margin: -2px 0 0 -2px;
  animation: particle-orbit-1 8s ease-in-out infinite;
  background: linear-gradient(45deg, #ffffff, #a0c4ff);
  z-index: 11;
}

.particle-2 {
  width: 3px;
  height: 3px;
  top: 50%;
  left: 50%;
  margin: -1.5px 0 0 -1.5px;
  animation: particle-orbit-2 10s ease-in-out infinite;
  animation-delay: 1s;
  background: linear-gradient(45deg, #ffffff, #b9d0ff);
  z-index: 11;
}

.particle-3 {
  width: 2px;
  height: 2px;
  top: 50%;
  left: 50%;
  margin: -1px 0 0 -1px;
  animation: particle-orbit-3 12s ease-in-out infinite;
  animation-delay: 2s;
  background: linear-gradient(45deg, #ffffff, #d1e0ff);
  z-index: 11;
}

@keyframes particle-orbit-1 {
  0%, 100% {
    transform: translate(0, 0) scale(1);
    opacity: 0;
  }
  25% {
    transform: translate(40px, -20px) scale(1.2);
    opacity: 0.7;
  }
  50% {
    transform: translate(0, -40px) scale(1);
    opacity: 0.4;
  }
  75% {
    transform: translate(-40px, -20px) scale(0.8);
    opacity: 0.7;
  }
}

@keyframes particle-orbit-2 {
  0%, 100% {
    transform: translate(0, 0) scale(1);
    opacity: 0;
  }
  25% {
    transform: translate(30px, 25px) scale(1.1);
    opacity: 0.6;
  }
  50% {
    transform: translate(0, 30px) scale(0.9);
    opacity: 0.8;
  }
  75% {
    transform: translate(-30px, 25px) scale(1.1);
    opacity: 0.6;
  }
}

@keyframes particle-orbit-3 {
  0% { 
    transform: translateX(0) translateY(-50%) rotate(0deg) translateX(40px) rotate(0deg);
    opacity: 0.4;
  }
  25% { 
    transform: translateX(0) translateY(-50%) rotate(90deg) translateX(90px) rotate(-90deg);
  }
  50% { 
    transform: translateX(0) translateY(-50%) rotate(180deg) translateX(40px) rotate(-180deg);
  }
  75% { 
    transform: translateX(0) translateY(-50%) rotate(270deg) translateX(70px) rotate(-270deg);
  }
}

/* Responsive Styles */
@media (max-width: 1024px) {
  .navbar-content {
    padding: 0 1.5rem;
  }
  
  .nav-link {
    padding: 0.5rem 1rem;
    margin: 0 0.125rem;
  }
}

@media (max-width: 768px) {
  /* Show mobile menu button */
  .mobile-menu-button {
    display: flex;
  }
  /* Style nav actions as a sliding drawer */
  .nav-actions {
    position: fixed;
    top: 0;
    right: -100%;
    width: 85%;
    max-width: 320px;
    height: 100vh;
    background: var(--bg-primary);
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    flex-direction: column;
    justify-content: flex-start;
    padding: calc(var(--navbar-height) + 1rem) 1.25rem 2rem;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease, background 0.3s ease;
    z-index: var(--z-index-mobile-menu);
    box-shadow: -4px 0 30px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateX(20px);
    border-left: 1px solid var(--border);
    overflow-y: auto;
  }
  .nav-actions.open {
    right: 0;
    opacity: 1;
    transform: translateX(0);
  }
  .nav-links-inner {
    flex-direction: column;
    width: 100%;
    height: auto;
    padding: 0.5rem 0;
    gap: 0.5rem;
    background: var(--bg-secondary);
    border-radius: 0.75rem;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
  }
  /* Make nav links large and full-width for touch */
  .nav-link {
    width: 100%;
    margin: 0.25rem 0;
    padding: 1.15rem 1.25rem;
    justify-content: flex-start;
    border-radius: 0.5rem;
    font-size: 1.1rem;
    height: auto;
    min-height: 3.25rem;
    transition: all 0.2s ease;
    background: var(--bg-primary);
    color: var(--text-primary) !important;
    border: 1px solid var(--border);
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  }
  .nav-link:hover, .nav-link:focus {
    transform: translateX(4px) !important;
    background: var(--primary);
    color: var(--text-on-primary) !important;
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    outline: none;
  }
  .nav-link.primary {
    margin-top: 1rem;
    justify-content: center;
    background: var(--primary);
    color: var(--text-on-primary) !important;
    border: none;
  }
  .theme-toggle-container {
    width: 100%;
    margin: 1.5rem 0 0;
    padding: 1.25rem 1rem 0;
    border-top: 1px solid var(--border);
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: 0.75rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  }
  /* Menu open state */
  .navbar-container.menu-open {
    background-color: transparent;
    box-shadow: none;
  }
  .navbar-container.menu-open .logo-container,
  .navbar-container.menu-open .mobile-menu-button {
    position: relative;
    z-index: calc(var(--z-index-mobile-menu) + 1);
  }
  /* Menu overlay for mobile nav */
  .menu-overlay {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: calc(var(--z-index-mobile-menu) - 1);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, backdrop-filter 0.3s ease;
  }
  .menu-overlay.visible {
    opacity: 1;
    pointer-events: auto;
    /* Ensure overlay covers everything and is clickable */
    cursor: pointer;
  }
}

/* Dark mode overrides */
[data-theme="dark"] .navbar-container {
  --navbar-bg: rgba(17, 24, 39, 0.85);
  --navbar-bg-scrolled: rgba(17, 24, 39, 0.95);
  --navbar-text: #f3f4f6;
  --navbar-hover: rgba(255, 255, 255, 0.1);
  --navbar-active: var(--color-primary-400);
  --navbar-border: rgba(255, 255, 255, 0.08);
  --navbar-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .navbar-container.scrolled {
  background-color: var(--navbar-bg-scrolled);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--navbar-border);
}

[data-theme="dark"] .mobile-menu-button {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.9);
}

[data-theme="dark"] .mobile-menu-button:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--primary);
}

[data-theme="dark"] .nav-link.outline {
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.9) !important;
}

[data-theme="dark"] .nav-link.outline:hover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary) !important;
}

[data-theme="dark"] .nav-link.ghost:hover {
  background: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .nav-link.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--text-on-primary) !important;
  box-shadow: 0 4px 12px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .nav-link.active::after {
  background: var(--text-on-primary);
  opacity: 0.8;
}

[data-theme="dark"] .nav-link.active:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .particle {
    display: none;
  }
  
  .navbar-container,
  .navbar-container * {
    transition: none !important;
  }
}
