/* ===================================
   ANIMATIONS CSS
   Advanced animations and transitions
   =================================== */

/* Professional Page Loader */
.page-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease-out, visibility 0.3s ease-out;
  pointer-events: auto;
  overflow: hidden;
}

.page-loader.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Moving blurred background flashes */
.loader-blur-bg {
  position: absolute;
  width: 200px;
  height: 200px;
  background: rgba(240, 177, 96, 0.25);
  border-radius: 50%;
  filter: blur(60px);
  pointer-events: none;
}

.loader-blur-1 {
  top: 20%;
  left: 15%;
  animation: moveFlash1 3s ease-in-out infinite;
}

.loader-blur-2 {
  top: 60%;
  right: 20%;
  animation: moveFlash2 3.5s ease-in-out infinite;
}

.loader-blur-3 {
  bottom: 25%;
  left: 50%;
  animation: moveFlash3 3.2s ease-in-out infinite;
}

/* Elastic bouncing bubble - no flash */
.loader-elastic-bubble {
  position: relative;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #f0b160 0%, #c47d1f 100%);
  border-radius: 50%;
  box-shadow: 
    0 0 30px rgba(240, 177, 96, 0.6),
    inset 0 0 20px rgba(255, 255, 255, 0.2);
  animation: elasticBounce 1s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
  z-index: 10;
}

/* CRT TV shutdown effect */
.page-loader.crt-shutdown {
  animation: crtShutdown 0.4s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

.page-loader.crt-shutdown .loader-elastic-bubble,
.page-loader.crt-shutdown .loader-blur-bg {
  animation: none;
  opacity: 0;
}

/* Moving flash animations */
@keyframes moveFlash1 {
  0%, 100% {
    transform: translate(0, 0);
    opacity: 0.3;
  }
  50% {
    transform: translate(40px, 60px);
    opacity: 0.6;
  }
}

@keyframes moveFlash2 {
  0%, 100% {
    transform: translate(0, 0);
    opacity: 0.4;
  }
  50% {
    transform: translate(-50px, -40px);
    opacity: 0.7;
  }
}

@keyframes moveFlash3 {
  0%, 100% {
    transform: translate(0, 0);
    opacity: 0.35;
  }
  50% {
    transform: translate(-30px, 50px);
    opacity: 0.65;
  }
}

/* CRT TV shutdown animation */
@keyframes crtShutdown {
  0% {
    transform: scale(1, 1);
    opacity: 1;
    filter: brightness(1);
  }
  50% {
    transform: scale(1, 0.1);
    opacity: 0.8;
    filter: brightness(2);
  }
  100% {
    transform: scale(0, 0.001);
    opacity: 0;
    filter: brightness(0);
  }
}

/* Elastic bounce animation */
@keyframes elasticBounce {
  0%, 100% {
    transform: translateY(0) scale(1, 1);
  }
  25% {
    transform: translateY(-30px) scale(1.1, 0.9);
  }
  50% {
    transform: translateY(-40px) scale(0.9, 1.1);
  }
  75% {
    transform: translateY(-10px) scale(1.05, 0.95);
  }
}

/* Professional Background */
.loader-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.gradient-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 30% 20%, rgba(240, 177, 96, 0.15) 0%, transparent 50%),
              radial-gradient(circle at 70% 80%, rgba(240, 177, 96, 0.1) 0%, transparent 50%);
  animation: gradientShift 8s ease-in-out infinite;
}

.floating-particles {
  position: absolute;
  width: 100%;
  height: 100%;
}

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: rgba(240, 177, 96, 0.6);
  border-radius: 50%;
  animation: particleFloat 6s ease-in-out infinite;
}

.particle-1 { top: 20%; left: 10%; animation-delay: 0s; }
.particle-2 { top: 60%; left: 90%; animation-delay: 1s; }
.particle-3 { top: 30%; left: 80%; animation-delay: 2s; }
.particle-4 { top: 80%; left: 20%; animation-delay: 3s; }
.particle-5 { top: 40%; left: 60%; animation-delay: 4s; }
.particle-6 { top: 70%; left: 40%; animation-delay: 5s; }

