/* Estilos para el modal de imágenes */
.image-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
}

.image-modal.active {
    display: flex;
    animation: fadeIn 0.3s ease-out;
}

.image-modal-content {
    position: relative;
    margin: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.modal-image-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 85vw;
    height: 70vh;
    max-width: 1200px;
    max-height: 800px;
    min-width: 300px;
    min-height: 200px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* Hybrid approach - different behavior based on image characteristics */
#modalImage {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    border-radius: 12px;
    transition: transform 0.3s ease-out;
    background: var(--white-pure);
    cursor: pointer;
}

/* For property images that are typically landscape, use contain on larger screens */
@media (min-width: 769px) {
    #modalImage.property-landscape {
        object-fit: contain;
    }
}

/* Use contain on mobile as well for consistency */
@media (max-width: 768px) {
    #modalImage {
        object-fit: contain;
    }
}

/* Alternative image fit option - uncomment if you prefer cropped images */
/*
#modalImage.cover-fit {
    object-fit: cover;
}
*/

/* Hover effect for modal image */
#modalImage:hover {
    transform: scale(1.02);
}

/* Loading state for images */
#modalImage[src=""], #modalImage:not([src]) {
    background: linear-gradient(45deg, #f0f0f0 25%, #e0e0e0 25%, #e0e0e0 50%, #f0f0f0 50%, #f0f0f0 75%, #e0e0e0 75%);
    background-size: 20px 20px;
    animation: loading-stripes 1s linear infinite;
    position: relative;
}

#modalImage[src=""]:before, #modalImage:not([src]):before {
    content: "Cargando imagen...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--gray-charcoal);
    font-size: 1.2rem;
    font-weight: 500;
    text-align: center;
    z-index: 1;
}

@keyframes loading-stripes {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 20px 0;
    }
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    color: var(--white-pure);
    font-size: 2rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    transition: all 0.3s ease;
    z-index: 10;
}

.close-modal:hover {
    background: var(--gold-primary);
    transform: rotate(90deg);
}

.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: var(--navy-primary);
    border: none;
    color: var(--white-pure);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: all 0.3s ease;
}

.modal-nav:hover {
    background: var(--gold-primary);
    transform: translateY(-50%) scale(1.1);
}

.modal-nav.prev {
    left: 20px;
}

.modal-nav.next {
    right: 20px;
}

.modal-open-new-tab {
    position: absolute;
    top: 20px;
    right: 70px;
    background: var(--navy-primary);
    border: none;
    color: var(--white-pure);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.3s ease;
    z-index: 10;
}

.modal-open-new-tab:hover {
    background: var(--gold-primary);
    transform: scale(1.1);
}

.modal-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--white-pure);
    font-size: 1.1rem;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 600;
    z-index: 10;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Responsive styles */
@media (max-width: 1024px) {
    
    .modal-image-container {
        width: 90vw;
        height: 70vh;
        max-width: 900px;
        max-height: 650px;
        min-width: 280px;
        min-height: 200px;
    }
}

@media (max-width: 768px) {

    .modal-image-container {
        width: 95vw;
        height: 75vh;
        max-width: 100%;
        max-height: 600px;
        min-width: 260px;
        min-height: 180px;
        border-radius: 8px;
    }
    
    #modalImage {
        border-radius: 8px;
    }
    
    .modal-nav {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }

    .close-modal {
        top: 15px;
        right: 15px;
        width: 35px;
        height: 35px;
        font-size: 1.5rem;
    }

    .modal-open-new-tab {
        top: 15px;
        right: 60px;
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }

    .modal-counter {
        font-size: 1rem;
        padding: 6px 16px;
        bottom: 15px;
    }
}

@media (max-width: 480px) {
    
    .modal-image-container {
        width: 98vw;
        height: 70vh;
        max-height: 500px;
        min-width: 240px;
        min-height: 160px;
        border-radius: 6px;
    }
    
    #modalImage {
        border-radius: 6px;
    }
    
    .modal-nav {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }

    .modal-nav.prev {
        left: 10px;
    }

    .modal-nav.next {
        right: 10px;
    }

    .close-modal {
        top: 10px;
        right: 10px;
        width: 30px;
        height: 30px;
        font-size: 1.2rem;
    }

    .modal-open-new-tab {
        top: 10px;
        right: 50px;
        width: 30px;
        height: 30px;
        font-size: 0.9rem;
    }

    .modal-counter {
        bottom: 10px;
        font-size: 0.9rem;
        padding: 5px 15px;
    }
}

