/* Mobile Menu Styles - Complete Implementation v2.0 */
/* Added loading state fixes and mobile reliability improvements */

/* Loading state for mobile menu - ensures proper initial state */
.mobile-menu:not(.initialized) {
  visibility: hidden;
  pointer-events: none;
}

.mobile-menu.initialized {
  visibility: visible;
  pointer-events: auto;
}

/* Mobile Menu Container */
.mobile-menu {
  position: fixed;
  top: 0;
  right: -100vw; /* Use viewport width instead of percentage */
  width: 280px;
  max-width: 85vw;
  height: 100vh;
  background: white;
  z-index: 1000;
  transition: right 0.3s ease;
  overflow-y: auto;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
}

/* More specific selector to override any conflicts */
#mobileMenu.mobile-menu.open {
  right: 0 !important;
  background: #ff0000 !important; /* TEMPORARY: Red background for testing */
}

.mobile-menu.open {
  right: 0 !important;
  background: #ff0000 !important; /* TEMPORARY: Red background for testing */
}

/* Ensure menu doesn't exceed screen width on very small devices */
@media (max-width: 375px) {
  .mobile-menu {
    width: 260px;
    max-width: 90vw;
  }
}

@media (max-width: 320px) {
  .mobile-menu {
    width: 240px;
    max-width: 95vw;
  }
}

/* Mobile Menu Overlay */
.mobile-menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-menu-overlay.open {
  opacity: 1;
  visibility: visible;
}

/* Mobile Menu Header */
.mobile-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid #e5e7eb;
}

.mobile-menu-header .logo {
  height: 40px;
}