.animated-shapes {
  position: absolute;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.shape {
  position: absolute;
  border: 1px solid rgba(240, 177, 96, 0.2);
  animation: shapeRotate 12s linear infinite;
}

.shape-circle {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  top: 10%;
  left: -100px;
  animation-delay: 0s;
}

.shape-triangle {
  width: 150px;
  height: 150px;
  top: 60%;
  right: -75px;
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
  animation-delay: 4s;
}

.shape-square {
  width: 120px;
  height: 120px;
  top: 30%;
  right: 10%;
  transform: rotate(45deg);
  animation-delay: 8s;
}

/* Professional Logo Container */
.loader-content {
  position: relative;
  z-index: 10;
  text-align: center;
  color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  max-width: 400px;
  padding: 0 1rem;
}

.logo-container {
  position: relative;
  margin-bottom: 1rem;
}

.logo-wrapper {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(240, 177, 96, 0.1) 0%, transparent 70%);
  border-radius: 50%;
  animation: logoBackgroundPulse 3s ease-in-out infinite;
}

.logo-shine {
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
  animation: logoShine 4s ease-in-out infinite;
  border-radius: 50%;
}

.loader-logo {
  width: 80px;
  height: 80px;
  object-fit: contain;
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 0 20px rgba(240, 177, 96, 0.3));
  animation: logoFloat 3s ease-in-out infinite;
}

.rotating-ring {
  position: absolute;
  top: -10px;
  left: -10px;
  width: calc(100% + 20px);
  height: calc(100% + 20px);
  border-radius: 50%;
}

.ring-segment {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 2px solid transparent;
  border-radius: 50%;
  animation: ringRotate 4s linear infinite;
}

.segment-1 {
  border-top-color: rgba(240, 177, 96, 0.8);
  animation-delay: 0s;
}

.segment-2 {
  border-right-color: rgba(240, 177, 96, 0.6);
  animation-delay: 1s;
}

.segment-3 {
  border-bottom-color: rgba(240, 177, 96, 0.4);
  animation-delay: 2s;
}

.segment-4 {
  border-left-color: rgba(240, 177, 96, 0.2);
  animation-delay: 3s;
}

/* Enhanced Brand Text */
.brand-text {
  text-align: center;
}

.clinic-name {
  font-size: 2.5rem;
  font-weight: 700;
  margin: 0 0 0.5rem 0;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 0%, #f0b160 50%, #ffffff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: textShimmer 3s ease-in-out infinite;
}

.word-pro {
  font-weight: 300;
}

.word-clinic {
  font-weight: 700;
}

.brand-subtitle {
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.8);
  font-weight: 400;
  margin-bottom: 0.25rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.brand-tagline {
  font-size: 0.85rem;
  color: rgba(240, 177, 96, 0.9);
  font-weight: 300;
  font-style: italic;
  letter-spacing: 0.05em;
}

/* Professional Progress Bar */
.loading-progress {
  width: 100%;
  max-width: 300px;
}

.progress-container {
  position: relative;
  margin-bottom: 1rem;
}

.progress-track {
  position: relative;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #f0b160, #ffd700, #f0b160);
  border-radius: 2px;
  position: relative;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  background-size: 200% 100%;
  animation: progressShimmer 2s ease-in-out infinite;
}

.progress-glow {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, transparent, rgba(240, 177, 96, 0.4), transparent);
  border-radius: 2px;
  opacity: 0;
  animation: progressGlow 2s ease-in-out infinite;
}

.progress-indicator {
  position: absolute;
  top: -6px;
  left: 0;
  width: 16px;
  height: 16px;
  transform: translateX(-8px);
  transition: left 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-dot {
  width: 16px;
  height: 16px;
  background: linear-gradient(135deg, #f0b160, #ffd700);
  border-radius: 50%;
  box-shadow: 0 0 15px rgba(240, 177, 96, 0.6);
  animation: dotPulse 1.5s ease-in-out infinite;
}

.progress-pulse {
  position: absolute;
  top: 0;
  left: 0;
  width: 16px;
  height: 16px;
  background: rgba(240, 177, 96, 0.3);
  border-radius: 50%;
  animation: dotRipple 2s ease-in-out infinite;
}

.progress-details {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
}

.loading-text {
  color: rgba(255, 255, 255, 0.7);
  font-weight: 300;
  letter-spacing: 0.05em;
}

.percentage {
  color: #f0b160;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 40px;
  text-align: right;
  font-size: 1rem;
}

/* Loader Footer */
.loader-footer {
  margin-top: 1rem;
}

.loading-dots {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
}

.dot {
  width: 8px;
  height: 8px;
  background: rgba(240, 177, 96, 0.6);
  border-radius: 50%;
  animation: dotWave 1.5s ease-in-out infinite;
}

.dot:nth-child(1) { animation-delay: 0s; }
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

/* Professional Loader Animations */
@keyframes gradientShift {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.1) rotate(180deg); }
}

