/**
 * Mobile UX Enhancements
 * Additional optimizations for exceptional mobile experience
 */

/* ========================================
   MOBILE-FIRST IMPROVEMENTS
   ======================================== */

/* Smooth scrolling for better UX */
html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Prevent horizontal scroll */
body {
  overflow-x: hidden;
  width: 100%;
}

/* Better tap highlight color */
* {
  -webkit-tap-highlight-color: rgba(59, 130, 246, 0.1);
}

/* ========================================
   ENHANCED TOUCH TARGETS
   ======================================== */

/* Ensure all interactive elements are at least 44x44px */
@media (max-width: 767px) {
  a, button, input[type="submit"], input[type="button"],
  input[type="checkbox"], input[type="radio"],
  select, .btn, .navbar-toggle {
    min-height: 44px;
    min-width: 44px;
  }

  /* Links in text content */
  p a, li a {
    padding: var(--space-1) var(--space-2);
    margin: 0 calc(var(--space-2) * -1);
    display: inline-block;
  }

  /* Form inputs */
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="url"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  textarea,
  select {
    min-height: 48px;
    font-size: 16px; /* Prevents zoom on iOS */
    padding: var(--space-3) var(--space-4);
  }

  textarea {
    min-height: 120px;
  }
}

/* ========================================
   MOBILE TYPOGRAPHY ENHANCEMENTS
   ======================================== */

@media (max-width: 767px) {
  /* Better line height for reading on mobile */
  body {
    line-height: 1.6;
  }

  /* Optimize paragraph width for mobile reading */
  p {
    max-width: 100%;
    margin-bottom: var(--space-5);
  }

  /* Better heading spacing */
  h1, h2, h3, h4, h5, h6 {
    margin-bottom: var(--space-4);
    line-height: 1.2;
  }

  /* Larger hero titles on mobile */
  .hero-title {
    font-size: clamp(2rem, 5vw, 2.5rem);
    line-height: 1.1;
    margin-bottom: var(--space-5);
  }

  .hero-subtitle {
    font-size: clamp(1rem, 3vw, 1.125rem);
    line-height: 1.5;
  }
}

/* ========================================
   ENHANCED STICKY CTA BUTTON
   ======================================== */

@media (max-width: 767px) {
  .sticky-cta {
    position: fixed;
    bottom: var(--space-4);
    right: var(--space-4);
    z-index: 1000;
    bottom: max(var(--space-4), env(safe-area-inset-bottom));
    right: max(var(--space-4), env(safe-area-inset-right));
  }

  .sticky-cta .btn {
    box-shadow: 0 8px 24px rgba(37, 211, 102, 0.35);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    animation: pulse-whatsapp 2s ease-in-out infinite;
  }

  @keyframes pulse-whatsapp {
    0%, 100% {
      box-shadow: 0 8px 24px rgba(37, 211, 102, 0.35);
    }
    50% {
      box-shadow: 0 8px 32px rgba(37, 211, 102, 0.5);
      transform: scale(1.05);
    }
  }
}

/* ========================================
   MOBILE NAVIGATION IMPROVEMENTS
   ======================================== */

@media (max-width: 767px) {
  .navbar {
    backdrop-filter: blur(20px);
    background-color: rgba(255, 255, 255, 0.98);
  }

  .navbar-mobile {
    padding-top: var(--space-4);
    padding-bottom: max(var(--space-8), env(safe-area-inset-bottom));
  }

  .navbar-mobile-link {
    font-size: var(--font-size-lg);
    padding: var(--space-4) var(--space-6);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
  }

  .navbar-mobile-link:active {
    background-color: var(--color-primary-50);
    transform: scale(0.98);
  }

  .navbar-toggle {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    transition: all 0.3s ease;
  }

  .navbar-toggle:active {
    background-color: var(--color-primary-50);
    transform: scale(0.95);
  }
}

/* ========================================
   MOBILE CARD LAYOUTS
   ======================================== */

@media (max-width: 767px) {
  .card {
    margin-bottom: var(--space-6);
  }

  .card-body {
    padding: var(--space-5);
  }

  .card:active {
    transform: scale(0.98);
  }

  .card-image {
    height: 220px;
    object-fit: cover;
  }

  .service-card {
    padding: var(--space-6);
    text-align: left;
  }

  .service-card-icon {
    margin: 0 0 var(--space-4) 0;
  }
}

/* ========================================
   MOBILE FORM IMPROVEMENTS
   ======================================== */

@media (max-width: 767px) {
  .form-group {
    margin-bottom: var(--space-5);
  }

  .form-label {
    font-size: var(--font-size-base);
    margin-bottom: var(--space-2);
    font-weight: var(--font-weight-medium);
  }

  .form-input,
  .form-textarea,
  .form-select {
    width: 100%;
    border-radius: var(--radius-lg);
    border: 2px solid var(--color-border-light);
    transition: all 0.2s ease;
  }

  .form-input:focus,
  .form-textarea:focus,
  .form-select:focus {
    border-color: var(--color-primary-500);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
    outline: none;
  }

  input[type="tel"] {
    font-size: 18px;
    letter-spacing: 0.5px;
  }

  .form-submit {
    width: 100%;
    min-height: 56px;
    font-size: var(--font-size-lg);
    margin-top: var(--space-4);
  }
}

/* ========================================
   MOBILE SECTION SPACING
   ======================================== */

@media (max-width: 767px) {
  .section {
    padding: var(--space-12) 0;
  }

  .section-header {
    margin-bottom: var(--space-8);
    text-align: center;
  }

  .section-title {
    font-size: clamp(1.75rem, 5vw, 2.25rem);
    margin-bottom: var(--space-4);
  }

  .section-subtitle {
    font-size: var(--font-size-sm);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: var(--space-3);
  }

  .section-description {
    font-size: var(--font-size-base);
    max-width: 100%;
  }

  .container {
    padding-left: var(--space-5);
    padding-right: var(--space-5);
  }
}

/* ========================================
   MOBILE HERO SECTION
   ======================================== */

@media (max-width: 767px) {
  .hero {
    min-height: auto;
    padding: var(--space-16) 0 var(--space-12);
  }

  .hero-content {
    text-align: center;
  }

  .hero-actions {
    flex-direction: column;
    width: 100%;
    gap: var(--space-3);
  }

  .hero-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .cta-section {
    padding: var(--space-16) 0;
  }

  .cta-actions {
    flex-direction: column;
    gap: var(--space-3);
  }

  .cta-actions .btn {
    width: 100%;
  }
}

/* ========================================
   MOBILE FOOTER
   ======================================== */

@media (max-width: 767px) {
  .footer {
    padding-bottom: max(var(--space-12), env(safe-area-inset-bottom));
  }

  .footer-content {
    grid-template-columns: 1fr;
    gap: var(--space-8);
  }

  .footer-section {
    text-align: center;
  }

  .footer-links {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
  }
}

/* ========================================
   MOBILE GRID LAYOUTS
   ======================================== */

@media (max-width: 767px) {
  .grid,
  .services-grid,
  .features-grid {
    grid-template-columns: 1fr;
    gap: var(--space-6);
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
  }
}

/* ========================================
   MOBILE UTILITIES
   ======================================== */

@media (max-width: 767px) {
  .hide-mobile {
    display: none !important;
  }

  .show-mobile {
    display: block !important;
  }
}

/* ========================================
   PERFORMANCE OPTIMIZATIONS
   ======================================== */

.btn,
.card,
.navbar-mobile,
.sticky-cta {
  will-change: transform;
  transform: translateZ(0);
}

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