<?php $attributes ??= new \Illuminate\View\ComponentAttributeBag;

$__newAttributes = [];
$__propNames = \Illuminate\View\ComponentAttributeBag::extractPropNames((['product', 'wishlistPage' => false]));

foreach ($attributes->all() as $__key => $__value) {
    if (in_array($__key, $__propNames)) {
        $$__key = $$__key ?? $__value;
    } else {
        $__newAttributes[$__key] = $__value;
    }
}

$attributes = new \Illuminate\View\ComponentAttributeBag($__newAttributes);

unset($__propNames);
unset($__newAttributes);

foreach (array_filter((['product', 'wishlistPage' => false]), 'is_string', ARRAY_FILTER_USE_KEY) as $__key => $__value) {
    $$__key = $$__key ?? $__value;
}

$__defined_vars = get_defined_vars();

foreach ($attributes->all() as $__key => $__value) {
    if (array_key_exists($__key, $__defined_vars)) unset($$__key);
}

unset($__defined_vars, $__key, $__value); ?>
<?php if($product): ?>
<?php
    $image = $product->primaryImage?->image_path ?? $product->images->first()?->image_path ?? null;
    // A second angle, when the product has one, gets crossfaded in on hover
    // instead of the plain zoom below — a restrained "let the product speak"
    // treatment rather than another motion effect layered on top.
    $secondaryImage = $product->images->firstWhere('image_path', '!=', $image)?->image_path ?? null;
    $productRoute = Route::has('shop.product') ? route('shop.product', $product) : '#';

    // Memoized once per request (not per card) via Laravel's once() helper —
    // this closure's call site is the same compiled line every time this
    // component renders, so a grid of 20 cards still costs a single query.
    $wishlistedIds = auth()->check() ? once(fn () => auth()->user()->wishlists()->pluck('product_id')->all()) : [];
    $isWishlisted = in_array($product->id, $wishlistedIds, true);
?>

