/* Modern Gallery Styles */
.modern-gallery-container {
    width: 100%;
    margin: 0;
    padding: 0;
}

.gallery-header {
    text-align: center;
    margin-top: 20px;
    color: #666;
    font-size: 14px;
    font-style: italic;
}

/* Desktop Gallery Layout */
.desktop-gallery {
    display: grid;
    gap: 10px;
    margin-bottom: 20px;
    padding: 0 5px; /* Reduced from 10px to 5px */
}

/* 5+ images: 1 big left, 4 small right (2x2) */
.desktop-gallery:has(.gallery-main-left) {
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    height: 400px;
}

.gallery-main-left {
    grid-column: 1;
    grid-row: 1 / 3;
}

.gallery-small {
    grid-column: 2 / 4;
}

.gallery-small:nth-of-type(2) { /* Image 2 - top left of right side */
    grid-column: 2;
    grid-row: 1;
}

.gallery-small:nth-of-type(3) { /* Image 3 - top right of right side */
    grid-column: 3;
    grid-row: 1;
}

.gallery-small:nth-of-type(4) { /* Image 4 - bottom left of right side */
    grid-column: 2;
    grid-row: 2;
}

.gallery-small:nth-of-type(5) { /* Image 5 - bottom right of right side */
    grid-column: 3;
    grid-row: 2;
}

/* 4 images: 2x2 grid */
.gallery-four-item {
    aspect-ratio: 1;
}

.desktop-gallery:has(.gallery-four-item) {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    height: 400px;
}

/* 3 images: 1 big top, 2 small bottom */
.gallery-three-main {
    grid-column: 1 / 3;
    grid-row: 1;
}

.gallery-three-small {
    grid-column: 1;
    grid-row: 2;
}

.gallery-three-small:nth-of-type(3) {
    grid-column: 2;
}

.desktop-gallery:has(.gallery-three-main) {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 2fr 1fr;
    height: 400px;
}

/* 1-2 images: simple grid */
.gallery-simple {
    aspect-ratio: 16/9;
}

.desktop-gallery:has(.gallery-simple) {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    height: 300px;
}

.gallery-hidden {
    display: none;
}

/* Mobile Gallery Layout - Single Image Carousel */
.mobile-gallery {
    display: none;
    position: relative;
    width: 100%;
    height: 300px;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.mobile-gallery-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.mobile-gallery-item {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.3s ease;
    cursor: pointer;
}

.mobile-gallery-item.active {
    opacity: 1;
}

.mobile-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0; /* Remove border radius for border-to-border effect */
}

/* Mobile Navigation Arrows */
.mobile-nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.7);
    border: none;
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s ease;
    font-size: 0;
    line-height: 1;
    padding: 0;
    margin: 0;
}

.mobile-nav-arrow::before {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border-style: solid;
}

.mobile-nav-arrow.prev::before {
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 12px solid white;
}

.mobile-nav-arrow.next::before {
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-left: 12px solid white;
}

.mobile-nav-arrow:hover {
    background: rgba(0,0,0,0.8);
    transform: translateY(-50%) scale(1.1);
}

.mobile-nav-arrow.prev {
    left: 15px;
}

.mobile-nav-arrow.next {
    right: 15px;
}

.mobile-nav-arrow.hidden {
    display: none;
}

/* Mobile Pagination Dots */
.mobile-pagination {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 10;
}

.mobile-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.5);
    cursor: pointer;
    transition: all 0.3s ease;
}

.mobile-dot.active {
    background: white;
    transform: scale(1.2);
}

.mobile-dot:hover {
    background: rgba(255,255,255,0.8);
}

/* Image Count Overlay */
.mobile-image-count {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    z-index: 10;
}

/* Legacy mobile classes for backward compatibility */
.mobile-main-left,
.mobile-small,
.mobile-four-item,
.mobile-three-main,
.mobile-three-small,
.mobile-simple,
.mobile-hidden {
    display: none;
}

/* Gallery Items */
.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background: #f5f5f5;
}

.gallery-item:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.gallery-item:hover img {
    transform: scale(1.05);
}

.gallery-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-item:hover .gallery-overlay {
    opacity: 1;
}

