/**
 * World Class Product Card Component
 * Modern, animated, interactive product cards with glassmorphism and performance optimizations
 */

/* Product Card Container */
.affc-product-card {
    position: relative;
    background: var(--aff-surface-1);
    border: 1px solid var(--aff-border-light);
    border-radius: var(--aff-radius-lg);
    overflow: hidden;
    transition: var(--aff-transition-smooth);
    cursor: pointer;
    animation: affc-slideUp var(--aff-transition-smooth) ease-out;
    contain: layout style;
    will-change: transform;
    backface-visibility: hidden;
    -webkit-font-smoothing: antialiased;
}

.affc-product-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--aff-shadow-hover);
    border-color: var(--aff-primary-400);
}

.affc-product-card:active {
    transform: translateY(-2px);
}

/* Product Image Container - Prevent CLS with aspect-ratio */
.affc-product-image {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: var(--aff-surface-2);
    contain: layout;
}

.affc-product-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--aff-transition-smooth);
    will-change: transform;
    backface-visibility: hidden;
}

.affc-product-card:hover .affc-product-image img {
    transform: scale(1.05);
}

/* Glassmorphism Overlay on Hover */
.affc-product-image::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.3) 0%,
        transparent 50%
    );
    opacity: 0;
    transition: opacity var(--aff-transition-fast);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    pointer-events: none;
}

.affc-product-card:hover .affc-product-image::after {
    opacity: 1;
}

/* Quick Actions Overlay */
.affc-product-quick-actions {
    position: absolute;
    top: var(--aff-space-4);
    right: var(--aff-space-4);
    display: flex;
    flex-direction: column;
    gap: var(--aff-space-2);
    opacity: 0;
    transform: translateX(20px);
    transition: var(--aff-transition-smooth);
    will-change: transform, opacity;
    pointer-events: none;
}

.affc-product-card:hover .affc-product-quick-actions {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.affc-quick-action-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--aff-radius-full);
    background: var(--aff-glass-bg);
    border: 1px solid var(--aff-glass-border);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--aff-transition-fast);
    box-shadow: var(--aff-shadow-md);
    will-change: transform;
    backface-visibility: hidden;
}

.affc-quick-action-btn:hover {
    background: var(--aff-primary-500);
    color: var(--aff-text-inverse);
    transform: scale(1.1);
    border-color: var(--aff-primary-500);
}

.affc-quick-action-btn:active {
    transform: scale(0.96);
}

.affc-quick-action-btn svg {
    width: 20px;
    height: 20px;
}

/* Wishlist Button */
.affc-wishlist-btn {
    position: absolute;
    top: var(--aff-space-4);
    right: var(--aff-space-4);
    width: 40px;
    height: 40px;
    border-radius: var(--aff-radius-full);
    background: var(--aff-glass-bg);
    border: 1px solid var(--aff-glass-border);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--aff-transition-fast);
    box-shadow: var(--aff-shadow-md);
    z-index: 10;
    will-change: transform;
    backface-visibility: hidden;
}

.affc-wishlist-btn svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    transition: var(--aff-transition-fast);
}

.affc-wishlist-btn:hover {
    background: var(--aff-error-500);
    color: var(--aff-text-inverse);
    transform: scale(1.1);
    border-color: var(--aff-error-500);
}

.affc-wishlist-btn:active {
    transform: scale(0.96);
}

.affc-wishlist-btn.is-active {
    background: var(--aff-error-500);
    color: var(--aff-text-inverse);
    border-color: var(--aff-error-500);
}

.affc-wishlist-btn.is-active svg {
    fill: currentColor;
}

/* Badge */
.affc-product-badge {
    position: absolute;
    top: var(--aff-space-4);
    left: var(--aff-space-4);
    padding: var(--aff-space-1) var(--aff-space-3);
    background: var(--aff-gradient-accent);
    color: var(--aff-text-inverse);
    font-size: var(--aff-text-xs);
    font-weight: var(--aff-font-semibold);
    border-radius: var(--aff-radius-full);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    box-shadow: var(--aff-shadow-md);
    z-index: 10;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.affc-product-badge.hot {
    background: var(--aff-gradient-success);
}

.affc-product-badge.new {
    background: var(--aff-gradient-primary);
}

.affc-product-badge.sale {
    background: var(--aff-error-500);
}

/* Product Content */
.affc-product-content {
    padding: var(--aff-space-5);
    contain: layout style;
}

/* Merchant */
.affc-product-merchant {
    display: inline-flex;
    align-items: center;
    gap: var(--aff-space-2);
    padding: var(--aff-space-1) var(--aff-space-3);
    background: var(--aff-surface-2);
    border-radius: var(--aff-radius-full);
    font-size: var(--aff-text-xs);
    font-weight: var(--aff-font-medium);
    color: var(--aff-text-secondary);
    margin-bottom: var(--aff-space-3);
    transition: var(--aff-transition-fast);
}

.affc-product-merchant:hover {
    background: var(--aff-surface-3);
    color: var(--aff-text-primary);
}

.affc-product-merchant svg {
    width: 14px;
    height: 14px;
}

/* Product Title */
.affc-product-title {
    font-size: var(--aff-text-lg);
    font-weight: var(--aff-font-semibold);
    line-height: var(--aff-leading-tight);
    color: var(--aff-text-primary);
    margin-bottom: var(--aff-space-3);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color var(--aff-transition-fast);
}

.affc-product-card:hover .affc-product-title {
    color: var(--aff-primary-600);
}

/* Price Block */
.affc-product-price {
    display: flex;
    align-items: baseline;
    gap: var(--aff-space-2);
    margin-bottom: var(--aff-space-4);
}

.affc-price-current {
    font-size: var(--aff-text-2xl);
    font-weight: var(--aff-font-bold);
    color: var(--aff-primary-600);
}

.affc-price-old {
    font-size: var(--aff-text-base);
    font-weight: var(--aff-font-normal);
    color: var(--aff-text-tertiary);
    text-decoration: line-through;
}

.affc-price-discount {
    padding: var(--aff-space-1) var(--aff-space-2);
    background: var(--aff-error-100);
    color: var(--aff-error-700);
    font-size: var(--aff-text-xs);
    font-weight: var(--aff-font-semibold);
    border-radius: var(--aff-radius-md);
}

/* Product Footer */
.affc-product-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--aff-space-3);
}