@keyframes particleFloat {
  0%, 100% { transform: translateY(0px) translateX(0px) scale(1); opacity: 0.6; }
  25% { transform: translateY(-20px) translateX(10px) scale(1.2); opacity: 0.8; }
  50% { transform: translateY(-10px) translateX(-10px) scale(0.8); opacity: 0.4; }
  75% { transform: translateY(-25px) translateX(15px) scale(1.1); opacity: 0.7; }
}

@keyframes shapeRotate {
  0% { transform: rotate(0deg) translateX(100px) rotate(0deg); }
  100% { transform: rotate(360deg) translateX(100px) rotate(-360deg); }
}

@keyframes logoBackgroundPulse {
  0%, 100% { transform: scale(1); opacity: 0.3; }
  50% { transform: scale(1.2); opacity: 0.1; }
}

@keyframes logoShine {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes logoFloat {
  0%, 100% { transform: translateY(0px) scale(1); }
  50% { transform: translateY(-8px) scale(1.05); }
}

@keyframes ringRotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

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

@keyframes progressShimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes progressGlow {
  0%, 100% { opacity: 0; transform: translateX(-100%); }
  50% { opacity: 1; transform: translateX(300%); }
}

@keyframes dotPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

@keyframes dotRipple {
  0% { transform: scale(0); opacity: 1; }
  100% { transform: scale(3); opacity: 0; }
}

@keyframes dotWave {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.3); opacity: 1; }
}

/* ===================================
   HERO TITLE ADVANCED ANIMATIONS
   =================================== */

/* Hero title container animation */
.hero-title {
  /* Ensure stable text rendering */
  font-display: swap;
  font-synthesis: none;
  -webkit-font-feature-settings: "kern" 1, "liga" 1;
  font-feature-settings: "kern" 1, "liga" 1;
  text-rendering: geometricPrecision;
}

/* Base title line styles with enhanced animations */
.title-line {
  display: block;
  font-size: clamp(var(--text-5xl), 8vw, var(--text-8xl));
  font-weight: var(--font-extrabold);
  line-height: 0.9;
  letter-spacing: -0.02em;
  position: relative;
  transform: translateY(50px);
  opacity: 0;
  animation: titleRevealFixed 1s ease-out forwards;
  text-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  will-change: transform, opacity;
  /* Prevent text corruption */
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "kern" 1;
  -webkit-text-stroke: 0.5px transparent;
}

/* Staggered animation delays */
.title-line-1 {
  animation-delay: 0.3s;
}

.title-line-2 {
  animation-delay: 0.6s;
}

.title-line-3 {
  animation-delay: 0.9s;
}

/* Enhanced gradient text with stable animation */
.gradient-text {
  background: linear-gradient(
    135deg,
    #f0b160 0%,
    #ffd700 25%,
    #f0b160 50%,
    #c47d1f 75%,
    #f4c784 100%
  );
  background-size: 200% 200%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: 
    gradientMorphStable 3s ease-in-out infinite,
    titleRevealFixed 1s ease-out forwards;
  position: relative;
  /* Prevent gradient text corruption */
  -webkit-text-stroke: 0.5px transparent;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Fallback color in case gradient fails */
  color: #f0b160;
}

/* Removed problematic shimmer and sparkle effects to prevent text corruption */

/* Simplified hover effects to prevent text corruption */
.hero-title:hover .title-line {
  transform: translateY(-2px);
  transition: transform 0.3s ease;
}

.hero-title:hover .gradient-text {
  text-shadow: 0 0 15px rgba(240, 177, 96, 0.6);
  transition: text-shadow 0.3s ease;
}

