
<?php $__env->startSection('title', 'Variation Details'); ?>

<?php $__env->startSection('content'); ?>
<div class="page-content">
    <div class="row">
        <div class="col-md-12">
            <div class="page-title-box">
                <div class="page-title-right">
                    <ol class="breadcrumb m-0">
                        <li class="breadcrumb-item"><a href="<?php echo e(route('dashboard')); ?>">Dashboard</a></li>
                        <li class="breadcrumb-item"><a href="<?php echo e(route('items.index')); ?>">Items</a></li>
                        <li class="breadcrumb-item"><a href="<?php echo e(route('items.variations.index', $item)); ?>">Variations of <?php echo e($item->name); ?></a></li>
                        <li class="breadcrumb-item active"><?php echo e($variation->name); ?></li>
                    </ol>
                </div>
                <h4 class="page-title">Variation Details</h4>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-body">
                    <div class="d-flex justify-content-between align-items-center mb-3">
                        <h6 class="card-title mb-0">Variation: <?php echo e($variation->name); ?></h6>
                        <div class="d-flex gap-2">
                            <a href="<?php echo e(route('items.variations.edit', [$item, $variation])); ?>" class="btn btn-primary">Edit</a>
                            <a href="<?php echo e(route('items.variations.index', $item)); ?>" class="btn btn-secondary">Back to List</a>
                        </div>
                    </div>

                    <div class="row g-3">
                        <!-- Basic Information -->
                        <div class="col-12">
                            <h6 class="card-title">Basic Information</h6>
                        </div>

                        <div class="col-md-6">
                            <label class="form-label fw-bold">Variation Name</label>
                            <p class="form-control-plaintext"><?php echo e($variation->name); ?></p>
                        </div>

                        <div class="col-md-6">
                            <label class="form-label fw-bold">Full SKU</label>
                            <p class="form-control-plaintext"><?php echo e($variation->full_sku); ?></p>
                        </div>

                        <div class="col-md-6">
                            <label class="form-label fw-bold">SKU Suffix</label>
                            <p class="form-control-plaintext"><?php echo e($variation->sku_suffix ?: 'None'); ?></p>
                        </div>

                        <div class="col-md-6">
                            <label class="form-label fw-bold">Status</label>
                            <p class="form-control-plaintext">
                                <?php if($variation->is_active): ?>
                                    <span class="badge bg-success">Active</span>
                                <?php else: ?>
                                    <span class="badge bg-danger">Inactive</span>
                                <?php endif; ?>
                            </p>
                        </div>

                        <!-- Physical Attributes -->
                        <div class="col-12">
                            <h6 class="card-title">Physical Attributes</h6>
                        </div>

                        <div class="col-md-4">
                            <label class="form-label fw-bold">Size</label>
                            <p class="form-control-plaintext"><?php echo e($variation->size ?: 'Not specified'); ?></p>
                        </div>

                        <div class="col-md-4">
                            <label class="form-label fw-bold">Color</label>
                            <p class="form-control-plaintext"><?php echo e($variation->color ?: 'Not specified'); ?></p>
                        </div>

                        <div class="col-md-4">
                            <label class="form-label fw-bold">Unit</label>
                            <p class="form-control-plaintext"><?php echo e($variation->unit ?: 'Not specified'); ?></p>
                        </div>

                        <!-- Dimensions -->
                        <div class="col-12">
                            <h6 class="card-title">Dimensions</h6>
                        </div>

                        <div class="col-md-3">
                            <label class="form-label fw-bold">Length</label>
                            <p class="form-control-plaintext"><?php echo e($variation->length ? $variation->length . ' units' : 'Not specified'); ?></p>
                        </div>

                        <div class="col-md-3">
                            <label class="form-label fw-bold">Width</label>
                            <p class="form-control-plaintext"><?php echo e($variation->width ? $variation->width . ' units' : 'Not specified'); ?></p>
                        </div>

                        <div class="col-md-3">
                            <label class="form-label fw-bold">Height</label>
                            <p class="form-control-plaintext"><?php echo e($variation->height ? $variation->height . ' units' : 'Not specified'); ?></p>
                        </div>

                        <div class="col-md-3">
                            <label class="form-label fw-bold">Weight</label>
                            <p class="form-control-plaintext"><?php echo e($variation->formatted_weight); ?></p>
                        </div>

                        <div class="col-md-6">
                            <label class="form-label fw-bold">Dimensions Display</label>
                            <p class="form-control-plaintext"><?php echo e($variation->dimensions ?: 'Not specified'); ?></p>
                        </div>

                        <!-- Pricing -->
                        <div class="col-12">
                            <h6 class="card-title">Pricing</h6>
                        </div>

                        <div class="col-md-6">
                            <label class="form-label fw-bold">Cost Price</label>
                            <p class="form-control-plaintext"><?php echo e($variation->formatted_cost_price); ?></p>
                        </div>

                        <div class="col-md-6">
                            <label class="form-label fw-bold">Selling Price</label>
                            <p class="form-control-plaintext"><?php echo e($variation->formatted_selling_price); ?></p>
                        </div>

                        <!-- Stock Information -->
                        <div class="col-12">
                            <h6 class="card-title">Stock Information</h6>
                        </div>

                        <div class="col-md-4">
                            <label class="form-label fw-bold">Total Stock</label>
                            <p class="form-control-plaintext"><?php echo e($variation->total_stock); ?></p>
                        </div>

                        <div class="col-md-4">
                            <label class="form-label fw-bold">Available Stock</label>
                            <p class="form-control-plaintext"><?php echo e($variation->available_stock); ?></p>
                        </div>

                        <div class="col-md-4">
                            <label class="form-label fw-bold">Reserved Stock</label>
                            <p class="form-control-plaintext"><?php echo e($variation->total_stock - $variation->available_stock); ?></p>
                        </div>

                        <!-- Description -->
                        <div class="col-12">
                            <label class="form-label fw-bold">Description</label>
                            <p class="form-control-plaintext"><?php echo e($variation->description ?: 'No description provided'); ?></p>
                        </div>

                        <!-- Timestamps -->
                        <div class="col-md-6">
                            <label class="form-label fw-bold">Created At</label>
                            <p class="form-control-plaintext"><?php echo e($variation->created_at->format('M d, Y H:i')); ?></p>
                        </div>

                        <div class="col-md-6">
                            <label class="form-label fw-bold">Last Updated</label>
                            <p class="form-control-plaintext"><?php echo e($variation->updated_at->format('M d, Y H:i')); ?></p>
                        </div>
                    </div>

                    <!-- Related Data -->
                    <?php if($variation->inventories->count() > 0): ?>
                    <div class="mt-4">
                        <h6 class="card-title">Stock Balances</h6>
                        <div class="table-responsive">
                            <table class="table table-sm">
                                <thead>
                                    <tr>
                                        <th>Warehouse</th>
                                        <th>Quantity</th>
                                        <th>Reserved</th>
                                        <th>Available</th>
                                        <th>Last Updated</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php $__currentLoopData = $variation->inventories->take(10); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $inventory): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr>
                                        <td><?php echo e($inventory->warehouse->name ?? 'N/A'); ?></td>
                                        <td><?php echo e($inventory->quantity ?? 'N/A'); ?></td>
                                        <td><?php echo e($inventory->reserved_quantity ?? 'N/A'); ?></td>
                                        <td><?php echo e(($inventory->quantity ?? 0) - ($inventory->reserved_quantity ?? 0)); ?></td>
                                        <td><?php echo e($inventory->updated_at->format('M d, Y')); ?></td>
                                    </tr>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <?php endif; ?>

                    <?php if($variation->itemSuppliers->count() > 0): ?>
                    <div class="mt-4">
                        <h6 class="card-title">Supplier Information</h6>
                        <div class="table-responsive">
                            <table class="table table-sm">
                                <thead>
                                    <tr>
                                        <th>Supplier</th>
                                        <th>Primary</th>
                                        <th>Lead Time</th>
                                        <th>Min Order Qty</th>
                                        <th>Last Price</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php $__currentLoopData = $variation->itemSuppliers->take(10); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $supplier): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr>
                                        <td><?php echo e($supplier->contact->name ?? 'N/A'); ?></td>
                                        <td>
                                            <?php if($supplier->is_primary): ?>
                                                <span class="badge bg-success">Primary</span>
                                            <?php else: ?>
                                                <span class="badge bg-secondary">Secondary</span>
                                            <?php endif; ?>
                                        </td>
                                        <td><?php echo e($supplier->lead_time_days ? $supplier->lead_time_days . ' days' : 'N/A'); ?></td>
                                        <td><?php echo e($supplier->min_order_qty ?: 'N/A'); ?></td>
                                        <td><?php echo e($supplier->formatted_last_price); ?></td>
                                    </tr>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\habibcables-ERP\resources\views\item_variations\show.blade.php ENDPATH**/ ?>