/* Prevent body scroll when modal is open */
body:has(dialog[open]) {
  overflow: hidden !important;
  position: fixed !important;
  width: 100% !important;
  height: 100% !important;
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
  body:has(dialog[open]) {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    overflow: hidden !important;
  }
}

/* Modal positioning for mobile - full screen with no padding */
@media (max-width: 767px) {
  .mobile-optimized-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important; /* Use dynamic viewport height */
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
  }
  
  /* Ensure modal content container handles viewport changes */
  .mobile-optimized-modal > div {
    height: 100vh !important;
    height: 100dvh !important; /* Use dynamic viewport height */
    display: flex !important;
    flex-direction: column !important;
    border-radius: 0 !important; /* Remove rounded corners on mobile for full screen */
  }
  
  /* Fix for all modals on mobile to prevent gaps */
  dialog.modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important; /* Use dynamic viewport height for iOS */
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
  }
  
  /* Ensure modal content fills entire screen */
  dialog.modal > div {
    height: 100vh !important;
    height: 100dvh !important; /* Use dynamic viewport height for iOS */
    min-height: 100vh !important;
    min-height: 100dvh !important;
    border-radius: 0 !important;
    background: white !important;
  }
  
  /* Prevent footer from being hidden by virtual keyboard */
  .mobile-optimized-modal .sticky {
    position: sticky !important;
    bottom: 0 !important;
    z-index: 1000 !important;
  }
  
  /* iOS Safari input field fixes */
  .mobile-optimized-modal input[type="text"] {
    font-size: 16px !important; /* Prevents zoom on iOS */
    padding: 12px !important;
    border-radius: 8px !important;
  }
  
  /* Ensure input area stays above keyboard */
  .mobile-optimized-modal form {
    position: sticky !important;
    bottom: 0 !important;
    background: white !important;
    padding: 16px !important;
    z-index: 1001 !important;
  }
  
  /* Ensure proper scrolling behavior */
  .mobile-optimized-modal .overflow-y-auto {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
}

/* Modal positioning for desktop */
@media (min-width: 768px) {
  .mobile-optimized-modal {
    position: fixed !important;
    top: 20px !important;
    left: 20px !important;
    right: 20px !important;
    bottom: 20px !important;
    width: calc(100vw - 40px) !important;
    height: calc(100vh - 40px) !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
  }
  
  /* Ensure modal content container keeps rounded corners on desktop */
  .mobile-optimized-modal > div {
    border-radius: 1rem !important; /* Keep rounded corners on desktop */
  }
}

/* Button styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition-property: all;
  transition-duration: 0.2s;
}

.btn-circle {
  border-radius: 9999px;
  height: 3rem;
  width: 3rem;
  padding: 0;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}



/* Make sure these buttons are always visible */
.fixed.right-0.bottom-0.transform.translate-x-\[51px\].-translate-y-36.-rotate-90,
.fixed.right-5.bottom-5.btn.btn-circle {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  z-index: 9999 !important;
  position: fixed !important;
  pointer-events: auto !important;
}

/* Prevent other elements from overlapping the help and rate buttons */
body::after {
  content: "";
  display: block;
  position: fixed;
  bottom: 0;
  right: 0;
  height: 100px;
  width: 100px;
  pointer-events: none;
  z-index: 1000;
}

/* Animated gradient background */
@keyframes gradient-slow {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.animate-gradient-slow {
  background-size: 200% 200% !important;
  animation: gradient-slow 8s ease infinite;
}

/* Performance-optimized CSS animations for motion fallbacks */
@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slide-in-left {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.animate-fade-in {
  animation: fade-in 0.6s ease-out forwards;
}

.animate-slide-up {
  animation: slide-up 0.6s ease-out forwards;
}

.animate-slide-in {
  animation: slide-in 0.6s ease-out forwards;
}

.animate-slide-in-left {
  animation: slide-in-left 0.6s ease-out forwards;
}

/* Staggered animation delays for child elements */
.animate-stagger > *:nth-child(1) { animation-delay: 0ms; }
.animate-stagger > *:nth-child(2) { animation-delay: 100ms; }
.animate-stagger > *:nth-child(3) { animation-delay: 200ms; }
.animate-stagger > *:nth-child(4) { animation-delay: 300ms; }
.animate-stagger > *:nth-child(5) { animation-delay: 400ms; }
.animate-stagger > *:nth-child(6) { animation-delay: 500ms; }

/* CTA Button Animations */
@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%) skewX(-12deg);
  }
  100% {
    transform: translateX(200%) skewX(-12deg);
  }
}

.animate-shimmer {
  animation: shimmer 2s ease-in-out infinite;
}