/* Header Styles - Mobile-First Responsive Design */

/* Desktop Navigation Link Styles */
.nav-link {
  position: relative;
  display: inline-block;
  white-space: nowrap;
}

/* Subscription Badge Hover Effect */
.nav-link .bg-green-500 {
  transform: scale(0.9);
  transition: all 0.2s ease-in-out;
}

.nav-link:hover .bg-green-500 {
  transform: scale(1);
  opacity: 1;
}

/* Mobile Navigation Items */
.mobile-nav-item {
  display: block;
  padding: 0.75rem 1rem;
  color: #374151;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease-in-out;
  border-radius: 0.5rem;
  margin: 0.125rem 0;
  min-height: 44px;
  display: flex;
  align-items: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.mobile-nav-item:hover,
.mobile-nav-item:focus {
  background-color: #f3f4f6;
  color: #1f2937;
  transform: translateX(4px);
}

.mobile-nav-item:active {
  background-color: #e5e7eb;
  transform: scale(0.98);
}

/* Mobile Menu Container */
#mobile-menu {
  animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mobile-first touch optimization */
.touch-manipulation {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Improved button transitions */
#account-btn {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  -webkit-user-select: none;
}

/* Better loading state for dropdown */
#account-dropdown[aria-hidden="false"] {
  pointer-events: auto;
}

#account-dropdown[aria-hidden="true"] {
  pointer-events: none;
}
#account-dropdown {
  transition: all 0.2s ease-in-out;
  transform-origin: top right;
}

#account-dropdown.opacity-0 {
  opacity: 0;
}

#account-dropdown.opacity-100 {
  opacity: 1;
}

#account-dropdown.scale-95 {
  transform: scale(0.95);
}

#account-dropdown.scale-100 {
  transform: scale(1);
}

/* Ensure dropdown appears above other content */
#account-dropdown {
  z-index: 9999;
}

/* Account button hover effect when used as dropdown trigger */
#account-btn:not([href]):hover {
  transform: scale(1.05);
}

/* Enhanced dropdown menu item interactions */
#account-dropdown a,
#account-dropdown button {
  transition: all 0.2s ease-in-out;
  cursor: pointer;
}

#account-dropdown a:hover,
#account-dropdown button:hover {
  background-color: rgba(243, 244, 246, 1);
  transform: translateX(2px);
}

/* Touch feedback for mobile devices */
#account-dropdown a:active,
#account-dropdown button:active {
  background-color: rgba(229, 231, 235, 1);
  transform: scale(0.98);
}

/* Mobile Hamburger Button Styles */
#mobile-menu-button {
  z-index: 1000;
  transition: all 0.2s ease-in-out;
}

#mobile-menu-button:hover {
  transform: scale(1.05);
}

#mobile-menu-button:active {
  transform: scale(0.95);
}

#mobile-menu-button[aria-expanded="true"] svg {
  transform: rotate(90deg);
  transition: transform 0.2s ease-in-out;
}

/* Mobile Menu Positioning and Animation */
#mobile-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 999;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Smooth show/hide transitions */
#mobile-menu.hidden {
  display: none;
}

#mobile-menu:not(.hidden) {
  display: block;
  animation: slideDown 0.2s ease-out;
}

/* Mobile-specific optimizations */
@media (max-width: 768px) {
  /* Ensure header doesn't take too much vertical space */
  header .h-16 {
    height: 4rem; /* Consistent 64px height */
  }
  
  /* Logo optimization for mobile */
  header img {
    width: 3rem !important;
    height: 3rem !important;
  }
  
  /* Account button mobile optimization */
  #account-btn {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
  }
  
  /* Mobile menu backdrop blur effect */
  #mobile-menu {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    background: rgba(255, 255, 255, 0.95);
  }
}

@media (max-width: 480px) {
  /* Extra small screens */
  header .max-w-7xl {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  
  header img {
    width: 2.5rem !important;
    height: 2.5rem !important;
  }
  
  #account-btn {
    padding: 0.625rem 0.875rem;
    font-size: 0.8125rem;
  }
}

/* Navigation State Management */
.nav-link.active {
  color: #2563eb;
  font-weight: 600;
}

