/* Elegant Gallery - Frontend Styles */

/* Gallery Container */
.elegant-gallery {
    width: 100%;
    margin: 2rem 0;
}

/* Grid Layout */
.elegant-gallery-grid {
    display: grid;
    grid-template-columns: repeat(var(--eg-columns-desktop, 3), 1fr);
    gap: var(--eg-spacing, 15px);
}

/* Masonry Layout */
.elegant-gallery-masonry .elegant-gallery-grid {
    display: grid;
    grid-template-columns: repeat(var(--eg-columns-desktop, 3), 1fr);
    grid-auto-rows: 10px;
    gap: var(--eg-spacing, 15px);
}

.elegant-gallery-masonry .elegant-gallery-item {
    grid-row-end: span var(--row-span, 20);
}

/* Gallery Item */
.elegant-gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: var(--eg-border-radius, 8px);
    background: #f5f5f5;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.elegant-gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
}

/* Item Inner */
.elegant-gallery-item-inner {
    position: relative;
    width: 100%;
    padding-top: 100%;
    overflow: hidden;
}

/* Gallery Image */
.elegant-gallery-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Lazy Loading */
.elegant-gallery-image.lazy {
    opacity: 0;
    transition: opacity 0.4s ease;
}

.elegant-gallery-image.lazy.loaded {
    opacity: 1;
}

/* Overlay */
.elegant-gallery-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0) 0%,
        rgba(0, 0, 0, 0.7) 100%
    );
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Zoom Button */
.elegant-gallery-zoom {
    width: 60px;
    height: 60px;
    border: none;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.elegant-gallery-zoom:hover {
    transform: scale(1.1);
    background: #fff;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.elegant-gallery-zoom svg {
    width: 28px;
    height: 28px;
    color: #333;
}

/* Lightbox */
.elegant-gallery-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.elegant-gallery-lightbox.active {
    display: flex;
    opacity: 1;
}

.elegant-gallery-lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
}

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

/* Lightbox Controls */
.elegant-gallery-lightbox-close,
.elegant-gallery-lightbox-prev,
.elegant-gallery-lightbox-next {
    position: absolute;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    z-index: 10;
}

.elegant-gallery-lightbox-close:hover,
.elegant-gallery-lightbox-prev:hover,
.elegant-gallery-lightbox-next:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.elegant-gallery-lightbox-close {
    top: 20px;
    right: 20px;
}

.elegant-gallery-lightbox-prev {
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.elegant-gallery-lightbox-prev:hover {
    transform: translateY(-50%) scale(1.1);
}

.elegant-gallery-lightbox-next {
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.elegant-gallery-lightbox-next:hover {
    transform: translateY(-50%) scale(1.1);
}

/* Lightbox Image Container */
.elegant-gallery-lightbox-image-container {
    max-width: 90%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.elegant-gallery-lightbox-image {
    max-width: 100%;
    max-height: calc(100vh - 150px);
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: zoomIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Lightbox Caption */
.elegant-gallery-lightbox-caption {
    margin-top: 20px;
    color: #fff;
    text-align: center;
    max-width: 600px;
    padding: 0 20px;
    font-size: 16px;
    line-height: 1.6;
    animation: fadeInUp 0.5s ease 0.2s both;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.elegant-gallery-lightbox-caption-title {
    font-weight: 700;
    font-size: 18px;
    margin-bottom: 8px;
}

.elegant-gallery-lightbox-caption-description {
    opacity: 0.85;
}

/* Lightbox Counter */
.elegant-gallery-lightbox-counter {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    background: rgba(0, 0, 0, 0.5);
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    backdrop-filter: blur(10px);
}

/* Loading State */
.elegant-gallery-lightbox-image.loading {
    opacity: 0.5;
}

/* Tablet Responsiveness */
@media (max-width: 1024px) {
    .elegant-gallery-grid {
        grid-template-columns: repeat(var(--eg-columns-tablet, 2), 1fr);
    }
    
    .elegant-gallery-masonry .elegant-gallery-grid {
        grid-template-columns: repeat(var(--eg-columns-tablet, 2), 1fr);
    }
    
    .elegant-gallery-lightbox-close,
    .elegant-gallery-lightbox-prev,
    .elegant-gallery-lightbox-next {
        width: 45px;
        height: 45px;
    }
    
    .elegant-gallery-lightbox-prev {
        left: 10px;
    }
    
    .elegant-gallery-lightbox-next {
        right: 10px;
    }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .elegant-gallery-grid {
        grid-template-columns: repeat(var(--eg-columns-mobile, 1), 1fr);
    }
    
    .elegant-gallery-masonry .elegant-gallery-grid {
        grid-template-columns: repeat(var(--eg-columns-mobile, 1), 1fr);
    }
    
    .elegant-gallery-zoom {
        width: 50px;
        height: 50px;
    }
    
    .elegant-gallery-zoom svg {
        width: 24px;
        height: 24px;
    }
    
    .elegant-gallery-lightbox-close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
    }
    
    .elegant-gallery-lightbox-prev,
    .elegant-gallery-lightbox-next {
        width: 40px;
        height: 40px;
    }
    
    .elegant-gallery-lightbox-prev {
        left: 5px;
    }
    
    .elegant-gallery-lightbox-next {
        right: 5px;
    }
    
    .elegant-gallery-lightbox-image {
        max-height: calc(100vh - 100px);
    }
    
    .elegant-gallery-lightbox-caption {
        font-size: 14px;
        margin-top: 15px;
    }
    
    .elegant-gallery-lightbox-counter {
        bottom: 20px;
        font-size: 12px;
        padding: 8px 16px;
    }
}

/* Error and Empty States */
.elegant-gallery-error {
    padding: 20px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    color: #856404;
    text-align: center;
}

.elegant-gallery-empty {
    padding: 40px;
    text-align: center;
    color: #999;
    font-style: italic;
}

/* Keyboard Navigation Indicators */
.elegant-gallery-lightbox:focus-within .elegant-gallery-lightbox-prev,
.elegant-gallery-lightbox:focus-within .elegant-gallery-lightbox-next {
    border-color: rgba(255, 255, 255, 0.4);
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .elegant-gallery-item,
    .elegant-gallery-image,
    .elegant-gallery-overlay,
    .elegant-gallery-zoom,
    .elegant-gallery-lightbox,
    .elegant-gallery-lightbox-close,
    .elegant-gallery-lightbox-prev,
    .elegant-gallery-lightbox-next {
        transition: none;
        animation: none;
    }
}
