/* Comprehensive Responsive Design Fixes for All Devices */

/* Base responsive settings */
* {
  box-sizing: border-box;
}

html, body {
  width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

/* Ensure images and media are responsive */
img, video, iframe, object, embed {
  max-width: 100%;
  height: auto;
}

/* Fix container max-widths for better mobile experience */
.container, .max-w-7xl, .max-w-6xl, .max-w-5xl, .max-w-4xl {
  width: 100%;
  padding-left: 1rem;
  padding-right: 1rem;
}

/* Enhanced mobile navigation */
@media (max-width: 768px) {
  /* Navigation improvements */
  nav {
    flex-wrap: wrap;
  }
  
  .nav-links {
    width: 100%;
    order: 3;
    margin-top: 1rem;
  }
  
  /* Hero section mobile optimizations */
  .hero-section {
    padding: 2rem 1rem !important;
  }
  
  .hero-section h1 {
    font-size: 2rem !important;
    line-height: 1.2 !important;
    margin-bottom: 1rem !important;
  }
  
  .hero-section p {
    font-size: 1rem !important;
    margin-bottom: 1.5rem !important;
  }
  
  /* Button improvements */
  .hero-buttons {
    flex-direction: column !important;
    gap: 1rem !important;
  }
  
  .hero-buttons > * {
    width: 100% !important;
    text-align: center !important;
  }
  
  /* Grid layout fixes */
  .grid-cols-1.sm\\:grid-cols-2.lg\\:grid-cols-3 {
    grid-template-columns: 1fr !important;
  }
  
  .grid-cols-1.md\\:grid-cols-2 {
    grid-template-columns: 1fr !important;
  }
  
  .grid-cols-1.md\\:grid-cols-3 {
    grid-template-columns: 1fr !important;
  }
  
  /* Form improvements */
  #orderForm {
    padding: 1rem !important;
  }
  
  #orderForm .grid-cols-1.md\\:grid-cols-2 {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }
  
  #orderForm .grid-cols-1.md\\:grid-cols-3 {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }
  
  /* Input and select styling */
  input, select, textarea {
    font-size: 16px !important; /* Prevents zoom on iOS */
    width: 100% !important;
  }
  
  /* Service cards mobile layout */
  .service-card {
    margin-bottom: 1rem !important;
  }
  
  /* Portfolio grid mobile */
  .portfolio-grid {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }
  
  /* Contact cards mobile */
  .contact-cards {
    flex-direction: column !important;
    gap: 1rem !important;
  }
  
  /* Testimonials mobile */
  .testimonial-grid {
    grid-template-columns: 1fr !important;
  }
  
  /* Fix long words breaking layout */
  p, span, div {
    word-wrap: break-word;
    word-break: break-word;
  }
  
  /* Mobile-specific text sizes */
  .text-4xl {
    font-size: 2rem !important;
  }
  
  .text-5xl {
    font-size: 2.5rem !important;
  }
  
  .text-6xl {
    font-size: 3rem !important;
  }
  
  /* Mobile padding adjustments */
  .py-16 {
    padding-top: 3rem !important;
    padding-bottom: 3rem !important;
  }
  
  .py-20 {
    padding-top: 4rem !important;
    padding-bottom: 4rem !important;
  }
  
  /* Modal improvements */
  .modal, .chat-window {
    width: calc(100vw - 2rem) !important;
    max-width: calc(100vw - 2rem) !important;
    margin: 1rem !important;
  }
  
  /* Toast notifications mobile positioning */
  .toast-container {
    left: 1rem !important;
    right: 1rem !important;
    width: auto !important;
  }
}

/* Tablet specific optimizations */
@media (min-width: 769px) and (max-width: 1024px) {
  .container, .max-w-7xl, .max-w-6xl, .max-w-5xl, .max-w-4xl {
    padding-left: 2rem;
    padding-right: 2rem;
  }
  
  /* Hero section tablet adjustments */
  .hero-section h1 {
    font-size: 3rem !important;
  }
  
  /* Grid layouts for tablet */
  .tablet-grid-2 {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  
  /* Form layout for tablet */
  #orderForm .grid-cols-1.md\\:grid-cols-3 {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* Large screen optimizations */
@media (min-width: 1400px) {
  .container, .max-w-7xl {
    max-width: 1400px;
    margin: 0 auto;
  }
  
  /* Prevent content from getting too wide */
  .hero-section .max-w-4xl {
    max-width: 60rem !important;
  }
}

/* Landscape phone specific fixes */
@media (max-height: 500px) and (orientation: landscape) {
  .hero-section {
    padding: 1rem !important;
  }
  
  .hero-section h1 {
    font-size: 1.8rem !important;
    margin-bottom: 0.5rem !important;
  }
  
  .hero-section p {
    font-size: 0.9rem !important;
    margin-bottom: 1rem !important;
  }
  
  /* Compact button layout */
  .hero-buttons {
    flex-direction: row !important;
    gap: 0.5rem !important;
  }
  
  .hero-buttons > * {
    padding: 0.5rem 1rem !important;
    font-size: 0.9rem !important;
  }
}

/* High DPI display optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  /* Sharper borders and shadows */
  .border {
    border-width: 0.5px;
  }
  
  .shadow-lg {
    box-shadow: 0 5px 15px -3px rgba(0, 0, 0, 0.1), 0 2px 6px -2px rgba(0, 0, 0, 0.05);
  }
}

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

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  /* Adjust colors for dark mode if needed */
  .bg-white {
    background-color: rgba(255, 255, 255, 0.95);
  }
}

/* Fix specific components */

/* Fixed contact form responsiveness */
.contact-form-container {
  width: 100% !important;
  max-width: 100% !important;
}

/* Fixed service selection dropdown */
select[multiple] {
  min-height: 120px !important;
}

@media (max-width: 768px) {
  select[multiple] {
    min-height: 100px !important;
  }
}

/* Fixed payment section */
.payment-section {
  width: 100% !important;
  overflow-x: auto !important;
}

/* Fixed button sizes */
button, .btn {
  min-height: 44px !important; /* Touch target size */
  padding: 0.75rem 1.5rem !important;
}

@media (max-width: 768px) {
  button, .btn {
    width: 100% !important;
    margin-bottom: 0.5rem !important;
  }
}

/* Fixed chat window */
.chat-window {
  position: fixed !important;
  z-index: 9999 !important;
}

@media (max-width: 768px) {
  .chat-window {
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 70vh !important;
    border-radius: 1rem 1rem 0 0 !important;
  }
}

/* Fix overflow issues */
.overflow-hidden {
  overflow: hidden !important;
}

.overflow-x-hidden {
  overflow-x: hidden !important;
}

/* Ensure touch targets are accessible */
a, button, input, select, textarea {
  min-height: 44px;
  min-width: 44px;
}

/* Fix sticky elements on mobile */
@media (max-width: 768px) {
  .sticky, .fixed {
    position: relative !important;
  }
  
  /* Exception for truly needed fixed elements */
  .chat-window, .toast-container {
    position: fixed !important;
  }
}

/* Print styles */
@media print {
  .no-print, .chat-window, .toast-container, button {
    display: none !important;
  }
  
  * {
    background: white !important;
    color: black !important;
  }
}
