/* Gallery Modal Container */
.gallery-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.gallery-modal.active {
    opacity: 1;
    visibility: visible;
}

/* Gallery Content Wrapper */
.gallery-content {
    position: relative;
    width: 95%;
    max-width: 1000px;
    height: 90%;
    max-height: 800px;
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
}

/* Main Image Container */
.gallery-container {
    position: relative;
    flex: 0 1 auto; /* Changed from flex: 1 to prevent taking all space */
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0; /* Important for flex item sizing */
    max-height: 75%; /* Limit height to leave room for caption */
}

.gallery-image-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    position: relative; /* Added to position caption absolutely */
}

/* UPDATED: Improved image responsiveness */
.gallery-image-container img {
    max-width: 80%;
    max-height: 65vh;
    width: auto; /* Allow natural sizing */
    height: auto; /* Allow natural sizing */
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
}

/* Navigation Controls */
.gallery-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    z-index: 1010;
    transition: color 0.3s ease;
}

.gallery-close:hover {
    color: var(--accent-color);
}

.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    font-size: 1.5rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.3s ease;
    z-index: 1005;
}

.gallery-nav:hover {
    background-color: var(--secondary-color);
}

.gallery-prev {
    left: 10px;
}

.gallery-next {
    right: 10px;
}

/* UPDATED: Indicators and Caption */
.gallery-indicators {
    display: flex;
    justify-content: center;
    margin-top: 110px;
    flex-wrap: wrap;
    position: relative; /* Ensure it's positioned properly */
    z-index: 10; /* Make sure it's above other elements */
    margin-bottom: 10px; /* Add space between indicators and caption */
}

.gallery-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.5);
    margin: 0 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.gallery-dot.active {
    background-color: var(--secondary-color);
}

/* UPDATED: Caption positioned below image */
.gallery-caption {
    color: white;
    text-align: center;
    padding: 10px 15px;
    font-size: 0.95rem;
    line-height: 1.4;
    max-width: 90%;
    margin: 10px auto 0;
    position: relative; /* Position it properly in the flow */
    z-index: 10; /* Ensure it's above other elements */
    background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent background */
    border-radius: 4px; /* Rounded corners */
    bottom: auto; /* Remove any bottom positioning */
    left: auto; /* Remove any left positioning */
    right: auto; /* Remove any right positioning */
    top: auto; /* Remove any top positioning */
}

.gallery-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin-top: 10px;
    color: var(--secondary-color);
    font-size: 0.85rem;
}

/* UPDATED: Improved Responsive Adjustments */
@media (max-width: 992px) {
    .gallery-content {
        max-width: 90%;
        max-height: 85vh;
    }
    
    .gallery-image-container img {
        max-width: 85%;
        max-height: 60vh;
    }
    
    .gallery-container {
        max-height: 70%;
    }
}

@media (max-width: 768px) {
    .gallery-content {
        height: 85%;
        padding: 15px;
    }
    
    .gallery-nav {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
    
    .gallery-image-container img {
        max-width: 90%;
        max-height: 55vh;
    }
    
    .gallery-caption {
        font-size: 0.9rem;
        padding: 8px 12px;
    }
    
    .gallery-container {
        max-height: 65%;
    }
}

@media (max-width: 576px) {
    .gallery-content {
        width: 100%;
        height: 90%;
        max-height: none;
        padding: 10px;
    }
    
    .gallery-image-container img {
        max-width: 95%;
        max-height: 50vh;
    }
    
    .gallery-nav {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }
    
    .gallery-dot {
        width: 8px;
        height: 8px;
        margin: 0 3px;
    }
    
    .gallery-close {
        top: -35px;
        font-size: 1.8rem;
    }
    
    .gallery-container {
        max-height: 60%;
    }
    
    .gallery-caption {
        padding: 6px 10px;
        margin-top: 8px;
    }
}

/* ADDED: Extra small screens */
@media (max-width: 400px) {
    .gallery-content {
        padding: 5px;
    }
    
    .gallery-image-container {
        padding: 5px;
    }
    
    .gallery-image-container img {
        max-width: 100%;
        max-height: 45vh;
    }
    
    .gallery-nav {
        width: 30px;
        height: 30px;
        font-size: 0.9rem;
    }
    
    .gallery-container {
        max-height: 55%;
    }
    
    .gallery-caption {
        padding: 5px 8px;
        font-size: 0.85rem;
        margin-top: 5px;
    }
    
    .gallery-indicators {
        margin-top: 8px;
        margin-bottom: 5px;
    }
}

/* Landscape orientation adjustments */
@media (max-height: 600px) {
    .gallery-content {
        max-height: 95vh;
    }
    
    .gallery-image-container img {
        max-height: 60vh;
    }
    
    .gallery-caption {
        padding: 5px 8px;
        font-size: 0.85rem;
    }
    
    .gallery-container {
        max-height: 65%;
    }
}

/* ADDED: Small height screens in landscape mode */
@media (max-height: 450px) {
    .gallery-content {
        padding: 5px;
    }
    
    .gallery-image-container img {
        max-height: 65vh;
        max-width: 70%;
    }
    
    .gallery-indicators {
        margin-top: 5px;
        margin-bottom: 3px;
    }
    
    .gallery-caption {
        padding: 3px 6px;
        font-size: 0.8rem;
        margin-top: 3px;
    }
    
    .gallery-container {
        max-height: 60%;
    }
}

