/* =====================================================
   MOBILE NAVBAR – ROBUST SCROLLABLE SOLUTION
   ===================================================== */
@media (max-width: 991.98px) {
  /* Navbar Base Styles */
  .navbar {
    background: transparent !important;
    transition: background 0.3s ease, box-shadow 0.3s ease;
    padding: 1rem 1.5rem !important;
    border-bottom: 1px solid transparent;
  }

  .navbar.scrolled,
  body.navbar-open .navbar {
    background: #ffffff !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    border-bottom: 1px solid #f1f5f9;
    padding: 0.75rem 1.5rem !important;
  }

  /* Backdrop Blur Effect */
  body.navbar-open::after {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 1040;
    animation: fadeIn 0.3s ease forwards;
  }

  @keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }

  /* Lock Body Scroll */
  body.navbar-open {
    overflow: hidden !important;
    position: fixed;
    width: 100%;
  }

  /* =====================================================
     CRITICAL FIX: SCROLLABLE MENU CONTAINER
     ===================================================== */
  #navbarNav {
    position: fixed !important;
    top: 85px !important;
    right: 1rem !important;
    left: auto !important;
    width: min(360px, calc(100vw - 2rem)) !important;
    background: transparent !important;
    z-index: 2000 !important;
    
    /* Hide by default */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    
    /* CRITICAL: Fixed height with scroll */
    height: calc(100vh - 80px) !important;
    max-height: calc(100vh - 80px) !important;
    
    /* Enable scrolling */
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-y: contain !important;
    
    /* Remove scrollbar visually */
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,0.2) transparent;
    
    /* Allow touch scroll */
    touch-action: pan-y !important;
    
    /* Smooth transitions */
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    transform: translateY(-10px);
  }

  /* Webkit scrollbar styling */
  #navbarNav::-webkit-scrollbar {
    width: 4px;
  }
  
  #navbarNav::-webkit-scrollbar-track {
    background: transparent;
  }
  
  #navbarNav::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.2);
    border-radius: 10px;
  }

  /* When menu is OPEN */
  #navbarNav.show {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: translateY(0) !important;
    display: block !important;
  }

  /* During collapse transition */
  #navbarNav.collapsing {
    display: block !important;
    overflow: hidden !important;
  }

  /* =====================================================
     MENU CARD CONTAINER
     ===================================================== */
  .nav-items {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px;
    padding: 20px;
    padding-bottom: 120px !important; /* Extra space for Contact button */
    background: #ffffff;
    border-radius: 24px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(0, 0, 0, 0.08);
    min-height: 200px; /* Ensure minimum height */
  }

  /* Navigation Links */
  .nav-items .nav-link,
  .nav-items .dropdown > button {
    width: 100%;
    text-align: left;
    padding: 16px 20px;
    border-radius: 14px;
    font-weight: 600;
    font-size: 16px;
    background: #ffffff;
    color: #0f172a;
    border: 1px solid transparent;
    transition: all 0.2s ease;
  }

  .nav-items .nav-link:hover,
  .nav-items .dropdown > button:hover {
    background: #f8fafc;
    border-color: #e2e8f0;
  }

  /* =====================================================
     SERVICES DROPDOWN - INLINE EXPANSION
     ===================================================== */
  .nav-items .dropdown {
    position: static !important;
    width: 100%;
  }

  .nav-items .dropdown-menu {
    position: static !important;
    transform: none !important;
    width: 100% !important;
    margin: 8px 0 0 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    
    /* Collapse animation */
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .nav-items .dropdown-menu.show {
    max-height: 600px !important;
    padding: 12px 0 !important;
  }

  /* Force single column */
  .dropdown-menu .row {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px;
    margin: 0 !important;
  }

  .dropdown-menu .col-6 {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
  }

  /* Service Items */
  .dropdown-menu .dropdown-item {
    width: 100% !important;
    padding: 14px 18px !important;
    border-radius: 12px;
    font-weight: 500;
    font-size: 15px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #334155;
    transition: all 0.2s ease;
    display: flex !important;
    align-items: center;
    gap: 12px;
  }

  .dropdown-menu .dropdown-item:hover,
  .dropdown-menu .dropdown-item:active {
    background: #f37021 !important;
    color: white !important;
    border-color: #f37021;
    transform: translateX(4px);
  }

  .dropdown-menu .dropdown-item i {
    width: 20px !important;
    height: 20px !important;
    flex-shrink: 0;
  }

  /* =====================================================
     CONTACT BUTTON - ALWAYS VISIBLE
     ===================================================== */
  #navbarNav > .nav-items > a.btn-primary,
  #navbarNav > a.btn-primary {
    margin-top: 16px;
    width: 100%;
    min-height: 56px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 99px;
    font-weight: 700;
    font-size: 15px;
    box-shadow: 0 10px 30px -5px rgba(37, 99, 235, 0.5);
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    position: relative;
    z-index: 10;
  }

  /* =====================================================
     TOGGLER ICON SWAP
     ===================================================== */
  .navbar-toggler-icon-close {
    display: none !important;
  }

  .navbar-toggler[aria-expanded="true"] .navbar-toggler-icon-menu {
    display: none !important;
  }

  .navbar-toggler[aria-expanded="true"] .navbar-toggler-icon-close {
    display: block !important;
  }

  /* =====================================================
     SMALL MOBILE DEVICES (< 375px)
     ===================================================== */
  @media (max-width: 374px) {
    #navbarNav {
      right: 0.5rem !important;
      width: calc(100vw - 1rem) !important;
    }
    
    .nav-items {
      padding: 16px;
    }
  }
}