@media (max-width: 360px) {
    
    .modal-image-container {
        width: 100vw;
        height: 65vh;
        max-height: 400px;
        min-width: 200px;
        min-height: 140px;
        border-radius: 0;
        margin: 0;
    }
    
    #modalImage {
        border-radius: 0;
    }
    
    .modal-nav {
        width: 30px;
        height: 30px;
        font-size: 0.9rem;
    }

    .modal-nav.prev {
        left: 5px;
    }

    .modal-nav.next {
        right: 5px;
    }

    .close-modal {
        top: 5px;
        right: 5px;
        width: 28px;
        height: 28px;
        font-size: 1.1rem;
    }

    .modal-open-new-tab {
        top: 5px;
        right: 40px;
        width: 28px;
        height: 28px;
        font-size: 0.8rem;
    }

    .modal-counter {
        bottom: 5px;
        font-size: 0.8rem;
        padding: 4px 12px;
    }
}

/* Ultra small screens (320px and below) */
@media (max-width: 320px) {

    .modal-image-container {
        width: 100vw;
        height: 45vh;
        max-height: 250px;
        min-width: 180px;
        min-height: 100px;
        border-radius: 0;
        margin: 0;
    }
    
    #modalImage {
        border-radius: 0;
    }
    
    .modal-nav {
        width: 28px;
        height: 28px;
        font-size: 0.8rem;
    }

    .modal-nav.prev {
        left: 3px;
    }

    .modal-nav.next {
        right: 3px;
    }

    .close-modal {
        top: 3px;
        right: 3px;
        width: 26px;
        height: 26px;
        font-size: 1rem;
    }

    .modal-open-new-tab {
        top: 3px;
        right: 35px;
        width: 26px;
        height: 26px;
        font-size: 0.7rem;
    }

    .modal-counter {
        bottom: 3px;
        font-size: 0.75rem;
        padding: 3px 10px;
    }
}

/* Very ultra small screens (280px and below) */
@media (max-width: 280px) {
    
    .modal-image-container {
        width: 100vw;
        height: 40vh;
        max-height: 200px;
        min-width: 160px;
        min-height: 90px;
        border-radius: 0;
        margin: 0;
    }
    
    .modal-nav {
        width: 26px;
        height: 26px;
        font-size: 0.7rem;
    }

    .modal-nav.prev {
        left: 2px;
    }

    .modal-nav.next {
        right: 2px;
    }

    .close-modal {
        top: 2px;
        right: 2px;
        width: 24px;
        height: 24px;
        font-size: 0.9rem;
    }

    .modal-open-new-tab {
        top: 2px;
        right: 30px;
        width: 24px;
        height: 24px;
        font-size: 0.65rem;
    }

    .modal-counter {
        bottom: 2px;
        font-size: 0.7rem;
        padding: 2px 8px;
    }
}

/* Extreme ultra small screens (260px and below) */
@media (max-width: 260px) {
    
    .modal-image-container {
        width: 100vw;
        height: 35vh;
        max-height: 180px;
        min-width: 140px;
        min-height: 80px;
        border-radius: 0;
        margin: 0;
    }
    
    .modal-nav {
        width: 24px;
        height: 24px;
        font-size: 0.65rem;
    }

    .modal-nav.prev {
        left: 1px;
    }

    .modal-nav.next {
        right: 1px;
    }

    .close-modal {
        top: 1px;
        right: 1px;
        width: 22px;
        height: 22px;
        font-size: 0.8rem;
    }

    .modal-open-new-tab {
        top: 1px;
        right: 27px;
        width: 22px;
        height: 22px;
        font-size: 0.6rem;
    }

    .modal-counter {
        bottom: 1px;
        font-size: 0.65rem;
        padding: 2px 6px;
    }
}

/* Special cases for very tall ultra small screens */
@media (max-width: 320px) and (min-height: 600px) {
    .modal-image-container {
        height: 50vh;
        max-height: 350px;
    }
}

@media (max-width: 280px) and (min-height: 500px) {
    .modal-image-container {
        height: 45vh;
        max-height: 300px;
    }
}

@media (max-width: 260px) and (min-height: 450px) {
    .modal-image-container {
        height: 40vh;
        max-height: 250px;
    }
} 

.modal-nav,
.close-modal,
.modal-open-new-tab {
    touch-action: manipulation;
} 