/* Gallery Improvements - Lightbox & Pagination Fix */
.esg-grid ul {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.eg-plumber-wrapper {
    cursor: pointer;
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease;
    opacity: 1;
    visibility: visible;
}

.eg-plumber-wrapper:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.esg-media-cover-wrapper {
    position: relative;
}

.esg-entry-media {
    position: relative;
    padding-top: 75%;
    overflow: hidden;
    background: #f5f5f5;
}

.esg-entry-media img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.eg-plumber-wrapper:hover .esg-entry-media img {
    transform: scale(1.1);
}

/* Zoom Icon Overlay */
.esg-media-cover-wrapper::after {
    content: '🔍';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 40px;
    color: white;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 2;
}

.eg-plumber-wrapper:hover .esg-media-cover-wrapper::after {
    opacity: 0.9;
}

/* Lightbox Modal */
.lightbox-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 99999;
    animation: fadeIn 0.3s ease;
}

.lightbox-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    animation: zoomIn 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-content img {
    max-width: 90vw;
    max-height: 90vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    display: block;
}

.lightbox-close {
    position: absolute;
    top: -50px;
    right: 0;
    font-size: 40px;
    color: white;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    transition: transform 0.3s ease;
    z-index: 10;
}

.lightbox-close:hover {
    transform: scale(1.2);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 50px;
    color: white;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    cursor: pointer;
    padding: 20px;
    transition: background 0.3s ease;
    border-radius: 8px;
    z-index: 10;
    user-select: none;
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

.lightbox-counter {
    position: absolute;
    bottom: -50px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 16px;
    font-weight: 500;
    white-space: nowrap;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes zoomIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Pagination Styles - IMPROVED CONTRAST */
.esg-pagination {
    display: flex !important;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 40px;
    flex-wrap: wrap;
    padding: 20px 0;
}

.esg-pagination-button {
    padding: 10px 16px;
    background: #f8f9fa;
    color: #1a1a1a !important;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    min-width: 42px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.esg-pagination-button:hover:not(:disabled) {
    background: #003e75;
    border-color: #003e75;
    color: white !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 62, 117, 0.3);
}

.esg-pagination-button.active {
    background: #003e75;
    border-color: #003e75;
    color: white !important;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(0, 62, 117, 0.4);
}

.esg-pagination-button:disabled {
    background: #e9ecef;
    border-color: #dee2e6;
    cursor: not-allowed;
    opacity: 0.6;
    color: #6c757d !important;
}

.pagination-dots {
    padding: 10px 8px;
    color: #1a1a1a;
    font-weight: bold;
    font-size: 16px;
}

/* Hide empty pagination container initially */
.esg-pagination:empty {
    display: none !important;
}

/* Tablet Responsive */
@media (max-width: 1024px) {
    .esg-grid ul {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
        padding: 0 10px;
    }

    .lightbox-content img {
        max-width: 85vw;
        max-height: 85vh;
    }

    .esg-pagination {
        gap: 6px;
        padding: 20px 10px;
    }

    .esg-pagination-button {
        padding: 10px 14px;
        font-size: 13px;
        min-width: 40px;
    }
}

/* Mobile Responsive for Gallery - IMPROVED */
@media (max-width: 768px) {
    .esg-grid ul {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 0 10px;
    }

    .eg-plumber-wrapper {
        border-radius: 6px;
    }

    .esg-entry-media {
        padding-top: 100%;
    }

    .lightbox-content img {
        max-width: 95vw;
        max-height: 80vh;
    }

    .lightbox-nav {
        font-size: 40px;
        padding: 12px 16px;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(5px);
    }

    .lightbox-prev {
        left: 5px;
    }

    .lightbox-next {
        right: 5px;
    }

    .lightbox-close {
        top: 10px;
        right: 10px;
        font-size: 32px;
        background: rgba(0, 0, 0, 0.7);
        backdrop-filter: blur(5px);
        border-radius: 50%;
        width: 50px;
        height: 50px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
    }

    .lightbox-counter {
        bottom: 15px;
        font-size: 15px;
        background: rgba(0, 0, 0, 0.8);
        backdrop-filter: blur(5px);
        padding: 8px 20px;
        border-radius: 25px;
    }

    /* Mobile Pagination - Better Contrast */
    .esg-pagination {
        gap: 6px;
        margin-top: 30px;
        padding: 20px 10px;
        flex-wrap: wrap;
        background: rgba(255, 255, 255, 0.05);
        border-radius: 12px;
    }

    .esg-pagination-button {
        padding: 10px 14px;
        font-size: 13px;
        min-width: 40px;
        border-radius: 8px;
        font-weight: 600;
    }

    .pagination-dots {
        padding: 10px 6px;
        font-size: 15px;
        color: #1a1a1a;
    }

    /* Hide hover effects on mobile */
    .eg-plumber-wrapper:hover {
        transform: none;
    }

    .esg-media-cover-wrapper::after {
        font-size: 30px;
    }
}

@media (max-width: 480px) {
    .esg-grid ul {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 0 8px;
    }

    .eg-plumber-wrapper {
        border-radius: 4px;
    }

    /* Even more compact pagination for small phones */
    .esg-pagination {
        gap: 4px;
        margin-top: 25px;
        padding: 15px 8px;
        background: rgba(255, 255, 255, 0.08);
    }

    .esg-pagination-button {
        padding: 9px 12px;
        font-size: 13px;
        min-width: 40px;
        border-radius: 6px;
        font-weight: 600;
    }

    .lightbox-content img {
        max-width: 98vw;
        max-height: 75vh;
    }

    .pagination-dots {
        padding: 9px 4px;
        font-size: 14px;
        color: #1a1a1a;
    }

    .lightbox-nav {
        font-size: 32px;
        padding: 10px 12px;
    }

    .lightbox-close {
        width: 45px;
        height: 45px;
        font-size: 28px;
    }

    .lightbox-counter {
        font-size: 13px;
        padding: 6px 16px;
        bottom: 10px;
    }
}

/* Extra small devices */
@media (max-width: 360px) {
    .esg-grid ul {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
        padding: 0 5px;
    }

    .esg-pagination-button {
        padding: 8px 10px;
        font-size: 12px;
        min-width: 38px;
        font-weight: 600;
    }

    .pagination-dots {
        padding: 8px 3px;
        font-size: 13px;
    }
}