/**
 * Product Card Component
 * Reusable across: Homepage, Category, Search, Related Products
 * 
 * @package Digidaad_Theme
 * @since 2.6.0
 */

/* ============================================
 * PRODUCT CARD
 * ============================================ */
.sv-product-card {
    position: relative;
    background: var(--sv-color-white);
    border-radius: var(--sv-radius-xl);
    border: 1px solid var(--sv-color-gray-100);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.sv-product-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--sv-shadow-lg);
    border-color: transparent;
}

/* Image Container */
/* Blijft position:static zodat de overlay-link de hele kaart blijft dekken. */
.sv-product-card .sv-product-card__image {
    position: static;
    display: block;
    aspect-ratio: 5 / 6;
    overflow: hidden;
    background: var(--sv-color-gray-50);
    border-radius: var(--sv-radius-xl) var(--sv-radius-xl) 0 0;
}

/* Twee classes = hogere specificiteit dan `.woocommerce img { height: auto }`,
   zodat de afbeelding het vlak vult zonder !important. */
.sv-product-card .sv-product-card__image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.sv-product-card .sv-product-card__origin {
    margin: 0 0 13px;
}

.sv-product-card .sv-product-card__foot {
    padding-top: 8px;
}

.sv-product-card .sv-product-card__pricing {
    margin: 0 0 13px;
}

.sv-product-card .sv-product-card__button {
    border-radius: 20px;
}

.sv-product-card:hover .sv-product-card__image img { 
    transform: scale(1.05); 
}

/* Badges */
.sv-product-card__badges {
    position: absolute;
    top: 12px;
    left: 12px;
    display: flex;
    flex-direction: column;
    gap: var(--sv-space-2);
    z-index: 2;
}

.sv-product-card__badge--sale {
    display: none;
}

.sv-product-card__price.is-sale {
    color: #c41511;
}

.sv-product-card__badge {
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: var(--sv-radius-full);
}

.sv-product-card__badge--sale { 
    background: var(--sv-color-error); 
    color: var(--sv-color-white); 
}

.sv-product-card__badge--new { 
    background: var(--sv-color-accent); 
    color: var(--sv-color-white); 
}

