/* Elementor Carousel Gallery Styles */

:root {
    --ecg-gap: 10px;
    --ecg-columns: 4;
    --ecg-columns-tablet: 3;
    --ecg-columns-mobile: 2;
    --ecg-row-height: 200px;
}

/* Dynamic CSS Custom Properties for Row Heights */
.ecg-carousel-gallery-wrapper[data-row-height] {
    --ecg-row-height: attr(data-row-height px, 200px);
}

.ecg-carousel-gallery-wrapper {
    --ecg-current-row-height: var(--ecg-row-height, 200px);
}

.ecg-carousel-gallery-wrapper {
    position: relative;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Ensure full-width containers work properly */
.elementor-widget-carousel-gallery {
    width: 100%;
    max-width: 100%;
}

.elementor-widget-carousel-gallery .elementor-widget-container {
    width: 100%;
    max-width: 100%;
    overflow: visible;
}

/* Elementor Full Width Support */
.elementor-section-stretched > .elementor-container > .elementor-column > .elementor-widget-wrap > .elementor-widget-carousel-gallery,
.elementor-section-full_width > .elementor-container > .elementor-column > .elementor-widget-wrap > .elementor-widget-carousel-gallery {
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    max-width: 100vw;
}

.elementor-section-stretched > .elementor-container > .elementor-column > .elementor-widget-wrap > .elementor-widget-carousel-gallery .ecg-carousel-gallery-wrapper,
.elementor-section-full_width > .elementor-container > .elementor-column > .elementor-widget-wrap > .elementor-widget-carousel-gallery .ecg-carousel-gallery-wrapper {
    width: 100vw;
    max-width: 100vw;
}

/* Full Width Column Support */
.elementor-column[data-settings*='"content_width":"full_width"'] .elementor-widget-carousel-gallery {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
}

/* Boxed Content Width Override */
.elementor-section-boxed .elementor-container .elementor-widget-carousel-gallery {
    width: 100%;
    position: static;
    left: auto;
    right: auto;
    margin-left: 0;
    margin-right: 0;
    max-width: 100%;
}

/* Container Pro Support - Modern Elementor Containers */
.e-con-full .elementor-widget-carousel-gallery,
.e-con[data-settings*='"content_width":"full"'] .elementor-widget-carousel-gallery,
.e-con[data-settings*='"width":{"unit":"%","size":"","sizes":[]}'] .elementor-widget-carousel-gallery,
.elementor-widget-carousel-gallery[data-settings*='"_element_width":"full"'],
.elementor-widget-carousel-gallery[data-settings*='"width":{"unit":"vw","size":100}'] {
    width: 100vw !important;
    max-width: 100vw !important;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw !important;
    margin-right: -50vw !important;
    box-sizing: border-box;
}

/* Additional Container Pro selectors for different scenarios */
.e-con-boxed .e-con-inner .elementor-widget-carousel-gallery[data-settings*='"_element_width":"full"'],
.e-container .elementor-widget-carousel-gallery[data-settings*='"width":{"unit":"vw"}'] {
    width: 100vw !important;
    max-width: 100vw !important;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw !important;
    margin-right: -50vw !important;
}

/* Ensure inner wrapper also expands properly */
.e-con-full .elementor-widget-carousel-gallery .ecg-carousel-gallery-wrapper,
.e-con[data-settings*='"content_width":"full"'] .elementor-widget-carousel-gallery .ecg-carousel-gallery-wrapper,
.elementor-widget-carousel-gallery[data-settings*='"_element_width":"full"'] .ecg-carousel-gallery-wrapper {
    width: 100vw;
    max-width: 100vw;
}

/* Universal Full Width Handler - Catch all full-width scenarios */
.elementor-widget-carousel-gallery:is(
    [data-settings*='"_element_width":"full"'],
    [data-settings*='"width":{"unit":"vw"'],
    [style*="width: 100vw"],
    [style*="width:100vw"]
) {
    width: 100vw !important;
    max-width: 100vw !important;
    position: relative !important;
    left: 50% !important;
    right: 50% !important;
    margin-left: -50vw !important;
    margin-right: -50vw !important;
    transform: none !important;
    box-sizing: border-box !important;
}

/* Reset alignment issues when full-width is active */
.elementor-widget-carousel-gallery:is(
    [data-settings*='"_element_width":"full"'],
    [data-settings*='"width":{"unit":"vw"'],
    [style*="width: 100vw"],
    [style*="width:100vw"]
) .elementor-widget-container {
    width: 100vw !important;
    max-width: 100vw !important;
    position: relative !important;
    left: 0 !important;
    right: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    transform: none !important;
    justify-self: stretch !important;
    align-self: stretch !important;
}

/* JavaScript-applied full-width class */
.elementor-widget-carousel-gallery.ecg-full-width-active {
    width: 100vw !important;
    max-width: 100vw !important;
    position: relative !important;
    left: 50% !important;
    right: 50% !important;
    margin-left: -50vw !important;
    margin-right: -50vw !important;
    transform: none !important;
    box-sizing: border-box !important;
    z-index: 1; /* Ensure proper stacking */
}

.elementor-widget-carousel-gallery.ecg-full-width-active .elementor-widget-container {
    width: 100vw !important;
    max-width: 100vw !important;
    position: relative !important;
    left: 0 !important;
    right: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    transform: none !important;
    justify-self: stretch !important;
    align-self: stretch !important;
}

.elementor-widget-carousel-gallery.ecg-full-width-active .ecg-carousel-gallery-wrapper {
    width: 100vw !important;
    max-width: 100vw !important;
}

/* CAROUSEL STYLES */
.ecg-carousel {
    position: relative;
    overflow: hidden;
}

.ecg-carousel .swiper-wrapper {
    display: flex;
    align-items: stretch;
}

/* Handle gaps in carousel mode */
.ecg-carousel.swiper-initialized {
    --carousel-gap: var(--gap, 10px);
}

.ecg-carousel-slide {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    height: calc(var(--ecg-current-row-height) * var(--row-span, 1));
    min-height: calc(var(--ecg-current-row-height) * var(--row-span, 1));
}

/* Ensure simple carousel images respect row height */
.ecg-carousel:not(.ecg-masonry-carousel) .ecg-carousel-slide .ecg-image-wrapper {
    height: 100%;
}

.ecg-carousel:not(.ecg-masonry-carousel) .ecg-carousel-slide .ecg-image {
    height: 100%;
    width: 100%;
    object-fit: contain;
}

/* MASONRY CAROUSEL STYLES */
.ecg-masonry-carousel {
    position: relative;
    overflow: hidden;
}

.ecg-masonry-carousel .swiper-slide {
    height: auto;
}

.ecg-masonry-slide {
    position: relative;
    width: 100%;
    height: 100%;
}

.ecg-masonry-grid {
    display: grid;
    width: 100%;
    height: 100%;
    min-height: calc(var(--ecg-current-row-height, var(--ecg-row-height, 200px)) * 2);
    grid-auto-rows: var(--ecg-current-row-height, var(--ecg-row-height, 200px));
}

.ecg-masonry-item {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    min-height: calc(var(--ecg-current-row-height, var(--ecg-row-height, 200px)) * var(--row-span, 1));
}

/* GRID STYLES */
.ecg-grid {
    display: grid;
    grid-template-columns: repeat(var(--columns), 1fr);
    gap: var(--ecg-gap);
    grid-auto-rows: var(--ecg-current-row-height, var(--ecg-row-height, 200px));
    grid-auto-flow: row dense;
    width: 100%;
    max-width: 100%;
}

.ecg-regular-grid {
    grid-auto-flow: row;
}

.ecg-masonry-grid {
    grid-auto-flow: row dense;
    grid-auto-rows: minmax(var(--ecg-row-height), auto);
}

.ecg-grid-item {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    grid-column: span var(--col-span, 1);
    grid-row: span var(--row-span, 1);
    min-height: calc(var(--ecg-current-row-height, var(--ecg-row-height, 200px)) * var(--row-span, 1));
    display: flex;
    flex-direction: column;
}

/* Column Span Classes */
.ecg-col-span-1 { --col-span: 1; }
.ecg-col-span-2 { --col-span: 2; }
.ecg-col-span-3 { --col-span: 3; }
.ecg-col-span-4 { --col-span: 4; }

/* Row Span Classes */
.ecg-row-span-1 { --row-span: 1; }
.ecg-row-span-2 { --row-span: 2; }
.ecg-row-span-3 { --row-span: 3; }

/* IMAGE WRAPPER */
.ecg-image-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: inherit;
    overflow: hidden;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}