/* Stable keyframe animations to prevent text corruption */
@keyframes titleRevealFixed {
  0% {
    transform: translateY(50px);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

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

/* Responsive adjustments */
@media (max-width: 768px) {
  .title-line {
    font-size: clamp(var(--text-4xl), 12vw, var(--text-6xl));
  }
  
  .hero-title:hover .title-line {
    transform: translateY(-1px);
  }
}

@media (max-width: 480px) {
  .title-line {
    letter-spacing: -0.01em;
    line-height: 1;
  }
}

/* Enhanced Hero Subtitle Animation */
.hero-subtitle {
  transform: translateY(40px);
  opacity: 0;
  animation: subtitleReveal 1s cubic-bezier(0.25, 0.46, 0.45, 0.94) 1.2s forwards;
  position: relative;
  overflow: hidden;
}

.hero-subtitle::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.1) 50%,
    transparent 100%
  );
  animation: subtitleShimmer 6s ease-in-out 2s infinite;
  pointer-events: none;
}

@keyframes subtitleReveal {
  0% {
    transform: translateY(40px);
    opacity: 0;
    filter: blur(5px);
  }
  60% {
    transform: translateY(-5px);
    opacity: 0.9;
    filter: blur(1px);
  }
  100% {
    transform: translateY(0);
    opacity: 1;
    filter: blur(0);
  }
}

@keyframes subtitleShimmer {
  0% {
    left: -100%;
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    left: 100%;
    opacity: 0;
  }
}

/* Enhanced Hero Actions Animation */
.hero-actions {
  transform: translateY(50px);
  opacity: 0;
  animation: actionsReveal 1s cubic-bezier(0.34, 1.56, 0.64, 1) 1.5s forwards;
}

