/* ===============================================
   ATTON FINANCE - MOBILE & TABLET FIXES
   Soluciones específicas para problemas responsive
   =============================================== */

/* =================================
   FIXES GENERALES PARA MÓVIL
   ================================= */

/* Prevenir scroll horizontal en móvil */
html, body {
  overflow-x: hidden;
  max-width: 100%;
}

/* Fix para iOS Safari - Viewport height */
@supports (-webkit-touch-callout: none) {
  .min-h-screen {
    min-height: -webkit-fill-available;
  }
}

/* Prevenir zoom en inputs en iOS */
@media (max-width: 767px) {
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  textarea,
  select {
    font-size: 16px !important;
  }
}

/* =================================
   NAVEGACIÓN MÓVIL MEJORADA
   ================================= */
@media (max-width: 1023px) {
  /* Ajustar altura del header en móvil */
  nav.fixed {
    height: 60px;
  }

  /* Logo más pequeño en móvil */
  nav img {
    height: 28px !important;
    width: auto;
  }

  /* Menú móvil overlay mejorado */
  .mobile-menu {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(5, 11, 20, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 9998;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1.5rem;
  }

  /* Items del menú móvil más grandes */
  .mobile-menu a {
    display: block;
    padding: 1rem;
    font-size: 1.125rem;
    border-radius: 0.5rem;
    transition: all 0.3s ease;
  }

  .mobile-menu a:active {
    background: rgba(255, 255, 255, 0.1);
  }

  /* Hamburger button más accesible */
  button[aria-label*="menu"],
  .hamburger-button {
    min-width: 44px;
    min-height: 44px;
    padding: 0.5rem;
  }
}

/* =================================
   HERO SECTION RESPONSIVE
   ================================= */
@media (max-width: 767px) {
  /* Hero en móvil */
  .hero,
  .eval-hero,
  section.hero {
    min-height: 100vh;
    padding: 4rem 1rem 2rem;
  }

  /* Títulos hero más pequeños */
  .hero h1,
  .eval-hero h1 {
    font-size: clamp(1.75rem, 8vw, 2.5rem) !important;
    line-height: 1.2;
    margin-bottom: 1rem;
  }

  /* Subtítulos hero */
  .hero p,
  .eval-hero p {
    font-size: clamp(1rem, 4vw, 1.125rem) !important;
    line-height: 1.6;
  }

  /* Botones CTA en móvil */
  .hero .btn,
  .hero button,
  .cta-buttons {
    width: 100%;
    margin-bottom: 1rem;
  }

  /* Stack vertical para CTAs */
  .cta-buttons,
  .hero-buttons {
    flex-direction: column !important;
    gap: 1rem;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  /* Hero en tablet */
  .hero,
  .eval-hero {
    min-height: 80vh;
    padding: 5rem 2rem 3rem;
  }

  .hero h1 {
    font-size: clamp(2rem, 6vw, 3rem) !important;
  }
}

/* =================================
   CARDS Y GRIDS RESPONSIVE
   ================================= */
@media (max-width: 639px) {
  /* Grids a 1 columna en móvil pequeño */
  .grid,
  .service-grid,
  .features-grid,
  .card-grid {
    grid-template-columns: 1fr !important;
    gap: 1rem;
  }

  /* Cards con menos padding */
  .card,
  .service-card,
  .feature-card {
    padding: 1rem !important;
  }
}

@media (min-width: 640px) and (max-width: 767px) {
  /* Grids a 2 columnas en móvil grande */
  .grid--services,
  .service-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  /* Grids optimizados para tablet */
  .grid--services {
    grid-template-columns: repeat(3, 1fr) !important;
  }

  .features-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* =================================
   FORMULARIOS GHL RESPONSIVE
   ================================= */
@media (max-width: 767px) {
  /* iFrames de formularios GHL */
  iframe[src*="gohighlevel"],
  iframe[src*="forms.app"],
  .ghl-form-container iframe {
    width: 100% !important;
    min-height: 600px !important;
    border-radius: 0 !important;
  }

  /* Contenedor del formulario */
  .form-container,
  .ghl-form-container {
    padding: 0 !important;
    margin: 0 -1rem !important;
    width: calc(100% + 2rem) !important;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  iframe[src*="gohighlevel"] {
    max-width: 100%;
    width: 100% !important;
  }
}

/* =================================
   SECCIONES Y CONTENIDO
   ================================= */
@media (max-width: 767px) {
  /* Secciones con menos padding */
  section {
    padding: 3rem 1rem !important;
  }

  /* Contenedores más estrechos */
  .container,
  .max-w-7xl {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  /* Títulos de sección más pequeños */
  h2 {
    font-size: clamp(1.5rem, 6vw, 2rem) !important;
  }

  h3 {
    font-size: clamp(1.25rem, 5vw, 1.5rem) !important;
  }

  /* Párrafos con mejor legibilidad */
  p {
    font-size: 1rem;
    line-height: 1.7;
  }
}

/* =================================
   FOOTER RESPONSIVE
   ================================= */
@media (max-width: 767px) {
  footer {
    padding: 2rem 1rem !important;
  }

  /* Footer grid a 1 columna */
  footer .grid,
  .footer-grid {
    grid-template-columns: 1fr !important;
    gap: 2rem;
    text-align: center;
  }

  /* Logo centrado */
  footer .logo {
    margin: 0 auto 1rem;
  }

  /* Links del footer */
  footer a {
    display: block;
    padding: 0.5rem;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  footer .grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* =================================
   IMÁGENES RESPONSIVE
   ================================= */
@media (max-width: 767px) {
  /* Imágenes hero más pequeñas */
  .hero-image,
  .feature-image {
    max-width: 100%;
    height: auto;
    margin: 2rem 0;
  }

  /* Imágenes de fondo ajustadas */
  .bg-image {
    background-size: cover !important;
    background-position: center !important;
  }
}

/* =================================
   BOTONES Y CTAs
   ================================= */
@media (max-width: 767px) {
  /* Botones full width en móvil */
  .btn,
  button:not(.hamburger-menu),
  a.button {
    width: 100% !important;
    padding: 1rem !important;
    font-size: 1rem !important;
    min-height: 48px;
  }

  /* Grupo de botones vertical */
  .button-group {
    flex-direction: column !important;
    gap: 1rem;
  }
}

/* =================================
   MODALES Y OVERLAYS
   ================================= */
@media (max-width: 767px) {
  /* Modales full screen en móvil */
  .modal,
  .overlay-content {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    margin: 0 !important;
  }

  .modal-content {
    padding: 1.5rem !important;
    max-height: 100vh;
    overflow-y: auto;
  }
}

/* =================================
   TABLAS RESPONSIVE
   ================================= */
@media (max-width: 767px) {
  /* Convertir tablas en cards */
  table {
    display: block;
    border: none;
  }

  thead {
    display: none;
  }

  tbody {
    display: block;
  }

  tr {
    display: block;
    margin-bottom: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 0.5rem;
    padding: 1rem;
  }

  td {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }

  td:last-child {
    border-bottom: none;
  }

  td::before {
    content: attr(data-label);
    font-weight: 600;
    margin-right: 1rem;
  }
}

/* =================================
   UTILIDADES ESPECÍFICAS MÓVIL
   ================================= */
@media (max-width: 767px) {
  /* Ocultar elementos decorativos */
  .decoration,
  .floating-element,
  .aurora-orb {
    display: none !important;
  }

  /* Simplificar animaciones */
  * {
    animation-duration: 0.5s !important;
  }

  /* Desactivar parallax en móvil */
  .parallax {
    background-attachment: scroll !important;
  }

  /* Espaciado vertical reducido */
  .space-y-8 {
    gap: 1.5rem !important;
  }

  .space-y-12 {
    gap: 2rem !important;
  }

  /* Márgenes laterales consistentes */
  .mx-auto {
    margin-left: 1rem !important;
    margin-right: 1rem !important;
  }
}

/* =================================
   TABLET ESPECÍFICO
   ================================= */
@media (min-width: 768px) and (max-width: 1023px) {
  /* Contenedor optimizado para tablet */
  .container {
    max-width: 720px;
    padding-left: 2rem;
    padding-right: 2rem;
  }

  /* Grid de 2 columnas por defecto */
  .grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }

  /* Navegación híbrida */
  nav {
    padding: 1rem 2rem;
  }
}

/* =================================
   WHATSAPP BUTTON MÓVIL
   ================================= */
@media (max-width: 767px) {
  .whatsapp-float,
  .whatsapp-button {
    bottom: 20px !important;
    right: 15px !important;
    width: 50px !important;
    height: 50px !important;
  }

  .whatsapp-float svg {
    width: 24px !important;
    height: 24px !important;
  }
}

/* =================================
   ACCESIBILIDAD MÓVIL
   ================================= */
@media (max-width: 767px) {
  /* Focus visible mejorado */
  *:focus {
    outline: 3px solid var(--color-secondary);
    outline-offset: 2px;
  }

  /* Skip to content visible */
  .skip-to-content {
    position: absolute;
    top: -100px;
    left: 0;
    background: var(--color-primary);
    color: white;
    padding: 0.5rem 1rem;
    z-index: 10000;
  }

  .skip-to-content:focus {
    top: 0;
  }
}

/* =================================
   PERFORMANCE OPTIMIZATIONS
   ================================= */
@media (max-width: 767px) {
  /* Reducir sombras complejas */
  .shadow-xl,
  .shadow-2xl {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
  }

  /* Simplificar gradientes */
  .gradient-complex {
    background: var(--color-primary) !important;
  }

  /* Desactivar filtros pesados */
  .blur-heavy {
    backdrop-filter: none !important;
    background: rgba(5, 11, 20, 0.95) !important;
  }
}

/* =================================
   FIXES PARA DISPOSITIVOS ESPECÍFICOS
   ================================= */

/* iPhone X y superiores - Safe areas */
@supports (padding: max(0px)) {
  .safe-area-inset {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }
}

/* Samsung Galaxy - Fix para teclado */
@media (max-width: 767px) {
  input:focus,
  textarea:focus {
    position: relative;
    z-index: 1;
  }
}

/* iPad Pro - Optimizaciones landscape */
@media only screen
  and (min-width: 1024px)
  and (max-width: 1366px)
  and (orientation: landscape) {
  .container {
    max-width: 960px;
  }
}