/* 
 * Image Styles - Ensures full image display without cropping
 * This file contains styles to ensure images display completely without cropping
 */

/* Core image display styles */
.post-image {
    display: block;
    max-width: 100%;
    margin: 1rem auto;
    position: relative;
}

.post-image img {
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 350px; /* Significantly reduced max-height for desktop */
    object-fit: contain;
    object-position: center !important; /* Changed from top to center for better alignment */
    display: block;
    margin: 0 auto !important; /* Center horizontally */
    padding: 0 !important; /* No padding anywhere */
    vertical-align: middle !important; /* Better vertical alignment */
}

/* Desktop uniform width for post images */
@media screen and (min-width: 768px) {
    .post-image img {
        width: 500px !important; /* Uniform width on desktop */
        max-width: 500px !important;
    }
    
    .post-image {
        width: 500px !important; /* Uniform container width */
        max-width: 500px !important;
        margin: 0 auto !important;
    }
}

/* Enhanced image container styles */
.image-container {
    position: relative;
    overflow: visible !important; /* Critical: Allow overflow to ensure full image display */
    width: 100%;
    margin-bottom: 1rem;
    min-height: 100px;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 5px;
    max-height: none !important; /* Remove any max-height restrictions */
}

.image-container img {
    display: block;
    width: auto !important; /* Changed from 100% to auto to prevent stretching */
    max-width: 100%;
    height: auto !important; /* Force height to be auto */
    object-fit: contain !important; /* This ensures the image is shown completely without cropping */
    object-position: center !important; /* Changed from top to center for better alignment */
    max-height: 350px !important; /* Further reduced for desktop */
    margin: 0 auto !important; /* Center the image horizontally */
    padding: 0 !important; /* No padding anywhere */
    transition: opacity 0.3s ease-in-out;
    vertical-align: middle !important; /* Changed from top to middle for better alignment */
}

/* Desktop uniform width for image containers */
@media screen and (min-width: 768px) {
    .image-container img {
        width: 500px !important; /* Uniform width on desktop */
        max-width: 500px !important;
    }
    
    .image-container {
        width: 500px !important; /* Uniform container width */
        max-width: 500px !important;
        margin: 0 auto !important;
    }
}

/* Make sure images in media carousel display fully */
.media-item img, 
.media-carousel img {
    max-height: 350px !important;
    width: auto !important; /* Changed from default to auto to prevent stretching */
    object-fit: contain !important;
    object-position: center !important; /* Changed from top to center for better alignment */
    height: auto !important;
    margin: 0 auto !important; /* Center horizontally */
    padding: 0 !important; /* No padding anywhere */
    vertical-align: middle !important; /* Changed from top to middle for better alignment */
}

/* Desktop uniform width for media carousel images */
@media screen and (min-width: 768px) {
    .media-item img, 
    .media-carousel img {
        width: 500px !important; /* Uniform width on desktop */
        max-width: 500px !important;
    }
    
    .media-item,
    .media-carousel {
        width: 500px !important; /* Uniform container width */
        max-width: 500px !important;
        margin: 0 auto !important;
    }
}

/* Mobile adjustments */
@media (max-width: 767px) {
    .post-image {
        margin: 0.5rem 0;
        min-height: 100px;
        max-height: 310px;
        height: auto !important;
        display: flex;
        align-items: center;
        justify-content: center;
        background-color: transparent !important;
        overflow: hidden !important;
    }

    .image-container {
        min-height: 50px;
        background-color: transparent !important;
        max-height: 310px;
        overflow: hidden !important;
    }
    
    /* Fix for the white space issue below images */
    .image-container::after,
    .post-image::after,
    .media-item::after,
    .media-carousel::after {
        display: none !important;
        content: none !important;
        height: 0 !important;
        min-height: 0 !important;
        max-height: 0 !important;
        visibility: hidden !important;
        overflow: hidden !important;
    }
}

/* Ensure older posts display correctly */
.post-content .post-image,
.card-body .post-image,
.media-carousel .post-image,
.media-item .post-image {
    max-width: 100% !important;
    margin: 1rem auto !important;
    overflow: visible !important;
    display: flex !important;
    align-items: center !important; /* Changed from flex-start to center for better alignment */
    justify-content: center !important; /* Added to ensure horizontal centering */
    padding: 0 !important; /* No padding anywhere */
}

.post-content .post-image img,
.card-body .post-image img,
.media-carousel .post-image img,
.media-item .post-image img {
    max-width: 100% !important;
    width: auto !important; /* Added to prevent stretching */
    height: auto !important;
    object-fit: contain !important;
    object-position: center !important; /* Changed from top to center for better alignment */
    max-height: 350px !important;
    margin: 0 auto !important; /* Center horizontally */
    padding: 0 !important; /* No padding anywhere */
    vertical-align: middle !important; /* Changed from top to middle for better alignment */
}

/* Loading indicator positioning */
.loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
}

/* Prevent image cropping in carousels */
.media-carousel {
    overflow: visible !important;
}

.media-item {
    overflow: visible !important;
}

/* Modal image styles */
#imageModal .modal-dialog {
    max-width: 100%;
    margin: 0;
    display: flex;
    align-items: center;
    height: 100vh;
}

#imageModal .modal-content {
    background-color: rgba(0, 0, 0, 0.9);
    border: none;
    border-radius: 0;
    height: 100%;
}

#imageModal .modal-body {
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

#modalImage {
    max-height: 80vh;
    max-width: 80vw;
    object-fit: contain;
    margin: auto;
    cursor: pointer;
}

/* Special modal handling for narrow-tall images */
#modalImage.narrow-tall-image {
    width: 80vw !important;
    object-fit: cover !important;
    object-position: top !important; /* Show from the very top, crop only bottom 30% */
    height: 80vh !important; /* Fixed height to ensure consistent cropping */
}

/* Modal navigation controls */
.modal-navigation-controls {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Allows clicking through to the image */
}

.modal-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(0, 0, 0, 0.3);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    pointer-events: auto; /* Restores click events on the buttons */
}

.modal-nav-btn:hover {
    background-color: rgba(0, 0, 0, 0.6);
}

.modal-nav-btn.prev {
    left: 20px;
}

.modal-nav-btn.next {
    right: 20px;
}

/* Make navigation buttons more visible on mobile */
@media (max-width: 768px) {
    .modal-nav-btn {
        width: 40px;
        height: 40px;
    }
    
    .modal-nav-btn.prev {
        left: 10px;
    }
    
    .modal-nav-btn.next {
        right: 10px;
    }
}

/* Add a pointer cursor to indicate images are clickable */
.image-container img,
.media-item img {
    cursor: pointer;
}

/* Special styling for narrow-tall images */
.narrow-tall-image {
    width: auto !important; /* Change from 100% to auto to maintain better aspect ratio */
    max-width: 70% !important; /* Limit width to prevent extreme stretching */
    object-fit: contain !important; /* Change to contain to show more of the image */
    /* Show from the very top, no cropping */
    object-position: top !important; /* Align to top explicitly */
    height: 600px !important; /* Significantly increased height to show much more of the image length */
    display: block !important;
    margin-top: 0 !important; /* Ensure image starts at the very top */
}

/* Container for narrow-tall images */
.narrow-tall-container {
    max-height: 610px !important; /* Increased to match the taller image height plus a small margin */
    overflow: visible !important; /* Changed from hidden to visible to show full image */
    display: flex !important;
    justify-content: center !important;
    align-items: flex-start !important; /* Align to top */
    padding-top: 0 !important; /* No padding at the top */
    width: 100% !important;
    vertical-align: top !important; /* Additional alignment for top */
}