/* ==========================================================================
   WC Gallery Carousel - Main Styles
   ========================================================================== */

:root {
    --wcgc-primary: #2c3e50;
    --wcgc-accent: #3498db;
    --wcgc-bg: #ffffff;
    --wcgc-text: #333333;
    --wcgc-light-gray: #f5f5f5;
    --wcgc-border: #e0e0e0;
    --wcgc-radius: 12px;
    --wcgc-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    --wcgc-shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.15);
    --wcgc-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Wrapper */
.wcgc-wrapper {
    position: relative;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    /* Prevent Elementor column/section styles from bleeding in */
    box-sizing: border-box;
}

.wcgc-wrapper,
.wcgc-wrapper .wcgc-product-card,
.wcgc-wrapper .wcgc-product-card *,
.wcgc-wrapper .wcgc-filters,
.wcgc-wrapper .wcgc-filters * {
    box-sizing: border-box;
}

/* ==========================================================================
   Filter Buttons
   ========================================================================== */

.wcgc-filters {
    margin-bottom: 30px;
    text-align: center;
}

.wcgc-filter-group {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.wcgc-filter-btn {
    display: inline-flex;
    align-items: center;
    padding: 10px 22px;
    border: 2px solid var(--wcgc-border);
    border-radius: 50px;
    background: var(--wcgc-bg);
    color: var(--wcgc-text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--wcgc-transition);
    outline: none;
    white-space: nowrap;
    line-height: 1.4;
}

.wcgc-filter-btn:hover {
    border-color: var(--wcgc-accent);
    color: var(--wcgc-accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.2);
}

.wcgc-filter-btn.active {
    background: var(--wcgc-accent);
    border-color: var(--wcgc-accent);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.35);
}

.wcgc-filter-btn.wcgc-filter-brand {
    border-style: dashed;
}

.wcgc-filter-btn.wcgc-filter-brand.active {
    border-style: solid;
}

/* Loading state */
.wcgc-filter-btn.loading {
    pointer-events: none;
    opacity: 0.6;
}

/* ==========================================================================
   Carousel Container
   ========================================================================== */

.wcgc-carousel-container {
    position: relative;
    padding: 0 50px;
}

.wcgc-swiper {
    overflow: hidden;
    padding: 10px 0 20px;
    opacity: 0;
    /* Hide initially to prevent FOUC */
    transition: opacity 0.4s ease;
}

.wcgc-swiper.swiper-initialized {
    opacity: 1;
    /* Show when ready */
}

.wcgc-swiper:not(.swiper-initialized) .swiper-wrapper {
    display: flex;
    /* Force horizontal layout initially */
    overflow: hidden;
}

.wcgc-swiper:not(.swiper-initialized) .swiper-slide {
    width: 25%;
    /* Fallback width to prevent stacking */
    flex-shrink: 0;
    margin-right: 20px;
}

/* Mobile fallback */
@media (max-width: 768px) {
    .wcgc-swiper:not(.swiper-initialized) .swiper-slide {
        width: 100%;
    }
}

/* ==========================================================================
   Product Card
   ========================================================================== */

.wcgc-slide {
    height: auto;
}

.wcgc-product-card {
    background: var(--wcgc-bg);
    border-radius: var(--wcgc-radius);
    overflow: hidden;
    box-shadow: var(--wcgc-shadow);
    transition: var(--wcgc-transition);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.wcgc-product-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--wcgc-shadow-hover);
}

.wcgc-product-link {
    text-decoration: none;
    color: inherit;
    display: block;
    flex-grow: 1;
}

/* Product Image - Always square 1:1 ratio */
.wcgc-product-image {
    position: relative;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    background: var(--wcgc-light-gray);
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wcgc-product-image .wcgc-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    transition: transform 0.5s ease;
    display: block;
}

.wcgc-product-card:hover .wcgc-product-image .wcgc-img {
    transform: scale(1.05);
}

