/**
 * Active State Indicators & Performance Optimization
 * Enhanced navigation with breadcrumbs and performance improvements
 */

/* =================================
   ACTIVE STATE INDICATORS
   ================================= */

/* Main navigation active states - DISABLED for main menu items */
nav > div > .nav-item.active,
nav > div > .nav-item[aria-current="page"] {
  color: inherit !important; /* No color change for main menu */
}

nav > div > .nav-item.active::before,
nav > div > .nav-item[aria-current="page"]::before {
  display: none !important; /* No underline for main menu */
}

/* Submenu active states - ENABLED for dropdown items */
.dropdown-menu a.active,
.dropdown-menu a[aria-current="page"],
.mega-menu a.active,
.mega-menu a[aria-current="page"] {
  background: #f3f4f6 !important; /* Light gray background */
  color: #111827 !important; /* Dark gray text */
  font-weight: 500 !important;
}

/* Disable active states for user dropdown menu items */
.user-dropdown .nav-item.active,
.user-dropdown .nav-item[aria-current="page"],
.user-dropdown a.active,
.user-dropdown a[aria-current="page"] {
  color: inherit !important;
  background: transparent !important;
}

.user-dropdown .nav-item.active::before,
.user-dropdown .nav-item[aria-current="page"]::before,
.user-dropdown a.active::before,
.user-dropdown a[aria-current="page"]::before {
  display: none !important;
}

@keyframes activeSlideIn {
  from {
    width: 0;
    opacity: 0;
  }
  to {
    width: 20px;
    opacity: 1;
  }
}

/* Mobile menu active states */
#mobileMenu .nav-item.active,
#mobileMenu .nav-item[aria-current="page"] {
  background: linear-gradient(90deg, rgba(147, 197, 253, 0.15), rgba(96, 165, 250, 0.15)); /* Soft blue */
  border-left: 4px solid #60a5fa;
  color: #93c5fd;
  font-weight: 600;
}

/* Breadcrumb indicators */
.nav-breadcrumb-container {
  position: fixed;
  top: 64px; /* Below header */
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  padding: 8px 16px;
  font-size: 14px;
  color: #6b7280;
  z-index: 40;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
}

.nav-breadcrumb-container.show {
  transform: translateY(0);
}

.breadcrumb-list {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 1280px;
  margin: 0 auto;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.breadcrumb-item a {
  color: #0f766e;
  text-decoration: none;
  transition: color 0.2s ease;
}

.breadcrumb-item a:hover {
  color: #60a5fa; /* Soft blue */
}

.breadcrumb-separator {
  color: #9ca3af;
  font-size: 12px;
}

.breadcrumb-current {
  color: #374151;
  font-weight: 500;
}

/* =================================
   PERFORMANCE OPTIMIZATIONS
   ================================= */

/* Use CSS containment for better performance */
.dropdown-menu,
.mega-menu,
.user-dropdown {
  contain: layout style paint;
}

/* Optimize animations with will-change */
.group:hover .dropdown-menu,
.group:focus-within .dropdown-menu {
  will-change: transform, opacity;
}

/* Use transform3d for hardware acceleration */
.dropdown-menu {
  transform: translate3d(0, -10px, 0);
  opacity: 0;
  visibility: hidden;
  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);
}

.group:hover .dropdown-menu,
.group:focus-within .dropdown-menu {
  transform: translate3d(0, 0, 0);
  opacity: 1;
  visibility: visible;
}

/* Lazy loading placeholder */
.nav-item-loading {
  position: relative;
  opacity: 0.7;
}

.nav-item-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 8px;
  width: 12px;
  height: 12px;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  transform: translateY(-50%);
}

/* Progressive enhancement for touch devices */
@media (hover: none) and (pointer: coarse) {
  .dropdown-menu {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
  }

  .group:hover .dropdown-menu,
  .group:focus-within .dropdown-menu,
  .group.active .dropdown-menu {
    max-height: 500px;
  }
}