<div class="tilt-card group relative">
    <div class="relative aspect-[3/4] overflow-hidden rounded-xl bg-cream shadow-[var(--shadow-soft)]">
        
        <a href="<?php echo e($productRoute); ?>" class="absolute inset-0 z-0 block" aria-label="<?php echo e($product->name); ?>">
            <?php if($image): ?>
                <img
                    src="<?php echo e(Storage::url($image)); ?>" alt="<?php echo e($product->name); ?>"
                    class="h-full w-full object-cover <?php echo e($secondaryImage ? 'transition-opacity duration-500 ease-out group-hover:opacity-0' : 'transition-transform duration-500 ease-out group-hover:scale-110'); ?>"
                    loading="lazy" decoding="async"
                >
                <?php if($secondaryImage): ?>
                    <img
                        src="<?php echo e(Storage::url($secondaryImage)); ?>" alt="" aria-hidden="true"
                        class="absolute inset-0 h-full w-full object-cover opacity-0 transition-opacity duration-500 ease-out group-hover:opacity-100"
                        loading="lazy" decoding="async"
                    >
                <?php endif; ?>
            <?php else: ?>
                <div class="flex h-full w-full items-center justify-center">
                    <?php if (isset($component)) { $__componentOriginalce262628e3a8d44dc38fd1f3965181bc = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalce262628e3a8d44dc38fd1f3965181bc = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.icon','data' => ['name' => 'shirt','class' => 'h-10 w-10 text-ink/10','strokeWidth' => 1.5]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('icon'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'shirt','class' => 'h-10 w-10 text-ink/10','stroke-width' => 1.5]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalce262628e3a8d44dc38fd1f3965181bc)): ?>
<?php $attributes = $__attributesOriginalce262628e3a8d44dc38fd1f3965181bc; ?>
<?php unset($__attributesOriginalce262628e3a8d44dc38fd1f3965181bc); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalce262628e3a8d44dc38fd1f3965181bc)): ?>
<?php $component = $__componentOriginalce262628e3a8d44dc38fd1f3965181bc; ?>
<?php unset($__componentOriginalce262628e3a8d44dc38fd1f3965181bc); ?>
<?php endif; ?>
                </div>
            <?php endif; ?>
        </a>

        <div class="pointer-events-none absolute inset-0 bg-gradient-to-t from-ink/25 via-transparent to-transparent opacity-0 transition-opacity duration-500 group-hover:opacity-100"></div>

        <?php if($product->is_on_sale): ?>
            <span class="absolute left-3 top-3 rounded-full bg-maroon px-2.5 py-1 text-[0.65rem] font-semibold uppercase tracking-wide text-ivory shadow-sm">
                -<?php echo e($product->discount_percentage); ?>%
            </span>
        <?php endif; ?>

        <?php if(! $product->is_in_stock): ?>
            <div class="absolute inset-0 flex items-center justify-center bg-ink/50 backdrop-blur-[2px]">
                <span class="rounded-full bg-ivory px-3 py-1 text-xs font-semibold uppercase tracking-wide text-ink">Out of Stock</span>
            </div>
        <?php endif; ?>

        <?php if(auth()->guard()->check()): ?>
            <form
                method="POST" action="<?php echo e(route('wishlist.toggle', $product)); ?>" data-ajax="wishlist"
                <?php if($wishlistPage): ?> data-remove-on-success <?php endif; ?>
                class="absolute right-3 top-3 z-10"
            >
                <?php echo csrf_field(); ?>
                <?php if (isset($component)) { $__componentOriginal658398a0e73a18931bb7def04d911f42 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal658398a0e73a18931bb7def04d911f42 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.icon-button','data' => ['type' => 'submit','name' => 'heart','variant' => 'chip-light','iconClass' => 'h-3.5 w-3.5','label' => $isWishlisted ? 'Remove from wishlist' : 'Add to wishlist','class' => 'icon-heart h-8! w-8! min-h-8! min-w-8! bg-ivory/90! text-ink/60 hover:text-maroon! '.e($isWishlisted ? 'is-active' : '').'']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('icon-button'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['type' => 'submit','name' => 'heart','variant' => 'chip-light','icon-class' => 'h-3.5 w-3.5','label' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($isWishlisted ? 'Remove from wishlist' : 'Add to wishlist'),'class' => 'icon-heart h-8! w-8! min-h-8! min-w-8! bg-ivory/90! text-ink/60 hover:text-maroon! '.e($isWishlisted ? 'is-active' : '').'']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal658398a0e73a18931bb7def04d911f42)): ?>
<?php $attributes = $__attributesOriginal658398a0e73a18931bb7def04d911f42; ?>
<?php unset($__attributesOriginal658398a0e73a18931bb7def04d911f42); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal658398a0e73a18931bb7def04d911f42)): ?>
<?php $component = $__componentOriginal658398a0e73a18931bb7def04d911f42; ?>
<?php unset($__componentOriginal658398a0e73a18931bb7def04d911f42); ?>
<?php endif; ?>
            </form>
        <?php else: ?>
            <a
                href="<?php echo e(route('login')); ?>"
                class="icon-btn icon-chip icon-chip--on-light absolute right-3 top-3 z-10 h-8! w-8! min-h-8! min-w-8! bg-ivory/90! text-ink/60 hover:text-maroon!"
                aria-label="Sign in to save to wishlist"
            >
                <?php if (isset($component)) { $__componentOriginalce262628e3a8d44dc38fd1f3965181bc = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalce262628e3a8d44dc38fd1f3965181bc = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.icon','data' => ['name' => 'heart','class' => 'h-3.5 w-3.5']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('icon'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'heart','class' => 'h-3.5 w-3.5']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalce262628e3a8d44dc38fd1f3965181bc)): ?>
<?php $attributes = $__attributesOriginalce262628e3a8d44dc38fd1f3965181bc; ?>
<?php unset($__attributesOriginalce262628e3a8d44dc38fd1f3965181bc); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalce262628e3a8d44dc38fd1f3965181bc)): ?>
<?php $component = $__componentOriginalce262628e3a8d44dc38fd1f3965181bc; ?>
<?php unset($__componentOriginalce262628e3a8d44dc38fd1f3965181bc); ?>
<?php endif; ?>
            </a>
        <?php endif; ?>
    </div>

    <div class="mt-3">
        <?php if($product->category): ?>
            <p class="text-[0.7rem] uppercase tracking-wide text-ink/40"><?php echo e($product->category->name); ?></p>
        <?php endif; ?>
        <a href="<?php echo e($productRoute); ?>" class="mt-0.5 block truncate text-sm font-medium text-ink transition-colors duration-200 hover:text-champagne-light">
            <?php echo e($product->name); ?>

        </a>
        <?php if(($product->reviews_count ?? 0) > 0): ?>
            <div class="mt-1 flex items-center gap-1.5">
                <span class="flex items-center gap-0.5 text-champagne-light">
                    <?php for($i = 1; $i <= 5; $i++): ?>
                        <i class="fa-<?php echo e($i <= round($product->reviews_avg_rating) ? 'solid' : 'regular'); ?> fa-star text-[0.6rem]"></i>
                    <?php endfor; ?>
                </span>
                <span class="text-xs text-ink/40">(<?php echo e($product->reviews_count); ?>)</span>
            </div>
        <?php endif; ?>
        <div class="mt-1.5 flex items-center gap-2">
            <span class="text-sm font-semibold text-ink"><?php echo e(config('niyarasa.currency.symbol')); ?> <?php echo e(number_format((float) $product->current_price)); ?></span>
            <?php if($product->is_on_sale): ?>
                <span class="text-xs text-ink/35 line-through"><?php echo e(config('niyarasa.currency.symbol')); ?> <?php echo e(number_format((float) $product->original_price)); ?></span>
            <?php endif; ?>
        </div>
    </div>
</div>
<?php endif; ?>
<?php /**PATH G:\Projects\ecommerce\resources\views/components/frontend/product-card.blade.php ENDPATH**/ ?>