/* JeepAG Gallery - Simple Grid That Works */

/* Container - Centered on page */
.jeepag-gallery-container {
    width: 100%;
    padding: 20px 0;
    margin: 0 auto;
    text-align: center; /* Center the gallery */
}

/* Grid - Using Flexbox for better compatibility */
.jeepag-masonry-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin: 0 auto;
    padding: 0;
    max-width: 1400px;
    justify-content: center; /* Center items within the grid */
}

/* Gallery Items - Flex basis for columns */
.jeepag-gallery-item {
    flex: 0 0 calc(25% - 15px); /* 4 columns by default */
    height: 250px;
    overflow: hidden;
    border-radius: 8px;
    background: #f5f5f5;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    cursor: pointer;
    position: relative;
}

/* Column controls using flex-basis */
.jeepag-gallery-container[data-columns="1"] .jeepag-gallery-item {
    flex: 0 0 100%;
}

.jeepag-gallery-container[data-columns="2"] .jeepag-gallery-item {
    flex: 0 0 calc(50% - 10px);
}

.jeepag-gallery-container[data-columns="3"] .jeepag-gallery-item {
    flex: 0 0 calc(33.333% - 14px);
}

.jeepag-gallery-container[data-columns="4"] .jeepag-gallery-item {
    flex: 0 0 calc(25% - 15px);
}

.jeepag-gallery-container[data-columns="5"] .jeepag-gallery-item {
    flex: 0 0 calc(20% - 16px);
}

.jeepag-gallery-container[data-columns="6"] .jeepag-gallery-item {
    flex: 0 0 calc(16.666% - 17px);
}

/* Link container */
.jeepag-gallery-link {
    display: block;
    width: 100%;
    height: 100%;
}

/* Images */
.jeepag-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: translateZ(0);
}

/* Hover effect */
.jeepag-gallery-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Tablet - Use tablet_columns attribute */
@media (max-width: 768px) and (min-width: 481px) {
    .jeepag-gallery-item {
        height: 200px;
    }
    
    /* Apply tablet columns from data attribute - FORCE with !important */
    body .jeepag-gallery-container[data-tablet-columns="1"] .jeepag-gallery-item {
        flex: 0 0 100% !important;
    }
    
    body .jeepag-gallery-container[data-tablet-columns="2"] .jeepag-gallery-item {
        flex: 0 0 calc(50% - 10px) !important;
    }
    
    body .jeepag-gallery-container[data-tablet-columns="3"] .jeepag-gallery-item {
        flex: 0 0 calc(33.333% - 14px) !important;
    }
    
    body .jeepag-gallery-container[data-tablet-columns="4"] .jeepag-gallery-item {
        flex: 0 0 calc(25% - 15px) !important;
    }
    
    /* Default to 3 columns if not specified */
    body .jeepag-gallery-container:not([data-tablet-columns]) .jeepag-gallery-item {
        flex: 0 0 calc(33.333% - 14px) !important;
    }
}

/* Mobile - Use mobile_columns attribute */
@media (max-width: 480px) {
    .jeepag-gallery-item {
        height: 150px;
    }
    
    .jeepag-masonry-gallery {
        gap: 10px;
    }
    
    /* Apply mobile columns from data attribute - FORCE with !important */
    body .jeepag-gallery-container[data-mobile-columns="1"] .jeepag-gallery-item {
        flex: 0 0 100% !important;
    }
    
    body .jeepag-gallery-container[data-mobile-columns="2"] .jeepag-gallery-item {
        flex: 0 0 calc(50% - 5px) !important;
    }
    
    body .jeepag-gallery-container[data-mobile-columns="3"] .jeepag-gallery-item {
        flex: 0 0 calc(33.333% - 7px) !important;
    }
    
    /* Default to 2 columns if not specified */
    body .jeepag-gallery-container:not([data-mobile-columns]) .jeepag-gallery-item {
        flex: 0 0 calc(50% - 5px) !important;
    }
}

/* Pagination */
.jeepag-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 30px;
    padding: 15px;
    flex-wrap: wrap;
}

.jeepag-page-numbers {
    display: flex;
    gap: 5px;
}

.jeepag-page-number {
    display: block;
    padding: 8px 12px;
    background: #fff;
    border: 1px solid #ddd;
    text-decoration: none;
    color: #333;
    border-radius: 4px;
}

.jeepag-page-number:hover {
    background: #007cba;
    color: white;
    border-color: #007cba;
}

.jeepag-page-number.current {
    background: #333;
    color: white;
    border-color: #333;
}

.jeepag-page-prev,
.jeepag-page-next {
    padding: 8px 15px;
    background: #fff;
    border: 1px solid #ddd;
    text-decoration: none;
    color: #333;
    border-radius: 4px;
}

.jeepag-page-prev:hover,
.jeepag-page-next:hover {
    background: #007cba;
    color: white;
    border-color: #007cba;
}

.jeepag-page-info {
    width: 100%;
    text-align: center;
    color: #666;
    font-size: 13px;
    margin-top: 10px;
}

/* Mobile pagination */
@media (max-width: 480px) {
    .jeepag-pagination {
        padding: 10px;
    }
    
    .jeepag-page-number {
        padding: 6px 10px;
        font-size: 14px;
    }
    
    /* Hide dots on mobile */
    .jeepag-page-dots {
        display: none;
    }
}