.gallery-zoom-icon {
    color: white;
    font-size: 24px;
    font-weight: normal;
}

/* +X images overlay for 5th image when more than 5 images */
.gallery-item:nth-child(5) .gallery-overlay {
    background: transparent;
    opacity: 1;
    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
    padding: 8px;
}

.gallery-item:nth-child(5) .gallery-zoom-icon {
    font-size: 14px;
    background: rgba(0,0,0,0.8);
    padding: 6px 10px;
    border-radius: 14px;
    border: 1px solid white;
    color: white;
    font-weight: normal;
}

/* Full Screen Modal */
.gallery-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    min-height: 100vh;
    background-color: rgba(0,0,0,0.9);
    overflow: hidden;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Ensure full height on all devices */
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body.gallery-open {
    overflow: hidden;
    height: 100vh;
    position: fixed;
    width: 100%;
}

.gallery-modal-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.gallery-main-image {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 20px;
}

.gallery-main-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

/* Navigation Arrows */
.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.5);
    border: none;
    color: transparent;
    font-size: 32px;
    font-weight: 300;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.3s ease;
    z-index: 10000;
    line-height: 1;
    overflow: hidden;
}

.gallery-nav:hover {
    background: rgba(0,0,0,0.7);
    transform: translateY(-50%) scale(1.1);
}

.gallery-nav::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 0;
    height: 0;
}

.gallery-prev::before {
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 12px solid white;
}

.gallery-next::before {
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-left: 12px solid white;
}

.gallery-prev {
    left: 30px;
}

.gallery-next {
    right: 30px;
}

/* Close Button */
.gallery-close {
    position: absolute;
    top: 30px;
    right: 30px;
    background: rgba(0,0,0,0.5);
    border: none;
    color: transparent;
    font-size: 32px;
    font-weight: 300;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.3s ease;
    z-index: 10000;
    line-height: 1;
    overflow: hidden;
}

.gallery-close:hover {
    background: rgba(0,0,0,0.7);
    transform: scale(1.1);
}

.gallery-close::before {
    content: '';
    position: absolute;
    width: 24px;
    height: 3px;
    background: white;
    border-radius: 2px;
    transform: rotate(45deg);
}

.gallery-close::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 3px;
    background: white;
    border-radius: 2px;
    transform: rotate(-45deg);
}

/* Indicators/Dots */
.gallery-indicators {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 10000;
}

.gallery-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    cursor: pointer;
    transition: all 0.3s ease;
}

.gallery-dot.active {
    background: white;
    transform: scale(1.2);
}

.gallery-dot:hover {
    background: rgba(255,255,255,0.6);
}

