/* Modal Styles */
.modal {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0, 0, 0, 0.8); /* Black w/ opacity */
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: var(--white);
    margin: 5% auto;
    padding: 40px;
    border: 1px solid #888;
    width: 90%;
    max-width: 1200px;
    border-radius: 12px;
    position: relative;
    box-shadow: 0 5px 30px rgba(0,0,0,0.3);
    animation: modalFadeIn 0.4s;
}

@keyframes modalFadeIn {
    from {opacity: 0; transform: translateY(-50px);}
    to {opacity: 1; transform: translateY(0);}
}

.close-modal {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    top: 20px;
    right: 30px;
    cursor: pointer;
    transition: color 0.3s;
    z-index: 10;
}

.close-modal:hover,
.close-modal:focus {
    color: var(--primary-color);
    text-decoration: none;
    cursor: pointer;
}

.modal-header {
    margin-bottom: 30px;
    border-bottom: 1px solid #eee;
    padding-bottom: 20px;
}

.modal-header h2 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.modal-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 10px;
    margin-bottom: 40px;
}

.modal-gallery img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 4px;
    transition: transform 0.3s, opacity 0.3s;
    cursor: pointer;
    opacity: 0.9;
}

.modal-gallery img:hover {
    transform: scale(1.05);
    opacity: 1;
}

/* Rimosso stile speciale per main-photo per avere una griglia uniforme */
.modal-gallery img.main-photo {
    grid-column: auto;
}

/* Lightbox Styles */
#lightbox {
    display: none;
    position: fixed;
    z-index: 3000;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

#lightbox img {
    max-width: 85%;
    max-height: 85vh;
    border: 2px solid #fff;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
    z-index: 3001;
}

.lightbox-controls {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-top: 20px;
}

.lightbox-nav {
    color: rgba(255, 255, 255, 0.7);
    font-size: 40px;
    cursor: pointer;
    user-select: none;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.lightbox-nav:hover {
    color: #fff;
    border-color: #fff;
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

.lightbox-prev, .lightbox-next {
    /* Reset specific positioning */
    position: static; 
}

.lightbox-caption {
    margin-top: 15px;
    color: #fff;
    font-family: var(--font-body);
    font-size: 1.1rem;
    text-align: center;
}

.modal-body {
    display: flex;
    flex-wrap: wrap;
    gap: 40px;
}

.modal-description {
    flex: 2;
    min-width: 300px;
}

.modal-description h3 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: var(--primary-color);
}

.modal-description p {
    font-family: var(--font-body);
    font-size: 1rem;
    color: #555;
    margin-bottom: 20px;
    line-height: 1.8;
}

.modal-features {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2 colonne */
    gap: 20px;
    background: #f9f9f9;
    padding: 30px;
    border-radius: 8px;
    margin-bottom: 30px;
}

.modal-feature-item {
    display: flex;
    align-items: center;
    gap: 15px;
    text-align: left;
    min-width: 0;
    margin-bottom: 0;
}

.modal-feature-item i {
    font-size: 1.1rem;
    color: var(--primary-color);
    background-color: #ffffff;
    width: 40px;
    height: 40px;
    min-width: 40px; /* Previene schiacciamento */
    line-height: 40px;
    border-radius: 50%;
    display: block;
    margin: 0; /* Reset margin */
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.modal-feature-text {
    display: flex;
    flex-direction: column;
}

.modal-feature-item span.value {
    display: block;
    font-weight: 600;
    font-size: 1rem;
    color: var(--primary-color);
    line-height: 1.2;
}

.modal-feature-item span.label {
    display: block;
    font-size: 0.85rem;
    color: var(--secondary-color);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.modal-location {
    flex: 1;
    min-width: 300px;
}

.modal-location h3 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: var(--primary-color);
}

.address-box {
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 15px;
}

.address-box i {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-top: 5px;
}

.address-box p {
    font-size: 1.1rem;
    color: var(--text-color);
}

.modal-map {
    width: 100%;
    height: 300px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #eee;
}

/* Modifiche per rendere la card cliccabile */
.struttura-card {
    cursor: pointer;
}

/* Contact Boxes below Map */
.modal-contact-boxes {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}

.contact-box {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background-color: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-color);
    transition: all 0.3s ease;
}

.contact-box:hover {
    background-color: var(--white);
    border-color: var(--primary-color);
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    transform: translateY(-2px);
}

.contact-box i {
    font-size: 1.5rem;
    color: var(--primary-color);
    min-width: 30px;
    text-align: center;
}

.contact-box span {
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 500;
}

/* Address specific style in contact box (non-clickable) */
.contact-box.address {
    cursor: default;
}
.contact-box.address:hover {
    transform: none;
    box-shadow: none;
    border-color: #eee;
    background-color: #f9f9f9;
}

/* Mobile Responsive for Modal */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 10% auto; /* More margin top for safe area */
        padding: 20px;
        max-height: 90vh; /* Prevent it from being too tall */
        overflow-y: auto; /* Internal scroll if needed */
    }

    .modal-header h2 {
        font-size: 1.8rem;
    }

    .close-modal {
        top: 10px;
        right: 15px;
        font-size: 24px;
    }

    .modal-gallery {
        grid-template-columns: repeat(2, 1fr); /* 2 columns on mobile */
        gap: 8px;
        margin-bottom: 20px;
    }

    .modal-gallery img {
        height: 100px; /* Smaller images */
    }

    .modal-body {
        gap: 20px;
        flex-direction: column;
    }

    .modal-description, .modal-location {
        min-width: 100%; /* Full width */
    }

    .modal-features {
        padding: 12px;
        gap: 10px;
        grid-template-columns: repeat(2, 1fr); /* Back to 2 columns to save vertical space */
    }

    .modal-feature-item {
        gap: 8px;
        align-items: center; /* Center vertically */
    }

    .modal-feature-item i {
        width: 30px;
        height: 30px;
        line-height: 30px;
        font-size: 0.9rem;
        min-width: 30px; /* Prevent shrinking */
    }
    
    .modal-feature-text .value {
        font-size: 0.9rem;
    }

    .modal-feature-text .label {
        font-size: 0.7rem;
    }

    .modal-map {
        height: 200px;
    }
}
