/* Gallery - ENHANCED STYLES */
.lorry-single-gallery {
    position: relative;
    margin-bottom: 30px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #eee;
}

.lorry-single-gallery-enhanced {
    width: 100%;
}

/* Main Gallery Container - Fixed Aspect Ratio */
.lorry-single-gallery .main-gallery-container {
    position: relative;
    width: 100%;
    margin-bottom: 15px;
    overflow: hidden;
    border-radius: 6px;
    background: #f5f5f5;
    /* Set fixed aspect ratio - 16:9 (you can change this) */
    aspect-ratio: 3/2;
}

.lorry-single-gallery .main-gallery-image {
    width: 100%;
    height: 100%;
    display: block;
    cursor: pointer;
    transition: transform 0.3s ease;
    /* CRITICAL: Use object-fit cover to crop consistently */
    object-fit: cover;
    object-position: center;
}

.lorry-single-gallery .main-gallery-image:hover {
    transform: scale(1.02);
}

/* Gallery counter positioning remains the same */
.lorry-single-gallery .gallery-counter {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 14px;
    font-weight: bold;
    z-index: 2;
}

.lorry-single-gallery .gallery-nav-thumb {
    flex-shrink: 0;
    width: 80px;
    height: 80px; 
    object-fit: cover;
    object-position: center;
    border-radius: 6px;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.3s ease;
}

.lorry-single-gallery .gallery-nav-thumb:hover {
    border-color: #000;
    transform: scale(1.05);
}

.lorry-single-gallery .gallery-nav-thumb.active {
    border-color: orange;
}

/* Responsive adjustments for different screen sizes */
@media (max-width: 768px) {
    .lorry-single-gallery .main-gallery-container {
        /* Slightly taller aspect ratio for mobile */
        aspect-ratio: 3/2;
    }
    
    .lorry-single-gallery .gallery-nav-thumb {
        width: 60px;
        height: 45px;
    }
}

@media (max-width: 480px) {
    .lorry-single-gallery .main-gallery-container {
        /* Even taller for very small screens */
        aspect-ratio: 3/2;
    }
    
    .lorry-single-gallery .gallery-nav-thumb {
        width: 50px;
        height: 38px;
    }
}

/* Lightbox Styles */
.lorry-lightbox.lorry-listing-lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10002;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.lorry-lightbox.lorry-listing-lightbox.active {
    display: flex;
}

/* FIXED: Lightbox content container with proper sizing */
.lorry-listing-lightbox .lightbox-content {
    position: relative;
    width: calc(100vw - 40px);
    height: calc(100vh - 40px);
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 40px);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* FIXED: Image styling to properly fit within container */
.lorry-listing-lightbox .lightbox-content img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: center;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: block;
    margin: 0;
    /* Ensure image never exceeds container */
    flex-shrink: 1;
}

/* Close button - positioned outside content area */
.lorry-listing-lightbox .lightbox-close {
    position: fixed !important;
    top: 20px !important;
    right: 20px !important;
    background: rgba(0, 0, 0, 0.8) !important;
    border: 2px solid rgba(255, 255, 255, 0.8) !important;
    border-radius: 50% !important;
    color: white !important;
    font-size: 24px !important;
    font-weight: bold !important;
    cursor: pointer;
    padding: 0 !important;
    width: 50px !important;
    height: 50px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 10001 !important;
    line-height: 1 !important;
    text-align: center !important;
}

.lorry-listing-lightbox .lightbox-close:hover {
    background: rgba(255, 255, 255, 0.9) !important;
    color: #000 !important;
    border-color: rgba(255, 255, 255, 1) !important;
    transform: scale(1.1) !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3) !important;
}

.lorry-listing-lightbox .lightbox-close:active {
    transform: scale(0.95) !important;
}

.lorry-listing-lightbox .lightbox-close.style-2 {
    background: rgba(255, 255, 255, 0.95) !important;
    color: #333 !important;
    border: none !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3) !important;
}

.lorry-listing-lightbox .lightbox-close.style-2:hover {
    background: #ff4444 !important;
    color: white !important;
    transform: scale(1.1) rotate(90deg) !important;
}

