<?php if (isset($component)) { $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54 = $attributes; } ?>
<?php $component = App\View\Components\AppLayout::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('app-layout'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\App\View\Components\AppLayout::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
     <?php $__env->slot('header', null, []); ?> 
        <h2 class="font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight">
            <?php echo e(__('Transaction Details')); ?>

        </h2>
     <?php $__env->endSlot(); ?>

    <div class="py-12">
        <div class="max-w-4xl mx-auto sm:px-6 lg:px-8">
            <?php if(session('success')): ?>
                <div class="bg-green-100 dark:bg-green-900 border border-green-400 text-green-700 dark:text-green-300 px-4 py-3 rounded mb-6">
                    <?php echo e(session('success')); ?>

                </div>
            <?php endif; ?>
            <?php if(session('error')): ?>
                <div class="bg-red-100 dark:bg-red-900 border border-red-400 text-red-700 px-4 py-3 rounded mb-6">
                    <?php echo e(session('error')); ?>

                </div>
            <?php endif; ?>

            <!-- Transaction Header -->
            <div class="bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg mb-8">
                <div class="p-6">
                    <div class="flex items-start justify-between">
                        <div>
                            <h1 class="text-2xl font-bold text-gray-900 dark:text-gray-100">Transaction #<?php echo e($transaction->id); ?></h1>
                            <p class="text-gray-600 dark:text-gray-400"><?php echo e($transaction->item->title); ?></p>
                            <p class="text-sm text-gray-500 dark:text-gray-400">Created <?php echo e($transaction->created_at->format('M j, Y \a\t g:i A')); ?></p>
                        </div>
                        <div class="text-right">
                            <span class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium
                                <?php if($transaction->status === 'pending'): ?> bg-yellow-100 dark:bg-yellow-900 text-yellow-800 dark:text-yellow-300
                                <?php elseif($transaction->status === 'completed'): ?> bg-green-100 dark:bg-green-900 text-green-800 dark:text-green-300
                                <?php elseif($transaction->status === 'cancelled'): ?> bg-red-100 dark:bg-red-900 text-red-800 dark:text-red-300
                                <?php else: ?> bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-200 <?php endif; ?>">
                                <?php echo e(ucfirst($transaction->status)); ?>

                            </span>
                            <p class="text-2xl font-bold text-green-600 mt-2">$<?php echo e(number_format($transaction->price, 2)); ?></p>
                        </div>
                    </div>
                </div>
            </div>

            <div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
                <!-- Item Details -->
                <div class="bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg">
                    <div class="p-6">
                        <h2 class="text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4">Item Details</h2>
                        <div class="flex items-start space-x-4">
                            <div class="w-20 h-20 bg-gray-200 dark:bg-gray-700 rounded-lg overflow-hidden flex-shrink-0">
                                <?php if($transaction->item->primaryPhoto): ?>
                                    <img src="<?php echo e(asset($transaction->item->primaryPhoto->url)); ?>" alt="<?php echo e($transaction->item->title); ?>" class="w-full h-full object-cover">
                                <?php else: ?>
                                    <div class="w-full h-full flex items-center justify-center">
                                        <span class="text-gray-400 dark:text-gray-500 text-xs">No Image</span>
                                    </div>
                                <?php endif; ?>
                            </div>
                            <div class="flex-1">
                                <h3 class="font-semibold text-gray-900 dark:text-gray-100"><?php echo e($transaction->item->title); ?></h3>
                                <?php if($transaction->item->category): ?>
                                    <p class="text-sm text-gray-600 dark:text-gray-400"><?php echo e($transaction->item->category->name); ?></p>
                                <?php endif; ?>
                                <?php if($transaction->item->model): ?>
                                    <p class="text-sm text-gray-500 dark:text-gray-400"><?php echo e($transaction->item->model); ?></p>
                                <?php endif; ?>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Transaction Participants -->
                <div class="bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg">
                    <div class="p-6">
                        <h2 class="text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4">Participants</h2>
                        <div class="space-y-4">
                            <div>
                                <h4 class="font-medium text-gray-900 dark:text-gray-100">Seller</h4>
                                <p class="text-sm text-gray-600 dark:text-gray-400"><?php echo e($transaction->seller->name); ?></p>
                                <p class="text-xs text-gray-500 dark:text-gray-400"><?php echo e($transaction->seller->email); ?></p>
                            </div>
                            <div>
                                <h4 class="font-medium text-gray-900 dark:text-gray-100">Buyer</h4>
                                <p class="text-sm text-gray-600 dark:text-gray-400"><?php echo e($transaction->buyer->name); ?></p>
                                <p class="text-xs text-gray-500 dark:text-gray-400"><?php echo e($transaction->buyer->email); ?></p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Payment Information -->
            <?php if(count($transaction->seller->payment_methods_display) > 0): ?>
                <div class="mt-8 bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg">
                    <div class="p-6">
                        <h2 class="text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4">Payment Information</h2>
                        <div class="bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4">
                            <h4 class="font-medium text-blue-800 dark:text-blue-300 mb-3"><?php echo e($transaction->seller->name); ?> accepts these payment methods:</h4>
                            <div class="space-y-3">
                                <?php $__currentLoopData = $transaction->seller->payment_methods_display; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $method): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <?php
                                        $methodNames = [
                                            'paypal' => 'PayPal',
                                            'venmo' => 'Venmo', 
                                            'cashapp' => 'Cash App',
                                            'zelle' => 'Zelle',
                                            'crypto_bitcoin' => 'Bitcoin',
                                            'crypto_ethereum' => 'Ethereum',
                                            'bank_transfer' => 'Bank Transfer',
                                            'cash' => 'Cash (In Person)'
                                        ];
                                        $address = $transaction->seller->getPaymentMethodAddress($method);
                                    ?>
                                    <div class="flex items-start justify-between p-3 bg-white dark:bg-gray-800 border border-blue-200 dark:border-blue-800 rounded-lg">
                                        <div class="flex items-center">
                                            <svg class="w-4 h-4 text-blue-600 dark:text-blue-400 mr-2" fill="currentColor" viewBox="0 0 20 20">
                                                <path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd"></path>
                                            </svg>
                                            <span class="font-medium text-blue-800 dark:text-blue-300"><?php echo e($methodNames[$method] ?? ucwords(str_replace('_', ' ', $method))); ?></span>
                                        </div>
                                        <?php if($address): ?>
                                            <div class="text-right">
                                                <code class="text-sm bg-gray-100 dark:bg-gray-700 px-2 py-1 rounded text-gray-800 dark:text-gray-200"><?php echo e($address); ?></code>
                                            </div>
                                        <?php endif; ?>
                                    </div>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </div>
                            <div class="mt-4 text-xs text-blue-700 dark:text-blue-300">
                                <p><strong>Important:</strong> Arrange payment directly with the seller using one of these methods. Our platform does not process payments.</p>
                            </div>
                        </div>
                    </div>
                </div>
            <?php endif; ?>

            <!-- Shipping & Tracking -->
            <?php if($transaction->seller_id === auth()->id() || $transaction->tracking_number): ?>
                <div class="mt-8 bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg">
                    <div class="p-6">
                        <h2 class="text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4">Shipping & Tracking</h2>
                        
                        <?php if($transaction->tracking_number): ?>
                            <!-- Tracking Information -->
                            <div class="bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4 mb-4">
                                <div class="flex items-start">
                                    <svg class="w-5 h-5 text-blue-600 dark:text-blue-400 mt-0.5 mr-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2M4 13h2m13-8l-8 5-8-5"></path>
                                    </svg>
                                    <div class="flex-1">
                                        <h4 class="font-semibold text-blue-800 dark:text-blue-300">Item Shipped!</h4>
                                        <p class="text-blue-700 dark:text-blue-300 text-sm mt-1">
                                            Tracking Number: <span class="font-mono"><?php echo e($transaction->tracking_number); ?></span>
                                        </p>
                                        <p class="text-blue-600 dark:text-blue-400 text-xs mt-1">
                                            Added <?php echo e($transaction->tracking_added_at->format('M j, Y \a\t g:i A')); ?>

                                        </p>
                                    </div>
                                </div>
                            </div>
                        <?php endif; ?>

                        <?php if($transaction->seller_id === auth()->id() && !$transaction->tracking_number): ?>
                            <!-- Add Tracking Form (Seller Only) -->
                            <div class="border border-gray-200 dark:border-gray-700 rounded-lg p-4">
                                <h4 class="font-medium text-gray-900 dark:text-gray-100 mb-3">Add Tracking Information</h4>
                                <form method="POST" action="<?php echo e(route('transactions.add-tracking', $transaction)); ?>">
                                    <?php echo csrf_field(); ?>
                                    <div class="flex space-x-3">
                                        <div class="flex-1">
                                            <input type="text" name="tracking_number" placeholder="Enter tracking number" required
                                                   class="block w-full border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
                                        </div>
                                        <button type="submit" class="inline-flex items-center px-4 py-2 bg-blue-600 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-blue-700 transition ease-in-out duration-150">
                                            Add Tracking
                                        </button>
                                    </div>
                                    <p class="mt-1 text-xs text-gray-500 dark:text-gray-400">The buyer will be automatically notified when you add tracking information.</p>
                                </form>
                            </div>
                        <?php endif; ?>
                    </div>
                </div>
            <?php endif; ?>

            <!-- Buyer Confirmation -->
            <?php if($transaction->buyer_id === auth()->id() || $transaction->buyer_confirmed): ?>
                <div class="mt-8 bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg">
                    <div class="p-6">
                        <h2 class="text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4">Delivery Confirmation</h2>
                        
                        <?php if($transaction->buyer_confirmed): ?>
                            <!-- Already Confirmed -->
                            <div class="bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-4">
                                <div class="flex items-start">
                                    <svg class="w-5 h-5 text-green-600 mt-0.5 mr-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path>
                                    </svg>
                                    <div>
                                        <h4 class="font-semibold text-green-800 dark:text-green-300">Transaction Completed!</h4>
                                        <p class="text-green-700 dark:text-green-300 text-sm mt-1">
                                            Buyer confirmed receipt on <?php echo e($transaction->buyer_confirmed_at->format('M j, Y \a\t g:i A')); ?>

                                        </p>
                                    </div>
                                </div>
                            </div>
                        <?php elseif($transaction->buyer_id === auth()->id()): ?>
                            <!-- Buyer Confirmation Form -->
                            <div class="border border-gray-200 dark:border-gray-700 rounded-lg p-4">
                                <?php if($transaction->tracking_number): ?>
                                    <div class="mb-4 p-3 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-md">
                                        <p class="text-sm text-blue-700 dark:text-blue-300">
                                            <strong>Waiting for delivery:</strong> Once you receive the item, please confirm below to complete the transaction.
                                        </p>
                                    </div>
                                <?php endif; ?>
                                
                                <h4 class="font-medium text-gray-900 dark:text-gray-100 mb-3">Confirm Receipt</h4>
                                <p class="text-sm text-gray-600 dark:text-gray-400 mb-4">
                                    Only confirm receipt after you have received the item and verified it matches the description.
                                </p>
                                
                                <form method="POST" action="<?php echo e(route('transactions.confirm-receipt', $transaction)); ?>" onsubmit="return confirm('Are you sure you want to confirm receipt? This action cannot be undone.')">
                                    <?php echo csrf_field(); ?>
                                    <button type="submit" class="inline-flex items-center px-4 py-2 bg-green-600 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-green-700 transition ease-in-out duration-150">
                                        <svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path>
                                        </svg>
                                        Confirm Receipt & Complete Transaction
                                    </button>
                                </form>
                            </div>
                        <?php endif; ?>
                    </div>
                </div>
            <?php endif; ?>

            <!-- Feedback -->
            <?php if($transaction->status === 'completed'): ?>
                <?php
                    $myFeedback = $transaction->feedback->firstWhere('reviewer_id', auth()->id());
                    $otherParty = $transaction->seller_id === auth()->id() ? $transaction->buyer : $transaction->seller;
                ?>
                <div class="mt-8 bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg">
                    <div class="p-6">
                        <h2 class="text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4">Feedback</h2>

                        <?php $__currentLoopData = $transaction->feedback; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $feedback): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <div class="mb-4 p-4 bg-gray-50 dark:bg-gray-900/50 rounded-lg">
                                <div class="flex items-center justify-between">
                                    <p class="text-sm font-medium text-gray-900 dark:text-gray-100">
                                        <?php echo e($feedback->reviewer_id === auth()->id() ? 'Your feedback' : $feedback->reviewer->name); ?>

                                    </p>
                                    <p class="text-sm text-yellow-500" aria-label="<?php echo e($feedback->rating); ?> out of 5 stars">
                                        <?php echo e(str_repeat('★', $feedback->rating)); ?><span class="text-gray-300 dark:text-gray-600"><?php echo e(str_repeat('★', 5 - $feedback->rating)); ?></span>
                                    </p>
                                </div>
                                <?php if($feedback->comment): ?>
                                    <p class="mt-2 text-sm text-gray-600 dark:text-gray-400"><?php echo e($feedback->comment); ?></p>
                                <?php endif; ?>
                            </div>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                        <?php if(!$myFeedback): ?>
                            <form method="POST" action="<?php echo e(route('transactions.feedback', $transaction)); ?>" class="border border-gray-200 dark:border-gray-700 rounded-lg p-4">
                                <?php echo csrf_field(); ?>
                                <h4 class="font-medium text-gray-900 dark:text-gray-100 mb-1">How was your experience with <?php echo e($otherParty->name); ?>?</h4>
                                <p class="text-xs text-gray-500 dark:text-gray-400 mb-3">Your rating is public and helps other members trade with confidence.</p>

                                <div class="flex items-center space-x-4 mb-3" role="radiogroup" aria-label="Rating">
                                    <?php $__currentLoopData = [5 => 'Great', 4 => 'Good', 3 => 'OK', 2 => 'Poor', 1 => 'Bad']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $value => $label): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <label class="flex items-center space-x-1 text-sm text-gray-700 dark:text-gray-300 cursor-pointer">
                                            <input type="radio" name="rating" value="<?php echo e($value); ?>" <?php echo e($value === 5 ? 'checked' : ''); ?> class="text-yellow-500 focus:ring-yellow-400">
                                            <span><?php echo e(str_repeat('★', $value)); ?></span>
                                            <span class="text-gray-500 dark:text-gray-400"><?php echo e($label); ?></span>
                                        </label>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </div>

                                <textarea name="comment" rows="2" maxlength="1000" placeholder="Optional comment — packaging, communication, speed…"
                                    class="w-full border-gray-300 dark:border-gray-600 dark:bg-gray-900 dark:text-gray-100 rounded-md text-sm mb-3"></textarea>

                                <button type="submit" class="inline-flex items-center px-4 py-2 bg-gray-800 dark:bg-gray-700 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-gray-700 dark:hover:bg-gray-600 transition ease-in-out duration-150">
                                    Post Feedback
                                </button>
                            </form>
                        <?php endif; ?>
                    </div>
                </div>
            <?php endif; ?>

            <!-- Auto-Close Information -->
            <?php if($transaction->status === 'pending' && $transaction->auto_close_at): ?>
                <div class="mt-8 bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg">
                    <div class="p-6">
                        <h2 class="text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4">Transaction Timeline</h2>
                        <div class="bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4">
                            <div class="flex items-start">
                                <svg class="w-5 h-5 text-yellow-600 dark:text-yellow-400 mt-0.5 mr-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path>
                                </svg>
                                <div>
                                    <h4 class="font-semibold text-yellow-800 dark:text-yellow-300">Auto-Close Schedule</h4>
                                    <p class="text-yellow-700 dark:text-yellow-400 text-sm mt-1">
                                        This transaction will automatically close on <?php echo e($transaction->auto_close_at->format('M j, Y')); ?> if not confirmed by the buyer.
                                    </p>
                                    <p class="text-yellow-600 dark:text-yellow-400 text-xs mt-1">
                                        <?php echo e($transaction->auto_close_at->diffForHumans()); ?>

                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            <?php endif; ?>

            <!-- Navigation -->
            <div class="mt-8 flex justify-between">
                <a href="<?php echo e(route('transactions.index')); ?>" class="inline-flex items-center px-4 py-2 bg-gray-300 dark:bg-gray-600 border border-transparent rounded-md font-semibold text-xs text-gray-700 dark:text-gray-300 uppercase tracking-widest hover:bg-gray-400 dark:hover:bg-gray-500 transition ease-in-out duration-150">
                    ← Back to My Transactions
                </a>
                
                <?php if($transaction->seller_id === auth()->id()): ?>
                    <a href="<?php echo e(route('items.manage-queue', $transaction->item)); ?>" class="inline-flex items-center px-4 py-2 bg-blue-600 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-blue-700 transition ease-in-out duration-150">
                        Manage Item Queue
                    </a>
                <?php endif; ?>
            </div>
        </div>
    </div>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $attributes = $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $component = $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?><?php /**PATH /var/www/html/resources/views/transactions/show.blade.php ENDPATH**/ ?>