.ecg-image-wrapper:hover {
    z-index: 2;
}

.ecg-image {
    width: 100%;
    height: 100%;
    min-height: inherit;
    object-fit: cover;
    object-position: center;
    display: block;
    flex: 1;
    transition: transform 0.3s ease, filter 0.3s ease;
}

/* Ensure inline object-fit styles take precedence with higher specificity */
.ecg-carousel-gallery-wrapper .ecg-image[style*="object-fit: contain"] {
    object-fit: contain !important;
}

/* Ensure contain images have proper background for visibility */
.ecg-carousel-gallery-wrapper .ecg-image[style*="object-fit: contain"] {
    background-color: transparent;
}

.ecg-carousel-gallery-wrapper .ecg-image[style*="object-fit: cover"] {
    object-fit: cover !important;
}

.ecg-carousel-gallery-wrapper .ecg-image[style*="object-fit: fill"] {
    object-fit: fill !important;
}

.ecg-carousel-gallery-wrapper .ecg-image[style*="object-fit: none"] {
    object-fit: none !important;
}

.ecg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: transparent;
    transition: background-color 0.3s ease;
    pointer-events: none !important; /* Ensure overlay doesn't block clicks */
}

.ecg-image-wrapper:hover .ecg-overlay {
    background-color: rgba(0, 0, 0, 0.3);
}