.affc-product-rating {
    display: flex;
    align-items: center;
    gap: var(--aff-space-1);
}

.affc-product-rating svg {
    width: 16px;
    height: 16px;
    fill: var(--aff-warning-400);
}

.affc-product-rating span {
    font-size: var(--aff-text-sm);
    color: var(--aff-text-secondary);
}

.affc-product-action {
    flex: 1;
}

.affc-product-action .btn {
    width: 100%;
}

/* Skeleton Loading State - Non-blocking animation */
.affc-product-card.skeleton {
    pointer-events: none;
}

.affc-product-card.skeleton .affc-product-image,
.affc-product-card.skeleton .affc-product-title,
.affc-product-card.skeleton .affc-product-price {
    background: linear-gradient(
        90deg,
        var(--aff-surface-2) 0%,
        var(--aff-surface-3) 50%,
        var(--aff-surface-2) 100%
    );
    background-size: 200% 100%;
    animation: affc-shimmer 1.5s ease-in-out infinite;
    border-radius: var(--aff-radius-md);
}

.affc-product-card.skeleton .affc-product-image {
    height: 100%;
}

.affc-product-card.skeleton .affc-product-title {
    height: 24px;
    width: 80%;
}

.affc-product-card.skeleton .affc-product-price {
    height: 32px;
    width: 40%;
}

/* Featured Product Card (Larger) */
.affc-product-card.featured {
    grid-column: span 2;
}

@media (max-width: 768px) {
    .affc-product-card.featured {
        grid-column: span 1;
    }
}

.affc-product-card.featured .affc-product-image {
    aspect-ratio: 3 / 2;
}

.affc-product-card.featured .affc-product-title {
    font-size: var(--aff-text-xl);
    -webkit-line-clamp: 3;
}

/* Compact Product Card */
.affc-product-card.compact .affc-product-image {
    aspect-ratio: 4 / 3;
}

.affc-product-card.compact .affc-product-content {
    padding: var(--aff-space-4);
}

.affc-product-card.compact .affc-product-title {
    font-size: var(--aff-text-base);
    -webkit-line-clamp: 1;
}

.affc-product-card.compact .affc-price-current {
    font-size: var(--aff-text-lg);
}

/* Product Card Grid */
.affc-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--aff-space-6);
    margin: var(--aff-space-8) 0;
    contain: layout;
}

.affc-product-grid.grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.affc-product-grid.grid-cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.affc-product-grid.grid-cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1024px) {
    .affc-product-grid.grid-cols-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .affc-product-grid.grid-cols-3,
    .affc-product-grid.grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .affc-product-grid {
        grid-template-columns: 1fr;
    }
}

/* Empty State */
.affc-products-empty {
    text-align: center;
    padding: var(--aff-space-16) var(--aff-space-4);
}

.affc-products-empty svg {
    width: 120px;
    height: 120px;
    margin: 0 auto var(--aff-space-6);
    color: var(--aff-neutral-300);
}

.affc-products-empty h3 {
    font-size: var(--aff-text-2xl);
    margin-bottom: var(--aff-space-3);
}

.affc-products-empty p {
    color: var(--aff-text-secondary);
    margin-bottom: var(--aff-space-6);
}

/* Animation Delays for Grid - Staggered for performance */
.affc-product-grid .affc-product-card:nth-child(1) { animation-delay: 0.05s; }
.affc-product-grid .affc-product-card:nth-child(2) { animation-delay: 0.1s; }
.affc-product-grid .affc-product-card:nth-child(3) { animation-delay: 0.15s; }
.affc-product-grid .affc-product-card:nth-child(4) { animation-delay: 0.2s; }
.affc-product-grid .affc-product-card:nth-child(5) { animation-delay: 0.25s; }
.affc-product-grid .affc-product-card:nth-child(6) { animation-delay: 0.3s; }
.affc-product-grid .affc-product-card:nth-child(7) { animation-delay: 0.35s; }
.affc-product-grid .affc-product-card:nth-child(8) { animation-delay: 0.4s; }
.affc-product-grid .affc-product-card:nth-child(9) { animation-delay: 0.45s; }
.affc-product-grid .affc-product-card:nth-child(10) { animation-delay: 0.5s; }

/* GPU-Accelerated Animations */
@keyframes affc-slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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