/* Modal Styles */
/* Evitar que el body haga scroll cuando el modal está abierto */
body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 1100;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.modal.show {
    opacity: 1;
}

.modal-content {
    position: relative;
    background-color: #fff;
    margin: 80px auto 40px; /* Aumentado el margen superior para el header */
    padding: 40px 30px 30px;
    width: 95%;
    max-width: 900px;
    min-height: 200px;
    max-height: calc(100vh - 120px); /* Reducido para compensar el header */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transform: translateY(-20px);
    transition: transform 0.3s ease-in-out;
    box-sizing: border-box;
    transform-origin: center center;
    transform: scale(0.95);
    opacity: 0;
}

.modal.show .modal-content {
    transform: scale(1);
    opacity: 1;
}

.modal.show .modal-content {
    transform: translateY(0);
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 32px;
    font-weight: bold;
    color: #333;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 1110;
    background: white;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    border: none;
    transform: translateZ(0);
    -webkit-tap-highlight-color: transparent;
}

.modal-close:hover {
    background: #f0f0f0;
    transform: scale(1.1) translateZ(0);
}

.modal-close:hover {
    color: #000;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 25px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    max-height: calc(100vh - 200px);
    padding: 10px 5px 30px 0;
    margin-right: -5px;
    scrollbar-width: thin;
    scrollbar-color: #e67e22 #f0f0f0;
    transform: translateZ(0);
    overscroll-behavior: contain;
}

/* Estilos para la barra de desplazamiento */
.modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb {
    background-color: #e67e22;
    border-radius: 3px;
}

.modal-gallery {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.modal-main-image {
    width: 100%;
    height: 500px;
    overflow: hidden;
    border-radius: 6px;
    background-color: #f5f5f5;
    margin: 0 auto;
    max-width: 100%;
}

.modal-main-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.modal-thumbnails {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 10px 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
    justify-content: center;
    flex-wrap: nowrap;
}

/* Hide scrollbar for Chrome, Safari and Opera */
.modal-thumbnails::-webkit-scrollbar {
    display: none;
}

/* Enable horizontal scroll only when needed on mobile */
@media (max-width: 768px) {
    .modal-thumbnails {
        justify-content: flex-start;
        padding-bottom: 15px;
        margin-bottom: -5px;
    }
}

.modal-thumbnail {
    min-width: 80px;
    height: 60px;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.modal-thumbnail:hover {
    border-color: #007bff;
}

.modal-thumbnail.active {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.5);
}

.modal-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.modal-details {
    flex: 1;
}

.modal-title {
    margin-top: 0;
    color: #333;
    font-size: 24px;
    margin-bottom: 15px;
}

.modal-description {
    color: #666;
    line-height: 1.6;
    margin-bottom: 20px;
}

.modal-specs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.spec-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background-color: #f9f9f9;
    border-radius: 6px;
}

.spec-item i {
    font-size: 20px;
    color: #007bff;
    width: 30px;
    text-align: center;
}

.spec-title {
    display: block;
    font-size: 12px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.spec-value {
    display: block;
    font-weight: 600;
    color: #333;
}

.modal-actions {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

/* Make 'Ver Planos' appear smaller in the modal */
.modal-actions #btnPlans {
    padding: 8px 14px;
    font-size: 13px;
}

.modal-actions #btnPlans i {
    font-size: 14px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn i {
    font-size: 16px;
}

.btn-primary {
    background-color: #007bff;
    color: white;
}

.btn-primary:hover {
    background-color: #0056b3;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

/* Responsive Styles */
@media (min-width: 992px) {
    .modal-body {
        flex-direction: row;
    }
    
    .modal-gallery {
        flex: 1;
    }
    
    .modal-details {
        flex: 1;
        padding-left: 30px;
    }
}

@media (max-width: 991px) {
    .modal-content {
        margin: 20px auto;
        width: 95%;
        max-height: 92vh;
    }
    
    .modal-main-image {
        height: 45vh;
        max-height: 380px;
    }
}

@media (max-width: 768px) {
    .modal {
        padding: 15px;
    }
    
    .modal-content {
        width: 100%;
        margin: 70px auto 20px; /* Ajustado para móviles */
        max-height: calc(100vh - 90px);
        padding: 30px 15px 15px;
        transform: scale(0.9) translateY(10px);
    }
    
    .modal.show .modal-content {
        transform: scale(1) translateY(0);
    }
    
    .modal-close {
        top: 70px; /* Ajustado para móviles */
        right: 15px;
        width: 44px;
        height: 44px;
        font-size: 24px;
        background: rgba(255, 255, 255, 0.95);
    }
    
    .modal-body {
        max-height: calc(100vh - 140px);
        gap: 20px;
    }
    
    /* Hacer el texto más grande en móviles */
    .modal-body p,
    .modal-body li {
        font-size: 1.05em;
        line-height: 1.6;
    }
    
    .modal-main-image {
        height: 40vh;
        max-height: 300px;
    }
    
    .modal-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .btn {
        width: 100%;
    }

    /* Make 'Ver Planos' a lightweight link under the 360 button */
    #btnPlans {
        background: transparent;
        color: #007bff;
        border: none;
        padding: 6px 0;
        width: auto;
        align-self: center;
        font-size: 13px;
    }
    #btnPlans:hover {
        background: transparent;
        color: #0056b3;
        text-decoration: underline;
    }
    #btnPlans i {
        font-size: 14px;
    }

    /* Quote section stacked on mobile */
    .quote-actions {
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }

    .quote-actions input,
    .quote-actions button {
        width: 100%;
    }

    /* Smaller thumbnails on mobile */
    .modal-thumbnails {
        gap: 8px;
    }

    .modal-thumbnail {
        min-width: 64px;
        height: 48px;
    }

    /* Larger tap target for close button */
    .modal-close {
        right: 15px;
        width: 44px;
        height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 24px;
    }
}