/* Small desktop screens - adjust container size */
@media (max-height: 700px) and (min-width: 769px) {
    .lorry-listing-lightbox .lightbox-content {
        width: calc(100vw - 60px);
        height: calc(100vh - 80px);
        max-width: calc(100vw - 60px);
        max-height: calc(100vh - 80px);
    }
    
    .lorry-listing-lightbox .lightbox-close {
        top: 15px !important;
        right: 15px !important;
        width: 45px !important;
        height: 45px !important;
        font-size: 22px !important;
    }
}

/* Very small desktop height */
@media (max-height: 600px) and (min-width: 769px) {
    .lorry-listing-lightbox .lightbox-content {
        width: calc(100vw - 80px);
        height: calc(100vh - 100px);
        max-width: calc(100vw - 80px);
        max-height: calc(100vh - 100px);
    }
    
    .lorry-listing-lightbox .lightbox-close {
        top: 10px !important;
        right: 10px !important;
        width: 40px !important;
        height: 40px !important;
        font-size: 20px !important;
    }
}

/* Tablet styles */
@media (max-width: 768px) {
    .lorry-lightbox.lorry-listing-lightbox {
        padding: 15px;
    }
    
    .lorry-listing-lightbox .lightbox-content {
        width: calc(100vw - 30px);
        height: calc(100vh - 120px);
        max-width: calc(100vw - 30px);
        max-height: calc(100vh - 120px);
    }
    
    .lorry-listing-lightbox .lightbox-close {
        top: 15px !important;
        right: 15px !important;
        width: 45px !important;
        height: 45px !important;
        font-size: 22px !important;
    }
}

/* Mobile styles */
@media (max-width: 480px) {
    .lorry-lightbox.lorry-listing-lightbox {
        padding: 10px;
    }
    
    .lorry-listing-lightbox .lightbox-content {
        width: calc(100vw - 20px);
        height: calc(100vh - 140px);
        max-width: calc(100vw - 20px);
        max-height: calc(100vh - 140px);
        min-height: 200px;
    }
    
    .lorry-listing-lightbox .lightbox-close {
        top: 10px !important;
        right: 10px !important;
        width: 44px !important;
        height: 44px !important;
        font-size: 20px !important;
        min-width: 44px !important;
        min-height: 44px !important;
    }
}

/* Focus and accessibility */
.lorry-listing-lightbox .lightbox-close:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .lorry-listing-lightbox .lightbox-close {
        transition: none;
    }
    
    .lorry-listing-lightbox .lightbox-close:hover {
        transform: none !important;
    }
}

.lorry-single-gallery .gallery-thumbnail-nav {
    display: flex;
    gap: 10px;
    padding: 6px;
    overflow-x: auto;
}

@media (max-width: 768px) {
    .lorry-single-gallery .gallery-nav-thumb {
        width: 60px;
        height: 60px;
    }
    
    .lorry-single-gallery .gallery-thumbnail-nav {
        gap: 8px;
        padding: 5px 0;
    }
    
    .lorry-single-gallery .main-gallery-container {
        margin-bottom: 10px;
    }
}

/* Mobile lightbox improvements */
@media (max-width: 768px) {
    .lorry-lightbox.lorry-listing-lightbox {
        padding: 10px;
    }
    
    .lorry-listing-lightbox .lightbox-content {
        max-width: calc(100vw - 20px);
        max-height: calc(100vh - 20px);
    }
    
    .lorry-listing-lightbox .lightbox-close {
        top: 15px !important;
        right: 15px !important;
        width: 45px !important;
        height: 45px !important;
        font-size: 22px !important;
    }
}

@media (max-width: 480px) {
    .lorry-lightbox.lorry-listing-lightbox {
        padding: 5px;
    }
    
    .lorry-listing-lightbox .lightbox-content {
        max-width: calc(100vw - 10px);
        max-height: calc(100vh - 10px);
    }
    
    .lorry-listing-lightbox .lightbox-close {
        top: 10px !important;
        right: 10px !important;
        width: 40px !important;
        height: 40px !important;
        font-size: 20px !important;
    }
}

