<?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, []); ?> 
        <div class="flex items-center justify-between w-full">
            <div>
                <h1 class="text-lg font-semibold text-gray-800"><?php echo e($business->name); ?></h1>
                <p class="text-xs text-gray-400 mt-0.5">Business details & FBR connection</p>
            </div>
            <a href="<?php echo e(route('businesses.index')); ?>" class="inline-flex items-center gap-1.5 text-sm text-gray-500 hover:text-indigo-600 transition">
                <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"/></svg>
                Back to Businesses
            </a>
        </div>
     <?php $__env->endSlot(); ?>

    <div class="max-w-4xl mx-auto py-6 space-y-6" x-data="businessShow()">
        <div class="lg:hidden">
            <h1 class="text-xl font-bold text-gray-900"><?php echo e($business->name); ?></h1>
            <p class="text-sm text-gray-500">Business details & FBR connection</p>
        </div>

        <div class="flex items-center justify-between">
            <div class="text-sm text-gray-500">
                Created on <?php echo e($business->created_at?->format('M d, Y') ?? 'N/A'); ?>

            </div>

            <div class="flex items-center gap-2">
                <a href="<?php echo e(route('businesses.edit', $business)); ?>"
                   class="inline-flex items-center gap-1.5 px-4 py-2 rounded-xl border border-gray-200 text-sm font-semibold text-gray-700 bg-white hover:bg-gray-50 transition shadow-sm">
                    <svg class="w-4 h-4 text-gray-500" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"/></svg>
                    Edit Business
                </a>
                <button @click="remove()"
                        class="inline-flex items-center gap-1.5 px-4 py-2 rounded-xl border border-rose-200 text-sm font-semibold text-rose-600 bg-white hover:bg-rose-50 transition shadow-sm">
                    <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/></svg>
                    Delete
                </button>
            </div>
        </div>

        
        <div class="grid grid-cols-1 sm:grid-cols-3 gap-4">
            <div class="bg-white rounded-2xl border border-gray-100 p-5 shadow-sm">
                <p class="text-xs font-semibold text-gray-400 uppercase tracking-wider mb-2">Status</p>
                <span class="inline-flex items-center gap-1.5 text-sm font-semibold px-3 py-1 rounded-full <?php echo e($business->is_active ? 'bg-green-50 text-green-700' : 'bg-red-50 text-red-700'); ?>">
                    <span class="w-1.5 h-1.5 rounded-full <?php echo e($business->is_active ? 'bg-green-500' : 'bg-red-500'); ?>"></span>
                    <?php echo e($business->is_active ? 'Active' : 'Inactive'); ?>

                </span>
            </div>
            <div class="bg-white rounded-2xl border border-gray-100 p-5 shadow-sm">
                <p class="text-xs font-semibold text-gray-400 uppercase tracking-wider mb-2">Mode</p>
                <span class="inline-block text-sm font-semibold px-3 py-1 rounded-full <?php echo e($business->is_sandbox ? 'bg-amber-50 text-amber-700' : 'bg-green-50 text-green-700'); ?>">
                    <?php echo e($business->is_sandbox ? 'Sandbox' : 'Production'); ?>

                </span>
            </div>
            <div class="bg-white rounded-2xl border border-gray-100 p-5 shadow-sm">
                <p class="text-xs font-semibold text-gray-400 uppercase tracking-wider mb-2">Auto Sync</p>
                <div class="flex items-center gap-2">
                    <span class="inline-block text-sm font-semibold px-3 py-1 rounded-full <?php echo e($business->auto_sync_enabled ? 'bg-indigo-50 text-indigo-700' : 'bg-gray-100 text-gray-500'); ?>">
                        <?php echo e($business->auto_sync_enabled ? 'Enabled' : 'Disabled'); ?>

                    </span>
                    <?php if($business->auto_sync_enabled): ?>
                        <span class="text-xs text-gray-500 font-semibold">(<?php echo e($business->auto_sync_interval); ?> min interval)</span>
                    <?php endif; ?>
                </div>
            </div>
        </div>

        
        <div class="bg-white rounded-2xl border border-gray-100 shadow-sm overflow-hidden">
            <div class="px-6 py-4 border-b border-gray-100 bg-gray-50/50">
                <h2 class="text-sm font-semibold text-gray-800 uppercase tracking-wider">General Information</h2>
            </div>
            <dl class="grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-5 p-6">
                <?php
                    $logoUrl = \App\Models\Setting::get('invoice_logo_url', '', $business->id);
                    $layoutTheme = \App\Models\Setting::get('invoice_layout', 'navy', $business->id);
                ?>
                <?php if($logoUrl): ?>
                    <div class="sm:col-span-2 flex items-center gap-4 py-2 border-b border-gray-100">
                        <dt class="text-xs font-semibold text-gray-400 uppercase tracking-wider">Logo</dt>
                        <dd>
                            <img src="<?php echo e($logoUrl); ?>" class="w-16 h-16 object-contain border border-gray-100 rounded-xl" alt="Logo">
                        </dd>
                    </div>
                <?php endif; ?>
                <div>
                    <dt class="text-xs font-semibold text-gray-400 uppercase tracking-wider mb-1">Name</dt>
                    <dd class="text-sm text-gray-700 font-medium"><?php echo e($business->name); ?></dd>
                </div>
                <div>
                    <dt class="text-xs font-semibold text-gray-400 uppercase tracking-wider mb-1">Business / Trade Name</dt>
                    <dd class="text-sm text-gray-700 font-medium"><?php echo e($business->business_name ?? '—'); ?></dd>
                </div>
                <div>
                    <dt class="text-xs font-semibold text-gray-400 uppercase tracking-wider mb-1">NTN / CNIC</dt>
                    <dd class="text-sm text-gray-700 font-medium"><?php echo e($business->ntn_cnic ?? '—'); ?></dd>
                </div>
                <div>
                    <dt class="text-xs font-semibold text-gray-400 uppercase tracking-wider mb-1">Province</dt>
                    <dd class="text-sm text-gray-700 font-medium"><?php echo e($business->province ?? '—'); ?></dd>
                </div>
                <div>
                    <dt class="text-xs font-semibold text-gray-400 uppercase tracking-wider mb-1">Email Address</dt>
                    <dd class="text-sm text-gray-700 font-medium"><?php echo e($business->email ?? '—'); ?></dd>
                </div>
                <div>
                    <dt class="text-xs font-semibold text-gray-400 uppercase tracking-wider mb-1">Phone Number</dt>
                    <dd class="text-sm text-gray-700 font-medium"><?php echo e($business->phone ?? '—'); ?></dd>
                </div>
                <div>
                    <dt class="text-xs font-semibold text-gray-400 uppercase tracking-wider mb-1">Invoice Layout Theme</dt>
                    <dd class="text-sm text-gray-700 font-medium capitalize"><?php echo e($layoutTheme); ?></dd>
                </div>
                <div class="sm:col-span-2">
                    <dt class="text-xs font-semibold text-gray-400 uppercase tracking-wider mb-1">Address</dt>
                    <dd class="text-sm text-gray-700 font-medium"><?php echo e($business->address ?? '—'); ?></dd>
                </div>
            </dl>
        </div>

        
        <div class="bg-white rounded-2xl border border-gray-100 shadow-sm overflow-hidden">
            <div class="flex items-center justify-between px-6 py-4 border-b border-gray-100 bg-gray-50/50">
                <h2 class="text-sm font-semibold text-gray-800 uppercase tracking-wider">FBR Connection</h2>
                <button @click="testConnection()" :disabled="testing"
                        class="inline-flex items-center gap-2 px-4 py-2 rounded-xl bg-indigo-600 text-white text-xs font-semibold hover:bg-indigo-700 disabled:opacity-60 transition shadow-sm">
                    <svg x-show="testing" class="w-3.5 h-3.5 animate-spin" fill="none" viewBox="0 0 24 24">
                        <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
                        <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8v8z"></path>
                    </svg>
                    <svg x-show="!testing" class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"/></svg>
                    <span x-text="testing ? 'Testing...' : 'Test Connection'"></span>
                </button>
            </div>
            <div class="p-6 space-y-4">
                <div class="grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-5">
                    <div>
                        <dt class="text-xs font-semibold text-gray-400 uppercase tracking-wider mb-1">Sandbox Token</dt>
                        <dd class="text-sm text-gray-700 font-mono"><?php echo e($business->sandbox_token ? '••••••••••••' : '—'); ?></dd>
                    </div>
                    <div>
                        <dt class="text-xs font-semibold text-gray-400 uppercase tracking-wider mb-1">Production Token</dt>
                        <dd class="text-sm text-gray-700 font-mono"><?php echo e($business->production_token ? '••••••••••••' : '—'); ?></dd>
                    </div>
                </div>

                <div x-show="result.show" x-transition x-cloak
                     class="flex items-start gap-2.5 rounded-xl px-4 py-3 text-sm font-semibold"
                     :class="result.success ? 'bg-green-50 text-green-700' : 'bg-red-50 text-red-700'">
                    <svg x-show="result.success" class="w-4 h-4 mt-0.5 flex-shrink-0" 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"/></svg>
                    <svg x-show="!result.success" class="w-4 h-4 mt-0.5 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"/></svg>
                    <span x-text="result.message"></span>
                </div>
            </div>
        </div>
    </div>

    <script>
        function businessShow() {
            return {
                testing: false,
                result: { show: false, success: false, message: '' },

                async testConnection() {
                    this.testing = true;
                    this.result.show = false;
                    try {
                        const res = await fetch('<?php echo e(route('businesses.testConnection', $business)); ?>', {
                            headers: {
                                'Accept': 'application/json',
                                'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content,
                            },
                        });
                        const data = await res.json();
                        this.result = { show: true, success: !!data.success, message: data.message ?? (data.success ? 'Connection successful.' : 'Connection failed.') };
                    } catch (e) {
                        this.result = { show: true, success: false, message: 'Could not reach the server.' };
                    } finally {
                        this.testing = false;
                    }
                },

                async remove() {
                    if (!confirm('Delete this business? This cannot be undone.')) return;
                    try {
                        const res = await fetch('<?php echo e(route('businesses.destroy', $business)); ?>', {
                            method: 'DELETE',
                            headers: {
                                'Accept': 'application/json',
                                'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content,
                            },
                        });
                        const data = await res.json();
                        if (data.success) {
                            window.location.href = '<?php echo e(route('businesses.index')); ?>';
                        }
                    } catch (e) {
                        alert('Could not reach the server.');
                    }
                },
            }
        }
    </script>
 <?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 /www/wwwroot/an.shiningerp.com/resources/views/businesses/show.blade.php ENDPATH**/ ?>