/* Custom Styles for Font and Animations */
body {
  font-family: "Cairo", sans-serif;
  /* Performance optimizations */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Critical above-the-fold optimizations */
.hero-bg-animation {
  will-change: transform;
  transform: translateZ(0); /* Hardware acceleration */
}

/* Service card image optimization */
.service-card-image {
  will-change: filter, background-image;
  transform: translateZ(0); /* Hardware acceleration */
  background-attachment: scroll; /* Better performance than fixed */
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transition: filter 0.3s ease;
}

/* Lazy loading states */
.service-card-image:not(.loaded):not([style*="background-image"]) {
  background-color: #f3f4f6;
  position: relative;
}

.service-card-image:not(.loaded):not([style*="background-image"])::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border: 2px solid #e5e7eb;
  border-top-color: #9ca3af;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.service-card-image.loaded {
  background-size: cover;
  background-position: center;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Optimize transitions */
.transition-optimized {
  will-change: transform, box-shadow;
  transform: translateZ(0);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Performance optimizations for hover states */
.service-card-container:hover .service-card-image {
  will-change: filter;
}

.service-card-container:not(:hover) .service-card-image {
  will-change: auto;
}

/* Remove will-change after animations complete */
.animate-on-scroll.animation-complete {
  will-change: auto;
}

/* Hero Ken Burns Effect - Performance Optimized */
@keyframes heroZoom {
  from {
    transform: scale3d(1, 1, 1);
  }
  to {
    transform: scale3d(1.1, 1.1, 1);
  }
}
.hero-bg-animation {
  animation: heroZoom 40s ease-in-out forwards;
  will-change: transform;
  transform: translateZ(0); /* Hardware acceleration */
}

/* Initial state for elements to be animated on scroll - Performance Optimized */
.fade-in-up {
  opacity: 0;
  transform: translate3d(0, 30px, 0);
  transition: opacity 0.8s ease-out, transform 0.8s ease-out;
  will-change: opacity, transform;
}

/* Final state for animated elements */
.fade-in-up.is-visible {
  opacity: 1;
  transform: translate3d(0, 0, 0);
  will-change: auto; /* Remove will-change after animation */
}

/* --- Style for the active link underline --- */
.active::after {
  transform: scaleX(1) !important;
}

/* Mobile-specific responsive enhancements */
@media (max-width: 768px) {
  /* Ensure proper touch targets */
  .nav-link, #mobile-menu a {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  
  /* Better spacing for mobile */
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  
  /* Hero section responsive height */
  #home {
    height: 70vh;
    min-height: 500px;
  }
  
  /* Grid adjustments for very small screens */
  @media (max-width: 480px) {
    .grid {
      gap: 1rem;
    }
    
    /* Single column on very small screens */
    .grid-cols-1 {
      grid-template-columns: 1fr;
    }
  }
}

/* Tablet-specific adjustments */
@media (min-width: 768px) and (max-width: 1024px) {
  /* Better spacing for tablets */
  .container {
    padding-left: 2rem;
    padding-right: 2rem;
  }
  
  /* Adjust service grid for tablets */
  .services-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Mobile menu styles */
#mobile-menu {
  position: absolute !important;
  top: 100% !important;
  left: 0 !important;
  right: 0 !important;
  z-index: 50 !important;
  max-height: 80vh !important;
  overflow-y: auto !important;
  background: white !important;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1) !important;
}

#mobile-menu.show {
  display: block !important;
}

#mobile-menu.hidden {
  display: none !important;
}

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

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

/* Mobile menu button styles */
#mobile-menu-button {
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 60;
  position: relative;
  background: transparent;
  border: none;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
}

#mobile-menu-button:hover {
  background-color: rgba(0, 0, 0, 0.05);
  border-radius: 0.375rem;
}

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

#mobile-menu-button:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Ensure the icon is clickable */
#mobile-menu-button i {
  pointer-events: none;
  color: #374151;
}

/* Force mobile menu button visibility on mobile devices */
@media (max-width: 1023px) {
  #mobile-menu-button {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }
}

/* Hide mobile menu button on desktop */
@media (min-width: 1024px) {
  #mobile-menu-button {
    display: none !important;
  }
}



/* Ensure mobile menu is properly positioned */
@media (max-width: 1023px) {
  #mobile-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    width: 100%;
    background: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  }
}

/* Ensure mobile menu links are clickable */
#mobile-menu a {
  display: block;
  width: 100%;
  text-decoration: none;
  transition: background-color 0.2s ease;
}

#mobile-menu a:hover {
  background-color: #f3f4f6 !important;
}

/* Smooth scrolling for all devices */
html {
  scroll-behavior: smooth;
}

/* Better image responsiveness */
img {
  max-width: 100%;
  height: auto;
}

/* Ensure buttons are touch-friendly */
button, .btn {
  min-height: 44px;
  padding: 0.75rem 1.5rem;
}

@media (max-width: 640px) {
  button, .btn {
    min-height: 40px;
    padding: 0.5rem 1rem;
  }
}

/* Dropdown Menu Styles */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  width: 200px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease;
  z-index: 50;
}

.dropdown:hover .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-menu a {
  display: block;
  padding: 12px 16px;
  font-size: 14px;
  color: #374151;
  text-decoration: none;
  transition: all 0.2s ease;
  border-bottom: 1px solid #f3f4f6;
}

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

.dropdown-menu a:hover {
  background-color: #f9fafb;
  color: #111827;
  padding-left: 20px;
}

.dropdown button {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: inherit;
}

.dropdown button i {
  transition: transform 0.2s ease;
}

.dropdown:hover button i {
  transform: rotate(180deg);
}

/* Mobile dropdown adjustments */
@media (max-width: 1023px) {
  .dropdown-menu {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    width: 100%;
    box-shadow: none;
    border: none;
    border-radius: 0;
    background: #f9fafb;
    margin-top: 0;
  }
  
  .dropdown-menu a {
    padding: 8px 16px;
    border-bottom: 1px solid #e5e7eb;
  }
}