/**
 * INFLAPY - Mobile Optimizations
 * Mejoras UX/UI para dispositivos móviles
 * Mobile-first approach
 */

/* ============================================
   1. HABILITAR TRANSICIONES (override del reset)
   ============================================ */
@media (prefers-reduced-motion: no-preference) {
  a, button, .btn, .nav-link, .product-card, .whatsapp-float {
    transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease !important;
  }
}

/* ============================================
   2. VARIABLES MÓVILES
   ============================================ */
:root {
  --mobile-min-touch: 44px;
  --mobile-padding: 1rem;
  --mobile-font-min: 0.875rem;
}

/* ============================================
   3. MEJORAS GLOBALES MÓVIL
   ============================================ */
@media (max-width: 768px) {
  /* Container padding más compacto */
  .container {
    padding: 0 var(--mobile-padding);
  }

  /* Asegurar que nada se desborde */
  body {
    overflow-x: hidden;
  }

  /* Mejorar legibilidad mínima */
  body {
    font-size: 1rem;
    -webkit-text-size-adjust: 100%;
  }
}

/* ============================================
   4. TOP INFO BAR - MÓVIL
   ============================================ */
@media (max-width: 768px) {
  .top-info-bar {
    padding: 0;
  }

  .top-info-container {
    padding: 8px var(--mobile-padding);
    gap: 8px;
  }

  .top-info-brand {
    font-size: 10px;
    letter-spacing: 0;
  }

  .top-info-item {
    font-size: 11px;
    min-height: var(--mobile-min-touch);
    display: flex;
    align-items: center;
  }

  /* Iconos sociales más grandes para touch */
  .top-info-social {
    width: 36px;
    height: 36px;
  }

  .top-info-social svg {
    width: 18px;
    height: 18px;
  }
}

@media (max-width: 480px) {
  .top-info-brand {
    display: none;
  }

  .top-info-left {
    flex: 1;
    justify-content: flex-start;
  }

  .top-info-right {
    gap: 4px;
  }

  .top-info-social {
    width: 32px;
    height: 32px;
  }
}

/* ============================================
   5. HEADER Y NAVEGACIÓN - MÓVIL
   ============================================ */
@media (max-width: 968px) {
  .nav {
    padding: 0 var(--mobile-padding);
  }

  /* Botón menú más accesible */
  .nav-toggle {
    min-width: var(--mobile-min-touch);
    min-height: var(--mobile-min-touch);
    padding: 8px 12px;
    gap: 8px;
  }

  .nav-toggle-text {
    font-size: 0.75rem;
  }

}

/* ============================================
   6. HERO SECTION - MÓVIL
   ============================================ */
@media (max-width: 968px) {
  .hero {
    padding: 140px var(--mobile-padding) var(--space-2xl);
    min-height: auto;
  }

  .hero-badge {
    font-size: 0.8rem;
    padding: 8px 16px;
    margin-bottom: var(--space-md);
  }

  .hero-title {
    font-size: clamp(1.5rem, 6vw, 2rem);
    margin-bottom: var(--space-md);
    line-height: 1.25;
  }

  .hero-subtitle {
    font-size: 0.95rem;
    margin-bottom: var(--space-lg);
    line-height: 1.6;
  }

  .hero-cta {
    flex-direction: column;
    gap: var(--space-sm);
    width: 100%;
    margin-bottom: var(--space-lg);
  }

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

  .hero-marketing {
    gap: var(--space-md);
  }

  .marketing-text {
    font-size: 0.9rem;
    line-height: 1.6;
  }
}

@media (max-width: 480px) {
  .hero {
    padding: 120px var(--mobile-padding) var(--space-xl);
  }

  .hero-title {
    font-size: 1.4rem;
  }

  .hero-badge {
    font-size: 0.75rem;
    padding: 6px 12px;
  }
}

/* ============================================
   7. BOTONES - MÓVIL (Áreas táctiles)
   ============================================ */
@media (max-width: 768px) {
  .btn {
    min-height: var(--mobile-min-touch);
    padding: 12px 20px;
    font-size: 0.95rem;
  }

  .btn-lg {
    padding: 14px 24px;
    font-size: 1rem;
  }

  .btn-xl {
    padding: 16px 28px;
    font-size: 1.05rem;
  }

  .btn-whatsapp,
  .btn-catalogo,
  .btn-llamar {
    padding: 14px 24px;
    font-size: 1rem;
    letter-spacing: 0.5px;
  }

  .btn-product {
    min-height: var(--mobile-min-touch);
    padding: 12px 16px;
    font-size: 0.9rem;
  }

  .btn-outline-small {
    min-height: 40px;
    padding: 10px 16px;
    font-size: 0.85rem;
  }
}

