/* ===================================================================
   MOBILE NAVBAR & NAVIGATION STYLES 
   =================================================================== */

@media (max-width: 1024px) {
  header.navbar > .menu, 
  header.navbar .search-box,
  header.navbar .track-btn,
  header.navbar .profile-container,
  body > #submenu-box,
  header.navbar .category-flyout {
    display: none !important;
  }

  /* --- Mobile Navbar Layout --- */
  header.navbar {
    padding: 8px 12px; 
    justify-content: space-between;
    position: sticky;
    top: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    gap: 12px; /* Add space between logo and right content */
  }

  header.navbar .logo img {
    height: 38px;
    width: auto;
    flex-shrink: 0; /* Prevent logo from shrinking */
  }

  /* --- Right-Side Mobile Container --- */
  header.navbar .nav-right {
    flex-grow: 1; /* Allow this container to take up space */
    display: flex;
    align-items: center;
    justify-content: space-between; /* CRITICAL FIX: Pushes search and icons apart */
  }
  
  /* ENHANCED: Polished the fake search bar design */
  header.navbar .mobile-search-icon {
    display: flex;
    flex-grow: 1; 
    align-items: center;
    justify-content: flex-start;
    background-color: #f7f7f7; 
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 0 15px;
    height: 38px; 
    width: auto; 
    gap: 10px;
    text-decoration: none;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
  }
  
  /* UPDATED: Specifically target the span for better font control */
  header.navbar .mobile-search-icon span {
    color: #909090; /* Lighter, calmer placeholder color */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    font-weight: 400;
  }


  header.navbar .mobile-search-icon:active {
      border-color: #3498db; /* A brand color or standard blue */
      box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
  }

  header.navbar .mobile-search-icon i {
      font-size: 1rem;
      color: #999; /* Slightly lighter icon color */
  }

  /* NEW: Style the icon group */
  header.navbar .mobile-nav-actions {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    gap: 4px; /* Space between cart and hamburger */
  }

  /* Ensure other icons don't grow or shrink */
  header.navbar .cart-icon-wrapper,
  header.navbar .hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 44px; /* Maintain consistent touch target size */
    height: 44px;
    font-size: 1.5rem;
    color: #2c3e50;
    position: relative;
    text-decoration: none;
    background: none;
    border: none;
    padding: 0;
  }

  header.navbar .cart-icon-wrapper .cart-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 11px;
    padding: 1px 5px;
    background-color: #e74c3c;
  }

  /* ===================================
     Full-Screen Mobile Search Overlay
     =================================== */
  body > .mobile-search-overlay {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #ffffff;
    z-index: 2000;
    transform: translateY(-100%);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
  }

  body > .mobile-search-overlay.open {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
  }

  .mobile-search-header {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid #ecf0f1;
    flex-shrink: 0;
  }

  .mobile-search-form {
      flex-grow: 1;
      display: flex;
      position: relative;
  }

  #mobile-search-input {
    width: 100%;
    border: none;
    outline: none;
    font-size: 1.1rem;
    padding: 12px 40px 12px 15px;
    font-family: inherit;
    color: #34495e;
  }
  
  .mobile-search-form button {
      position: absolute;
      right: 0;
      top: 0;
      height: 100%;
      background: none;
      border: none;
      font-size: 1.2rem;
      color: #7f8c8d;
      padding: 0 12px;
  }

  .mobile-search-close {
    background: none;
    border: none;
    font-size: 1.8rem;
    line-height: 1;
    color: #7f8c8d;
    padding: 0 10px;
    cursor: pointer;
  }

  .mobile-search-suggestions {
      overflow-y: auto;
      flex-grow: 1;
  }
    
  .mobile-search-suggestions .suggestion-item {
      display: flex;
      align-items: center;
      padding: 12px 15px;
      gap: 15px;
      cursor: pointer;
      border-bottom: 1px solid #ecf0f1;
  }
  .mobile-search-suggestions .suggestion-item:last-child {
      border-bottom: none;
  }
  .mobile-search-suggestions .suggestion-item img {
      width: 50px;
      height: 50px;
  }
  .mobile-search-suggestions .suggestion-item span {
      font-size: 1rem;
  }


  /* ===================================
     IMPROVED Mobile Side Menu Panel
     =================================== */
  body > .mobile-menu-overlay {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(0, 0, 0, 0.5);
      z-index: 2999;
      opacity: 0;
      visibility: hidden;
      transition: opacity 0.35s ease;
  }
  
  body > .mobile-menu-overlay.open {
      opacity: 1;
      visibility: visible;
  }

  body > nav.mobile-menu-panel {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    width: 85vw;
    max-width: 340px;
    /* CRITICAL FIX: Use dvh for dynamic viewport height to account for mobile browser UI */
    height: 100dvh; 
    background: #ffffff;
    box-shadow: -5px 0 25px rgba(0,0,0,0.1);
    z-index: 3000;
    transform: translateX(100%);
    visibility: hidden;
    transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    overflow: hidden; /* Prevent the main panel from scrolling */
  }

  body > nav.mobile-menu-panel.open {
    visibility: visible;
    transform: translateX(0);
  }
  
  nav.mobile-menu-panel .mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #ecf0f1;
    flex-shrink: 0; /* Header should not shrink */
  }

  nav.mobile-menu-panel .mobile-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #2c3e50;
    font-weight: 600;
    font-size: 1.1rem;
  }
  nav.mobile-menu-panel .mobile-user-info .fa-user-circle {
      font-size: 1.8rem;
      color: #3498db;
  }

  nav.mobile-menu-panel .mobile-auth-links {
    display: flex;
    gap: 10px;
  }
  nav.mobile-menu-panel .mobile-auth-links a {
      text-decoration: none;
      padding: 8px 16px;
      border-radius: 6px;
      font-weight: 600;
      transition: all 0.2s ease;
  }
  nav.mobile-menu-panel .btn-login {
      background-color: #f0f0f0;
      color: #333;
  }
  nav.mobile-menu-panel .btn-signup {
      background-color: #3498db;
      color: white;
  }
  
  nav.mobile-menu-panel .mobile-menu-close {
    font-size: 2rem;
    line-height: 1;
    padding: 0 10px;
    background: none;
    border: none;
    color: #7f8c8d;
    cursor: pointer;
  }

  nav.mobile-menu-panel .mobile-categories, 
  nav.mobile-menu-panel .mobile-help-links {
    list-style: none;
    padding: 0;
    margin: 0;
  }
    
  /* Make category list scrollable */
  nav.mobile-menu-panel .mobile-categories {
      flex-grow: 1; /* Takes up all available space */
      overflow-y: auto; /* Allows scrolling */
      min-height: 0; /* CRUCIAL FIX for flexbox scrolling */
  }

  nav.mobile-menu-panel .mobile-category .mobile-cat-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 15px;
    background: none;
    border: none;
    border-bottom: 1px solid #ecf0f1;
    text-align: left;
    font-size: 1rem;
    font-weight: 500;
    color: #34495e;
    cursor: pointer;
  }
    
  nav.mobile-menu-panel .mobile-cat-arrow {
      transition: transform 0.3s ease;
  }
  /* Rotate arrow on open */
  nav.mobile-menu-panel .mobile-cat-btn.open .mobile-cat-arrow {
      transform: rotate(90deg);
  }

  /* Subcategories hidden by default */
  nav.mobile-menu-panel .mobile-subcategories {
    list-style: none;
    padding: 0;
    background: #f8f9fa;
    max-height: 0; /* Start collapsed */
    overflow: hidden;
    transition: max-height 0.4s ease-in-out; /* Smooth transition */
  }

  nav.mobile-menu-panel .mobile-subcategories a {
      display: block;
      padding: 12px 15px 12px 30px; /* Indent sub-links */
      text-decoration: none !important;
      color: #555 !important;
      border-bottom: 1px solid #ecf0f1;
      background: none !important;
  }
  
  nav.mobile-menu-panel .mobile-subcategories a:hover {
      background: #e9ecef !important;
  }

  /* Divider between categories and help links */
  nav.mobile-menu-panel .mobile-menu-divider {
      border: none;
      border-top: 5px solid #ecf0f1;
      margin: 0;
      flex-shrink: 0; /* Should not shrink */
  }

  /* Help links at the bottom (non-scrollable) */
  nav.mobile-menu-panel .mobile-help-links {
      flex-shrink: 0; /* Should not shrink */
      padding: 10px 0;
      background-color: #fff; /* Give it a solid background */
  }
  
  nav.mobile-menu-panel .mobile-help-links a {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    text-decoration: none !important;
    color: #34495e !important;
    background: none !important;
  }

  nav.mobile-menu-panel .mobile-help-links a:hover {
      background: #e9ecef !important;
  }

  nav.mobile-menu-panel .mobile-help-links i {
      font-size: 1.2rem;
      width: 20px;
      text-align: center;
      color: #95a5a6;
  }
}
