/* ===== Enhanced Preloader Animation ===== */
#preloader {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.8s ease, transform 0.8s ease;
}

#preloader::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(56, 189, 248, 0.1) 0%, transparent 70%);
  animation: pulse-glow 3s ease-in-out infinite;
}

#preloader svg {
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 0 20px rgba(56, 189, 248, 0.5));
}

#preloader svg text {
  fill: none;
  stroke: #38bdf8;
  stroke-width: 2.5;
  stroke-dasharray: 260;
  stroke-dashoffset: 260;
  animation: dash 2.8s forwards ease-in-out, glow 2s ease-in-out infinite alternate;
}

@keyframes dash {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes pulse-glow {
  0%, 100% {
    opacity: 0.5;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.1);
  }
}

@keyframes glow {
  from {
    stroke: #38bdf8;
    filter: drop-shadow(0 0 10px #38bdf8);
  }
  to {
    stroke: #06b6d4;
    filter: drop-shadow(0 0 25px #06b6d4);
  }
}

body.loaded #preloader {
  opacity: 0;
  pointer-events: none;
  transform: scale(1.1);
}

/* ===== Smooth Scrollbar ===== */
::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: #0f172a;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #38bdf8, #06b6d4);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #06b6d4, #0891b2);
}

/* ===== Enhanced Service Cards ===== */
.service-card {
  position: relative;
  background: white;
  border-radius: 1rem;
  padding: 2rem;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.service-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #38bdf8, #06b6d4, #0891b2);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.service-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.05) 0%, rgba(6, 182, 212, 0.05) 100%);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.service-card:hover {
  transform: translateY(-12px) scale(1.02);
  box-shadow: 0 20px 25px -5px rgba(56, 189, 248, 0.3), 0 10px 10px -5px rgba(56, 189, 248, 0.2);
}

.service-card:hover::before {
  transform: scaleX(1);
}

.service-card:hover::after {
  opacity: 1;
}

.service-card .icon {
  width: 3.5rem;
  height: 3.5rem;
  margin-bottom: 1.5rem;
  color: #38bdf8;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  filter: drop-shadow(0 4px 6px rgba(56, 189, 248, 0.3));
}

.service-card:hover .icon {
  transform: scale(1.15) rotate(5deg);
  color: #06b6d4;
  filter: drop-shadow(0 8px 12px rgba(6, 182, 212, 0.5));
}

.card-title {
  font-size: 1.375rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: #0f172a;
  transition: color 0.3s ease;
  position: relative;
  z-index: 1;
}

.service-card:hover .card-title {
  color: #0891b2;
}

.card-body {
  color: #475569;
  line-height: 1.75;
  margin-bottom: 1.5rem;
  position: relative;
  z-index: 1;
}

.card-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: #0891b2;
  font-weight: 600;
  transition: all 0.3s ease;
  position: relative;
  z-index: 1;
}

.card-link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, #38bdf8, #06b6d4);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.3s ease;
}

.card-link:hover {
  gap: 0.75rem;
  color: #0e7490;
}

.card-link:hover::after {
  transform: scaleX(1);
  transform-origin: left;
}

/* ===== Sticky Navigation Enhancement ===== */
nav.sticky {
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px) saturate(180%);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(56, 189, 248, 0.1);
}

/* ===== Back to Top Button Enhancement ===== */
.back-to-top {
  position: fixed;
  bottom: 3rem;
  right: 3rem;
  width: 3.5rem;
  height: 3.5rem;
  background: linear-gradient(135deg, #38bdf8, #06b6d4);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: bold;
  opacity: 0;
  transform: translateY(100%);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  z-index: 50;
  box-shadow: 0 10px 25px rgba(56, 189, 248, 0.4);
}

.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
}

.back-to-top:hover {
  transform: translateY(-5px) scale(1.1);
  box-shadow: 0 15px 35px rgba(56, 189, 248, 0.6);
  background: linear-gradient(135deg, #06b6d4, #0891b2);
}

.back-to-top:active {
  transform: translateY(-5px) scale(0.95);
}

/* ===== Gradient Text Effect ===== */
.gradient-text {
  background: linear-gradient(135deg, #38bdf8 0%, #06b6d4 50%, #0891b2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradient-shift 3s ease infinite;
  background-size: 200% 200%;
}

@keyframes gradient-shift {
  0%, 100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

/* ===== Animated Background Particles ===== */
.particles-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: #38bdf8;
  border-radius: 50%;
  opacity: 0.6;
  animation: float-particle 15s infinite ease-in-out;
}

@keyframes float-particle {
  0%, 100% {
    transform: translate(0, 0) scale(1);
    opacity: 0;
  }
  10% {
    opacity: 0.6;
  }
  90% {
    opacity: 0.6;
  }
  100% {
    transform: translate(var(--tx), var(--ty)) scale(0.5);
    opacity: 0;
  }
}

/* ===== CTA Button Enhancement ===== */
.cta-button {
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.cta-button::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s ease, height 0.6s ease;
}

.cta-button:hover::before {
  width: 300px;
  height: 300px;
}

.cta-button:active {
  transform: scale(0.96);
}

/* ===== Mobile Menu Animation ===== */
@media (max-width: 768px) {
  #navMenu {
    position: fixed;
    top: 4rem;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(12px);
    padding: 2rem;
    flex-direction: column;
    gap: 1.5rem;
    transform: translateY(-100%);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-bottom: 2px solid rgba(56, 189, 248, 0.2);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  }

  #navMenu.show {
    transform: translateY(0);
    opacity: 1;
  }

  #navMenu li {
    opacity: 0;
    transform: translateX(-20px);
    animation: slideInMenu 0.3s forwards;
  }

  #navMenu li:nth-child(1) { animation-delay: 0.1s; }
  #navMenu li:nth-child(2) { animation-delay: 0.15s; }
  #navMenu li:nth-child(3) { animation-delay: 0.2s; }
  #navMenu li:nth-child(4) { animation-delay: 0.25s; }
  #navMenu li:nth-child(5) { animation-delay: 0.3s; }
  #navMenu li:nth-child(6) { animation-delay: 0.35s; }

  @keyframes slideInMenu {
    to {
      opacity: 1;
      transform: translateX(0);
    }
  }
}

/* ===== Link Hover Effects ===== */
a {
  position: relative;
  transition: all 0.3s ease;
}

nav a:not(.cta-button)::after,
footer a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, #38bdf8, #06b6d4);
  transition: width 0.3s ease;
}

nav a:not(.cta-button):hover::after,
footer a:hover::after {
  width: 100%;
}

/* ===== Loading Animation ===== */
@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

.shimmer {
  animation: shimmer 2s infinite linear;
  background: linear-gradient(90deg, transparent, rgba(56, 189, 248, 0.2), transparent);
  background-size: 1000px 100%;
}

/* ===== Hero Section Enhancement ===== */
.hero-overlay {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.85) 0%, rgba(30, 41, 59, 0.7) 50%, rgba(15, 23, 42, 0.85) 100%);
  backdrop-filter: blur(2px);
}

/* ===== Glassmorphism Effect ===== */
.glass {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* ===== Performance Optimization ===== */
* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img {
  will-change: transform;
}

.service-card,
.back-to-top {
  will-change: transform;
}

/* ===== Accessibility Improvements ===== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

button:focus,
a:focus {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

/* ===== Print Styles ===== */
@media print {
  #preloader,
  nav,
  .back-to-top,
  .particles-bg {
    display: none !important;
  }
}