/**
 * PROPERTY MODAL - MOBILE SCROLL OPTIMIZATION (CONSERVATIVE VERSION)
 * =================================================================
 * 
 * Versión conservadora que permite scroll móvil sin interferir
 * con la funcionalidad JavaScript del modal
 * 
 * PRINCIPIOS:
 * - Desktop: Sin cambios absolutos
 * - Mobile: Solo ajustes de layout y scroll, sin override de position/overflow críticos
 * - Tablet: Transición suave manteniendo funcionalidad
 */

/* ========================================
   MOBILE LAYOUT OPTIMIZATION (CONSERVATIVE)
   ======================================== */

/* Tablets y pantallas medianas - Scroll completo */
@media (max-width: 1024px) {
    .modal-content {
        max-height: 92vh;
        display: flex;
        flex-direction: column;
    }
    
    .modal-grid {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
    }
    
    .gallery-section {
        height: 50vh;
        min-height: 350px;
        max-height: 50vh;
        flex-shrink: 0;
    }
    
    .property-content {
        height: auto;
        max-height: calc(100vh - 50vh - 3rem);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        flex: 1;
        min-height: 0;
    }
    
    .property-content-scroll {
        padding: 1.5rem;
        height: auto;
        max-height: none;
        padding-bottom: 3rem; /* Espacio extra para scroll completo */
    }
}

/* Móviles - Optimización cuidadosa */
@media (max-width: 768px) {
    .modal-content {
        max-height: 90vh;
        margin: 0.5rem;
    }
    
    .modal-grid {
        grid-template-columns: 1fr;
        height: auto;
        max-height: none;
    }
    
    .gallery-section {
        height: 45vh;
        min-height: 300px;
        max-height: 45vh;
        flex-shrink: 0;
    }
    
    .property-content {
        height: auto;
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .property-content-scroll {
        padding: 1rem;
        height: auto;
        max-height: none;
        overflow: visible;
    }
    
    /* Botón de cerrar ajustado */
    #close-property-modal-btn {
        top: 0.75rem;
        right: 0.75rem;
        width: 2.25rem;
        height: 2.25rem;
    }
}

/* Móviles pequeños - Ajustes mínimos */
@media (max-width: 480px) {
    .modal-content {
        margin: 0.25rem;
        border-radius: 0.75rem;
    }
    
    .gallery-section {
        height: 40vh;
        min-height: 250px;
    }
    
    .property-content-scroll {
        padding: 0.75rem;
    }
    
    #close-property-modal-btn {
        top: 0.5rem;
        right: 0.5rem;
        width: 2rem;
        height: 2rem;
    }
    
    #close-property-modal-btn i {
        font-size: 0.875rem;
    }
}

/* ========================================
   SCROLL BEHAVIOR OPTIMIZATION (SAFE)
   ======================================== */

/* Scroll suave solo en contenido, no en overlay */
@media (max-width: 768px) {
    .property-content {
        scroll-behavior: smooth;
    }
    
    /* Asegurar que las secciones no tengan restricciones */
    .section-card {
        height: auto;
        min-height: auto;
    }
    
    .features-grid,
    .amenities-grid,
    .requirements-chips {
        height: auto;
        min-height: auto;
    }
}

/* ========================================
   TOUCH OPTIMIZATION (CONSERVATIVE)
   ======================================== */

