:root {
    --bg-color: #f0f0f0;
    --text-color: #060606;
}

.gallery img {
    border: 1px solid var(--text-color);
}

.modal img {
    border: none;
}

body.modal-open {
    overflow: hidden; /* Disable scrolling when modal is open */
}

.row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    padding: 0 8px;
}

.column {
    flex: 1 1 22%; /* Approximately 4 columns on desktop */
    max-width: 22%;
    margin: 8px;
    box-sizing: border-box;
}

.column img {
    width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
    transition: 0.3s;
}

.column img:hover {
    opacity: 0.5;
}

.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: hidden; /* Prevent scrolling */
    background-color: var(--bg-color);
}

.modal-content {
    position: relative;
    background-color: var(--bg-color);
    margin: auto;
    width: 75%;
    max-width: 1200px;
    height: 80vh; /* Make sure it fits within the viewport height */
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid var(--text-color);
    box-sizing: border-box;
    overflow: hidden;
}

.modal-content img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.close {
    color: var(--text-color);
    position: absolute;
    top: 10px;
    right: 25px;
    font-size: 35px;
    font-weight: bold;
}

.close:hover,
.close:focus {
    color: var(--text-color);
    text-decoration: none;
    cursor: pointer;
}

.mySlides {
    display: none;
    text-align: center;
    height: calc(70vh); /* Adjust for number and caption heights */
}

.mySlides img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* Ensure the slides don't overflow */
    margin-top: 30px;
}

.prev,
.next, .prev:active, .next:visited, .next:active, .prev:visited {
    cursor: pointer;
    position: fixed; /* Position relative to the viewport */
    top: 50%;
    width: auto;
    padding: 16px;
    margin-top: -22px;
    color: var(--bg-color);
    background-color: var(--text-color);
    font-weight: bold;
    font-size: 20px;
    transition: 0.6s ease;
    user-select: none;
    -webkit-user-select: none;
    transform: translateY(-50%);
    z-index: 10001; /* Ensure buttons are above other content */
    text-decoration: none;
}

.prev {
    left: 0;
    border-radius: 0 3px 3px 0;
}

.next {
    right: 0;
    border-radius: 3px 0 0 3px;
}

.prev:hover,
.next:hover {
    background-color: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--text-color);
}

.numbertext {
    color: var(--text-color);
    font-size: 12px;
    padding: 8px 12px;
    position: absolute;
    top: 0;
    left: 0;
}

.caption-container {
    text-align: center;
    background-color: var(--bg-color);
    color: var(--text-color);
    width: 100%;
    padding: 8px;
    border-top: 1px solid var(--text-color);
    box-sizing: border-box;
    margin-top: 30px;
}

img.demo {
    opacity: 0.6;
}

.thumbnail-row {
    display: flex;
    justify-content: center;
    flex-wrap: nowrap;
    overflow-x: auto;
    border-top: 1px solid var(--text-color);
    width: 100%;
    padding: 8px;
    background-color: var(--bg-color);
    box-sizing: border-box;
    position: relative; /* Changed from absolute to relative */
}

.thumbnail-row img {
    width: 50px;
}

.active,
.demo:hover {
    opacity: 1;
}

@media (max-width: 750px) {
    .column {
        flex: 1 1 48%; /* Approximately 2 columns on mobile */
        max-width: 48%;
        margin: 4px;
    }

    .thumbnail-row {
        display: none;
    }

    .thumbnail-column img {
        width: 50px; /* Smaller thumbnails for mobile */
    }
}