.edel-gallery-wrapper {
    width: 100% !important;
    margin-bottom: var(--edel-gap, 10px) !important;
    border: none !important;
    box-sizing: border-box !important;
}

.edel-gallery-wrapper .edel-gallery-grid {
    display: grid !important;
    grid-template-columns: repeat(var(--edel-cols, 4), minmax(0, 1fr)) !important;
    gap: var(--edel-gap, 10px) !important;
    align-items: stretch !important;
    /* Stretch items to match tallest in row */
}

.edel-gallery-wrapper .edel-gallery-item {
    margin: 0 !important;
    padding: 0 !important;
    position: relative !important;
    border: var(--edel-border-width, 10px) solid var(--edel-border-color, #ffffff) !important;
    background-color: var(--edel-border-color, #ffffff) !important;
    box-shadow: var(--edel-shadow, 0px 4px 15px rgba(0, 0, 0, 0.2)) !important;
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
    /* Height 100% with stretch takes up the full grid row height */
    height: 100% !important;
    align-self: stretch !important;
    min-width: 0 !important;
}

.edel-gallery-wrapper .edel-gallery-img-wrap {
    width: 100% !important;
    flex-shrink: 0 !important;
    /* Prevent shrinking below aspect ratio */
    aspect-ratio: var(--edel-aspect-ratio, 1/1) !important;
    overflow: hidden !important;
    position: relative !important;
    background: #f5f5f5 !important;
    box-sizing: border-box !important;
}

.edel-gallery-wrapper .edel-gallery-img-wrap a {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    text-decoration: none !important;
    border: none !important;
}

.edel-gallery-wrapper .edel-gallery-img-wrap img {
    width: 100% !important;
    height: 100% !important;
    object-fit: var(--edel-fit, cover) !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
}

.edel-gallery-wrapper .edel-gallery-caption {
    padding: 10px !important;
    background-color: var(--edel-border-color, #ffffff) !important;
    text-align: center !important;
    /* Grow to fill remaining height */
    flex-grow: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    margin: 0 !important;
}

.edel-gallery-wrapper .edel-gallery-caption h4 {
    margin: 0 0 5px 0 !important;
    font-size: 16px !important;
    color: var(--edel-title-color, #333333) !important;
    line-height: 1.4 !important;
    padding: 0 !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
}

.edel-gallery-wrapper .edel-gallery-caption p {
    margin: 0 !important;
    font-size: 13px !important;
    color: var(--edel-title-color, #666666) !important;
    opacity: 0.8 !important;
    line-height: 1.4 !important;
    padding: 0 !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
}

/* Responsive fallbacks if cols are set high */
@media (max-width: 1024px) {
    .edel-gallery-wrapper .edel-gallery-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) !important;
    }
}

@media (max-width: 600px) {
    .edel-gallery-wrapper {
        --edel-cols: 2 !important;
    }

    .edel-gallery-wrapper .edel-gallery-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* @media (max-width: 400px) {
    .edel-gallery-wrapper {
        --edel-cols: 1 !important;
    }

    .edel-gallery-wrapper .edel-gallery-grid {
        grid-template-columns: 1fr !important;
    }
} */

/* =========================================
   Hover Overlay Effect
   ========================================= */
.edel-gallery-wrapper .edel-gallery-img-wrap .edel-gallery-hover-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 2;
}

.edel-gallery-wrapper .edel-gallery-hover-overlay svg {
    /* Slightly animate the search icon strictly for aesthetic touch */
    transform: scale(0.8);
    transition: transform 0.3s ease;
}

.edel-gallery-wrapper .edel-gallery-img-wrap:hover .edel-gallery-hover-overlay {
    opacity: 1;
}

.edel-gallery-wrapper .edel-gallery-img-wrap:hover .edel-gallery-hover-overlay svg {
    transform: scale(1);
}

/* =========================================
   Lightbox Modal Styles
   ========================================= */
.edel-lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.9);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition:
        opacity 0.3s ease,
        visibility 0.3s ease;
}

.edel-lightbox-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Header */
.edel-lightbox-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    color: #fff;
    font-family: sans-serif;
    position: relative;
    z-index: 2;
    flex-shrink: 0;
}

.edel-lightbox-counter {
    font-size: 14px;
    opacity: 0.8;
}

.edel-lightbox-title {
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    flex-grow: 1;
    margin: 0 20px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.edel-lightbox-close {
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.edel-lightbox-close:hover {
    opacity: 1;
}

/* Content Area */
.edel-lightbox-content {
    flex-grow: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 60px;
    /* Space for arrows */
    min-height: 0;
    /* Critical: Prevent image from expanding height past viewport */
    overflow: hidden;
}

.edel-lightbox-image-wrap {
    max-width: 100%;
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.edel-lightbox-content img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    /* Prevents cropping */
    user-select: none;
    display: block;
    /* Removes inline bottom spacing */
    transition: transform 0.1s ease-out;
    /* Smooth zoom */
}

/* Navigation Arrows */
.edel-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: #fff;
    cursor: pointer;
    padding: 15px;
    opacity: 0.5;
    transition: opacity 0.2s;
    z-index: 3;
}

.edel-lightbox-nav:hover {
    opacity: 1;
}

.edel-lightbox-prev {
    left: 10px;
}

.edel-lightbox-next {
    right: 10px;
}

/* Footer Description */
.edel-lightbox-footer {
    padding: 20px;
    color: #ddd;
    text-align: center;
    font-size: 14px;
    line-height: 1.6;
    max-height: 120px;
    overflow-y: auto;
    font-family: sans-serif;
    position: relative;
    z-index: 2;
    flex-shrink: 0;
    /* Critical: Prevent footer from being compressed by tall image */
}

/* Responsive adjustments for lightbox */
@media (max-width: 768px) {
    .edel-lightbox-content {
        padding: 0 40px;
    }

    .edel-lightbox-nav {
        padding: 5px;
    }

    .edel-lightbox-title {
        font-size: 14px;
    }
}