/* ============================================
   8. STATS BAR - MÓVIL
   ============================================ */
@media (max-width: 768px) {
  .stats-bar {
    padding: var(--space-lg) 0;
  }

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

  .stat-number {
    font-size: 1.75rem;
  }

  .stat-label {
    font-size: 0.8rem;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    gap: var(--space-sm);
  }

  .stat-number {
    font-size: 1.5rem;
  }

  .stat-label {
    font-size: 0.75rem;
  }
}

/* ============================================
   9. SECCIONES - MÓVIL
   ============================================ */
@media (max-width: 768px) {
  .catalogo,
  .como-funciona,
  .testimonios,
  .faq,
  .coverage-section {
    padding: var(--space-2xl) 0;
  }

  .section-header {
    margin-bottom: var(--space-xl);
  }

  .section-badge {
    font-size: 0.8rem;
    padding: 6px 14px;
  }

  .section-title {
    font-size: clamp(1.5rem, 5vw, 2rem);
    line-height: 1.2;
  }

  .section-subtitle {
    font-size: 0.95rem;
  }
}

/* ============================================
   10. PRODUCT CARDS - MÓVIL
   ============================================ */
@media (max-width: 640px) {
  .catalogo-grid {
    gap: var(--space-md);
    max-width: 100%;
  }

  .product-card {
    border-radius: var(--radius-lg);
  }

  .product-image {
    height: 200px;
  }

  .product-content {
    padding: var(--space-md);
  }

  .product-title {
    font-size: 1.1rem;
  }

  .product-description {
    font-size: 0.875rem;
    -webkit-line-clamp: 3;
    min-height: auto;
    margin-bottom: var(--space-sm);
  }

  .product-specs {
    margin-bottom: var(--space-sm);
    padding-top: var(--space-sm);
  }

  .spec-icon {
    font-size: 0.9rem;
  }

  .spec-text {
    font-size: 0.7rem;
  }

  .product-badge {
    font-size: 0.65rem;
    padding: 4px 8px;
  }
}

/* ============================================
   11. STEP CARDS - MÓVIL
   ============================================ */
@media (max-width: 640px) {
  .steps-grid-v2 {
    gap: var(--space-md);
    max-width: 100%;
  }

  .step-image-wrapper {
    height: 180px;
  }

  .step-content-v2 {
    padding: var(--space-md);
  }

  .step-title-v2 {
    font-size: 1.05rem;
  }

  .step-description-v2 {
    font-size: 0.875rem;
  }

  .step-badge {
    font-size: 0.7rem;
    padding: 6px 12px;
  }
}

/* ============================================
   12. INCLUDED SERVICES - MÓVIL
   ============================================ */