/* Optimizar elementos táctiles sin forzar cambios */
@media (max-width: 768px) {
    .indenant-btn-prev,
    .indenant-btn-next {
        width: 3rem;
        height: 3rem;
        padding: 0.75rem;
    }
    
    .indenant-btn-fullscreen {
        width: 2.5rem;
        height: 2.5rem;
        padding: 0.5rem;
    }
    
    .contact-btn {
        min-height: 44px;
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
    
    .amenity-chip,
    .requirement-chip {
        min-height: 40px;
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
}

@media (max-width: 480px) {
    .indenant-btn-prev,
    .indenant-btn-next {
        width: 2.5rem;
        height: 2.5rem;
        padding: 0.5rem;
    }
    
    .indenant-btn-fullscreen {
        width: 2rem;
        height: 2rem;
        padding: 0.375rem;
    }
}

/* ========================================
   CONTENT SPACING OPTIMIZATION (SAFE)
   ======================================== */

/* Espaciado optimizado sin forzar cambios */
@media (max-width: 768px) {
    .section-card {
        margin-bottom: 1rem;
        padding: 1rem;
    }
    
    .property-title {
        font-size: 1.375rem;
        line-height: 1.3;
        margin-bottom: 0.75rem;
    }
    
    .property-price-display {
        font-size: 1.75rem;
        margin-bottom: 0.5rem;
    }
    
    .features-grid {
        gap: 0.75rem;
        margin-top: 1rem;
    }
    
    .amenities-grid {
        gap: 0.5rem;
        margin-top: 0.75rem;
    }
    
    .requirements-chips {
        gap: 0.5rem;
        margin-top: 0.75rem;
    }
    
    /* Espacio adicional al final */
    .property-content-scroll::after {
        content: '';
        display: block;
        height: 2rem;
    }
}

@media (max-width: 480px) {
    .section-card {
        margin-bottom: 0.75rem;
        padding: 0.75rem;
    }
    
    .property-title {
        font-size: 1.25rem;
    }
    
    .property-price-display {
        font-size: 1.5rem;
    }
    
    .features-grid {
        gap: 0.5rem;
    }
    
    .amenities-grid {
        gap: 0.375rem;
    }
    
    .requirements-chips {
        gap: 0.375rem;
    }
    
    .property-content-scroll::after {
        height: 3rem;
    }
}

/* ========================================
   SCROLLBAR CUSTOMIZATION FOR MOBILE (SAFE)
   ======================================== */

/* Scrollbar personalizada solo para contenido */
@media (max-width: 768px) {
    .property-content::-webkit-scrollbar {
        width: 6px;
    }
    
    .property-content::-webkit-scrollbar-track {
        background: rgba(0, 0, 0, 0.1);
        border-radius: 3px;
    }
    
    .property-content::-webkit-scrollbar-thumb {
        background: linear-gradient(180deg, #FF5733, #FF8A50);
        border-radius: 3px;
        box-shadow: 0 0 4px rgba(255, 135, 80, 0.4);
    }
    
    .property-content::-webkit-scrollbar-thumb:hover {
        background: linear-gradient(135deg, #FF8A50, #FF5733);
        box-shadow: 0 0 6px rgba(255, 87, 51, 0.6);
    }
}

/* ========================================
   JAVASCRIPT COMPATIBILITY
   ======================================== */

/* Mantener compatibilidad con JavaScript sin interferir */
@media (max-width: 768px) {
    /* El body scroll lock se maneja desde JavaScript */
    /* No forzamos cambios que puedan interferir con fetch/API calls */
}

/* ========================================
   PERFORMANCE OPTIMIZATION (CONSERVATIVE)
   ======================================== */

/* Optimizaciones suaves de performance */
@media (max-width: 768px) {
    .property-content {
        will-change: scroll-position;
    }
    
    .gallery-main-image {
        will-change: auto;
    }
    
    /* Transiciones más rápidas en móvil */
    .section-card,
    .amenity-chip,
    .requirement-chip,
    .feature-card {
        transition-duration: 0.2s;
    }
}

/* ========================================
   ACCESSIBILITY IMPROVEMENTS (SAFE)
   ======================================== */

/* Mejoras de accesibilidad sin interferir funcionalidad */
@media (max-width: 768px) {
    .contact-btn:focus,
    #close-property-modal-btn:focus,
    .indenant-btn-prev:focus,
    .indenant-btn-next:focus,
    .indenant-btn-fullscreen:focus {
        outline: 2px solid #FF5733;
        outline-offset: 2px;
    }
    
    .property-title {
        color: #111827;
    }
    
    .section-title {
        color: #1f2937;
    }
}

/* ========================================
   FINAL MOBILE SCROLL SOLUTION
   ======================================== */

/* Solución final: scroll completo hasta requisitos */
@media (max-width: 768px) {
    /* El modal overlay mantiene su funcionalidad original */
    /* Contenido con scroll completo sin restricciones de altura */
    .property-content {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        max-height: calc(100vh - 45vh - 4rem); /* Más espacio disponible */
        flex: 1;
        min-height: 0; /* Permite que flex funcione correctamente */
    }
    
    /* Modal content ajustado para permitir scroll completo */
    .modal-content {
        max-height: 95vh; /* Más altura disponible */
        display: flex;
        flex-direction: column;
    }
    
    /* Modal grid como flex para mejor control */
    .modal-grid {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
    }
    
    /* Gallery con altura fija */
    .gallery-section {
        flex-shrink: 0; /* No se reduce */
    }
    
    /* Asegurar que el contenido sea completamente scrolleable */
    .property-content-scroll {
        min-height: fit-content;
        padding-bottom: 4rem; /* Más espacio al final para asegurar scroll completo */
    }
}

@media (max-width: 480px) {
    .property-content {
        max-height: calc(100vh - 40vh - 3rem); /* Más espacio en móviles pequeños */
    }
    
    .modal-content {
        max-height: 98vh; /* Casi toda la pantalla en móviles pequeños */
    }
    
    .property-content-scroll {
        padding-bottom: 5rem; /* Aún más espacio al final */
    }
}