.mobile-menu-close {
  background: none;
  border: none;
  padding: 8px;
  color: #374151;
  cursor: pointer;
  border-radius: 8px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.mobile-menu-close:hover {
  background-color: #f3f4f6;
  color: #ff634a;
}

/* Mobile Navigation */
.mobile-nav {
  padding: 0;
}

.mobile-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.mobile-nav > ul > li {
  border-bottom: 1px solid #f3f4f6;
}

.mobile-nav a {
  display: block;
  padding: 1rem;
  color: #374151;
  text-decoration: none;
  font-weight: 500;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.mobile-nav a:hover {
  background-color: #f9fafb;
  color: #ff634a;
}

/* Mobile Dropdown */
.mobile-dropdown {
  position: relative;
}

/* Mobile-specific dropdown split styles */
.mobile-nav .dropdown-split {
  display: flex;
  align-items: center;
  width: 100%;
}

.mobile-nav .dropdown-split .dropdown-link {
  flex: 1;
  border-right: 1px solid #e5e7eb;
  min-width: 0; /* Allow text to truncate if needed */
}

.mobile-nav .dropdown-split .dropdown-toggle {
  background: none;
  border: none;
  padding: 1rem 16px;
  color: #6b7280;
  cursor: pointer;
  transition: color 0.2s ease, background-color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  flex-shrink: 0; /* Prevent arrow from shrinking */
}

.mobile-nav .dropdown-split .dropdown-toggle:hover {
  color: #ff634a;
  background-color: #f9fafb;
}

.mobile-nav .dropdown-toggle .chevron-icon {
  width: 16px;
  height: 16px;
  transition: transform 0.2s ease;
}

.mobile-nav .dropdown-toggle[aria-expanded="true"] .chevron-icon {
  transform: rotate(180deg);
}

/* Mobile Dropdown Menu */
.mobile-dropdown-menu {
  max-height: 0;
  overflow: hidden;
  background-color: #f9fafb;
  transition: max-height 0.3s ease;
  list-style: none;
  margin: 0;
  padding: 0;
}

.mobile-dropdown-menu.open {
  max-height: 500px;
}

.mobile-dropdown-menu li {
  border-bottom: 1px solid #e5e7eb;
}

.mobile-dropdown-menu li:last-child {
  border-bottom: none;
}

.mobile-dropdown-menu a {
  padding: 0.75rem 1.5rem;
  font-size: 0.875rem;
  color: #4b5563;
  background-color: transparent;
}

.mobile-dropdown-menu a:hover {
  background-color: #f3f4f6;
  color: #ff634a;
}

/* Mobile CTA Section */
.mobile-cta {
  padding: 1rem;
  border-top: 1px solid #e5e7eb;
  margin-top: auto;
}

.mobile-cta .btn {
  width: 100%;
  margin-bottom: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-weight: 500;
  text-align: center;
  transition: all 0.2s ease;
  border: none;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.mobile-cta .btn-primary {
  background-color: #ff634a;
  color: white;
}

.mobile-cta .btn-primary:hover {
  background-color: #e55439;
}

.mobile-cta .btn-secondary {
  background-color: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
}

.mobile-cta .btn-secondary:hover {
  background-color: #e5e7eb;
}

/* Force mobile menu visibility on mobile devices */
@media (max-width: 1023px) {
  newtron-header:defined .mobile-menu-button {
    display: flex !important;
    visibility: visible !important;
  }
}

/* Responsive Behavior */
@media (max-width: 1023px) {
  /* Show mobile menu button */
  .mobile-menu-button {
    display: flex !important;
  }
  
  /* Hide desktop menu */
  .desktop-menu {
    display: none !important;
  }
}

@media (min-width: 1024px) {
  /* Hide mobile menu button - TEMPORARILY DISABLED FOR TESTING */
  /* .mobile-menu-button {
    display: none !important;
  } */

  /* Show desktop menu with proper spacing */
  .desktop-menu {
    display: flex !important;
    gap: 3.5rem; /* Equivalent to gap-x-14 (14 * 0.25rem = 3.5rem) */
    margin-left: 3rem; /* Equivalent to ml-12 (12 * 0.25rem = 3rem) */
    align-items: center; /* Ensure vertical alignment */
  }

  /* Desktop dropdown split - clean inline layout */
  .desktop-menu .dropdown-split {
    display: inline-flex;
    align-items: center;
    gap: 0;
  }

  .desktop-menu .dropdown-split .dropdown-link {
    border: none !important; /* Remove mobile border */
    padding: 0;
    margin: 0;
  }

  .desktop-menu .dropdown-split .dropdown-toggle {
    padding: 0;
    margin: 0;
    margin-left: 0.5rem;
    background: none;
    border: none;
    color: inherit;
    min-width: auto;
  }

  .desktop-menu .dropdown-toggle .chevron-icon {
    width: 16px;
    height: 16px;
  }

  /* Hide mobile menu entirely on desktop - TEMPORARILY DISABLED FOR TESTING */
  /* .mobile-menu,
  .mobile-menu-overlay {
    display: none !important;
  } */
}

/* Accessibility */
.mobile-menu-button:focus,
.mobile-menu-close:focus,
.dropdown-toggle:focus {
  outline: 2px solid #ff634a;
  outline-offset: 2px;
}

/* Prevent body scroll when menu is open */
body.mobile-menu-open {
  overflow: hidden;
}

/* Touch-friendly sizing for mobile */
@media (max-width: 768px) {
  .mobile-nav a {
    padding: 1.25rem 1rem;
    min-height: 48px;
  }
  
  .mobile-nav .dropdown-split .dropdown-link {
    padding: 1.25rem 1rem;
  }
  
  .mobile-nav .dropdown-split .dropdown-toggle {
    padding: 1.25rem 12px;
    min-width: 52px;
  }
  
  .mobile-dropdown-menu a {
    padding: 1rem 1.25rem;
    min-height: 44px;
  }
}

/* Extra responsive adjustments for very narrow screens */
@media (max-width: 375px) {
  .mobile-nav a {
    padding: 1rem 0.75rem;
    font-size: 0.95rem;
  }
  
  .mobile-nav .dropdown-split .dropdown-link {
    padding: 1rem 0.75rem;
  }
  
  .mobile-nav .dropdown-split .dropdown-toggle {
    padding: 1rem 8px;
    min-width: 48px;
  }
  
  .mobile-dropdown-menu a {
    padding: 0.875rem 1rem;
    font-size: 0.85rem;
  }
}