.mobile-nav-item.active {
  background-color: #dbeafe;
  color: #1d4ed8;
  font-weight: 600;
}

/* Subscription-specific styling */
#my-subscription-nav,
#my-subscription-mobile {
  position: relative;
}

#my-subscription-nav::after,
#my-subscription-mobile::after {
  content: "●";
  color: #10b981;
  font-size: 0.5rem;
  position: absolute;
  top: 0.25rem;
  right: -0.5rem;
}

/* Loading states */
.nav-loading {
  opacity: 0.6;
  pointer-events: none;
}

/* Enhanced focus states for accessibility */
.nav-link:focus-visible,
.mobile-nav-item:focus-visible,
#mobile-menu-button:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
  border-radius: 0.375rem;
}

/* Account Dropdown Mobile Responsiveness */
@media (max-width: 768px) {
  #account-dropdown {
    /* Improved mobile positioning */
    position: fixed;
    top: 4.5rem;
    right: 1rem;
    left: 1rem;
    width: auto;
    max-width: none;
    
    /* Enhanced mobile styling */
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    
    /* Better backdrop effect */
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    background: rgba(255, 255, 255, 0.95);
  }
  
  /* Mobile-optimized dropdown items */
  #account-dropdown a,
  #account-dropdown button {
    padding: 1rem;
    font-size: 1rem;
    min-height: 48px;
    border-radius: 0.75rem;
    margin: 0.25rem;
  }
  
  #account-dropdown a:active,
  #account-dropdown button:active {
    background-color: rgba(59, 130, 246, 0.1);
    transform: scale(0.97);
  }
  
  /* User info section enhancement */
  #user-info-section {
    padding: 1.25rem 1rem 1rem;
    background: linear-gradient(to right, rgba(124, 163, 153, 0.1), rgba(167, 199, 231, 0.1));
    border-radius: 0.75rem;
    margin: 0.5rem;
  }
  
  /* Enhanced mobile icons */
  #account-dropdown svg {
    width: 1.5rem;
    height: 1.5rem;
    margin-right: 1rem;
  }
}

/* Tablet responsiveness */
@media (min-width: 641px) and (max-width: 1024px) {
  #account-dropdown {
    width: 16rem;
    right: -0.5rem;
  }
  
  /* Slightly larger touch targets for tablet */
  #account-dropdown a,
  #account-dropdown button {
    padding: 0.75rem 1rem;
    min-height: 40px;
  }
}

/* Improved focus states for accessibility */
#account-btn:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

#account-dropdown a:focus-visible,
#account-dropdown button:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: -2px;
  background-color: rgba(59, 130, 246, 0.1);
}

/* Smooth animations for mobile */
@media (max-width: 640px) {
  #account-dropdown {
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  }
}

/* Safe area handling for notched devices */
@supports (padding: env(safe-area-inset-left)) {
  header .max-w-7xl {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
  
  #mobile-menu {
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
  }
  
  #account-dropdown {
    left: max(1rem, env(safe-area-inset-left));
    right: max(1rem, env(safe-area-inset-right));
  }
}

/* Large Mobile and Tablet Optimizations */
@media (min-width: 769px) and (max-width: 1024px) {
  /* Tablet-specific adjustments */
  header nav {
    gap: 1.5rem;
  }
  
  .nav-link {
    font-size: 0.9375rem;
  }
}

/* Desktop Enhancements */
@media (min-width: 1025px) {
  /* Full desktop experience */
  header nav {
    gap: 2rem;
  }
  
  .nav-link {
    font-size: 1rem;
  }
  
  /* Enhanced hover effects for desktop */
  .nav-link:hover {
    transform: translateY(-1px);
  }
}

/* High-DPI and Accessibility Enhancements */
@media (min-resolution: 2dppx) {
  /* Crisp rendering on high-DPI displays */
  #mobile-menu-button svg {
    stroke-width: 2.5;
  }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  #mobile-menu {
    animation: none;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .mobile-nav-item {
    border: 1px solid transparent;
  }
  
  .mobile-nav-item:hover,
  .mobile-nav-item:focus {
    border-color: #374151;
    background-color: #f9fafb;
  }
}