/* Custom CSS for rearranging menu items with 4 on top and 3 centered below */

/* Custom CSS for grid layout adjustment */
.environments-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin: 2rem 0;
    width: 100%;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

/* First row - 4 items */
.environments-grid > :nth-child(1),
.environments-grid > :nth-child(2),
.environments-grid > :nth-child(3),
.environments-grid > :nth-child(4) {
    grid-row: 1;
}

.environments-grid > :nth-child(1) {
    grid-column: 1;
}

.environments-grid > :nth-child(2) {
    grid-column: 2;
}

.environments-grid > :nth-child(3) {
    grid-column: 3;
}

.environments-grid > :nth-child(4) {
    grid-column: 4;
}

/* Create a separate container for the bottom row */
.environments-grid::after {
    content: "";
    display: block;
    grid-column: 1 / -1;
    height: 20px;
}

/* Second row - 3 centered items */
.environments-grid > :nth-child(5),
.environments-grid > :nth-child(6),
.environments-grid > :nth-child(7) {
    grid-row: 2;
}

/* Position the 3 items in the center of the grid */
.environments-grid > :nth-child(5) {
    grid-column: 2 / span 1;
}

.environments-grid > :nth-child(6) {
    grid-column: 3 / span 1;
}

.environments-grid > :nth-child(7) {
    grid-column: 4 / span 1;
}

/* Override inline style for environments-grid */
.environments-grid[style*="justify-content: center"] {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
}

/* Create a separate container for the bottom row items */
.bottom-row {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-top: 1.5rem;
    gap: 1.5rem;
}

/* Ensure consistent styling for all environment items */
.environment-item {
    width: 100%;
    max-width: 250px;
    text-align: center;
    margin-left: auto;
    margin-right: auto;
}

html[dir="rtl"] .environment-item {
    text-align: center;
}

/* Modify the HTML structure with JavaScript to ensure proper centering */
.environments-grid::before {
    content: "";
    display: none;
}

@media (max-width: 992px) {
    .environments-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .environments-grid > :nth-child(1),
    .environments-grid > :nth-child(2),
    .environments-grid > :nth-child(3),
    .environments-grid > :nth-child(4),
    .environments-grid > :nth-child(5),
    .environments-grid > :nth-child(6),
    .environments-grid > :nth-child(7) {
        grid-column: auto;
        grid-row: auto;
    }
    
    .bottom-row {
        flex-direction: column;
        align-items: center;
    }
}

@media (max-width: 576px) {
    .environments-grid {
        grid-template-columns: 1fr;
        display: flex !important;
        flex-direction: column;
        align-items: center;
    }
    
    /* Make all environment items the same height and width in mobile view */
    .environment-item {
        height: auto;
        min-height: 120px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: 1rem;
        width: 100%;
        max-width: 280px;
        margin-left: auto;
        margin-right: auto;
    }
    
    /* Ensure all environment items have the same text size */
    .environment-item h3 {
        font-size: 1.1rem;
        line-height: 1.4;
        margin: 0;
        text-align: center;
    }
    
    /* Make specific items match the size of the classrooms item */
    .environment-item.video-teleconferencing,
    .environment-item.conference-rooms,
    .environment-item.theaters,
    .environment-item.classrooms {
        min-height: 120px;
        padding: 1rem;
        margin-left: auto;
        margin-right: auto;
    }
    
    /* Fix for theaters alignment in mobile view */
    .environment-item.theaters {
        margin-left: auto !important;
        margin-right: auto !important;
        text-align: center !important;
    }
    
    /* Ensure icons are the same size and centered */
    .environment-item i {
        font-size: 1.8rem;
        margin-bottom: 0.8rem;
        margin-left: auto;
        margin-right: auto;
        text-align: center;
    }
}
