/* Grid layout for .cfg-gallery - respects left-to-right order */
.cfg-gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

@media (max-width: 1024px) {
    .cfg-gallery {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .cfg-gallery {
        grid-template-columns: 1fr; /* single column */
    }
}


/* Optional: ensure items flow and don't break weirdly */
.cfg-item {
    break-inside: avoid;
    position: relative;
    display: block;
    width: 100%;
}

.cfg-item img {
    width: 100%;
    height: 250px; /* or any value you like */
    object-fit: cover; /* crops the image to fill the box */
    display: block;
}


.new-gallery-button {
    background: white;
    color: #007cba;
    border: 2px solid #007cba;
    border-radius: 3px;
    padding: 6px 12px;
    font-size: 13px;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.3s, color 0.3s, border-color 0.3s;
    box-shadow: none;
}

.new-gallery-button:hover {
    background-color: #28a745 !important;
    color: white !important;
    border-color: #28a745 !important;
}

.cfg-gallery-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.cfg-gallery-item img {
    flex: 0 0 auto;
}

.cfg-gallery-item input[type="text"] {
    flex: 1 1 200px; /* allows it to grow */
    max-width: 300px;
}

.cfg-gallery-item select {
    flex: 0 0 auto;
}

.cfg-gallery-item .cfg-remove-image {
    flex: 0 0 auto;
}


.cfg-item {
    display: inline-block;
    width: 90%;
    margin-bottom: 15px;
}

.cfg-overlay {
    position: relative;
    display: block;
    overflow: hidden;
    z-index: 1;
}

.cfg-overlay img {
    width: 100%;
    display: block;
    transition: transform 0.3s ease, filter 0.3s ease;
}

.cfg-caption {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    opacity: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    transition: opacity 0.3s ease;
    padding: 15px;
    pointer-events: none;
}
body.modal-open .cfg-caption {
    display: none !important;
}

.cfg-caption h1,
.cfg-caption h2,
.cfg-caption h3,
.cfg-caption h4,
.cfg-caption h5 {
    margin: 0;
    color: #fff;
}

.cfg-overlay:hover .cfg-caption {
    opacity: 1;
}

.cfg-overlay:hover img {
    transform: scale(1.05);
    filter: brightness(40%);
}

/* Lightbox modal */
#cfg-lightbox-modal {
    display: none;
    position: fixed;
    z-index: 99999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    padding: 20px;
    background-color: rgba(0,0,0,0.9);
    text-align: center;
}
#cfg-lightbox-modal img {
    max-width: 60%;
    max-height: 80vh;
    margin: 40px auto;
    display: block;
}
 
#cfg-lightbox-modal .cfg-lightbox-caption {
    color: #fff;
    margin-top: 10px;
    font-size: 18px;
}

/* CLOSE (X) BUTTON */
#cfg-lightbox-modal .cfg-close {
    position: absolute;
    top: 30px;           /* adjust vertical */
    right: 30px;         /* adjust horizontal */
    color: #fff;
    font-size: 40px;     /* size of X */
    font-weight: bold;
    cursor: pointer;
    padding: 5px;
    z-index: 100001;
}

/* ARROWS */
.cfg-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 48px;
    color: #fff;
    padding: 10px 10px;
    cursor: pointer;
    user-select: none;
    z-index: 10000;
    background-color: rgba(0, 0, 0, 0.3);
}

.cfg-arrow-left {
    left: 10px;
}
.cfg-arrow-right {
    right: 10px;
}
.cfg-arrow:hover {
    color: #ccc;
}
.cfg-lightbox-hint {
    color: #aaa;
    font-size: 14px;
    margin-top: 10px;
}


.cfg-load-more {
    display: block;
    margin: 20px auto;
    padding: 10px 20px;
    background-color: #333;
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 16px;
    border-radius: 5px;
    transition: background-color 0.3s ease;
}
.cfg-load-more:hover {
    background-color: #555;
}



.cfg-item {
    break-inside: avoid;
    position: relative;
}

.cfg-caption {
    pointer-events: none;
    display: flex;
}



/* === Responsive Centering for Lightbox Content === */
#cfg-lightbox-modal {
    display: none;
    position: fixed;
    z-index: 99999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    padding: 20px;
    background-color: rgba(0, 0, 0, 0.9);
    text-align: center;
    box-sizing: border-box;
}

#cfg-lightbox-modal .cfg-lightbox-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    height: 100%;
    margin: 0 auto;
}

#cfg-lightbox-modal img {
    max-width: 90%;
    max-height: 80vh;
    object-fit: contain;
    margin: 20px 0;
}

#cfg-lightbox-modal .cfg-lightbox-caption {
    color: #fff;
    font-size: 18px;
    max-width: 90%;
    word-break: break-word;
    text-align: center;
}

@media (max-width: 768px) {
    #cfg-lightbox-modal .cfg-lightbox-caption {
        font-size: 16px;
        padding: 0 10px;
    }
}

@media (max-width: 768px) {
    .cfg-arrow {
        font-size: 36px;
        padding: 5px;
    }
    #cfg-lightbox-modal .cfg-close {
        top: 20px;
        right: 20px;
        font-size: 28px;
    }
}

#cfg-gallery-images { list-style: none; margin: 0; padding: 0; }
#cfg-gallery-images .cfg-gallery-item { margin: 10px 0; padding: 10px; border: 1px solid #ccc; cursor: move; background: #fff; }
.cfg-placeholder { background: #f0f0f0; border: 2px dashed #999; height: 60px; }