/* Estilos específicos para solucionar problemas de Tailwind CSS en dispositivos móviles */

/* Asegurar que el viewport funcione correctamente */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Mejoras específicas para iOS */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari específico */
    .mobile-safe-area {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    
    /* Eliminar tap highlight en iOS */
    * {
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Mejorar scrolling en iOS */
    .mobile-scroll-smooth {
        -webkit-overflow-scrolling: touch;
    }
}

/* Mejoras específicas para Android */
@supports not (-webkit-touch-callout: none) {
    /* Android específico */
    .mobile-safe-area {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    
    /* Eliminar tap highlight en Android */
    * {
        -webkit-tap-highlight-color: transparent;
    }
}

/* Fallback para clases de Tailwind que puedan no estar funcionando */
.mobile-fallback-bg-blue-500 {
    background-color: #3b82f6 !important;
}

.mobile-fallback-text-white {
    color: white !important;
}

.mobile-fallback-p-4 {
    padding: 1rem !important;
}

.mobile-fallback-rounded-lg {
    border-radius: 0.5rem !important;
}

.mobile-fallback-bg-green-500 {
    background-color: #10b981 !important;
}

.mobile-fallback-bg-red-500 {
    background-color: #ef4444 !important;
}

.mobile-fallback-p-2 {
    padding: 0.5rem !important;
}

.mobile-fallback-text-xs {
    font-size: 0.75rem !important;
    line-height: 1rem !important;
}

/* Mejoras para elementos específicos que pueden tener problemas en móvil */
.mobile-button-fix {
    min-height: 44px; /* Tamaño mínimo recomendado para botones táctiles */
    touch-action: manipulation;
}

.mobile-input-fix {
    font-size: 16px; /* Evita zoom en iOS */
    -webkit-appearance: none;
    border-radius: 0;
}

.mobile-link-fix {
    cursor: pointer;
    touch-action: manipulation;
}

/* Mejoras para grid y flexbox en móvil */
.mobile-grid-fix {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 640px) {
    .mobile-grid-fix {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .mobile-grid-fix {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Mejoras para tipografía en móvil */
.mobile-text-fix {
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Mejoras para imágenes en móvil */
.mobile-image-fix {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Mejoras para formularios en móvil */
.mobile-form-fix input,
.mobile-form-fix textarea,
.mobile-form-fix select {
    font-size: 16px;
    -webkit-appearance: none;
    border-radius: 0;
}

/* Mejoras para navegación en móvil */
.mobile-nav-fix {
    position: sticky;
    top: 0;
    z-index: 50;
    background-color: white;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Mejoras para modales en móvil */
.mobile-modal-fix {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

/* Mejoras para tooltips en móvil */
.mobile-tooltip-fix {
    position: relative;
}

.mobile-tooltip-fix:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #1f2937;
    color: white;
    padding: 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    white-space: nowrap;
    z-index: 1000;
}

/* Mejoras para animaciones en móvil */
@media (prefers-reduced-motion: reduce) {
    .mobile-animation-fix {
        animation: none !important;
        transition: none !important;
    }
}

/* Mejoras para accesibilidad en móvil */
.mobile-accessibility-fix {
    outline: 2px solid transparent;
    outline-offset: 2px;
}

.mobile-accessibility-fix:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Mejoras para rendimiento en móvil */
.mobile-performance-fix {
    will-change: auto;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Mejoras para orientación en móvil */
@media screen and (orientation: landscape) and (max-height: 500px) {
    .mobile-landscape-fix {
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
}

/* Mejoras para pantallas de alta densidad */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .mobile-retina-fix {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}