/* CONTENT OVERLAY */
.ecg-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    color: white;
    padding: 20px;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    pointer-events: none; /* Don't block clicks */
}

.ecg-image-wrapper:hover .ecg-content {
    transform: translateY(0);
}

.ecg-title {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
}

.ecg-caption {
    margin: 0;
    font-size: 14px;
    opacity: 0.9;
    line-height: 1.4;
}

/* HOVER EFFECTS */
.ecg-image-wrapper.is-hover img,
.ecg-image-wrapper:hover img {
    transform: scale(1.05);
}

.ecg-carousel-gallery-wrapper[data-hover="scale"] .ecg-image-wrapper:hover img {
    transform: scale(1.1);
}

.ecg-carousel-gallery-wrapper[data-hover="brightness"] .ecg-image-wrapper:hover img {
    filter: brightness(1.2);
}

.ecg-carousel-gallery-wrapper[data-hover="grayscale"] .ecg-image-wrapper:hover img {
    filter: grayscale(100%);
}

.ecg-carousel-gallery-wrapper[data-hover="blur"] .ecg-image-wrapper:hover img {
    filter: blur(2px);
}

/* NAVIGATION ARROWS (Carousel only) */
.ecg-carousel .swiper-button-prev,
.ecg-carousel .swiper-button-next {
    background-color: rgba(0, 0, 0, 0.5);
    color: #ffffff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: background-color 0.3s ease, transform 0.3s ease;
    margin-top: 0;
    top: 50%;
    transform: translateY(-50%);
}

.ecg-carousel .swiper-button-prev:hover,
.ecg-carousel .swiper-button-next:hover {
    background-color: rgba(0, 0, 0, 0.7);
    transform: translateY(-50%) scale(1.1);
}

.ecg-carousel .swiper-button-prev:after,
.ecg-carousel .swiper-button-next:after {
    font-size: 16px;
    font-weight: bold;
}

.ecg-carousel .swiper-button-prev {
    left: 10px;
}

.ecg-carousel .swiper-button-next {
    right: 10px;
}

/* PAGINATION (Carousel only) */
.ecg-carousel .swiper-pagination {
    position: absolute;
    bottom: 10px;
    left: 0;
    right: 0;
    text-align: center;
    z-index: 10;
}

.ecg-carousel .swiper-pagination-bullet {
    width: 10px;
    height: 10px;
    background-color: rgba(255, 255, 255, 0.5);
    opacity: 1;
    margin: 0 4px;
    transition: background-color 0.3s ease, transform 0.3s ease;
}

.ecg-carousel .swiper-pagination-bullet-active {
    background-color: #ffffff;
    transform: scale(1.2);
}

/* LIGHTBOX TRIGGER */
.ecg-lightbox-trigger {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    z-index: 2; /* Ensure clickable above other elements */
}

.ecg-lightbox-trigger:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Ensure lightbox triggers remain clickable in full-width mode */
.ecg-full-width-active .ecg-lightbox-trigger {
    pointer-events: auto !important;
    z-index: 2 !important;
}

/* RESPONSIVE BREAKPOINTS */