.hero-actions .btn {
  transform: translateY(30px) scale(0.9);
  opacity: 0;
  animation: buttonFloat 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

.hero-actions .btn:first-child {
  animation-delay: 1.8s;
}

.hero-actions .btn:last-child {
  animation-delay: 2s;
}

@keyframes actionsReveal {
  0% {
    transform: translateY(50px);
    opacity: 0;
  }
  70% {
    transform: translateY(-5px);
    opacity: 0.9;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes buttonFloat {
  0% {
    transform: translateY(30px) scale(0.9);
    opacity: 0;
  }
  60% {
    transform: translateY(-8px) scale(1.05);
    opacity: 0.8;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .title-line {
    animation: titleRevealSimple 1s ease-out forwards;
    transform: translateY(20px);
  }
  
  .gradient-text {
    animation: titleRevealSimple 1s ease-out forwards;
    background: #f0b160;
    -webkit-text-fill-color: #f0b160;
    color: #f0b160;
  }
  
  .hero-subtitle {
    animation: titleRevealSimple 1s ease-out 0.5s forwards;
  }
  
  .hero-actions {
    animation: titleRevealSimple 1s ease-out 0.8s forwards;
  }
  
  .hero-actions .btn {
    animation: titleRevealSimple 0.8s ease-out forwards;
  }
  
  /* Removed pseudo-elements that caused corruption */
  
  .hero-title:hover .title-line {
    transform: none;
  }
  
  .hero-title:hover .gradient-text {
    filter: none;
  }
  
  @keyframes titleRevealSimple {
    from {
      transform: translateY(20px);
      opacity: 0;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }
}

/* Section Transition Loader */
.section-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.section-loader.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.section-loader-content {
  text-align: center;
  color: white;
  transform: scale(0.8);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.section-loader.active .section-loader-content {
  transform: scale(1);
}

.section-loader-spinner {
  position: relative;
  width: 60px;
  height: 60px;
  margin: 0 auto var(--space-4);
}

.spinner-ring {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 3px solid transparent;
  border-radius: 50%;
  animation: spinnerRotate 1.2s linear infinite;
}

.spinner-ring:nth-child(1) {
  border-top-color: var(--color-primary);
  animation-delay: 0s;
}

.spinner-ring:nth-child(2) {
  width: 80%;
  height: 80%;
  top: 10%;
  left: 10%;
  border-top-color: rgba(240, 177, 96, 0.6);
  animation-delay: 0.4s;
  animation-direction: reverse;
}

.spinner-ring:nth-child(3) {
  width: 60%;
  height: 60%;
  top: 20%;
  left: 20%;
  border-top-color: rgba(240, 177, 96, 0.3);
  animation-delay: 0.8s;
}

.section-loader-text {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: rgba(255, 255, 255, 0.9);
  animation: sectionTextPulse 1.5s ease-in-out infinite;
}

@keyframes spinnerRotate {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@keyframes sectionTextPulse {
  0%, 100% {
    opacity: 0.9;
  }
  50% {
    opacity: 0.5;
  }
}

/* Mobile optimizations */
@media (max-width: 768px) {
  .section-loader-spinner {
    width: 50px;
    height: 50px;
  }
  
  .section-loader-text {
    font-size: var(--text-xs);
  }
  
  /* Professional Loader Mobile Styles */
  .loader-content {
    gap: 1.5rem;
    padding: 0 1.5rem;
  }
  
  .logo-wrapper {
    width: 100px;
    height: 100px;
  }
  
  .loader-logo {
    width: 70px;
    height: 70px;
  }
  
  .clinic-name {
    font-size: 2rem;
  }
  
  .brand-subtitle {
    font-size: 0.875rem;
  }
  
  .brand-tagline {
    font-size: 0.75rem;
  }
  
  .loading-progress {
    max-width: 280px;
  }
  
  .progress-details {
    font-size: 0.8rem;
  }
  
  .loading-text {
    font-size: 0.75rem;
  }
  
  .percentage {
    font-size: 0.875rem;
  }
  
  .particle {
    width: 3px;
    height: 3px;
  }
  
  .shape-circle {
    width: 150px;
    height: 150px;
  }
  
  .shape-triangle {
    width: 100px;
    height: 100px;
  }
  
  .shape-square {
    width: 80px;
    height: 80px;
  }
}

/* Hero Animations */
@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Floating Elements */
.floating-element {
  position: absolute;
  width: 20px;
  height: 20px;
  background: linear-gradient(135deg, var(--color-primary-light), var(--color-primary));
  border-radius: 50%;
  opacity: 0.6;
  animation: float 6s ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}

.floating-element:nth-child(odd) {
  animation-direction: reverse;
}

.floating-element:before {
  content: '';
  position: absolute;
  top: -10px;
  left: -10px;
  right: -10px;
  bottom: -10px;
  background: radial-gradient(circle, var(--color-primary-200) 0%, transparent 70%);
  border-radius: 50%;
  opacity: 0.3;
  animation: pulse 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0px) rotate(0deg);
  }
  25% {
    transform: translateY(-20px) rotate(90deg);
  }
  50% {
    transform: translateY(-10px) rotate(180deg);
  }
  75% {
    transform: translateY(-25px) rotate(270deg);
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.3;
  }
  50% {
    transform: scale(1.2);
    opacity: 0.1;
  }
}

/* Grid Background Animation */
.hero-grid {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 50px 50px;
  animation: gridMove 20s linear infinite;
}

@keyframes gridMove {
  0% { transform: translate(0, 0); }
  100% { transform: translate(50px, 50px); }
}

/* Text Reveal Animation */
.text-reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.text-reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered Animation Delays - Fixed timing */
.title-line:nth-child(1) { 
  animation-delay: 0.2s; 
  animation-fill-mode: both;
}
.title-line:nth-child(2) { 
  animation-delay: 0.4s; 
  animation-fill-mode: both;
}
.title-line:nth-child(3) { 
  animation-delay: 0.6s; 
  animation-fill-mode: both;
}

.stat-card:nth-child(1) { animation-delay: 0.1s; }
.stat-card:nth-child(2) { animation-delay: 0.2s; }
.stat-card:nth-child(3) { animation-delay: 0.3s; }
.stat-card:nth-child(4) { animation-delay: 0.4s; }

/* Button Hover Animations */
.btn {
  position: relative;
  overflow: hidden;
  transition: all var(--duration-300) var(--ease-out);
}

.btn:before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s;
}

.btn:hover:before {
  left: 100%;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-xl);
}

/* Card Hover Animations */
.card, .about-card, .service-card, .team-card {
  transition: all var(--duration-300) var(--ease-out);
}

.card:hover, .about-card:hover, .service-card:hover, .team-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-2xl);
}

.card:hover .card-icon, 
.about-card:hover .card-icon,
.service-card:hover .card-icon {
  transform: scale(1.1);
  color: var(--color-primary-500);
}

/* Scroll Indicator Animation */
.scroll-indicator {
  animation: scrollBounce 2s ease-in-out infinite;
}

.scroll-line {
  height: 0;
  animation: scrollLine 2s ease-in-out infinite;
}

.scroll-dot {
  animation: scrollDot 2s ease-in-out infinite;
}

@keyframes scrollBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(10px); }
}

@keyframes scrollLine {
  0%, 100% { height: 0; }
  50% { height: 40px; }
}

@keyframes scrollDot {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(45px) scale(1.2); }
}

