body {
    font-family: Gotham, "Helvetica Neue", Helvetica, Arial, "sans-serif"; /* Adjusted font family */
    margin: 0;
    background-color: #C8A500; /* Changed background color */
    color: #333;
}

header { /* This section is effectively removed by index.php changes, but kept for completeness if needed */
    background-color: #333;
    color: white;
    padding: 20px 0;
    text-align: center;
}

h1 {
    margin: 0;
    margin-bottom: 20px;
}

.gallery-container {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 20px;
}

/* Category Header for grouped images */
.category-header {
    text-align: center;
    margin-top: 5px; /* Space above each category section */
    margin-bottom: 5px;
    color: #832000;
    background-color: #846C00; /* Light background for the header */
    padding: 1px 0; /* Reduced padding for thinner header */
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.gallery-grid {
    display: grid;
    /* Use CSS variable for columns from PHP */
    grid-template-columns: repeat(var(--images-per-row), 1fr);
    gap: 5px; /* Reduced gap between thumbnails */
    margin-bottom: 3px;
}

.gallery-item {
    background-color: white;
    border: 1px solid #846C00;
    border-radius: 5px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    text-align: center;
    display: flex;
    flex-direction: column;
}

.gallery-item img {
    width: 100%;
    height: 80px; /* Adjusted thumbnail height */
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.gallery-item img:hover {
    transform: scale(1.2);
}

.gallery-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

/* .gallery-caption is no longer used for thumbnails but kept for reference */
/* .gallery-caption {
    padding: 10px;
    font-size: 0.9em;
    color: #555;
    background-color: #f9f9f9;
    border-top: 1px solid #eee;
    min-height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    word-wrap: break-word;
    overflow-wrap: break-word;
} */


/* Pagination */
.pagination {
    text-align: center;
    margin-top: 30px;
    padding: 10px;
    background-color: white;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.pagination-link {
    display: inline-block;
    padding: 8px 15px;
    margin: 0 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-decoration: none;
    color: #007bff;
    transition: background-color 0.3s, color 0.3s;
}

.pagination-link:hover {
    background-color: #007bff;
    color: white;
}

.pagination-link.active {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
    font-weight: bold;
}

/* Sort Options (CSS still present but not used in index.php anymore) */
.sort-options {
    text-align: center;
    margin-top: 15px;
    margin-bottom: 20px;
    color: white;
}

.sort-options label {
    margin-right: 10px;
}

.sort-options select {
    padding: 8px 12px;
    border-radius: 5px;
    border: 1px solid #ccc;
    background-color: white;
    font-size: 1em;
    cursor: pointer;
}

/* Lightbox Styles */
.lightbox {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.9);
    align-items: center;
    justify-content: center;
}

.lightbox-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 90%; /* Adjusted for true centering, allows image to be taller */
    object-fit: contain;
    transition: transform 0.3s ease-out;
    /* margin-bottom: 50px; -- REMOVED THIS LINE */
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
}

.lightbox-close:hover,
.lightbox-close:focus {
    color: #bbb;
    text-decoration: none;
    cursor: pointer;
}

.lightbox-prev, .lightbox-next {
    cursor: pointer;
    position: absolute;
    top: 50%;
    width: auto;
    padding: 16px;
    margin-top: -50px;
    color: white;
    font-weight: bold;
    font-size: 20px;
    transition: 0.6s ease;
    border-radius: 0 3px 3px 0;
    user-select: none;
    -webkit-user-select: none;
}

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

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

.lightbox-prev:hover,
.lightbox-next:hover {
    background-color: rgba(0,0,0,0.8);
}

/* Lightbox Caption */
.lightbox-caption {
    color: white;
    font-size: 1.1em;
    padding: 10px 20px;
    position: absolute;
    bottom: 20px; /* Position at the bottom with some padding */
    left: 50%; /* Start from the middle */
    transform: translateX(-50%); /* Center horizontally */
    text-align: center;
    max-width: 80%; /* Limit width to prevent it from going too wide */
    background-color: rgba(0, 0, 0, 0.7); /* Semi-transparent background */
    border-radius: 5px;
    word-wrap: break-word; /* Ensure long captions wrap */
    white-space: normal; /* Allow text to wrap */
}


/* Responsive adjustments */
@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .lightbox-close, .lightbox-prev, .lightbox-next {
        font-size: 25px;
        padding: 10px;
    }
    .lightbox-close {
        top: 10px;
        right: 15px;
    }
    .lightbox-caption {
        font-size: 1em;
        bottom: 10px;
        padding: 8px 15px;
        max-width: 90%;
    }
    .lightbox-content {
        max-height: calc(90% - 50px);
        margin-bottom: 40px;
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: 1fr;
    }
    .lightbox-close, .lightbox-prev, .lightbox-next {
        font-size: 20px;
        padding: 8px;
    }
    .lightbox-close {
        top: 5px;
        right: 10px;
    }
    .lightbox-caption {
        font-size: 0.9em;
        padding: 5px 10px;
        bottom: 5px;
    }
    .lightbox-content {
        max-height: calc(90% - 35px);
        margin-bottom: 30px;
    }
}