/* Gallery Masonry Layout */
.gallery-container {
    columns: auto;
    column-gap: 1.5rem;
    padding: 0 1rem;
}

@media (max-width: 576px) {
    .gallery-container {
        columns: 1;
        column-gap: 1rem;
    }
}

@media (min-width: 577px) and (max-width: 768px) {
    .gallery-container {
        columns: 2;
    }
}

@media (min-width: 769px) {
    .gallery-container {
        columns: 3;
    }
}

.gallery-item {
    break-inside: avoid;
    margin-bottom: 1.5rem;
    cursor: pointer;
    transition: transform 0.2s ease, filter 0.2s ease;
    position: relative;
    overflow: hidden;
    border-radius: 0.375rem;
    background-color: #f8f9fa;
}

.gallery-item:hover {
    transform: translateY(-4px);
    filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.2));
}

.gallery-item img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 0.375rem;
}

.gallery-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    color: white;
    padding: 1rem 0.75rem 0.75rem;
    font-size: 0.875rem;
    text-align: center;
}

.gallery-item:hover .gallery-caption {
    /* hover effect can stay but caption is always visible */
}

/* Modal Styles */
.gallery-modal .modal-body {
    padding: 0;
    background-color: #000;
    position: relative;
    min-height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-modal .modal-dialog {
    margin: 0;
    height: 100vh;
    max-width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-modal .modal-content {
    border-radius: 0;
    border: none;
    background-color: transparent;
}

.gallery-modal img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 0.375rem;
}

.gallery-modal .modal-header {
    background-color: rgba(0, 0, 0, 0.8);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1rem;
}

.gallery-modal .modal-title {
    color: white;
    font-size: 0.95rem;
}

.gallery-modal .btn-close {
    filter: brightness(0) invert(1);
}

/* Navigation Controls */
.gallery-nav-button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    font-size: 1.5rem;
    padding: 1rem 0.75rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    z-index: 10;
    border-radius: 0.25rem;
}

.gallery-nav-button:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

.gallery-nav-button.prev {
    left: 1rem;
}

.gallery-nav-button.next {
    right: 1rem;
}

.gallery-nav-button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.gallery-nav-button:disabled:hover {
    background-color: rgba(0, 0, 0, 0.5);
}

/* Image Counter */
.gallery-counter {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
}

/* Loading State */
.gallery-item.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: rgba(0, 0, 0, 0.3);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}