/* Photo Gallery Modal Styles */

.main-gallery-image {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    height: 500px;
    min-height: 500px;
    max-height: 500px;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.main-gallery-image img {
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                filter 0.3s ease;
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 12px;
    position: absolute;
    top: 0;
    left: 0;
}

/* Enhanced transitions for smooth photo switching */
.main-gallery-image img.fading-out {
    opacity: 0;
    transform: scale(0.98);
    filter: blur(1px);
}

.main-gallery-image img.fading-in {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
}

.main-gallery-image img.loading {
    opacity: 0.3;
    filter: blur(2px);
}

/* Smooth transitions for image info text */
.gallery-image-info {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.gallery-image-info.fading {
    opacity: 0.4;
    transform: translateY(5px);
}

/* Enhanced thumbnail transitions */
.gallery-thumbnail {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 8px;
    overflow: hidden;
}

.gallery-thumbnail:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.gallery-thumbnail.active {
    transform: scale(1.02);
    box-shadow: 0 0 0 3px rgba(0, 120, 212, 0.5);
}

/* Gallery Navigation Buttons */
.gallery-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.6);
    border: none;
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
}

.gallery-nav-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: translateY(-50%) scale(1.05);
}

.gallery-prev {
    left: 15px;
}

.gallery-next {
    right: 15px;
}

/* Gallery Counter */
.gallery-counter {
    position: absolute;
    bottom: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
    backdrop-filter: blur(8px);
}

/* Gallery Info Section */
.gallery-info {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.gallery-info h5 {
    color: #0078d4;
    font-size: clamp(1.1rem, 2.5vw, 1.4rem);
    margin-bottom: 0.75rem;
    font-weight: 600;
    line-height: 1.3;
    transition: opacity 0.2s ease;
}

.gallery-info p {
    color: #605e5c;
    font-size: clamp(0.875rem, 2vw, 1rem);
    line-height: 1.6;
    margin-bottom: 0;
    font-weight: 400;
    transition: opacity 0.2s ease;
}

/* Thumbnails Grid - Dynamic and Responsive */
.thumbnails-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    max-height: 350px;
    overflow-y: auto;
    padding: 0.25rem;
    border-radius: 8px;
}

/* Custom scrollbar for thumbnails */
.thumbnails-grid::-webkit-scrollbar {
    width: 6px;
}

.thumbnails-grid::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.thumbnails-grid::-webkit-scrollbar-thumb {
    background: #0078d4;
    border-radius: 3px;
    opacity: 0.7;
}

.thumbnails-grid::-webkit-scrollbar-thumb:hover {
    background: #106ebe;
    opacity: 1;
}

.gallery-thumbnail {
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    position: relative;
    opacity: 0.7;
}

.gallery-thumbnail:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 1;
}

.gallery-thumbnail.active {
    border-color: #0078d4;
    transform: scale(1.02);
    opacity: 1;
    box-shadow: 0 6px 16px rgba(0, 120, 212, 0.25);
}

.gallery-thumbnail img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    transition: transform 0.2s ease;
}

.gallery-thumbnail:hover img {
    transform: scale(1.1);
}

/* Loading State */
.gallery-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 500px;
    color: var(--text-muted);
}

/* Enhanced Mobile Responsiveness */
@media (max-width: 1200px) {
    .main-gallery-image img {
        height: 450px;
    }

    .gallery-info {
        padding: 1.25rem;
    }
}

@media (max-width: 992px) {
    #photoGalleryModal .modal-dialog {
        max-width: 95%;
        margin: 1rem auto;
    }

    .thumbnails-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
        max-height: 280px;
    }

    .main-gallery-image img {
        height: 380px;
    }

    .gallery-nav-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .gallery-counter {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
}

@media (max-width: 768px) {
    #photoGalleryModal .modal-dialog {
        max-width: 98%;
        margin: 0.5rem auto;
    }

    #photoGalleryModal .modal-body {
        padding: 1rem !important;
    }

    .row {
        flex-direction: column;
    }

    .main-gallery-image img {
        height: 280px;
    }

    .gallery-info {
        padding: 1rem;
        margin-bottom: 1rem;
        margin-top: 1rem;
    }

    .thumbnails-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.375rem;
        max-height: 200px;
        margin-top: 0.5rem;
    }

    .gallery-thumbnail img {
        height: 55px;
    }

    .gallery-nav-btn {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }

    .gallery-prev {
        left: 10px;
    }

    .gallery-next {
        right: 10px;
    }

    .gallery-counter {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
        bottom: 10px;
        right: 10px;
    }
}

@media (max-width: 576px) {
    #photoGalleryModal .modal-header {
        padding: 0.75rem 1rem;
    }

    #photoGalleryModal .modal-title {
        font-size: 1.1rem;
    }

    .main-gallery-image img {
        height: 250px;
    }

    .gallery-info {
        padding: 0.875rem;
    }

    .thumbnails-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.25rem;
        max-height: 150px;
    }

    .gallery-thumbnail img {
        height: 45px;
    }

    #photoGalleryModal .modal-footer {
        padding: 0.75rem 1rem;
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }

    #photoGalleryModal .modal-footer .d-flex {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }

    #photoGalleryModal .modal-footer .btn {
        width: 100%;
    }
}

/* Dark Theme Support */
[data-theme="dark"] .gallery-info {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border-color: #475569;
}

[data-theme="dark"] .gallery-info h5 {
    color: #58a6ff;
}

[data-theme="dark"] .gallery-info p {
    color: #cbd5e1;
}

[data-theme="dark"] .gallery-thumbnail {
    background: #334155;
}

[data-theme="dark"] .gallery-thumbnail.active {
    border-color: #58a6ff;
}

[data-theme="dark"] .main-gallery-image {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Gallery Modal Specific Overrides */
#photoGalleryModal .modal-content {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    box-shadow: 0 16px 64px rgba(0, 0, 0, 0.15);
}

#photoGalleryModal .modal-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-bottom: 1px solid var(--border-color);
    border-radius: 12px 12px 0 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

#photoGalleryModal .modal-header .bi-images {
    color: #0078d4 !important;
    text-shadow: 0 1px 2px rgba(0, 120, 212, 0.2);
}

[data-theme="dark"] #photoGalleryModal .modal-content {
    background: #1e1e1e;
    border-color: #333333;
    box-shadow: 0 16px 64px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] #photoGalleryModal .modal-header {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border-bottom-color: #404040;
}

[data-theme="dark"] #photoGalleryModal .modal-title {
    color: #ffffff;
}