/* Mobile-First Web App Optimization for BodyYar */

/* Base styles */
* {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Allow text selection in input fields */
input, textarea, [contenteditable] {
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Mobile viewport optimization */
body {
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Prevent zoom on input focus */
input, select, textarea {
  font-size: 16px !important;
}

/* Mobile container enhancements */
.mobile-container {
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  -webkit-perspective: 1000;
  perspective: 1000;
  -webkit-transform: translate3d(0, 0, 0);
  transform: translate3d(0, 0, 0);
}

/* Loading screen animations */
.loading-screen {
  -webkit-animation: fadeIn 0.5s ease-in-out;
  animation: fadeIn 0.5s ease-in-out;
}

@-webkit-keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Flutter app container */
#flutter-app {
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* Responsive breakpoints */
@media (max-width: 480px) {
  .mobile-container {
    max-width: 100%;
    border-radius: 0;
  }
  
  .desktop-wrapper {
    padding: 0;
  }
}

@media (min-width: 481px) and (max-width: 768px) {
  .mobile-container {
    max-width: 100%;
    border-radius: 15px;
  }
}

@media (min-width: 769px) {
  .mobile-container {
    max-width: 430px;
    border-radius: 25px;
    box-shadow: 0 0 50px rgba(0,0,0,0.4);
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .loading-logo {
    -webkit-transform: scale(1.1);
    transform: scale(1.1);
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .desktop-wrapper {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
  }
  
  .mobile-container {
    background: #1a1a1a;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .loading-spinner {
    animation: none;
  }
  
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Print styles */
@media print {
  .desktop-wrapper {
    background: white;
  }
  
  .mobile-container {
    box-shadow: none;
    border: 1px solid #ccc;
  }
  
  .loading-screen {
    display: none;
  }
}

/* Accessibility improvements */
@media (prefers-contrast: high) {
  .loading-screen {
    background: #000;
    color: #fff;
  }
  
  .mobile-container {
    border: 2px solid #000;
  }
}

/* Focus styles for keyboard navigation */
.mobile-container:focus {
  outline: 2px solid #4CAF50;
  outline-offset: 2px;
}

/* Touch feedback */
.mobile-container {
  -webkit-tap-highlight-color: rgba(76, 175, 80, 0.1);
}

/* Performance optimizations */
.mobile-container,
.loading-screen,
#flutter-app {
  will-change: transform;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

/* iOS specific fixes */
@supports (-webkit-touch-callout: none) {
  .mobile-container {
    -webkit-overflow-scrolling: touch;
  }
  
  body {
    -webkit-overflow-scrolling: touch;
  }
}

/* Android specific fixes */
@supports (display: -webkit-box) {
  .mobile-container {
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
  }
}