/* Sale Badge */
.wcgc-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.wcgc-sale {
    background: #e74c3c;
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.wcgc-sale-percent {
    background: #e67e22;
    color: #ffffff;
    font-size: 13px;
    letter-spacing: 0;
    padding: 5px 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.wcgc-sale-both {
    background: #e74c3c;
    color: #ffffff;
    font-size: 11px;
    letter-spacing: 0;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.wcgc-out-of-stock {
    background: #95a5a6;
    color: #ffffff;
    font-size: 11px;
    letter-spacing: 0;
    top: auto;
    bottom: 12px;
    left: 12px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* Gallery Overlay */
.wcgc-gallery-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    gap: 4px;
    padding: 8px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.5));
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.wcgc-product-card:hover .wcgc-gallery-overlay {
    transform: translateY(0);
}

.wcgc-gallery-thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 6px;
    border: 2px solid rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: var(--wcgc-transition);
}

.wcgc-gallery-thumb:hover {
    border-color: var(--wcgc-accent);
    transform: scale(1.1);
}

/* Product Title */
.wcgc-product-title {
    margin: 12px 15px 6px;
    font-size: 15px;
    font-weight: 600;
    color: var(--wcgc-primary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 42px;
}

/* Product Rating */
.wcgc-product-rating {
    padding: 0 15px;
    margin-bottom: 4px;
    min-height: 20px;
}

.wcgc-product-rating .star-rating {
    font-size: 13px;
}

/* Product Price */
.wcgc-product-price {
    padding: 4px 15px 8px;
    font-size: 16px;
    font-weight: 700;
    color: var(--wcgc-primary);
    min-height: 30px;
}

.wcgc-product-price del {
    color: #999;
    font-size: 13px;
    font-weight: 400;
    margin-right: 6px;
    opacity: 0.75;
}

.wcgc-product-price ins {
    text-decoration: none;
    color: #e74c3c;
    font-weight: 700;
}

/* Variable product price range */
.wcgc-product-price .woocommerce-Price-amount {
    white-space: nowrap;
}

.wcgc-product-price > .amount,
.wcgc-product-price > span {
    display: inline;
}

/* Add to Cart */
.wcgc-product-actions {
    padding: 0 15px 15px;
    margin-top: auto;
}

.wcgc-add-to-cart {
    display: block;
    width: 100%;
    padding: 10px 16px;
    background-color: var(--wcgc-accent);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: var(--wcgc-transition);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1.4;
}

.wcgc-add-to-cart:hover,
.wcgc-add-to-cart:focus {
    background-color: var(--wcgc-primary);
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.wcgc-add-to-cart:visited {
    color: #ffffff;
}

.wcgc-add-to-cart.added::after {
    content: " \2713";
}

/* ==========================================================================
   Navigation Arrows
   ========================================================================== */

.wcgc-carousel-container .wcgc-button-prev,
.wcgc-carousel-container .wcgc-button-next {
    position: absolute;
    top: calc(50% - 10px);
    transform: translateY(-50%);
    z-index: 100;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--wcgc-bg);
    border: 2px solid var(--wcgc-border);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--wcgc-transition);
    color: var(--wcgc-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 0;
    margin: 0;
    line-height: 1;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
    user-select: none;
}

.wcgc-carousel-container .wcgc-button-prev {
    left: 0;
}

.wcgc-carousel-container .wcgc-button-next {
    right: 0;
}

.wcgc-carousel-container .wcgc-button-prev:hover,
.wcgc-carousel-container .wcgc-button-next:hover {
    background: var(--wcgc-accent);
    border-color: var(--wcgc-accent);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.35);
}

.wcgc-carousel-container .wcgc-button-prev svg,
.wcgc-carousel-container .wcgc-button-next svg {
    width: 24px;
    height: 24px;
    pointer-events: none;
}

/* ==========================================================================
   Pagination
   ========================================================================== */

.wcgc-pagination {
    text-align: center;
    margin-top: 15px;
    position: relative;
}

.wcgc-pagination .swiper-pagination-bullet {
    width: 10px;
    height: 10px;
    background: var(--wcgc-border);
    opacity: 1;
    margin: 0 5px;
    transition: var(--wcgc-transition);
    display: inline-block;
    border-radius: 50%;
}

.wcgc-pagination .swiper-pagination-bullet-active {
    background: var(--wcgc-accent);
    width: 28px;
    border-radius: 5px;
}

/* ==========================================================================
   Loading Animation
   ========================================================================== */

.wcgc-loading {
    position: relative;
    min-height: 200px;
}

.wcgc-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid var(--wcgc-border);
    border-top-color: var(--wcgc-accent);
    border-radius: 50%;
    animation: wcgc-spin 0.8s linear infinite;
}

@keyframes wcgc-spin {
    to {
        transform: rotate(360deg);
    }
}

/* No products message */
.wcgc-no-products {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    width: 100%;
}

.wcgc-no-products p {
    color: #999;
    font-size: 16px;
}

/* ==========================================================================
   Fade animation for filtered results
   Only apply opacity transition during AJAX filtering, not during normal slide.
   We use a separate element to avoid overriding Swiper's transform transition.
   ========================================================================== */

.wcgc-swiper.wcgc-fading {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.wcgc-swiper {
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1024px) {
    .wcgc-carousel-container {
        padding: 0 40px;
    }

    .wcgc-carousel-container .wcgc-button-prev,
    .wcgc-carousel-container .wcgc-button-next {
        width: 38px;
        height: 38px;
    }
}

@media (max-width: 768px) {
    .wcgc-carousel-container {
        padding: 0 35px;
    }

    .wcgc-filter-btn {
        padding: 8px 16px;
        font-size: 13px;
    }

    .wcgc-product-title {
        font-size: 14px;
    }

    .wcgc-product-price {
        font-size: 15px;
    }

    .wcgc-carousel-container .wcgc-button-prev,
    .wcgc-carousel-container .wcgc-button-next {
        width: 34px;
        height: 34px;
    }

    .wcgc-carousel-container .wcgc-button-prev svg,
    .wcgc-carousel-container .wcgc-button-next svg {
        width: 20px;
        height: 20px;
    }
}

@media (max-width: 480px) {
    .wcgc-carousel-container {
        padding: 0 30px;
    }

    .wcgc-filter-group {
        gap: 6px;
    }

    .wcgc-filter-btn {
        padding: 7px 14px;
        font-size: 12px;
    }
}

/* ==========================================================================
   Elementor Editor Compatibility
   ========================================================================== */

/* Prevent Elementor editor styles from breaking the carousel */
.elementor-editor-active .wcgc-wrapper .swiper-wrapper {
    display: flex;
}

.elementor-editor-active .wcgc-wrapper .swiper-slide {
    flex-shrink: 0;
}

.elementor-editor-active .wcgc-product-card:hover {
    transform: none;
}

/* Ensure the widget preview renders properly in the editor */
.elementor-widget-wcgc_carousel .elementor-widget-container {
    overflow: visible;
}

/* Override WooCommerce default button styles within our carousel */
.wcgc-wrapper .wcgc-add-to-cart.button {
    background-color: var(--wcgc-accent);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
}

.wcgc-wrapper .wcgc-add-to-cart.button:hover {
    background-color: var(--wcgc-primary);
    color: #ffffff;
}

/* Prevent theme overrides on our product cards */
.wcgc-wrapper .wcgc-product-link:hover {
    text-decoration: none;
}

.wcgc-wrapper a.wcgc-add-to-cart {
    text-decoration: none;
}