/* Memory-efficient animations */
@media (prefers-reduced-motion: no-preference) {
  .nav-item {
    transition: color 0.2s ease, background-color 0.2s ease;
  }

  .nav-item:hover {
    will-change: color, background-color;
  }

  .nav-item:not(:hover) {
    will-change: auto;
  }
}

/* Intersection observer target for lazy loading */
.nav-lazy-target {
  height: 1px;
  visibility: hidden;
}

/* =================================
   THEME SWITCHING SUPPORT
   ================================= */

/* CSS custom properties for theming */
:root {
  --nav-bg-primary: #0f766e;
  --nav-bg-secondary: #14b8a6;
  --nav-text-primary: #ffffff;
  --nav-text-secondary: rgba(255, 255, 255, 0.9);
  --nav-accent: #60a5fa; /* Soft blue */
  --nav-hover-bg: rgba(255, 255, 255, 0.1);
  --nav-border: rgba(255, 255, 255, 0.2);
  --nav-shadow: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
  --nav-bg-primary: #1f2937;
  --nav-bg-secondary: #374151;
  --nav-text-primary: #f9fafb;
  --nav-text-secondary: #d1d5db;
  --nav-accent: #93c5fd; /* Soft blue for dark theme */
  --nav-hover-bg: rgba(255, 255, 255, 0.05);
  --nav-border: rgba(255, 255, 255, 0.1);
  --nav-shadow: rgba(0, 0, 0, 0.3);
}

/* Apply theme variables */
header {
  background: linear-gradient(135deg, var(--nav-bg-primary), var(--nav-bg-secondary));
  color: var(--nav-text-primary);
}

.dropdown-menu {
  background: var(--nav-text-primary);
  border: 1px solid var(--nav-border);
  box-shadow: 0 20px 25px -5px var(--nav-shadow);
}

.nav-search input {
  border-color: var(--nav-border);
  background: var(--nav-hover-bg);
  color: var(--nav-text-primary);
}

/* =================================
   RESPONSIVE ENHANCEMENTS
   ================================= */

/* Fine-tuned breakpoints */
@media (max-width: 1024px) {
  .mega-menu {
    width: 500px;
    padding: 20px;
  }

  .nav-search {
    max-width: 250px;
  }
}

@media (max-width: 768px) {
  .nav-breadcrumb-container {
    top: 56px; /* Adjusted for smaller header */
    padding: 6px 12px;
    font-size: 13px;
  }

  .breadcrumb-list {
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .breadcrumb-list::-webkit-scrollbar {
    display: none;
  }
}

@media (max-width: 480px) {
  .nav-breadcrumb-container {
    padding: 4px 8px;
    font-size: 12px;
  }
}

/* =================================
   PRINT STYLES
   ================================= */

@media print {
  header,
  #mobileMenu,
  .nav-breadcrumb-container {
    display: none !important;
  }
}

/* =================================
   HIGH CONTRAST MODE
   ================================= */

@media (prefers-contrast: high) {
  .nav-item.active::before {
    background: currentColor;
    height: 4px;
  }

  .dropdown-menu {
    border: 2px solid;
  }

  .nav-search input {
    border: 2px solid;
  }
}

/* =================================
   UTILITY CLASSES
   ================================= */

.nav-hidden {
  display: none !important;
}

.nav-visible {
  display: block !important;
}

.nav-sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.nav-focus-visible:focus {
  outline: 2px solid var(--nav-accent);
  outline-offset: 2px;
}

/* =================================
   DEBUG MODE (Development only)
   ================================= */

[data-nav-debug="true"] .dropdown-menu {
  border: 2px dashed red !important;
}

[data-nav-debug="true"] .mega-menu {
  border: 2px dashed blue !important;
}

[data-nav-debug="true"] .nav-item.active {
  background: rgba(255, 0, 0, 0.1) !important;
}
