/* Image Carousel - Full Screen Overlay Styles */

/* Carousel Overlay */
.image-carousel-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Ensure carousel doesn't exceed viewport */
    max-height: 100vh;
    overflow: hidden;
    /* Respond to viewport height changes */
    min-height: 100vh;
}

/* Backdrop */
.carousel-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
}

/* Main Container */
.carousel-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    z-index: 1;
}

/* Header */
.carousel-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent);
    z-index: 10;
}

.carousel-counter {
    color: white;
    font-size: 1.55rem;
    font-weight: 600;
    background-color: rgba(0, 0, 0, 0.6);
    padding: 0.9rem 1.8rem;
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

.carousel-close {
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    font-size: 1.95rem;
    line-height: 1;
    font-weight: bold;
}

.carousel-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* Content Area */
.carousel-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 0.5rem;
    /* Use viewport height to ensure perfect fit */
    height: calc(100vh - 140px);
    margin-top: 8px;
    margin-bottom: 85px;
    z-index: 25;
}

/* Navigation Buttons */
.carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    z-index: 10;
    font-size: 3.5rem;
    line-height: 0.8;
    font-weight: bold;
    padding-bottom: 7px;
}

.carousel-nav:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%) scale(1.1);
}

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

.carousel-nav.disabled:hover {
    background: rgba(0, 0, 0, 0.5);
    transform: translateY(-50%) scale(1);
}

.carousel-prev {
    left: 2rem;
}

.carousel-next {
    right: 2rem;
}

/* Image Container */
.carousel-image-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    position: relative;
}

.carousel-image {
    max-width: 80%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    height: 100%;
    cursor: pointer;
}

.full-size-popup {
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(39, 39, 39, 0.9);
    color: white;
    padding: 0.6rem 1.5rem;
    border-radius: 0 0 8px 8px;
    font-size: 1.35rem;
    font-weight: 600;
    backdrop-filter: blur(10px);
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 100;
    white-space: nowrap;
    cursor: pointer;
}

.full-size-popup:hover {
    background: rgba(0, 0, 0, 0.9);
}

.carousel-image:hover + .full-size-popup,
.full-size-popup:hover {
    opacity: 0.75;
    transform: translateX(-50%) translateY(0);
}

/* Thumbnails */
.carousel-thumbnails {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.5);
    padding: 0.75rem;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    max-width: 90%;
    overflow-x: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
    /* Ensure thumbnails don't overlap with taskbar */
    max-height: 80px;
}

.carousel-thumbnails::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.carousel-thumbnail {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.carousel-thumbnail:hover {
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.05);
}

.carousel-thumbnail.active {
    border-color: #0d6efd;
    box-shadow: 0 0 10px rgba(13, 110, 253, 0.5);
}

.carousel-thumbnail .thumbnail-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Animations */
@keyframes carouselFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.image-carousel-overlay {
    animation: carouselFadeIn 0.3s ease-out;
}

/* Responsive Design */
@media (max-width: 768px) {
    /* Hide navigation arrows on mobile */
    .carousel-nav {
        display: none !important;
    }
    
    /* Hide counter on mobile */
    .carousel-counter {
        display: none !important;
    }
    
    /* Hide thumbnails on mobile */
    .carousel-thumbnails {
        display: none !important;
    }
    
    /* Header with just close button */
    .carousel-header {
        padding: 0.75rem 1rem;
        justify-content: flex-end;
    }
    
    /* Close button stays visible */
    .carousel-close {
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
    }
    
    /* Content takes full height with bottom padding for mobile nav bars */
    .carousel-content {
        padding: 0.25rem;
        height: calc(100vh - 120px);
        margin-top: 60px;
        margin-bottom: 60px;
    }
    
    /* Image container optimized for mobile */
    .carousel-image-container {
        width: 100%;
        height: 100%;
        padding: 0.25rem;
        padding-top: 6rem;
        padding-bottom: 1rem;
        position: relative;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
    }
    
    /* Always show "View Full Size Image" on mobile - move to top */
    .full-size-popup {
        opacity: 1 !important;
        visibility: visible !important;
        font-size: 1.3rem;
        padding: 0.9rem 1.8rem;
        top: 0.25rem;
        background: rgba(39, 39, 39, 0.95);
        border-radius: 8px;
        margin-top: 4em;
    }
    
    /* Add swipe instruction indicator - move above image */
    .carousel-image-container::after {
        content: '← Tap image to navigate →';
        position: absolute;
        top: 9rem;
        left: 50%;
        transform: translateX(-50%);
        color: white;
        padding: 0.8rem 1.6rem;
        border-radius: 20px;
        font-size: 1.15rem;
        font-weight: 500;
        white-space: nowrap;
        pointer-events: none;
        z-index: 10;
    }
    
    /* Hide swipe instruction if only 1 image */
    .single-image .carousel-image-container::after {
        display: none;
    }
    
    /* Adjust image position to sit below indicators */
    .carousel-image {
        margin-top: 8rem;
        height: auto;
        max-width: 95% !important;
    }
}

@media (max-width: 480px) {
    .carousel-nav {
        width: 35px;
        height: 35px;
    }
    
    .carousel-nav i {
        font-size: 1.2rem;
    }
    
    .carousel-thumbnail {
        width: 40px;
        height: 40px;
    }
    
    .carousel-counter {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .carousel-backdrop {
        background-color: rgba(0, 0, 0, 0.80);
    }
    
    .carousel-counter {
        background-color: rgba(255, 255, 255, 0.1);
    }
    
    .carousel-close {
        background: rgba(255, 255, 255, 0.1);
    }
    
    .carousel-nav {
        background: rgba(255, 255, 255, 0.1);
    }
    
    .carousel-thumbnails {
        background: rgba(255, 255, 255, 0.1);
    }
}

/* Loading state */
.carousel-image.loading {
    opacity: 0.5;
    filter: blur(2px);
}

/* Smooth transitions for all interactive elements */
.carousel-container * {
    transition: all 0.2s ease;
}

/* Focus styles for accessibility */
.carousel-close:focus,
.carousel-nav:focus,
.carousel-thumbnail:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .carousel-backdrop {
        background-color: rgba(0, 0, 0, 1);
    }
    
    .carousel-counter,
    .carousel-close,
    .carousel-nav {
        background-color: rgba(255, 255, 255, 0.9);
        color: black;
    }
    
    .carousel-thumbnails {
        background-color: rgba(255, 255, 255, 0.9);
    }
}
