.custom-loop-widget-container {
    --gap: 20px;
    --columns: 3;
    width: 100%; /* Ensure container has width */
}

/* Grid Layout */
.custom-loop-grid {
    display: grid;
    grid-template-columns: repeat(var(--columns), 1fr);
    gap: var(--gap);
}

/* Carousel Layout - Swiper Overrides/Fixes */
.custom-loop-carousel {
    overflow: hidden; /* Essential for Swiper */
    position: relative;
}

.custom-loop-carousel .swiper-container,
.custom-loop-carousel.swiper-container,
.custom-loop-carousel.swiper {
    width: 100%;
    height: 100%;
    padding-bottom: 40px; /* Space for pagination */
}

.custom-loop-carousel .swiper-slide {
    height: auto; /* Ensure equal height if using flex in cards */
    display: flex;
    flex-direction: column;
    width: 100%; /* Ensure slide has width */
}

/* Loading State Fix for Carousel 
   This attempts to show items in a row before Swiper initializes 
   to prevent the "1 giant card" FOUC.
*/
.custom-loop-carousel:not(.swiper-container-initialized):not(.swiper-initialized) .swiper-wrapper {
    display: flex;
    gap: var(--gap);
    overflow: hidden;
}

.custom-loop-carousel:not(.swiper-container-initialized):not(.swiper-initialized) .swiper-slide {
    width: calc((100% - (var(--gap) * (var(--columns) - 1))) / var(--columns));
    flex-shrink: 0;
}

/* Responsive adjustments for loading state */
@media (max-width: 1024px) {
    .custom-loop-widget-container {
        --columns: 2;
    }
}

@media (max-width: 767px) {
    .custom-loop-widget-container {
        --columns: 1;
    }
}

/* Navigation Buttons */
.custom-loop-nav-button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 99;
    transition: all 0.3s ease;
    color: #333;
    font-size: 18px; /* Ensure icon has size */
}

.custom-loop-nav-button svg {
    fill: currentColor;
    width: 1em;
    height: 1em;
}

.custom-loop-nav-button:hover {
    background: #333;
    color: #fff;
}

/* Equal Height Fixes */
.custom-loop-carousel .swiper-slide > .elementor-element,
.custom-loop-carousel .swiper-slide > .elementor-widget,
.custom-loop-carousel .swiper-slide > div {
    height: 100%;
}

.custom-loop-button-prev {
    left: 10px; /* Add some spacing from edge */
}

.custom-loop-button-next {
    right: 10px; /* Add some spacing from edge */
}

.custom-loop-pagination {
    bottom: 0 !important;
}