/* Tablet */
@media (max-width: 1024px) {
    .ecg-grid {
        grid-template-columns: repeat(var(--columns-tablet), 1fr);
        gap: var(--ecg-gap-tablet, var(--ecg-gap, 10px));
    }
    
    .ecg-masonry-grid {
        grid-template-columns: repeat(var(--columns-tablet), 1fr);
        gap: var(--ecg-gap-tablet, var(--ecg-gap, 10px));
        grid-auto-rows: var(--ecg-row-height-tablet, var(--ecg-current-row-height));
    }
    
    /* Update row heights for tablet if data attribute is present */
    .ecg-carousel-gallery-wrapper[data-row-height-tablet] {
        --ecg-current-row-height: attr(data-row-height-tablet);
    }
    
    .ecg-carousel .swiper-button-prev,
    .ecg-carousel .swiper-button-next {
        width: 35px;
        height: 35px;
    }
    
    .ecg-carousel .swiper-button-prev:after,
    .ecg-carousel .swiper-button-next:after {
        font-size: 14px;
    }
    
    .ecg-content {
        padding: 15px;
    }
    
    .ecg-title {
        font-size: 15px;
    }
    
    .ecg-caption {
        font-size: 13px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .ecg-grid {
        grid-template-columns: repeat(var(--columns-mobile), 1fr);
        gap: var(--ecg-gap-mobile, var(--ecg-gap, 10px));
    }
    
    .ecg-masonry-grid {
        grid-template-columns: repeat(var(--columns-mobile), 1fr);
        gap: var(--ecg-gap-mobile, var(--ecg-gap, 10px));
        grid-auto-rows: var(--ecg-row-height-mobile, var(--ecg-current-row-height));
    }
    
    /* Update row heights for mobile if data attribute is present */
    .ecg-carousel-gallery-wrapper[data-row-height-mobile] {
        --ecg-current-row-height: attr(data-row-height-mobile);
    }
    
    .ecg-carousel .swiper-button-prev,
    .ecg-carousel .swiper-button-next {
        width: 30px;
        height: 30px;
    }
    
    .ecg-carousel .swiper-button-prev:after,
    .ecg-carousel .swiper-button-next:after {
        font-size: 12px;
    }
    
    .ecg-carousel .swiper-pagination-bullet {
        width: 8px;
        height: 8px;
    }
    
    .ecg-content {
        padding: 12px;
    }
    
    .ecg-title {
        font-size: 14px;
    }
    
    .ecg-caption {
        font-size: 12px;
    }
    
    /* Simplify hover effects on mobile */
    .ecg-content {
        position: static;
        background: rgba(0, 0, 0, 0.7);
        transform: none;
        padding: 8px 12px;
    }
    
    /* Limit column spans on mobile for masonry */
    .ecg-masonry-item.ecg-col-span-3,
    .ecg-masonry-item.ecg-col-span-4 {
        grid-column: span 2 !important;
    }
    
    /* Suggest contain for better mobile experience, but don't force it if user explicitly set cover */
    .ecg-image:not([style*="object-fit"]) {
        object-fit: contain !important;
    }
    
    /* Mobile-specific selector for contain images */
    .ecg-image-wrapper>a>img.ecg-image[style*="object-fit: contain"] {
        height: 100%;
    }
    
    .ecg-image-wrapper > a > img {
        height: 100%;
    }
}

/* Very small mobile */
@media (max-width: 480px) {
    .ecg-grid {
        grid-template-columns: repeat(1, 1fr);
    }
    
    .ecg-masonry-grid {
        grid-template-columns: repeat(1, 1fr);
    }
    
    .ecg-grid-item,
    .ecg-masonry-item {
        grid-column: span 1 !important;
    }
    
    .ecg-content {
        padding: 8px;
    }
}

/* SPECIAL EFFECTS */
.ecg-carousel[data-effect="fade"] .swiper-slide {
    opacity: 0;
}

.ecg-carousel[data-effect="fade"] .swiper-slide-active {
    opacity: 1;
}

/* LOADING STATE */
.ecg-carousel.is-loading,
.ecg-grid.is-loading {
    min-height: var(--ecg-row-height);
    background: linear-gradient(90deg, #f0f0f0 25%, #f8f8f8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

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

/* ACCESSIBILITY */
.ecg-carousel:focus-visible,
.ecg-grid:focus-visible,
.ecg-image-wrapper:focus-visible {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .ecg-image,
    .ecg-overlay,
    .ecg-content,
    .ecg-image-wrapper {
        transition: none;
    }
    
    .ecg-carousel .swiper-pagination-bullet,
    .ecg-carousel .swiper-button-prev,
    .ecg-carousel .swiper-button-next {
        transition: none;
    }
}

/* HIGH CONTRAST MODE */
@media (prefers-contrast: high) {
    .ecg-overlay {
        background-color: rgba(0, 0, 0, 0.8);
    }
    
    .ecg-carousel .swiper-button-prev,
    .ecg-carousel .swiper-button-next {
        background-color: #000000;
        color: #ffffff;
        border: 2px solid #ffffff;
    }
    
    .ecg-carousel .swiper-pagination-bullet {
        background-color: #000000;
        border: 1px solid #ffffff;
    }
    
    .ecg-carousel .swiper-pagination-bullet-active {
        background-color: #ffffff;
    }
}

/* PRINT STYLES */
@media print {
    .ecg-carousel .swiper-button-prev,
    .ecg-carousel .swiper-button-next,
    .ecg-carousel .swiper-pagination,
    .ecg-overlay {
        display: none !important;
    }
    
    .ecg-image-wrapper,
    .ecg-grid-item {
        page-break-inside: avoid;
        break-inside: avoid;
    }
    
    .ecg-content {
        position: static !important;
        background: transparent !important;
        color: #000000 !important;
        transform: none !important;
        padding: 10px 0 !important;
    }
}

/* RTL SUPPORT */
.rtl .ecg-carousel .swiper-button-prev {
    right: 10px;
    left: auto;
}

.rtl .ecg-carousel .swiper-button-next {
    left: 10px;
    right: auto;
}

/* DARK MODE SUPPORT */
@media (prefers-color-scheme: dark) {
    .ecg-carousel.is-loading,
    .ecg-grid.is-loading {
        background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 50%, #2a2a2a 75%);
    }
}

/* UTILITY CLASSES FOR DYNAMIC STYLING */
.ecg-hover-none .ecg-image-wrapper:hover img {
    transform: none !important;
    filter: none !important;
}

.ecg-hover-scale .ecg-image-wrapper:hover img {
    transform: scale(1.1) !important;
}

.ecg-hover-brightness .ecg-image-wrapper:hover img {
    filter: brightness(1.2) !important;
}

.ecg-hover-grayscale .ecg-image-wrapper:hover img {
    filter: grayscale(100%) !important;
}

.ecg-hover-blur .ecg-image-wrapper:hover img {
    filter: blur(2px) !important;
}

/* MASONRY SPECIFIC ADJUSTMENTS */
.ecg-masonry-grid .ecg-grid-item {
    align-self: start;
}

.ecg-masonry-grid .ecg-grid-item.ecg-row-span-2 {
    grid-row: span 2;
}

.ecg-masonry-grid .ecg-grid-item.ecg-row-span-3 {
    grid-row: span 3;
}

/* MASONRY CAROUSEL ITEM ADJUSTMENTS */
.ecg-masonry-item .ecg-image-wrapper {
    height: 100%;
    flex: 1;
}

.ecg-masonry-item .ecg-image {
    height: 100%;
    width: 100%;
    object-fit: cover;
    object-position: center;
}

/* Ensure proper aspect ratios for masonry items */
.ecg-masonry-carousel .ecg-col-span-1 {
    min-height: var(--ecg-current-row-height, var(--ecg-row-height, 200px));
}

.ecg-masonry-carousel .ecg-col-span-2 {
    min-height: var(--ecg-current-row-height, var(--ecg-row-height, 200px));
}

.ecg-masonry-carousel .ecg-row-span-1 {
    height: var(--ecg-current-row-height, var(--ecg-row-height, 200px));
}

.ecg-masonry-carousel .ecg-row-span-2 {
    height: calc(var(--ecg-current-row-height, var(--ecg-row-height, 200px)) * 2 + var(--ecg-gap, 10px));
}

.ecg-masonry-carousel .ecg-row-span-3 {
    height: calc(var(--ecg-current-row-height, var(--ecg-row-height, 200px)) * 3 + var(--ecg-gap, 10px) * 2);
}

/* GRID ITEM POSITIONING */
.ecg-grid-item[style*="grid-column-start"] {
    grid-column: var(--grid-column-start) / var(--grid-column-end);
}

.ecg-grid-item[style*="grid-row-start"] {
    grid-row: var(--grid-row-start) / var(--grid-row-end);
}

/* ENHANCED VISUAL FEEDBACK */
.ecg-image-wrapper {
    border-radius: inherit;
    overflow: hidden;
}

.ecg-image-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    transition: background 0.3s ease;
    z-index: 1;
    pointer-events: none;
}

.ecg-image-wrapper:hover::before {
    background: radial-gradient(circle at center, transparent 20%, rgba(255,255,255,0.1) 100%);
}

/* PERFORMANCE OPTIMIZATIONS */
.ecg-image {
    will-change: transform;
    backface-visibility: hidden;
}

.ecg-overlay {
    will-change: background-color;
}

.ecg-content {
    will-change: transform;
}