/* Navigation Animation */
.navbar {
  transition: all var(--duration-300) var(--ease-out);
}

.navbar.scrolled {
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Mobile Menu Animations */
.nav-toggle {
  transition: all var(--duration-300) var(--ease-out);
}

.nav-toggle.active {
  transform: rotate(90deg);
}

.hamburger-line {
  transition: all var(--duration-300) var(--ease-out);
  transform-origin: center;
}

.nav-toggle.active .hamburger-line:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.nav-toggle.active .hamburger-line:nth-child(2) {
  opacity: 0;
}

.nav-toggle.active .hamburger-line:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -6px);
}

/* Service Filter Animation */
.filter-btn {
  transition: all var(--duration-200) var(--ease-out);
}

.filter-btn.active {
  background: var(--color-primary-600);
  color: white;
  transform: scale(1.05);
}

.service-card {
  transition: all var(--duration-300) var(--ease-out);
}

.service-card.hidden {
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
}

/* Counter Animation */
.stat-number {
  font-variant-numeric: tabular-nums;
}

/* Testimonial Carousel */
.testimonial-card {
  transition: all var(--duration-300) var(--ease-out);
  opacity: 0.7;
  transform: scale(0.95);
}

.testimonial-card.active {
  opacity: 1;
  transform: scale(1);
}

/* Form Animations */
.form-input:focus {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.form-input:focus + .form-label {
  transform: translateY(-20px) scale(0.85);
  color: var(--color-primary-600);
}

/* Emergency Button Animation */
.emergency-btn {
  animation: emergencyPulse 3s ease-in-out infinite;
}

@keyframes emergencyPulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }
  50% {
    box-shadow: 0 0 0 20px rgba(239, 68, 68, 0);
  }
}

.emergency-btn:hover {
  transform: scale(1.1);
  animation-duration: 1s;
}

/* Notification Animation */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  max-width: 400px;
  transform: translateX(500px);
  transition: all var(--duration-300) var(--ease-out);
  z-index: 1000;
}

.notification.show {
  transform: translateX(0);
}

.notification-success {
  border-left: 4px solid var(--color-success);
}

.notification-error {
  border-left: 4px solid var(--color-error);
}

.notification-info {
  border-left: 4px solid var(--color-primary-500);
}

/* Page Transitions */
.page-transition {
  opacity: 0;
  animation: pageTransition 0.5s ease-out forwards;
}

@keyframes pageTransition {
  to {
    opacity: 1;
  }
}

/* Responsive Animations */
@media (max-width: 768px) {
  .floating-element {
    display: none;
  }
  
  .hero-grid {
    background-size: 30px 30px;
  }
  
  .card:hover, .about-card:hover, .service-card:hover, .team-card:hover {
    transform: translateY(-4px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  ::before,
  ::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Performance Optimizations */
.will-change-transform {
  will-change: transform;
}

.will-change-opacity {
  will-change: opacity;
}

.gpu-accelerated {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
}

/* Animation Utilities */
.animate-fade-in {
  animation: fadeInUp 0.8s ease-out;
}

.animate-fade-in-delay-1 {
  animation: fadeInUp 0.8s ease-out 0.2s backwards;
}

.animate-fade-in-delay-2 {
  animation: fadeInUp 0.8s ease-out 0.4s backwards;
}

.animate-fade-in-delay-3 {
  animation: fadeInUp 0.8s ease-out 0.6s backwards;
}

.animate-scale-in {
  animation: scaleIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.animate-slide-left {
  animation: fadeInLeft 0.8s ease-out;
}

.animate-slide-right {
  animation: fadeInRight 0.8s ease-out;
}

/* Enhanced Modal Animations */
@keyframes modalFadeIn {
  0% {
    opacity: 0;
    backdrop-filter: blur(0px);
  }
  100% {
    opacity: 1;
    backdrop-filter: blur(12px);
  }
}

@keyframes modalSlideIn {
  0% {
    transform: scale(0.9) translateY(40px);
    opacity: 0;
  }
  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

@keyframes modalSlideOut {
  0% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
  100% {
    transform: scale(0.95) translateY(20px);
    opacity: 0;
  }
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* Form field focus animations */
@keyframes fieldFocus {
  0% {
    box-shadow: 0 0 0 0 rgba(240, 177, 96, 0.2);
  }
  100% {
    box-shadow: 0 0 0 4px rgba(240, 177, 96, 0.1);
  }
}