/* Mobile-specific overrides */
@media (max-width: 768px) {
    /* Force full viewport on mobile */
    .gallery-modal {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        min-height: 100vh !important;
        max-height: 100vh !important;
        margin: 0 !important;
        padding: 0 !important;
        transform: none !important;
        z-index: 99999 !important;
    }
    
    .gallery-modal-content {
        width: 100% !important;
        height: 100% !important;
        min-height: 100% !important;
        max-height: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        display: flex !important;
        flex-direction: column !important;
    }
    
    /* Ensure body doesn't scroll */
    body.gallery-open {
        overflow: hidden !important;
        height: 100vh !important;
        position: fixed !important;
        width: 100% !important;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .desktop-gallery {
        display: none !important;
    }
    
    .mobile-gallery {
        display: block !important;
        height: 300px !important;
    }
    
    .mobile-gallery-container {
        display: block !important;
    }
    
    
    /* Mobile Gallery Modal */
    .gallery-modal {
        padding: 0;
        margin: 0;
        width: 100vw;
        height: 100vh;
        left: 0;
        top: 0;
    }
    
    .gallery-modal-content {
        padding: 0;
        margin: 0;
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
    }
    
    .gallery-main-image {
        flex: 1;
        padding: 0;
        margin: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: calc(100vh - 80px);
        overflow: hidden;
    }
    
    .gallery-main-image img {
        max-width: 100%;
        max-height: 100%;
        width: auto;
        height: auto;
        object-fit: contain;
        display: block;
    }
    
    .gallery-nav {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .gallery-prev::before {
        border-top: 5px solid transparent;
        border-bottom: 5px solid transparent;
        border-right: 8px solid white;
    }
    
    .gallery-next::before {
        border-top: 5px solid transparent;
        border-bottom: 5px solid transparent;
        border-left: 8px solid white;
    }
    
    .gallery-prev {
        left: 10px;
    }
    
    .gallery-next {
        right: 10px;
    }
    
    .gallery-close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .gallery-close::before,
    .gallery-close::after {
        width: 16px;
        height: 2px;
    }
    
    .gallery-indicators {
        bottom: 10px;
    }
    
    .gallery-dot {
        width: 6px;
        height: 6px;
    }
}

@media (max-width: 480px) {
    .mobile-gallery {
        height: 250px !important;
    }
    
    .mobile-nav-arrow {
        width: 45px;
        height: 45px;
    }
    
    .mobile-nav-arrow.prev::before {
        border-top: 7px solid transparent;
        border-bottom: 7px solid transparent;
        border-right: 10px solid white;
    }
    
    .mobile-nav-arrow.next::before {
        border-top: 7px solid transparent;
        border-bottom: 7px solid transparent;
        border-left: 10px solid white;
    }
    
    .mobile-nav-arrow.prev {
        left: 10px;
    }
    
    .mobile-nav-arrow.next {
        right: 10px;
    }
    
    .mobile-pagination {
        bottom: 10px;
    }
    
    .mobile-dot {
        width: 6px;
        height: 6px;
    }
    
    .mobile-image-count {
        top: 10px;
        right: 10px;
        padding: 4px 8px;
        font-size: 11px;
    }
    
    /* Extra small mobile adjustments */
    .gallery-modal {
        padding: 0;
        margin: 0;
        width: 100vw;
        height: 100vh;
        left: 0;
        top: 0;
    }
    
    .gallery-main-image {
        flex: 1;
        padding: 0;
        margin: 0;
        height: calc(100vh - 60px);
        overflow: hidden;
    }
    
    .gallery-nav {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
    
    .gallery-prev::before {
        border-top: 4px solid transparent;
        border-bottom: 4px solid transparent;
        border-right: 6px solid white;
    }
    
    .gallery-next::before {
        border-top: 4px solid transparent;
        border-bottom: 4px solid transparent;
        border-left: 6px solid white;
    }
    
    .gallery-prev {
        left: 5px;
    }
    
    .gallery-next {
        right: 5px;
    }
    
    .gallery-close {
        top: 5px;
        right: 5px;
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
    
    .gallery-close::before,
    .gallery-close::after {
        width: 14px;
        height: 2px;
    }
    
    .gallery-indicators {
        bottom: 5px;
    }
    
    .gallery-dot {
        width: 5px;
        height: 5px;
    }
}

/* Extra small screens - maintain layout consistency */
@media (max-width: 360px) {
    .mobile-gallery {
        height: 220px !important;
    }
    
    .mobile-nav-arrow {
        width: 40px;
        height: 40px;
    }
    
    .mobile-nav-arrow.prev::before {
        border-top: 6px solid transparent;
        border-bottom: 6px solid transparent;
        border-right: 8px solid white;
    }
    
    .mobile-nav-arrow.next::before {
        border-top: 6px solid transparent;
        border-bottom: 6px solid transparent;
        border-left: 8px solid white;
    }
    
    .mobile-nav-arrow.prev {
        left: 8px;
    }
    
    .mobile-nav-arrow.next {
        right: 8px;
    }
    
    .mobile-pagination {
        bottom: 8px;
    }
    
    .mobile-dot {
        width: 5px;
        height: 5px;
    }
    
    .mobile-image-count {
        top: 8px;
        right: 8px;
        padding: 3px 6px;
        font-size: 10px;
    }
}

/* Loading Animation */
.gallery-item img {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.gallery-item img[src] {
    animation: none;
    background: none;
}

/* Smooth transitions */
* {
    box-sizing: border-box;
}

.gallery-modal {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.gallery-main-image img {
    animation: zoomIn 0.3s ease;
}

@keyframes zoomIn {
    from { 
        opacity: 0;
        transform: scale(0.8);
    }
    to { 
        opacity: 1;
        transform: scale(1);
    }
}
