/**
 * Wayfair-Style Product Card CSS
 * Image swap on hover, variant thumbnails, clean UI
 */

/* ==========================================================================
   Wayfair Product Card Base Styles
   ========================================================================== */
.wayfair-card {
    position: relative;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.3s ease;
}

.wayfair-card:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   Sale Badge - High z-index to stay on top during image swap
   ========================================================================== */
.wayfair-sale-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: #dc3545;
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 10;
}

/* ==========================================================================
   Image Wrapper with Hover Swap
   ========================================================================== */
.wayfair-image-wrapper {
    position: relative;
    width: 100%;
    padding-top: 100%; /* 1:1 Aspect Ratio */
    overflow: hidden;
    background: #f8f9fa;
}

.wayfair-image-wrapper a {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.wayfair-primary-image,
.wayfair-secondary-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: unset;
    transition: opacity 0.3s ease;
}

.wayfair-primary-image {
    opacity: 1;
}

.wayfair-secondary-image {
    opacity: 0;
}

/* Hover: Show secondary image - ONLY when secondary image exists */
.wayfair-image-wrapper.wayfair-has-secondary:hover .wayfair-secondary-image {
    opacity: 1;
}

.wayfair-image-wrapper.wayfair-has-secondary:hover .wayfair-primary-image {
    opacity: 0;
}

/* ==========================================================================
   Heart Button - High z-index to stay visible during image swap
   ========================================================================== */
.wayfair-heart-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    background: #fff;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.wayfair-heart-btn:hover {
    background: #f8f9fa;
    transform: scale(1.05);
}

.wayfair-heart-btn .material-icons {
    font-size: 1.25rem;
    color: #6c757d;
}

.wayfair-heart-btn.active .material-icons {
    color: #dc3545;
}

.wayfair-heart-btn.active {
    background: #fff5f5;
}

/* ==========================================================================
   Variant Thumbnail Strip (Max 5 variants)
   ========================================================================== */
.wayfair-variant-strip {
    display: flex;
    gap: 6px;
    padding: 10px 0;
    overflow-x: auto;
    scrollbar-width: none; /* Firefox */
}

.wayfair-variant-strip::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.wayfair-variant-thumb {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border: 2px solid transparent;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #f8f9fa;
}

.wayfair-variant-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wayfair-variant-thumb:hover {
    border-color: #dee2e6;
}

.wayfair-variant-thumb.active {
    border-color: #28a745; /* Green border for active variant */
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.1);
}

/* +X More indicator */
.wayfair-variant-more {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border: 2px dashed #dee2e6;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: #6c757d;
    background: #f8f9fa;
    cursor: pointer;
    transition: all 0.2s ease;
}

.wayfair-variant-more:hover {
    border-color: #6f42c1;
    color: #6f42c1;
    background: #f8f9fa;
}

/* Mobile: Hide thumbnail strip */
@media (max-width: 767px) {
    .wayfair-variant-strip {
        display: none;
    }
}

/* ==========================================================================
   Card Details Section
   ========================================================================== */
.wayfair-card-details {
    padding: 12px;
}

/* ==========================================================================
   Product Title - Truncate to 2 lines
   ========================================================================== */
/* Info wrapper - transparent on desktop */
.wayfair-card-info {
    display: contents;
}

.wayfair-title {
    font-weight: 500;
    font-size: 0.9375rem;
    color: #212529;
    text-decoration: none;
    line-height: 1.4;
    transition: color 0.2s ease;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
    overflow-wrap: break-word;
    max-height: 4.2em;
}

.wayfair-title:hover {
    color: #6f42c1;
}

/* ==========================================================================
   Rating Stars + Review Count
   ========================================================================== */
.wayfair-rating {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
}

.wayfair-rating .material-icons {
    font-size: 0.875rem;
    color: #ffc107;
}

.wayfair-rating .wayfair-review-count {
    font-size: 0.75rem;
    color: #6c757d;
    margin-left: 4px;
}

/* ==========================================================================
   Price Section
   ========================================================================== */
.wayfair-price {
    margin-top: 10px;
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.wayfair-current {
    font-weight: 700;
    font-size: 1.0625rem;
    color: #212529;
}

.wayfair-old {
    font-size: 0.875rem;
    color: #adb5bd;
    text-decoration: line-through;
}

/* ==========================================================================
   Add to Cart Link - Purple styling
   ========================================================================== */
.wayfair-add-cart {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    color: #6f42c1; /* Purple */
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    transition: opacity 0.2s ease;
    cursor: pointer;
}

.wayfair-add-cart:hover {
    opacity: 0.8;
    color: #6f42c1;
}

.wayfair-add-cart .material-icons {
    font-size: 1rem;
}

/* ==========================================================================
   Responsive Adjustments - Vertical card on mobile with large image
   ========================================================================== */
@media (max-width: 767px) {
    .wayfair-card {
        display: flex;
        flex-direction: column;
        border-radius: 8px;
    }

    .wayfair-image-wrapper {
        width: 100%;
        padding-top: 100%;
        border-radius: 8px 8px 0 0;
    }

    .wayfair-card-info {
        display: block;
    }

    .wayfair-card-details {
        padding: 8px 10px;
    }

    .wayfair-title {
        font-size: 0.8125rem;
        -webkit-line-clamp: 1;
        line-clamp: 1;
        max-height: 1.2em;
    }

    .wayfair-sale-badge {
        top: 8px;
        left: 8px;
        font-size: 0.6875rem;
        padding: 3px 8px;
    }

    .wayfair-heart-btn {
        top: 8px;
        right: 8px;
        left: auto;
        width: 32px;
        height: 32px;
    }

    .wayfair-heart-btn .material-icons {
        font-size: 1.125rem;
    }

    .wayfair-price {
        margin-top: 4px;
    }

    .wayfair-current {
        font-size: 1rem;
        font-weight: 700;
    }

    .wayfair-old {
        font-size: 0.8125rem;
    }

    .wayfair-rating {
        display: none;
    }

    .wayfair-variant-thumb {
        width: 40px;
        height: 40px;
    }
}

/* ==========================================================================
   Animation for variant switch
   ========================================================================== */
@keyframes wayfair-image-fade {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.wayfair-image-switch {
    animation: wayfair-image-fade 0.3s ease;
}

/* ==========================================================================
   Product Page Overrides
   ========================================================================== */

/* Product title - responsive font size */
h1#product-title, h1.product-title, .product-title {
    font-size: clamp(0.5rem, 1rem + 0.6vw, 1.75rem);
}