@media (max-width: 968px) {
  .included-info {
    padding: var(--space-xl);
    text-align: center;
  }

  .included-title-v3 {
    font-size: 1.4rem;
  }

  .included-description {
    font-size: 0.95rem;
  }

  .included-info .btn-primary {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .included-feature {
    padding: var(--space-md);
    gap: var(--space-sm);
  }

  .feature-number {
    font-size: 1.25rem;
    min-width: 32px;
  }

  .feature-title {
    font-size: 0.95rem;
  }

  .feature-description {
    font-size: 0.8rem;
  }
}

/* ============================================
   13. TESTIMONIALS - MÓVIL
   ============================================ */
@media (max-width: 640px) {
  .testimonios-grid {
    gap: var(--space-md);
    max-width: 100%;
  }

  .testimonio-card {
    padding: var(--space-lg);
  }

  .testimonio-text {
    font-size: 0.9rem;
    -webkit-line-clamp: 5;
  }

  .author-avatar {
    width: 40px;
    height: 40px;
    min-width: 40px;
    font-size: 0.8rem;
  }

  .author-name {
    font-size: 0.85rem;
  }

  .author-event {
    font-size: 0.75rem;
  }
}

/* ============================================
   14. FAQ - MÓVIL
   ============================================ */
@media (max-width: 768px) {
  .faq-grid {
    gap: var(--space-sm);
  }

  .faq-question {
    padding: var(--space-md);
    font-size: 0.95rem;
    min-height: var(--mobile-min-touch);
  }

  .faq-icon {
    font-size: 1.1rem;
  }

  .faq-answer {
    padding: 0 var(--space-md) var(--space-md);
    padding-left: var(--space-md);
    font-size: 0.9rem;
  }
}

/* ============================================
   15. COBERTURA SECTION - MÓVIL
   ============================================ */
@media (max-width: 768px) {
  .cobertura {
    padding: var(--space-2xl) 0;
  }

  .zones-featured-grid {
    gap: var(--space-md);
  }

  .zone-featured-card {
    border-radius: var(--radius-lg);
  }

  .zone-featured-image {
    height: 150px;
  }

  .zone-featured-content {
    padding: var(--space-md);
  }

  .zone-featured-content h3 {
    font-size: 1.1rem;
  }

  .zone-featured-content p {
    font-size: 0.85rem;
  }

  .zone-featured-highlights li {
    font-size: 0.8rem;
  }

  .zone-featured-badge {
    font-size: 0.6rem;
    padding: 4px 8px;
  }

  /* Cobertura cards */
  .cobertura-card {
    padding: var(--space-lg);
  }

  .cobertura-card-header h3 {
    font-size: 1.2rem;
  }

  .alcaldia {
    font-size: 0.8rem;
    padding: 6px 10px;
  }

  /* Logística */
  .logistica-grid,
  .logistica-grid-v2 {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }

  .logistica-card,
  .logistica-card-v2 {
    padding: var(--space-md);
  }

  .logistica-kpi,
  .logistica-kpi-v2 {
    font-size: 1.25rem;
  }
}

/* ============================================
   16. CTA FINAL - MÓVIL
   ============================================ */
@media (max-width: 768px) {
  .cta-final {
    padding: var(--space-2xl) 0;
  }

  .cta-confetti {
    font-size: 2.5rem;
  }

  .cta-title {
    font-size: clamp(1.5rem, 6vw, 2rem);
    line-height: 1.2;
  }

  .cta-subtitle {
    font-size: 1rem;
    margin-bottom: var(--space-lg);
  }

  .cta-buttons {
    flex-direction: column;
    width: 100%;
    gap: var(--space-sm);
  }

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

  .cta-contact-info {
    flex-direction: column;
    gap: var(--space-md);
  }

  .contact-item {
    font-size: 0.9rem;
  }
}

/* ============================================
   17. FOOTER - MÓVIL
   ============================================ */
@media (max-width: 768px) {
  .footer-main {
    padding: var(--space-2xl) 0;
  }

  .footer-grid {
    gap: var(--space-xl);
  }

  .footer-col--brand {
    text-align: center;
    padding-right: 0;
  }

  .footer-logo {
    display: inline-block;
  }

  .footer-logo-img {
    height: 80px;
    margin: 0 auto;
  }

  .footer-description {
    font-size: 0.85rem;
  }

  .footer-phone {
    font-size: 1.25rem;
  }

  .footer-social {
    justify-content: center;
  }

  .footer-title {
    font-size: 0.9rem;
    margin-bottom: var(--space-md);
  }

  .footer-links li a {
    font-size: 0.85rem;
    display: inline-block;
    padding: 4px 0;
    min-height: 32px;
    line-height: 24px;
  }

  /* Alcaldías grid más legible */
  .footer-links--alcaldias {
    grid-template-columns: 1fr 1fr;
    gap: 4px var(--space-sm);
  }

  .footer-links--alcaldias li a {
    font-size: 0.75rem;
    white-space: normal;
  }
}

@media (max-width: 480px) {
  .footer-grid {
    text-align: center;
  }

  .footer-col {
    align-items: center;
  }

  .footer-links {
    align-items: center;
  }

  .footer-links--alcaldias {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .footer-bottom-inner {
    gap: var(--space-md);
  }

  .footer-legal {
    flex-direction: column;
    gap: var(--space-sm);
  }

  .footer-payment {
    flex-wrap: wrap;
    justify-content: center;
  }
}

/* ============================================
   18. WHATSAPP FLOAT - MÓVIL
   ============================================ */
@media (max-width: 768px) {
  .whatsapp-float {
    bottom: 16px;
    right: 16px;
    width: 56px;
    height: 56px;
  }

  .whatsapp-float-icon {
    width: 28px;
    height: 28px;
  }

  .whatsapp-float-tooltip {
    display: none;
  }

  .whatsapp-float-badge {
    width: 20px;
    height: 20px;
    font-size: 10px;
  }
}

/* ============================================
   19. BREADCRUMB - MÓVIL
   ============================================ */
@media (max-width: 768px) {
  .breadcrumb {
    margin-top: 112px; /* header height + top-bar */
    padding: var(--space-sm) 0;
  }

  .breadcrumb-list {
    font-size: 0.8rem;
    gap: 4px;
  }

  .breadcrumb-list a,
  .breadcrumb-list .current {
    padding: 4px 0;
  }
}

@media (max-width: 480px) {
  .breadcrumb {
    margin-top: 100px;
  }

  .breadcrumb-list {
    font-size: 0.75rem;
  }
}

/* ============================================
   20. SERVICIOS ZONA - MÓVIL
   ============================================ */
@media (max-width: 640px) {
  .servicios-zona-grid {
    gap: var(--space-md);
    max-width: 100%;
  }

  .servicio-zona-card {
    border-radius: var(--radius-lg);
  }

  .servicio-zona-image {
    height: 160px;
  }

  .servicio-zona-content {
    padding: var(--space-md);
  }

  .servicio-zona-content h3 {
    font-size: 1.05rem;
  }

  .servicio-zona-content p {
    font-size: 0.85rem;
  }

  .servicio-zona-features li {
    font-size: 0.8rem;
  }
}

/* ============================================
   21. ACCESIBILIDAD MÓVIL
   ============================================ */
@media (max-width: 768px) {
  /* Focus visible mejorado */
  a:focus-visible,
  button:focus-visible,
  .btn:focus-visible {
    outline: 3px solid var(--color-primary);
    outline-offset: 2px;
  }

  /* Espaciado entre elementos interactivos */
  .nav-menu > li + li {
    margin-top: 2px;
  }

  /* Prevenir zoom en inputs en iOS */
  input, select, textarea {
    font-size: 16px;
  }
}

/* ============================================
   22. SAFE AREAS (iPhone X+)
   ============================================ */
@supports (padding: env(safe-area-inset-bottom)) {
  .nav-menu {
    padding-bottom: calc(var(--space-xl) + env(safe-area-inset-bottom));
  }

  .footer-bottom {
    padding-bottom: calc(var(--space-lg) + env(safe-area-inset-bottom));
  }

  .whatsapp-float {
    bottom: calc(16px + env(safe-area-inset-bottom));
  }
}

/* ============================================
   23. LANDSCAPE MÓVIL
   ============================================ */
@media (max-width: 968px) and (orientation: landscape) {
  .hero {
    min-height: auto;
    padding: 100px var(--mobile-padding) var(--space-xl);
  }

  .nav-menu {
    padding-top: var(--space-sm);
    padding-bottom: var(--space-sm);
  }

  .nav-link {
    padding: 10px var(--mobile-padding);
  }
}

/* ============================================
   24. PRINT STYLES
   ============================================ */
@media print {
  .top-info-bar,
  .nav-toggle,
  .whatsapp-float,
  .cta-final {
    display: none !important;
  }

  .header {
    position: static;
  }

  body {
    font-size: 12pt;
  }
}

/* ============================================
   25. MEJORAS DE RENDIMIENTO
   ============================================ */

/* Prevenir scroll bouncing en iOS */
html {
  overscroll-behavior: none;
}

/* Optimizar repaint en elementos fijos */
.header,
.whatsapp-float,
.sidebar-toggle {
  will-change: transform;
  contain: layout style;
}

/* Touch action para elementos scrollables */
.nav-menu,
.catalog-sidebar {
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

/* Mejorar scroll en listas largas */
.footer-links--alcaldias {
  contain: content;
}

/* ============================================
   26. CORRECCIONES DE TOUCH TARGETS
   ============================================ */
@media (max-width: 768px) {
  /* Filtros de catalogo */
  .filter-checkbox input {
    width: 24px;
    height: 24px;
  }

  .filter-checkbox {
    min-height: 44px;
    padding: 8px 0;
  }

  /* Botones de filtro */
  .filter-btn {
    min-height: 48px;
    padding: 12px 16px;
  }

  /* Links del footer */
  .footer-links li a {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  /* Range slider */
  input[type="range"] {
    height: 44px;
  }

  input[type="range"]::-webkit-slider-thumb {
    width: 28px;
    height: 28px;
  }
}

/* ============================================
   27. MEJORAS DE FORMULARIOS MOVIL
   ============================================ */
@media (max-width: 768px) {
  .form-input,
  .form-select,
  .form-textarea {
    min-height: 48px;
    font-size: 16px;
    padding: 12px 16px;
  }

  .form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
    -webkit-appearance: none;
    appearance: none;
  }

  .form-checkbox {
    width: 24px;
    height: 24px;
  }

  /* Estados de validacion */
  .form-input:invalid:not(:placeholder-shown),
  .form-select:invalid:not(:placeholder-shown) {
    border-color: #e53935;
  }

  .form-input:valid:not(:placeholder-shown),
  .form-select:valid:not(:placeholder-shown) {
    border-color: #43a047;
  }
}

/* ============================================
   28. CATALOG MOBILE FIXES
   ============================================ */
@media (max-width: 1024px) {
  .sidebar-toggle {
    bottom: 24px;
    padding: 14px 24px;
    font-size: 0.95rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  }

  .catalog-sidebar {
    overscroll-behavior: contain;
  }

  .sidebar-overlay {
    backdrop-filter: blur(2px);
    transition: opacity 0.2s ease !important;
  }

  .catalog-card-actions {
    gap: 8px;
  }

  .catalog-card-btn {
    min-height: 48px;
    font-size: 0.95rem;
  }
}

/* ============================================
   29. CONTACTO PAGE MOBILE
   ============================================ */
@media (max-width: 768px) {
  .contact-methods-grid {
    gap: var(--space-md);
  }

  .contact-method-card {
    border-radius: var(--radius-lg);
  }

  .contact-method-image {
    height: 120px;
  }

  .contact-method-icon {
    font-size: 3rem;
  }

  .contact-method-btn {
    min-height: 44px;
    padding: 12px 20px;
  }

  .contact-info-content {
    padding: var(--space-xl);
  }

  .map-container {
    min-height: 300px;
    border-radius: var(--radius-lg);
  }

  .horarios-grid {
    gap: 8px;
  }

  .horario-item {
    padding: 10px 12px;
    font-size: 0.85rem;
  }
}

/* ============================================
   30. HERO INTERNO MOBILE FIXES
   ============================================ */
@media (max-width: 768px) {
  .hero-interno {
    padding: var(--space-xl) var(--mobile-padding);
  }

  .hero-interno .hero-badge {
    font-size: 0.75rem;
    padding: 6px 12px;
    margin-bottom: var(--space-sm);
  }

  .hero-interno .hero-title {
    font-size: 1.5rem;
    margin-bottom: var(--space-sm);
  }

  .hero-interno .hero-subtitle {
    font-size: 0.9rem;
    margin-bottom: var(--space-md);
  }

  .hero-interno .marketing-card {
    padding: var(--space-sm) 0;
  }

  .hero-interno .marketing-text {
    font-size: 0.85rem;
  }
}

/* ============================================
   31. BLOG CARDS MOBILE
   ============================================ */
@media (max-width: 640px) {
  .blog-grid {
    gap: var(--space-md);
  }

  .blog-card {
    border-radius: var(--radius-lg);
  }

  .blog-card-image {
    height: 180px;
  }

  .blog-card-content {
    padding: var(--space-md);
  }

  .blog-card-title {
    font-size: 1.1rem;
  }

  .blog-card-excerpt {
    font-size: 0.85rem;
    -webkit-line-clamp: 2;
  }
}

/* ============================================
   32. SMOOTH SCROLL CONTROLADO
   ============================================ */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* ============================================
   33. MEJORAS ADICIONALES DE ACCESIBILIDAD
   ============================================ */

/* Skip link para accesibilidad */
.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-primary);
  color: white;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  z-index: 10000;
  text-decoration: none;
  font-weight: 600;
}

.skip-link:focus {
  top: 10px;
}

/* Focus trap visual */
.nav-menu.active {
  outline: 2px solid transparent;
}

/* Mejor contraste en estados hover */
@media (hover: hover) {
  .btn:hover,
  .nav-link:hover,
  .product-card:hover {
    outline: none;
  }
}

/* ============================================
   34. OPTIMIZACIONES PARA PANTALLAS PEQUEÑAS
   ============================================ */
@media (max-width: 360px) {
  :root {
    --mobile-padding: 0.75rem;
  }

  .hero-title {
    font-size: 1.25rem;
  }

  .btn-whatsapp,
  .btn-catalogo {
    padding: 12px 16px;
    font-size: 0.9rem;
  }

  .product-card {
    border-radius: var(--radius-md);
  }

  .footer-phone {
    font-size: 1.1rem;
  }
}

/* ============================================
   35. LOADING STATES
   ============================================ */
.loading {
  position: relative;
  pointer-events: none;
}

.loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Skeleton loading para imagenes */
.img-skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
