@tailwind base;
@tailwind components;
@tailwind utilities;

/* Performance optimizations */
* {
  box-sizing: border-box;
}

/* Optimize font loading */
@layer base {
  html {
    font-display: swap;
  }
}

/* Reduce layout shifts */
img {
  max-width: 100%;
  height: auto;
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(to bottom, #3b82f6, #00b0ff);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(to bottom, #2563eb, #00b0ff);
}

/* Add padding to body to account for fixed navigation */
body {
  padding-top: 110px;
}

@media (min-width: 640px) {
  body {
    padding-top: 126px;
  }
}

/* Prevent horizontal scroll */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

/* Ensure all containers don't exceed viewport width */
* {
  box-sizing: border-box;
}

/* Fix for mobile viewport issues */
@media (max-width: 768px) {
  body {
    padding-top: 100px;
  }
  
  .container, .max-w-7xl, .max-w-6xl, .max-w-5xl, .max-w-4xl {
    max-width: 100vw !important;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }
  
  /* Prevent text from breaking layout */
  h1, h2, h3, h4, h5, h6, p, span, div {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
  }
  
  /* Fix for images */
  img {
    max-width: 100%;
    height: auto;
  }
  
  /* Fix for grid layouts on mobile */
  .grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
  }
  
  /* Ensure buttons don't overflow */
  button, .btn {
    max-width: 100%;
    word-wrap: break-word;
  }
  
  /* Ensure dropdown menus don't overflow on mobile */
  .dropdown-menu {
    left: 0.5rem !important;
    right: 0.5rem !important;
    width: auto !important;
    transform: none !important;
  }
  
  /* Optimize animations on mobile */
  .animate-fade-in,
  .animate-slide-in-left,
  .animate-slide-in-right,
  .animate-scale-in {
    animation-duration: 0.4s;
  }
  
  /* Mobile-specific text sizing */
  .text-responsive {
    font-size: clamp(1.25rem, 4vw, 2rem) !important;
  }
  
  .text-responsive-lg {
    font-size: clamp(1.75rem, 6vw, 3rem) !important;
  }
  
  /* Improve touch targets on mobile */
  button, a {
    min-height: 44px;
  }
  
  /* Better spacing for mobile cards */
  .mobile-card-spacing {
    margin-bottom: 1rem;
  }
  
  /* Optimize image loading on mobile */
  img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
  
  /* Fix for slider navigation arrows on mobile */
  .slider-container {
    position: relative;
  }
  
  .slider-arrow {
    z-index: 20;
  }
  
  /* Ensure centered content in sliders */
  .slider-content-center {
    text-align: center;
  }
  
  .slider-content-center .flex {
    justify-content: center;
  }
}

/* Additional mobile optimizations */
@media (max-width: 480px) {
  body {
    padding-top: 95px;
  }
  
  .container, .max-w-7xl, .max-w-6xl, .max-w-5xl, .max-w-4xl {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }
  
  /* Smaller text on very small screens */
  h1 {
    font-size: clamp(1.5rem, 5vw, 2.5rem) !important;
    line-height: 1.2 !important;
  }
  
  h2 {
    font-size: clamp(1.25rem, 4vw, 2rem) !important;
    line-height: 1.3 !important;
  }
  
  h3 {
    font-size: clamp(1rem, 3vw, 1.5rem) !important;
    line-height: 1.4 !important;
  }
  
  /* Reduce padding on very small screens */
  .p-8 {
    padding: 1rem !important;
  }
  
  .p-6 {
    padding: 0.75rem !important;
  }
  
  /* Optimize button sizes */
  button {
    min-height: 40px;
    font-size: 0.875rem !important;
  }
}

/* Animations for smooth transitions */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

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

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

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

.animate-fade-in-simple {
  animation: fadeIn 0.2s ease-out forwards;
}

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

.animate-slide-in-right {
  animation: slideInRight 0.3s ease-out forwards;
}

.animate-scale-in {
  animation: scaleIn 0.3s ease-out forwards;
}

/* Glass morphism effect */
.glass {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.glass-dark {
  background: rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Gradient text utilities */
.gradient-text-blue {
  background: linear-gradient(135deg, #3b82f6, #00b0ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.gradient-text-purple {
  background: linear-gradient(135deg, #8b5cf6, #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Custom button hover effects */
.btn-hover-lift {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Smooth focus styles */
.focus-ring {
  @apply focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 focus:ring-offset-white;
}

/* Smooth category transitions */
.category-transition {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Category slider animations */
.category-slider {
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.category-button {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.category-button:hover {
  transform: translateY(-1px);
}

.category-indicator {
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.3);
}

/* Work process step animations */
.work-step-card {
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.work-step-card.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Consultation panel animations */
.consultation-panel-enter {
  transform: translateY(100%);
}

.consultation-panel-enter-active {
  transform: translateY(0);
  transition: transform 300ms ease-in-out;
}

.consultation-panel-exit {
  transform: translateY(0);
}

.consultation-panel-exit-active {
  transform: translateY(100%);
  transition: transform 300ms ease-in-out;
}

/* Loading animations */
@keyframes shimmer {
  0% {
    background-position: -200px 0;
  }
  100% {
    background-position: calc(200px + 100%) 0;
  }
}

.shimmer {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200px 100%;
  animation: shimmer 1.5s infinite;
}

/* Improved mobile responsiveness */
@media (max-width: 640px) {
  .text-responsive {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
  }
  
  .text-responsive-lg {
    font-size: clamp(2rem, 6vw, 4rem);
  }
}