.sv-product-card__badge--eco {
    background: var(--sv-color-accent);
    color: var(--sv-color-white);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.sv-product-card__badge--eco svg { 
    width: 12px; 
    height: 12px; 
}

/* Content */
.sv-product-card__content {
    padding: 16px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.sv-product-card__title {
    font-size: 14px;
    font-weight: 600;
    color: var(--sv-color-gray-900);
    margin: 0 0 8px 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sv-product-card__title a { 
    color: inherit; 
    text-decoration: none; 
}

.sv-product-card__title a:hover {
    color: var(--sv-color-accent);
}

/* Rating */
.sv-product-card__rating { 
    display: flex; 
    align-items: center; 
    gap: 4px; 
    margin-bottom: 8px; 
}

.sv-product-card__stars { 
    display: flex; 
    gap: 2px; 
}

.sv-product-card__stars svg { 
    width: 14px; 
    height: 14px;
    fill: var(--sv-color-star);
    stroke: var(--sv-color-star);
}

.sv-product-card__reviews { 
    font-size: 12px; 
    color: var(--sv-color-gray-500); 
}

/* Pricing */
.sv-product-card__pricing {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
    margin-top: auto;
}

.sv-product-card__price-old { 
    font-size: 14px; 
    color: var(--sv-color-gray-400); 
    text-decoration: line-through; 
}

.sv-product-card__price { 
    font-size: 18px; 
    font-weight: 800; 
    color: var(--sv-color-error); 
}

.sv-product-card__price .woocommerce-Price-amount { 
    font-size: inherit; 
    font-weight: inherit; 
    color: inherit; 
}

/* Non-sale price (normal) */
.sv-product-card__pricing:not(:has(.sv-product-card__price-old)) .sv-product-card__price {
    color: var(--sv-color-gray-900);
}

/* Button */
.sv-product-card__button {
    width: 100%;
    height: 44px;
    background: var(--sv-color-primary);
    color: var(--sv-color-white);
    font-size: 14px;
    font-weight: 700;
    border-radius: var(--sv-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.3s ease;
    border: none;
    cursor: pointer;
    text-decoration: none;
}

.sv-product-card__button:hover { 
    background: var(--sv-color-accent); 
    color: var(--sv-color-white); 
}

.sv-product-card__button svg { 
    width: 16px; 
    height: 16px; 
}

/* Button States for AJAX */
.sv-product-card__button:disabled {
    opacity: 0.7;
    cursor: wait;
}

.sv-product-card__button--success {
    background: var(--sv-color-success);
}

.sv-product-card__button--error {
    background: var(--sv-color-error);
}

/* Spinner Animation */
.sv-product-card__button .sv-spinner {
    width: 18px;
    height: 18px;
    animation: sv-spin 1s linear infinite;
}

to { transform: rotate(360deg); }
}

/* ============================================
 * PRODUCTS GRID CONTAINER
 * ============================================ */
.sv-products {
    padding: var(--sv-space-16) 0;
    background: var(--sv-color-white);
}

.sv-products__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: var(--sv-space-10);
    flex-wrap: wrap;
    gap: var(--sv-space-4);
}

/* Scrollable on mobile, grid on desktop */
.sv-products__grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.sv-products__grid::-webkit-scrollbar { 
    display: none; 
}

.sv-products__grid .sv-product-card {
    min-width: 0;
}

@media (min-width: 768px) {
    .sv-products__grid {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 24px;
        overflow-x: visible;
        scroll-snap-type: none;
        padding-bottom: 0;
    }
    
    .sv-products__grid .sv-product-card {
        flex: none;
        min-width: auto;
    }
}

/* 3-column variant */
.sv-products__grid--3 {
    grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 768px) {
    .sv-products__grid--3 {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Full grid (no scroll on mobile) */
.sv-products__grid--full {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    overflow-x: visible;
}

@media (min-width: 768px) {
    .sv-products__grid--full {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }
}

@media (min-width: 1024px) {
    .sv-products__grid--full {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Footer link */
.sv-products__footer {
    text-align: center;
    margin-top: var(--sv-space-10);
}

/* ============================================
 * PLACEHOLDER IMAGE
 * ============================================ */
.sv-product-card__placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sv-color-gray-100);
    color: var(--sv-color-gray-400);
}

.sv-product-card__placeholder svg { 
    width: 48px; 
    height: 48px; 
}

/* ============================================
 * FILTER ANIMATION STATES
 * ============================================ */

/* Skeleton shimmer animation */
@keyframes sv-skeleton-shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Skeleton loading state */
.sv-product-card--skeleton {
    position: relative;
    pointer-events: none;
}

.sv-product-card--skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.8) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    background-size: 200% 100%;
    animation: sv-skeleton-shimmer 0.3s ease-in-out;
    border-radius: inherit;
    z-index: 10;
}

.sv-product-card--skeleton .sv-product-card__image,
.sv-product-card--skeleton .sv-product-card__content {
    opacity: 0.4;
    transition: opacity 0.15s ease;
}

/* Hidden state (filtered out) */
.sv-product-card--hidden {
    opacity: 0;
    transform: scale(0.96);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Reveal animation (matching products) */
.sv-product-card:not(.sv-product-card--skeleton):not(.sv-product-card--hidden) {
    animation: sv-card-reveal 0.2s ease-out;
}

@keyframes sv-card-reveal {
    from {
        opacity: 0.6;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Dimension badge shown after filtering */
.sv-product-card__dimension-badge {
    display: inline-block;
    background: var(--sv-color-primary);
    color: white;
    font-size: var(--sv-font-size-xs);
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--sv-radius-full);
    margin-left: var(--sv-space-2);
    vertical-align: middle;
    animation: sv-badge-pop 0.3s ease-out;
}

@keyframes sv-badge-pop {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Price update animation */
.sv-product-card__price,
.sv-product-card__price-old {
    transition: opacity 0.2s ease;
}

/* ============================================
 * FILTERED STATE - QUICK ORDER ACTIONS
 * ============================================ */

.sv-product-card__actions {
    display: flex;
    flex-direction: column;
    gap: var(--sv-space-2);
    margin-top: var(--sv-space-3);
    animation: sv-actions-appear 0.3s ease-out;
}

@keyframes sv-actions-appear {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Quantity selector row */
.sv-product-card__qty {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}

.sv-product-card__qty-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sv-color-gray-100);
    border: 2px solid var(--sv-color-gray-200);
    border-radius: 70px;
    font-size: 1.325rem;
    font-weight: 500;
    color: var(--sv-color-gray-700);
    cursor: pointer;
    padding-bottom: 4px;
    transition: all 0.15s ease;
}

.sv-product-card__qty-btn:hover {
    background: var(--sv-color-gray-200);
    border-color: var(--sv-color-gray-300);
}

.sv-product-card__qty-input {
    width: 48px;
    height: 36px;
    border: none;
    background: var(--sv-color-gray-100);
    text-align: center;
    font-size: 0.975rem;
    font-weight: 600;
    color: var(--sv-color-gray-900);
    margin-left: 10px;
    margin-right: 10px;
    padding: 0;
    -moz-appearance: textfield;
}

.sv-product-card__qty-input::-webkit-outer-spin-button,
.sv-product-card__qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Primary add to cart button */
.sv-product-card__add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sv-space-2);
    width: 100%;
    padding: var(--sv-space-3) var(--sv-space-4);
    background: var(--sv-color-gray-900);
    color: white;
    border: none;
    border-radius: var(--sv-radius-lg);
    font-size: var(--sv-font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sv-product-card__add-btn:hover {
    background: var(--sv-color-primary);
    transform: translateY(-1px);
}

.sv-product-card__add-btn--loading {
    pointer-events: none;
    opacity: 0.7;
}

.sv-product-card__add-btn--success {
    background: var(--sv-color-success, #10b981);
}

.sv-product-card__add-btn .sv-icon {
    width: 18px;
    height: 18px;
}

/* Spinner for loading state */
.sv-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: sv-spin 0.6s linear infinite;
}

@keyframes sv-spin {
    to { transform: rotate(360deg); }
}

/* Secondary view product button */
.sv-product-card__view-btn {
    display: block;
    width: 100%;
    padding: var(--sv-space-2) var(--sv-space-4);
    background: transparent;
    color: var(--sv-color-gray-700);
    border: 1px solid var(--sv-color-gray-300);
    border-radius: var(--sv-radius-lg);
    font-size: var(--sv-font-size-sm);
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sv-product-card__view-btn:hover {
    border-color: var(--sv-color-gray-400);
    background: var(--sv-color-gray-50);
    color: var(--sv-color-gray-900);
}

/* Filtered state card styling */
.sv-product-card--filtered {
    border-color: var(--sv-color-primary);
    box-shadow: 0 0 0 1px var(--sv-color-primary);
}

/* Mobiel: kaart leesbaar houden op halve schermbreedte */
@media (max-width: 767px) {
    .sv-product-card .sv-product-card__body,
    .sv-product-card .sv-product-card__content { padding: 14px; }

    .sv-product-card .sv-product-card__title { font-size: 1rem; line-height: 1.35; font-weight: 700; }
    .sv-product-card .sv-product-card__origin { font-size: 0.8125rem; font-weight: 600; }
    .sv-product-card .sv-product-card__price { font-size: 1.0625rem; }
    .sv-product-card .sv-product-card__button { font-size: 0.875rem; padding: 12px 16px; }

    .sv-filter-bar__tab,
    .sv-pagination .page-numbers { min-height: 44px; }

    input, select, textarea { font-size: 16px; }
}

/* Herkomstregel mag afbreken in plaats van afkappen */
.sv-product-card .sv-product-card__origin { white-space: normal; }
.sv-product-card .sv-product-card__origin-text { min-width: 0; }
